1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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_SolidSolid.cxx
24 // Created: Wed Jan 26 12:06:26 2005
25 // Author: Peter KURNEV
28 #include <GEOMAlgo_SolidSolid.hxx>
30 #include <Standard_Failure.hxx>
32 #include <TopAbs_State.hxx>
33 #include <TopoDS_Shape.hxx>
36 #include <TopTools_ListOfShape.hxx>
37 #include <TopTools_ListIteratorOfListOfShape.hxx>
38 #include <TopTools_IndexedMapOfShape.hxx>
40 #include <GEOMAlgo_IndexedDataMapOfShapeState.hxx>
42 //=======================================================================
43 //function : GEOMAlgo_SolidSolid
45 //=======================================================================
46 GEOMAlgo_SolidSolid::GEOMAlgo_SolidSolid()
51 //=======================================================================
54 //=======================================================================
55 GEOMAlgo_SolidSolid::~GEOMAlgo_SolidSolid()
58 //=======================================================================
59 // function: SetShape2
61 //=======================================================================
62 void GEOMAlgo_SolidSolid::SetShape2(const TopoDS_Shape& aS2)
66 //=======================================================================
69 //=======================================================================
70 const TopoDS_Shape& GEOMAlgo_SolidSolid::Shape2()const
74 //=======================================================================
77 //=======================================================================
78 void GEOMAlgo_SolidSolid::Perform()
82 if (myDSFiller==NULL) {
86 if(myDSFiller->HasErrors()) {
94 catch (Standard_Failure) {
98 //=================================================================================
99 // function: BuildResult
101 //=================================================================================
102 void GEOMAlgo_SolidSolid::BuildResult()
106 Standard_Integer i, j, aNbF, aNbS;
107 Standard_Integer aNbFIN, aNbFOUT, aNbFON, aNbFINTR;
109 TopTools_ListIteratorOfListOfShape aIt;
110 TopTools_IndexedMapOfShape aMF, aMS;
111 GEOMAlgo_IndexedDataMapOfShapeState aMFS;
113 // 1. classify the faces
114 GEOMAlgo_ShellSolid::Perform();
116 // 2. fill Shape-State map
117 aIt.Initialize(myLSIN);
118 for (; aIt.More(); aIt.Next()) {
119 const TopoDS_Shape& aF=aIt.Value();
120 aMFS.Add(aF, TopAbs_IN);
122 aIt.Initialize(myLSOUT);
123 for (; aIt.More(); aIt.Next()) {
124 const TopoDS_Shape& aF=aIt.Value();
125 aMFS.Add(aF, TopAbs_OUT);
127 aIt.Initialize(myLSON);
128 for (; aIt.More(); aIt.Next()) {
129 const TopoDS_Shape& aF=aIt.Value();
130 aMFS.Add(aF, TopAbs_ON);
137 // 3. fill states for solids
138 TopExp::MapShapes(myS2, TopAbs_SOLID, aMS);
141 for (i=1; i<=aNbS; ++i) {
142 const TopoDS_Shape& aSolid=aMS(i);
145 TopExp::MapShapes(aSolid, TopAbs_FACE, aMF);
153 for(j=1; j<aNbF; ++j) {
154 const TopoDS_Shape& aF=aMF(j);
156 if (!aMFS.Contains(aF)) {// the face is intesected
161 aState=aMFS.FindFromKey(aF);
175 if (aNbFIN && aNbFOUT) {
183 myLSON.Append(aSolid);
186 myLSIN.Append(aSolid);
189 myLSOUT.Append(aSolid);