1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

65
src/BRepBndLib/BRepBndLib.cdl Executable file
View File

@@ -0,0 +1,65 @@
-- File: BRepBndLib.cdl
-- Created: Thu Jul 22 16:12:28 1993
-- Author: Isabelle GRIGNON
-- <isg@nonox>
---Copyright: Matra Datavision 1993
package BRepBndLib
---Purpose: This package provides the bounding boxes for curves
-- and surfaces from BRepAdaptor.
-- Functions to add a topological shape to a bounding box
uses BRepAdaptor,
Bnd,
TopoDS,
Geom,
GeomAbs,
TColgp,
gp
is
--
-- Package methods for shapes
--
Add(S : Shape from TopoDS; B : in out Box from Bnd);
---Purpose:Adds the shape S to the bounding box B.
-- More precisely are successively added to B:
-- - each face of S; the triangulation of the face is used if it exists,
-- - then each edge of S which does not belong to a face,
-- the polygon of the edge is used if it exists
-- - and last each vertex of S which does not belong to an edge.
-- After each elementary operation, the bounding box B is
-- enlarged by the tolerance value of the relative sub-shape.
-- When working with the triangulation of a face this value of
-- enlargement is the sum of the triangulation deflection and
-- the face tolerance. When working with the
-- polygon of an edge this value of enlargement is
-- the sum of the polygon deflection and the edge tolerance.
-- Warning
-- - This algorithm is time consuming if triangulation has not
-- been inserted inside the data structure of the shape S.
-- - The resulting bounding box may be somewhat larger than the object.
AddClose(S : Shape from TopoDS; B : in out Box from Bnd);
---Purpose: Adds the shape S to the bounding box B.
-- This is a quick algorithm but only works if the shape S is
-- composed of polygonal planar faces, as is the case if S is
-- an approached polyhedral representation of an exact
-- shape. Pay particular attention to this because this
-- condition is not checked and, if it not respected, an error
-- may occur in the algorithm for which the bounding box is built.
-- Note that the resulting bounding box is not enlarged by the
-- tolerance value of the sub-shapes as is the case with the
-- Add function. So the added part of the resulting bounding
-- box is closer to the shape S.
end BRepBndLib;

159
src/BRepBndLib/BRepBndLib.cxx Executable file
View File

@@ -0,0 +1,159 @@
#include <BRepBndLib.ixx>
#include <TopExp_Explorer.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <BndLib_Add3dCurve.hxx>
#include <BndLib_AddSurface.hxx>
#include <Geom_Surface.hxx>
#include <TopLoc_Location.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <BRep_Polygon3D.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <Geom_Curve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <BndLib_Add3dCurve.hxx>
//=======================================================================
//function : Add
//purpose : Add a shape bounding to a box
//=======================================================================
void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B)
{
TopExp_Explorer ex;
// Add the faces
BRepAdaptor_Surface BS;
Handle(Geom_Surface) GS;
Handle(Poly_Triangulation) T;
TopLoc_Location l;
Standard_Integer i, nbNodes;
BRepAdaptor_Curve BC;
for (ex.Init(S,TopAbs_FACE); ex.More(); ex.Next()) {
const TopoDS_Face& F = TopoDS::Face(ex.Current());
T = BRep_Tool::Triangulation(F, l);
if (!T.IsNull()) {
nbNodes = T->NbNodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
for (i = 1; i <= nbNodes; i++) {
if (l.IsIdentity()) B.Add(Nodes(i));
else B.Add(Nodes(i).Transformed(l));
}
// B.Enlarge(T->Deflection());
B.Enlarge(T->Deflection() + BRep_Tool::Tolerance(F));
}
else {
GS = BRep_Tool::Surface(F, l);
if (!GS.IsNull()) {
BS.Initialize(F, Standard_False);
if (BS.GetType() != GeomAbs_Plane) {
BS.Initialize(F);
BndLib_AddSurface::Add(BS, BRep_Tool::Tolerance(F), B);
}
else {
// on travaille directement sur les courbes 3d.
TopExp_Explorer ex2(F, TopAbs_EDGE);
if (!ex2.More()) {
BS.Initialize(F);
BndLib_AddSurface::Add(BS, BRep_Tool::Tolerance(F), B);
}
else {
for (;ex2.More();ex2.Next()) {
BC.Initialize(TopoDS::Edge(ex2.Current()));
BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(F), B);
}
B.Enlarge(BRep_Tool::Tolerance(F));
}
}
}
}
}
// Add the edges not in faces
Handle(TColStd_HArray1OfInteger) HIndices;
Handle(Poly_PolygonOnTriangulation) Poly;
for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE); ex.More(); ex.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
Handle(Poly_Polygon3D) P3d = BRep_Tool::Polygon3D(E, l);
if (!P3d.IsNull()) {
const TColgp_Array1OfPnt& Nodes = P3d->Nodes();
nbNodes = P3d->NbNodes();
for (i = 1; i <= nbNodes; i++) {
if (l.IsIdentity()) B.Add(Nodes(i));
else B.Add(Nodes(i).Transformed(l));
}
// B.Enlarge(P3d->Deflection());
B.Enlarge(P3d->Deflection() + BRep_Tool::Tolerance(E));
}
else {
BRep_Tool::PolygonOnTriangulation(E, Poly, T, l);
if (!Poly.IsNull()) {
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
nbNodes = Indices.Length();
for (i = 1; i <= nbNodes; i++) {
if (l.IsIdentity()) B.Add(Nodes(Indices(i)));
else B.Add(Nodes(Indices(i)).Transformed(l));
}
// B.Enlarge(T->Deflection());
B.Enlarge(Poly->Deflection() + BRep_Tool::Tolerance(E));
}
else {
if (BRep_Tool::IsGeometric(E)) {
BC.Initialize(E);
BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(E), B);
}
}
}
}
// Add the vertices not in edges
for (ex.Init(S,TopAbs_VERTEX,TopAbs_EDGE); ex.More(); ex.Next()) {
B.Add(BRep_Tool::Pnt(TopoDS::Vertex(ex.Current())));
B.Enlarge(BRep_Tool::Tolerance(TopoDS::Vertex(ex.Current())));
}
}
//=======================================================================
//function : AddClose
//purpose : Add a precise shape bounding to a box
//=======================================================================
void BRepBndLib::AddClose(const TopoDS_Shape& S, Bnd_Box& B)
{
TopExp_Explorer ex;
// No faces
// Add the edges
BRepAdaptor_Curve BC;
for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next()) {
BC.Initialize(TopoDS::Edge(ex.Current()));
BndLib_Add3dCurve::Add(BC,0.,B);
}
// Add the vertices not in edges
for (ex.Init(S,TopAbs_VERTEX,TopAbs_EDGE); ex.More(); ex.Next()) {
B.Add(BRep_Tool::Pnt(TopoDS::Vertex(ex.Current())));
}
}