1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: GEOMAlgo_VertexSolid.cxx
24 // Created: Wed Jan 12 16:36:40 2005
25 // Author: Peter KURNEV
28 #include <GEOMAlgo_VertexSolid.ixx>
32 #include <TopAbs_ShapeEnum.hxx>
33 #include <TopAbs_State.hxx>
35 #include <TopTools_ListIteratorOfListOfShape.hxx>
36 #include <TopTools_ListOfShape.hxx>
37 #include <TopTools_IndexedMapOfShape.hxx>
40 #include <TopoDS_Solid.hxx>
41 #include <TopoDS_Vertex.hxx>
45 #include <BRep_Tool.hxx>
46 #include <BRepClass3d_SolidClassifier.hxx>
48 #include <BOPTColStd_Dump.hxx>
50 #include <IntTools_Context.hxx>
52 #include <BooleanOperations_StateOfShape.hxx>
53 #include <BooleanOperations_ShapesDataStructure.hxx>
55 #include <BOPTools_InterferencePool.hxx>
56 #include <BOPTools_CArray1OfVVInterference.hxx>
57 #include <BOPTools_VVInterference.hxx>
58 #include <BOPTools_PaveFiller.hxx>
59 #include <BOPTools_DSFiller.hxx>
61 //=======================================================================
62 //function : GEOMAlgo_VertexSolid
64 //=======================================================================
65 GEOMAlgo_VertexSolid::GEOMAlgo_VertexSolid()
70 //=======================================================================
73 //=======================================================================
74 GEOMAlgo_VertexSolid::~GEOMAlgo_VertexSolid()
77 //=======================================================================
80 //=======================================================================
81 void GEOMAlgo_VertexSolid::Perform()
86 if (myDSFiller==NULL) {
90 if(!myDSFiller->IsDone()) {
95 Standard_Boolean bIsNewFiller;
96 Standard_Integer aNbF;
97 TopTools_IndexedMapOfShape aM;
99 const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
100 const TopoDS_Shape& aObj=aDS.Object();
102 TopExp::MapShapes(aObj, TopAbs_FACE, aM);
104 myRank=(aNbF) ? 2 : 1;
106 bIsNewFiller=myDSFiller->IsNewFiller();
110 myDSFiller->SetNewFiller(!bIsNewFiller);
115 catch (Standard_Failure) {
119 //=======================================================================
122 //=======================================================================
123 void GEOMAlgo_VertexSolid::Prepare()
125 Standard_Integer i, iBeg, iEnd, aNbVV, j, n1, n2, iFound;
128 TopAbs_ShapeEnum aType;
129 BooleanOperations_StateOfShape aState;
132 const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
133 BooleanOperations_ShapesDataStructure* pDS=(BooleanOperations_ShapesDataStructure*)&aDS;
134 const BOPTools_InterferencePool& aIP=myDSFiller->InterfPool();
135 BOPTools_InterferencePool* pIP=(BOPTools_InterferencePool*) &aIP;
136 BOPTools_CArray1OfVVInterference& aVVs=pIP->VVInterferences();
137 const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller();
138 BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF;
139 IntTools_Context& aCtx=pPF->ChangeContext();
141 const TopoDS_Shape& aObj=aDS.Object();
142 const TopoDS_Shape& aTool=aDS.Tool();
144 const TopoDS_Solid& aSolid=(myRank==1) ? TopoDS::Solid(aTool) : TopoDS::Solid(aObj);
145 const TopoDS_Shape& aSV =(myRank==1)? aObj : aTool;
147 BRepClass3d_SolidClassifier& aSC=aCtx.SolidClassifier(aSolid);
150 iEnd=aDS.NumberOfShapesOfTheObject();
153 iEnd=aDS.NumberOfSourceShapes();
156 for (i=iBeg; i<=iEnd; ++i) {
157 aType=aDS.GetShapeType(i);
158 if (aType!=TopAbs_VERTEX) {
162 const TopoDS_Vertex& aV=TopoDS::Vertex(aDS.Shape(i));
164 aState=aDS.GetState(i);
165 if (aState==BooleanOperations_ON ||
166 aState==BooleanOperations_IN ||
167 aState==BooleanOperations_OUT) {
173 for (j=1; j<=aNbVV; ++j) {
174 BOPTools_VVInterference& aVV=aVVs(j);
176 if (n1==i || n2==i) {
177 pDS->SetState (n1, BooleanOperations_ON);
178 pDS->SetState (n2, BooleanOperations_ON);
187 aP3D=BRep_Tool::Pnt(aV);
189 aSC.Perform(aP3D, aTol);
191 if (aSt==TopAbs_IN) {
192 pDS->SetState (i, BooleanOperations_IN);
194 else if (aSt==TopAbs_OUT) {
195 pDS->SetState (i, BooleanOperations_OUT);
199 //=======================================================================
200 // function: BuildResult
202 //=======================================================================
203 void GEOMAlgo_VertexSolid::BuildResult()
205 const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
207 Standard_Integer i, iBeg, iEnd;
208 TopAbs_ShapeEnum aType;
209 BooleanOperations_StateOfShape aState;
216 iEnd=aDS.NumberOfShapesOfTheObject();
219 iEnd=aDS.NumberOfSourceShapes();
222 for (i=iBeg; i<=iEnd; ++i) {
223 aType=aDS.GetShapeType(i);
224 if (aType!=TopAbs_VERTEX) {
227 const TopoDS_Shape& aV=aDS.Shape(i);
228 aState=aDS.GetState(i);
230 if (aState==BooleanOperations_IN) {
233 else if (aState==BooleanOperations_OUT) {
236 else if (aState==BooleanOperations_ON) {