1 // Copyright (C) 2007-2008 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
22 // File: GEOMAlgo_SolidSolid.cxx
23 // Created: Wed Jan 26 12:06:26 2005
24 // Author: Peter KURNEV
27 #include <GEOMAlgo_SolidSolid.ixx>
29 #include <Standard_Failure.hxx>
31 #include <TopAbs_State.hxx>
32 #include <TopoDS_Shape.hxx>
35 #include <TopTools_ListOfShape.hxx>
36 #include <TopTools_ListIteratorOfListOfShape.hxx>
37 #include <TopTools_IndexedMapOfShape.hxx>
39 #include <BooleanOperations_ShapesDataStructure.hxx>
40 #include <BOPTools_DSFiller.hxx>
42 #include <GEOMAlgo_IndexedDataMapOfShapeState.hxx>
44 //=======================================================================
45 //function : GEOMAlgo_SolidSolid
47 //=======================================================================
48 GEOMAlgo_SolidSolid::GEOMAlgo_SolidSolid()
53 //=======================================================================
56 //=======================================================================
57 GEOMAlgo_SolidSolid::~GEOMAlgo_SolidSolid()
60 //=======================================================================
61 // function: SetShape2
63 //=======================================================================
64 void GEOMAlgo_SolidSolid::SetShape2(const TopoDS_Shape& aS2)
68 //=======================================================================
71 //=======================================================================
72 const TopoDS_Shape& GEOMAlgo_SolidSolid::Shape2()const
76 //=======================================================================
79 //=======================================================================
80 void GEOMAlgo_SolidSolid::Perform()
84 if (myDSFiller==NULL) {
88 if(!myDSFiller->IsDone()) {
93 Standard_Boolean bIsNewFiller;
95 bIsNewFiller=myDSFiller->IsNewFiller();
98 myDSFiller->SetNewFiller(!bIsNewFiller);
104 catch (Standard_Failure) {
108 //=================================================================================
109 // function: BuildResult
111 //=================================================================================
112 void GEOMAlgo_SolidSolid::BuildResult()
116 Standard_Integer i, j, aNbF, aNbS;
117 Standard_Integer aNbFIN, aNbFOUT, aNbFON, aNbFINTR;
119 TopTools_ListIteratorOfListOfShape aIt;
120 TopTools_IndexedMapOfShape aMF, aMS;
121 GEOMAlgo_IndexedDataMapOfShapeState aMFS;
123 // 1. classify the faces
124 GEOMAlgo_ShellSolid::BuildResult();
126 // 2. fill Shape-State map
127 aIt.Initialize(myLSIN);
128 for (; aIt.More(); aIt.Next()) {
129 const TopoDS_Shape& aF=aIt.Value();
130 aMFS.Add(aF, TopAbs_IN);
132 aIt.Initialize(myLSOUT);
133 for (; aIt.More(); aIt.Next()) {
134 const TopoDS_Shape& aF=aIt.Value();
135 aMFS.Add(aF, TopAbs_OUT);
137 aIt.Initialize(myLSON);
138 for (; aIt.More(); aIt.Next()) {
139 const TopoDS_Shape& aF=aIt.Value();
140 aMFS.Add(aF, TopAbs_ON);
146 // 3. fill states for solids
147 TopExp::MapShapes(myS2, TopAbs_SOLID, aMS);
150 for (i=1; i<=aNbS; ++i) {
151 const TopoDS_Shape& aSolid=aMS(i);
154 TopExp::MapShapes(aSolid, TopAbs_FACE, aMF);
162 for(j=1; j<aNbF; ++j) {
163 const TopoDS_Shape& aF=aMF(j);
165 if (!aMFS.Contains(aF)) {// the face is intesected
170 aState=aMFS.FindFromKey(aF);
184 if (aNbFIN && aNbFOUT) {
192 myLSON.Append(aSolid);
195 myLSIN.Append(aSolid);
198 myLSOUT.Append(aSolid);