1 // File: NMTAlgo_Splitter1.cxx
2 // Created: Wed Feb 11 14:26:27 2004
3 // Author: Peter KURNEV
7 #include <NMTAlgo_Splitter1.ixx>
8 #include <NMTAlgo_Splitter.hxx>
9 #include <TopAbs_ShapeEnum.hxx>
10 #include <TopoDS_Iterator.hxx>
11 #include <TopTools_IndexedMapOfShape.hxx>
12 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
13 #include <TopTools_ListIteratorOfListOfShape.hxx>
14 #include <NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
16 #include <TopoDS_Shape.hxx>
17 #include <TopTools_ListOfShape.hxx>
18 #include <TopExp_Explorer.hxx>
19 #include <TopoDS_Shape.hxx>
20 #include <TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape.hxx>
21 #include <TopoDS_Compound.hxx>
22 #include <TopTools_DataMapOfIntegerListOfShape.hxx>
23 #include <TopTools_DataMapIteratorOfDataMapOfShapeInteger.hxx>
24 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
26 #include <TopTools_MapOfShape.hxx>
27 #include <NMTAlgo_Loop3d.hxx>
28 #include <TopTools_MapOfOrientedShape.hxx>
29 #include <BRep_Builder.hxx>
30 #include <TopoDS_Solid.hxx>
31 #include <NMTAlgo_Tools.hxx>
33 //=======================================================================
34 //function : NMTAlgo_Spliter1::NMTAlgo_Splitter1
36 //=======================================================================
37 NMTAlgo_Splitter1::NMTAlgo_Splitter1()
41 myRemoveWebs=Standard_False;
43 //=======================================================================
44 // function: ~NMTAlgo_Splitter1
46 //=======================================================================
47 NMTAlgo_Splitter1::~NMTAlgo_Splitter1()
51 //=======================================================================
54 //=======================================================================
55 void NMTAlgo_Splitter1::Clear()
57 NMTAlgo_Splitter::Clear();
59 myRemoveWebs=Standard_False;
63 //=======================================================================
64 //function : SetRemoveWebs
66 //=======================================================================
67 void NMTAlgo_Splitter1::SetRemoveWebs(const Standard_Boolean bFlag)
71 //=======================================================================
72 //function : RemoveWebs
74 //=======================================================================
75 Standard_Boolean NMTAlgo_Splitter1::RemoveWebs()const
79 //=======================================================================
80 //function : GetMaterialTable
82 //=======================================================================
83 const TopTools_DataMapOfShapeInteger& NMTAlgo_Splitter1::GetMaterialTable()const
87 //=======================================================================
88 //function : SetMaterial
90 //=======================================================================
91 void NMTAlgo_Splitter1::SetMaterial(const TopoDS_Shape& aS,
92 const Standard_Integer iMt)
96 aExp.Init(aS, TopAbs_SOLID);
97 for(; aExp.More(); aExp.Next()) {
98 const TopoDS_Shape& aSd=aExp.Current();
99 myMapSWM.Bind(aSd, iMt);
102 //=======================================================================
103 //function : AddShape
105 //=======================================================================
106 void NMTAlgo_Splitter1::AddShape(const TopoDS_Shape& aS)
109 NMTAlgo_Splitter::AddShape(aS);
111 //=======================================================================
112 //function : AddToolWithMaterial
114 //=======================================================================
115 void NMTAlgo_Splitter1::AddTool(const TopoDS_Shape& aS)
119 NMTAlgo_Splitter::AddTool(aS);
121 //=======================================================================
124 //=======================================================================
125 void NMTAlgo_Splitter1::Build(const TopAbs_ShapeEnum aLimit)
127 NMTAlgo_Splitter::Build(aLimit);
133 if (myRemoveWebs && myMapSWMOut.Extent()) {
138 //=======================================================================
139 //function : TreatWebs
141 //=======================================================================
142 void NMTAlgo_Splitter1::TreatWebs()
144 Standard_Integer nMt;
145 TopTools_DataMapOfIntegerListOfShape aMMLS;
147 TopTools_DataMapIteratorOfDataMapOfShapeInteger aIt2;
148 TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape aIt1;
149 TopTools_ListIteratorOfListOfShape aItS;
153 aIt2.Initialize(myMapSWMOut);
154 for (; aIt2.More(); aIt2.Next()) {
155 const TopoDS_Shape& aS=aIt2.Key();
158 if (aMMLS.IsBound(nMt)){
159 TopTools_ListOfShape& aLS=aMMLS.ChangeFind(nMt);
163 TopTools_ListOfShape aLS;
165 aMMLS.Bind(nMt, aLS);
170 myBuilder.MakeCompound(aCx);
172 aIt1.Initialize(aMMLS);
173 for (; aIt1.More(); aIt1.Next()) {
177 myBuilder.MakeCompound(aCS);
178 const TopTools_ListOfShape& aLS=aIt1.Value();
179 aItS.Initialize(aLS);
180 for (; aItS.More(); aItS.Next()) {
181 const TopoDS_Shape& aS=aItS.Value();
182 myBuilder.Add(aCS, aS);
185 NMTAlgo_Tools::BreakWebs(aCS, aCSR);
187 aIt.Initialize(aCSR);
188 for(; aIt.More(); aIt.Next()) {
189 const TopoDS_Shape& aS=aIt.Value();
190 myBuilder.Add(aCx, aS);
192 myMapSWMOut.Bind(aS, nMt);
196 aIt.Initialize(myRestParts);
197 for(; aIt.More(); aIt.Next()) {
198 const TopoDS_Shape& aS=aIt.Value();
199 myBuilder.Add(aCx, aS);
205 //=======================================================================
206 //function : RestParts
208 //=======================================================================
209 void NMTAlgo_Splitter1::RestParts()
214 myBuilder.MakeCompound(aR);
216 aIt.Initialize(myShape);
217 for(; aIt.More(); aIt.Next()) {
218 const TopoDS_Shape& aS=aIt.Value();
219 if (aS.ShapeType()==TopAbs_SOLID){
220 if (myMapSWMOut.IsBound(aS)) {
224 myBuilder.Add(aR, aS);
228 //=======================================================================
229 //function : TreatSolids
231 //=======================================================================
232 void NMTAlgo_Splitter1::TreatSolids()
234 Standard_Integer i, j, aNbSd, aNbSdx, nMtMax, nMt;
235 TopAbs_ShapeEnum aType;
237 TopTools_IndexedMapOfShape aMSo, aMSd;
238 TopTools_IndexedDataMapOfShapeListOfShape aMFS;
239 TopTools_ListIteratorOfListOfShape aItS, aItLS;
240 NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMCS;
242 TopExp::MapShapesAndAncestors(myShape, TopAbs_FACE, TopAbs_SOLID, aMFS);
243 TopExp::MapShapes(myShape, TopAbs_SOLID, aMSo);
250 aItS.Initialize(myListShapes);
251 for ( ;aItS.More(); aItS.Next()) {
252 const TopoDS_Shape& aS=aItS.Value();
254 aType=aS.ShapeType();
255 if (aType != TopAbs_SOLID) {
259 if (myToolShapes.Contains(aS)) {
263 if (!myMapSIFC.IsBound(aS)){
269 const TopoDS_Shape& aIFC=myMapSIFC.Find(aS);
271 aIt.Initialize(aIFC);
272 for (; aIt.More(); aIt.Next()) {
273 const TopoDS_Shape& aIF=aIt.Value();
274 if (aMFS.Contains(aIF)) {
275 const TopTools_ListOfShape& aLS=aMFS.FindFromKey(aIF);
276 aItLS.Initialize(aLS);
277 for ( ;aItLS.More(); aItLS.Next()) {
278 const TopoDS_Shape& aSd=aItLS.Value();
279 if (!aMSd.Contains(aSd)) {
288 //modified by NIZNHY-PKV Thu Dec 23 15:07:46 2004 f
289 Standard_Boolean bFound;
290 //modified by NIZNHY-PKV Thu Dec 23 15:07:49 2004 t
293 const TopoDS_Shape& aFC=myImageShape.Image(aS).First();
294 //modified by NIZNHY-PKV Thu Dec 23 15:08:17 2004 f
295 //NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd);
297 bFound=NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd);
301 //modified by NIZNHY-PKV Thu Dec 23 15:09:02 2004 t
304 } //for ( ;aItS.More(); aItS.Next())
309 for (i=1; i<=aNbSd; ++i) {
310 const TopoDS_Shape& aSd=aMCS.FindKey(i);
311 const TopTools_IndexedMapOfShape& aMSdx=aMCS(i);
312 aNbSdx=aMSdx.Extent();
313 for (j=1; j<=aNbSdx; ++j) {
314 const TopoDS_Shape& aSdx=aMSdx(j);
316 if (aMFS.Contains(aSdx)) {
317 TopTools_ListOfShape& aLS=aMFS.ChangeFromKey(aSdx);
321 TopTools_ListOfShape aLS;
328 // Assign materials values to subsolids
332 aNbSdx=aMFS.Extent();
333 for (i=1; i<=aNbSdx; ++i) {
334 const TopoDS_Shape& aSdx=aMFS.FindKey(i);
335 const TopTools_ListOfShape& aLS=aMFS(i);
336 aItLS.Initialize(aLS);
337 for (j=0; aItLS.More(); aItLS.Next(), ++j) {
338 const TopoDS_Shape& aSd=aItLS.Value();
340 if (!myMapSWM.IsBound(aSd)){
344 nMt=myMapSWM.Find(aSd);
353 myMapSWMOut.Bind(aSdx, nMtMax);