1 // File: GEOMAlgo_SolidSolid.cxx
2 // Created: Wed Jan 26 12:06:26 2005
3 // Author: Peter KURNEV
7 #include <GEOMAlgo_SolidSolid.ixx>
9 #include <Standard_Failure.hxx>
11 #include <TopAbs_State.hxx>
12 #include <TopoDS_Shape.hxx>
15 #include <TopTools_ListOfShape.hxx>
16 #include <TopTools_ListIteratorOfListOfShape.hxx>
17 #include <TopTools_IndexedMapOfShape.hxx>
19 #include <BooleanOperations_ShapesDataStructure.hxx>
20 #include <BOPTools_DSFiller.hxx>
22 #include <GEOMAlgo_IndexedDataMapOfShapeState.hxx>
24 //=======================================================================
25 //function : GEOMAlgo_SolidSolid
27 //=======================================================================
28 GEOMAlgo_SolidSolid::GEOMAlgo_SolidSolid()
33 //=======================================================================
36 //=======================================================================
37 GEOMAlgo_SolidSolid::~GEOMAlgo_SolidSolid()
40 //=======================================================================
41 // function: SetShape2
43 //=======================================================================
44 void GEOMAlgo_SolidSolid::SetShape2(const TopoDS_Shape& aS2)
48 //=======================================================================
51 //=======================================================================
52 const TopoDS_Shape& GEOMAlgo_SolidSolid::Shape2()const
56 //=======================================================================
59 //=======================================================================
60 void GEOMAlgo_SolidSolid::Perform()
64 if (myDSFiller==NULL) {
68 if(!myDSFiller->IsDone()) {
73 Standard_Boolean bIsNewFiller;
75 bIsNewFiller=myDSFiller->IsNewFiller();
78 myDSFiller->SetNewFiller(!bIsNewFiller);
84 catch (Standard_Failure) {
88 //=================================================================================
89 // function: BuildResult
91 //=================================================================================
92 void GEOMAlgo_SolidSolid::BuildResult()
96 Standard_Integer i, j, aNbF, aNbS;
97 Standard_Integer aNbFIN, aNbFOUT, aNbFON, aNbFINTR;
99 TopTools_ListIteratorOfListOfShape aIt;
100 TopTools_IndexedMapOfShape aMF, aMS;
101 GEOMAlgo_IndexedDataMapOfShapeState aMFS;
103 // 1. classify the faces
104 GEOMAlgo_ShellSolid::BuildResult();
106 // 2. fill Shape-State map
107 aIt.Initialize(myLSIN);
108 for (; aIt.More(); aIt.Next()) {
109 const TopoDS_Shape& aF=aIt.Value();
110 aMFS.Add(aF, TopAbs_IN);
112 aIt.Initialize(myLSOUT);
113 for (; aIt.More(); aIt.Next()) {
114 const TopoDS_Shape& aF=aIt.Value();
115 aMFS.Add(aF, TopAbs_OUT);
117 aIt.Initialize(myLSON);
118 for (; aIt.More(); aIt.Next()) {
119 const TopoDS_Shape& aF=aIt.Value();
120 aMFS.Add(aF, TopAbs_ON);
126 // 3. fill states for solids
127 TopExp::MapShapes(myS2, TopAbs_SOLID, aMS);
130 for (i=1; i<=aNbS; ++i) {
131 const TopoDS_Shape& aSolid=aMS(i);
134 TopExp::MapShapes(aSolid, TopAbs_FACE, aMF);
142 for(j=1; j<aNbF; ++j) {
143 const TopoDS_Shape& aF=aMF(j);
145 if (!aMFS.Contains(aF)) {// the face is intesected
150 aState=aMFS.FindFromKey(aF);
164 if (aNbFIN && aNbFOUT) {
172 myLSON.Append(aSolid);
175 myLSIN.Append(aSolid);
178 myLSOUT.Append(aSolid);