1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: GEOMAlgo_VertexSolid.cxx
21 // Created: Wed Jan 12 16:36:40 2005
22 // Author: Peter KURNEV
26 #include <GEOMAlgo_VertexSolid.ixx>
30 #include <TopAbs_ShapeEnum.hxx>
31 #include <TopAbs_State.hxx>
33 #include <TopTools_ListIteratorOfListOfShape.hxx>
34 #include <TopTools_ListOfShape.hxx>
35 #include <TopTools_IndexedMapOfShape.hxx>
38 #include <TopoDS_Solid.hxx>
39 #include <TopoDS_Vertex.hxx>
43 #include <BRep_Tool.hxx>
44 #include <BRepClass3d_SolidClassifier.hxx>
46 #include <BOPTColStd_Dump.hxx>
48 #include <IntTools_Context.hxx>
50 #include <BooleanOperations_StateOfShape.hxx>
51 #include <BooleanOperations_ShapesDataStructure.hxx>
53 #include <BOPTools_InterferencePool.hxx>
54 #include <BOPTools_CArray1OfVVInterference.hxx>
55 #include <BOPTools_VVInterference.hxx>
56 #include <BOPTools_PaveFiller.hxx>
57 #include <BOPTools_DSFiller.hxx>
59 //=======================================================================
60 //function : GEOMAlgo_VertexSolid
62 //=======================================================================
63 GEOMAlgo_VertexSolid::GEOMAlgo_VertexSolid()
68 //=======================================================================
71 //=======================================================================
72 GEOMAlgo_VertexSolid::~GEOMAlgo_VertexSolid()
75 //=======================================================================
78 //=======================================================================
79 void GEOMAlgo_VertexSolid::Perform()
84 if (myDSFiller==NULL) {
88 if(!myDSFiller->IsDone()) {
93 Standard_Boolean bIsNewFiller;
94 Standard_Integer aNbF;
95 TopTools_IndexedMapOfShape aM;
97 const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
98 const TopoDS_Shape& aObj=aDS.Object();
100 TopExp::MapShapes(aObj, TopAbs_FACE, aM);
102 myRank=(aNbF) ? 2 : 1;
104 bIsNewFiller=myDSFiller->IsNewFiller();
108 myDSFiller->SetNewFiller(!bIsNewFiller);
113 catch (Standard_Failure) {
117 //=======================================================================
120 //=======================================================================
121 void GEOMAlgo_VertexSolid::Prepare()
123 Standard_Integer i, iBeg, iEnd, aNbVV, j, n1, n2, iFound;
126 TopAbs_ShapeEnum aType;
127 BooleanOperations_StateOfShape aState;
130 const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
131 BooleanOperations_ShapesDataStructure* pDS=(BooleanOperations_ShapesDataStructure*)&aDS;
132 const BOPTools_InterferencePool& aIP=myDSFiller->InterfPool();
133 BOPTools_InterferencePool* pIP=(BOPTools_InterferencePool*) &aIP;
134 BOPTools_CArray1OfVVInterference& aVVs=pIP->VVInterferences();
135 const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller();
136 BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF;
137 IntTools_Context& aCtx=pPF->ChangeContext();
139 const TopoDS_Shape& aObj=aDS.Object();
140 const TopoDS_Shape& aTool=aDS.Tool();
142 const TopoDS_Solid& aSolid=(myRank==1) ? TopoDS::Solid(aTool) : TopoDS::Solid(aObj);
143 const TopoDS_Shape& aSV =(myRank==1)? aObj : aTool;
145 BRepClass3d_SolidClassifier& aSC=aCtx.SolidClassifier(aSolid);
148 iEnd=aDS.NumberOfShapesOfTheObject();
151 iEnd=aDS.NumberOfSourceShapes();
154 for (i=iBeg; i<=iEnd; ++i) {
155 aType=aDS.GetShapeType(i);
156 if (aType!=TopAbs_VERTEX) {
160 const TopoDS_Vertex& aV=TopoDS::Vertex(aDS.Shape(i));
162 aState=aDS.GetState(i);
163 if (aState==BooleanOperations_ON ||
164 aState==BooleanOperations_IN ||
165 aState==BooleanOperations_OUT) {
171 for (j=1; j<=aNbVV; ++j) {
172 BOPTools_VVInterference& aVV=aVVs(j);
174 if (n1==i || n2==i) {
175 pDS->SetState (n1, BooleanOperations_ON);
176 pDS->SetState (n2, BooleanOperations_ON);
185 aP3D=BRep_Tool::Pnt(aV);
187 aSC.Perform(aP3D, aTol);
189 if (aSt==TopAbs_IN) {
190 pDS->SetState (i, BooleanOperations_IN);
192 else if (aSt==TopAbs_OUT) {
193 pDS->SetState (i, BooleanOperations_OUT);
197 //=======================================================================
198 // function: BuildResult
200 //=======================================================================
201 void GEOMAlgo_VertexSolid::BuildResult()
203 const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
205 Standard_Integer i, iBeg, iEnd;
206 TopAbs_ShapeEnum aType;
207 BooleanOperations_StateOfShape aState;
214 iEnd=aDS.NumberOfShapesOfTheObject();
217 iEnd=aDS.NumberOfSourceShapes();
220 for (i=iBeg; i<=iEnd; ++i) {
221 aType=aDS.GetShapeType(i);
222 if (aType!=TopAbs_VERTEX) {
225 const TopoDS_Shape& aV=aDS.Shape(i);
226 aState=aDS.GetState(i);
228 if (aState==BooleanOperations_IN) {
231 else if (aState==BooleanOperations_OUT) {
234 else if (aState==BooleanOperations_ON) {