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_SolidSolid.cxx
21 // Created: Wed Jan 26 12:06:26 2005
22 // Author: Peter KURNEV
26 #include <GEOMAlgo_SolidSolid.ixx>
28 #include <Standard_Failure.hxx>
30 #include <TopAbs_State.hxx>
31 #include <TopoDS_Shape.hxx>
34 #include <TopTools_ListOfShape.hxx>
35 #include <TopTools_ListIteratorOfListOfShape.hxx>
36 #include <TopTools_IndexedMapOfShape.hxx>
38 #include <BooleanOperations_ShapesDataStructure.hxx>
39 #include <BOPTools_DSFiller.hxx>
41 #include <GEOMAlgo_IndexedDataMapOfShapeState.hxx>
43 //=======================================================================
44 //function : GEOMAlgo_SolidSolid
46 //=======================================================================
47 GEOMAlgo_SolidSolid::GEOMAlgo_SolidSolid()
52 //=======================================================================
55 //=======================================================================
56 GEOMAlgo_SolidSolid::~GEOMAlgo_SolidSolid()
59 //=======================================================================
60 // function: SetShape2
62 //=======================================================================
63 void GEOMAlgo_SolidSolid::SetShape2(const TopoDS_Shape& aS2)
67 //=======================================================================
70 //=======================================================================
71 const TopoDS_Shape& GEOMAlgo_SolidSolid::Shape2()const
75 //=======================================================================
78 //=======================================================================
79 void GEOMAlgo_SolidSolid::Perform()
83 if (myDSFiller==NULL) {
87 if(!myDSFiller->IsDone()) {
92 Standard_Boolean bIsNewFiller;
94 bIsNewFiller=myDSFiller->IsNewFiller();
97 myDSFiller->SetNewFiller(!bIsNewFiller);
103 catch (Standard_Failure) {
107 //=================================================================================
108 // function: BuildResult
110 //=================================================================================
111 void GEOMAlgo_SolidSolid::BuildResult()
115 Standard_Integer i, j, aNbF, aNbS;
116 Standard_Integer aNbFIN, aNbFOUT, aNbFON, aNbFINTR;
118 TopTools_ListIteratorOfListOfShape aIt;
119 TopTools_IndexedMapOfShape aMF, aMS;
120 GEOMAlgo_IndexedDataMapOfShapeState aMFS;
122 // 1. classify the faces
123 GEOMAlgo_ShellSolid::BuildResult();
125 // 2. fill Shape-State map
126 aIt.Initialize(myLSIN);
127 for (; aIt.More(); aIt.Next()) {
128 const TopoDS_Shape& aF=aIt.Value();
129 aMFS.Add(aF, TopAbs_IN);
131 aIt.Initialize(myLSOUT);
132 for (; aIt.More(); aIt.Next()) {
133 const TopoDS_Shape& aF=aIt.Value();
134 aMFS.Add(aF, TopAbs_OUT);
136 aIt.Initialize(myLSON);
137 for (; aIt.More(); aIt.Next()) {
138 const TopoDS_Shape& aF=aIt.Value();
139 aMFS.Add(aF, TopAbs_ON);
145 // 3. fill states for solids
146 TopExp::MapShapes(myS2, TopAbs_SOLID, aMS);
149 for (i=1; i<=aNbS; ++i) {
150 const TopoDS_Shape& aSolid=aMS(i);
153 TopExp::MapShapes(aSolid, TopAbs_FACE, aMF);
161 for(j=1; j<aNbF; ++j) {
162 const TopoDS_Shape& aF=aMF(j);
164 if (!aMFS.Contains(aF)) {// the face is intesected
169 aState=aMFS.FindFromKey(aF);
183 if (aNbFIN && aNbFOUT) {
191 myLSON.Append(aSolid);
194 myLSIN.Append(aSolid);
197 myLSOUT.Append(aSolid);