1 // File: GEOMAlgo_VertexSolid.cxx
2 // Created: Wed Jan 12 16:36:40 2005
3 // Author: Peter KURNEV
7 #include <GEOMAlgo_VertexSolid.ixx>
11 #include <TopAbs_ShapeEnum.hxx>
12 #include <TopAbs_State.hxx>
14 #include <TopTools_ListIteratorOfListOfShape.hxx>
15 #include <TopTools_ListOfShape.hxx>
16 #include <TopTools_IndexedMapOfShape.hxx>
19 #include <TopoDS_Solid.hxx>
20 #include <TopoDS_Vertex.hxx>
24 #include <BRep_Tool.hxx>
25 #include <BRepClass3d_SolidClassifier.hxx>
27 #include <BOPTColStd_Dump.hxx>
29 #include <IntTools_Context.hxx>
31 #include <BooleanOperations_StateOfShape.hxx>
32 #include <BooleanOperations_ShapesDataStructure.hxx>
34 #include <BOPTools_InterferencePool.hxx>
35 #include <BOPTools_CArray1OfVVInterference.hxx>
36 #include <BOPTools_VVInterference.hxx>
37 #include <BOPTools_PaveFiller.hxx>
38 #include <BOPTools_DSFiller.hxx>
40 //=======================================================================
41 //function : GEOMAlgo_VertexSolid
43 //=======================================================================
44 GEOMAlgo_VertexSolid::GEOMAlgo_VertexSolid()
49 //=======================================================================
52 //=======================================================================
53 GEOMAlgo_VertexSolid::~GEOMAlgo_VertexSolid()
56 //=======================================================================
59 //=======================================================================
60 void GEOMAlgo_VertexSolid::Perform()
65 if (myDSFiller==NULL) {
69 if(!myDSFiller->IsDone()) {
74 Standard_Boolean bIsNewFiller;
75 Standard_Integer aNbF;
76 TopTools_IndexedMapOfShape aM;
78 const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
79 const TopoDS_Shape& aObj=aDS.Object();
81 TopExp::MapShapes(aObj, TopAbs_FACE, aM);
83 myRank=(aNbF) ? 2 : 1;
85 bIsNewFiller=myDSFiller->IsNewFiller();
89 myDSFiller->SetNewFiller(!bIsNewFiller);
94 catch (Standard_Failure) {
98 //=======================================================================
101 //=======================================================================
102 void GEOMAlgo_VertexSolid::Prepare()
104 Standard_Integer i, iBeg, iEnd, aNbVV, j, n1, n2, iFound;
107 TopAbs_ShapeEnum aType;
108 BooleanOperations_StateOfShape aState;
111 const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
112 BooleanOperations_ShapesDataStructure* pDS=(BooleanOperations_ShapesDataStructure*)&aDS;
113 const BOPTools_InterferencePool& aIP=myDSFiller->InterfPool();
114 BOPTools_InterferencePool* pIP=(BOPTools_InterferencePool*) &aIP;
115 BOPTools_CArray1OfVVInterference& aVVs=pIP->VVInterferences();
116 const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller();
117 BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF;
118 IntTools_Context& aCtx=pPF->ChangeContext();
120 const TopoDS_Shape& aObj=aDS.Object();
121 const TopoDS_Shape& aTool=aDS.Tool();
123 const TopoDS_Solid& aSolid=(myRank==1) ? TopoDS::Solid(aTool) : TopoDS::Solid(aObj);
124 const TopoDS_Shape& aSV =(myRank==1)? aObj : aTool;
126 BRepClass3d_SolidClassifier& aSC=aCtx.SolidClassifier(aSolid);
129 iEnd=aDS.NumberOfShapesOfTheObject();
132 iEnd=aDS.NumberOfSourceShapes();
135 for (i=iBeg; i<=iEnd; ++i) {
136 aType=aDS.GetShapeType(i);
137 if (aType!=TopAbs_VERTEX) {
141 const TopoDS_Vertex& aV=TopoDS::Vertex(aDS.Shape(i));
143 aState=aDS.GetState(i);
144 if (aState==BooleanOperations_ON ||
145 aState==BooleanOperations_IN ||
146 aState==BooleanOperations_OUT) {
152 for (j=1; j<=aNbVV; ++j) {
153 BOPTools_VVInterference& aVV=aVVs(j);
155 if (n1==i || n2==i) {
156 pDS->SetState (n1, BooleanOperations_ON);
157 pDS->SetState (n2, BooleanOperations_ON);
166 aP3D=BRep_Tool::Pnt(aV);
168 aSC.Perform(aP3D, aTol);
170 if (aSt==TopAbs_IN) {
171 pDS->SetState (i, BooleanOperations_IN);
173 else if (aSt==TopAbs_OUT) {
174 pDS->SetState (i, BooleanOperations_OUT);
178 //=======================================================================
179 // function: BuildResult
181 //=======================================================================
182 void GEOMAlgo_VertexSolid::BuildResult()
184 const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
186 Standard_Integer i, iBeg, iEnd;
187 TopAbs_ShapeEnum aType;
188 BooleanOperations_StateOfShape aState;
195 iEnd=aDS.NumberOfShapesOfTheObject();
198 iEnd=aDS.NumberOfSourceShapes();
201 for (i=iBeg; i<=iEnd; ++i) {
202 aType=aDS.GetShapeType(i);
203 if (aType!=TopAbs_VERTEX) {
206 const TopoDS_Shape& aV=aDS.Shape(i);
207 aState=aDS.GetState(i);
209 if (aState==BooleanOperations_IN) {
212 else if (aState==BooleanOperations_OUT) {
215 else if (aState==BooleanOperations_ON) {