1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2012 OPEN CASCADE SAS
3 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5 // EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 // The content of this file is subject to the Open CASCADE Technology Public
8 // License Version 6.5 (the "License"). You may not use the content of this file
9 // except in compliance with the License. Please obtain a copy of the License
10 // at http://www.opencascade.org and read it completely before using this file.
12 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
13 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
15 // The Original Code and all software distributed under the License is
16 // distributed on an "AS IS" basis, without warranty of any kind, and the
17 // Initial Developer hereby disclaims all such warranties, including without
18 // limitation, any warranties of merchantability, fitness for a particular
19 // purpose or non-infringement. Please see the License for the specific terms
20 // and conditions governing the rights and limitations under the License.
22 #include <BOPAlgo_Builder.hxx>
24 #include <NCollection_IncAllocator.hxx>
26 #include <TopAbs_State.hxx>
29 #include <TopoDS_Iterator.hxx>
30 #include <TopoDS_Solid.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <TopoDS_Face.hxx>
33 #include <TopoDS_Edge.hxx>
34 #include <TopoDS_Solid.hxx>
35 #include <TopoDS_Iterator.hxx>
36 #include <TopoDS_Shell.hxx>
37 #include <TopoDS_Compound.hxx>
40 #include <TopExp_Explorer.hxx>
42 #include <BRep_Builder.hxx>
43 #include <BRepTools.hxx>
44 #include <BRepClass3d_SolidClassifier.hxx>
46 #include <BOPCol_IndexedMapOfShape.hxx>
47 #include <BOPCol_MapOfShape.hxx>
48 #include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
49 #include <BOPCol_ListOfShape.hxx>
51 #include <BOPDS_DS.hxx>
52 #include <BOPDS_ShapeInfo.hxx>
54 #include <BOPTools.hxx>
55 #include <BOPTools_AlgoTools.hxx>
57 #include <BOPTools_MapOfSet.hxx>
58 #include <BOPTools_Set.hxx>
60 #include <BOPAlgo_BuilderSolid.hxx>
62 #include <BOPCol_DataMapOfIntegerShape.hxx>
63 #include <Bnd_Box.hxx>
64 #include <BRepBndLib.hxx>
66 #include <NCollection_UBTreeFiller.hxx>
67 #include <BOPDS_BoxBndTree.hxx>
68 #include <BOPCol_ListOfInteger.hxx>
69 #include <BOPInt_Context.hxx>
73 Standard_Boolean IsClosedShell(const TopoDS_Shell& aSh);
76 void OwnInternalShapes(const TopoDS_Shape& ,
77 BOPCol_IndexedMapOfShape& );
79 //=======================================================================
80 //class : BOPAlgo_ShapeBox
81 //purpose : Auxiliary class
82 //=======================================================================
83 class BOPAlgo_ShapeBox {
91 void SetShape(const TopoDS_Shape& aS) {
95 const TopoDS_Shape& Shape()const {
99 void SetBox(const Bnd_Box& aBox) {
103 const Bnd_Box& Box()const {
108 TopoDS_Shape myShape;
112 typedef NCollection_DataMap\
113 <Standard_Integer, BOPAlgo_ShapeBox, TColStd_MapIntegerHasher> \
114 BOPAlgo_DataMapOfIntegerShapeBox;
116 typedef BOPAlgo_DataMapOfIntegerShapeBox::Iterator \
117 BOPAlgo_DataMapIteratorOfDataMapOfIntegerShapeBox;
120 //=======================================================================
121 //function : FillImagesSolids
123 //=======================================================================
124 void BOPAlgo_Builder::FillImagesSolids()
126 Standard_Boolean bHasSolids;
127 Standard_Integer i, aNbS;
131 bHasSolids=Standard_False;
132 aNbS=myDS->NbSourceShapes();
133 for (i=0; i<aNbS; ++i) {
134 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
135 if (aSI.ShapeType()==TopAbs_SOLID) {
136 bHasSolids=!bHasSolids;
145 Handle(NCollection_IncAllocator) aAlr;
147 aAlr=new NCollection_IncAllocator();
149 BOPCol_DataMapOfShapeListOfShape theInParts(100, aAlr);
150 BOPCol_DataMapOfShapeShape theDraftSolids(100, aAlr);
152 FillIn3DParts(theInParts, theDraftSolids, aAlr);
153 BuildSplitSolids(theInParts, theDraftSolids, aAlr);
154 FillInternalShapes();
157 theDraftSolids.Clear();
159 //=======================================================================
160 //function : FillIn3DParts
162 //=======================================================================
163 void BOPAlgo_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts,
164 BOPCol_DataMapOfShapeShape& theDraftSolids,
165 const BOPCol_BaseAllocator& )
167 Standard_Boolean bHasImage;
168 Standard_Integer i, k, aNbS, aNbLIF, nFP, aNbFP, aNbFIN, iIsIN;
172 BOPCol_ListIteratorOfListOfInteger aItLI, aItLI1;
173 BOPCol_ListIteratorOfListOfShape aItLS;
174 BOPAlgo_ShapeBox aSB;
175 Handle(NCollection_IncAllocator) aAlr0;
177 aAlr0=new NCollection_IncAllocator();
178 BOPAlgo_DataMapOfIntegerShapeBox aDMISB(100, aAlr0);
179 BOPAlgo_DataMapIteratorOfDataMapOfIntegerShapeBox aItDMISB;
182 theDraftSolids.Clear();
184 // 1. aDMISB map Index/FaceBox
186 aNbS=myDS->NbSourceShapes();
187 for (i=0; i<aNbS; ++i) {
188 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
189 if (aSI.ShapeType()!=TopAbs_FACE) {
193 const TopoDS_Shape& aS=aSI.Shape();
195 if (myImages.IsBound(aS)) {
196 const BOPCol_ListOfShape& aLS=myImages.Find(aS);
197 aItLS.Initialize(aLS);
198 for (; aItLS.More(); aItLS.Next()) {
199 const TopoDS_Shape& aSx=aItLS.Value();
202 BRepBndLib::Add(aSx, aBox);
212 const Bnd_Box& aBox=aSI.Box();
220 }//for (i=0; i<aNbS; ++i) {
223 for (i=0; i<aNbS; ++i) {
224 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
225 if (aSI.ShapeType()!=TopAbs_SOLID) {
229 //---------------------------------------------
230 Handle(NCollection_IncAllocator) aAlr1;
232 aAlr1=new NCollection_IncAllocator();
234 BOPCol_ListOfShape aLFIN(aAlr1);
235 BOPCol_ListOfShape aLIF(aAlr1);
236 BOPCol_IndexedMapOfShape aMF(100, aAlr1);
237 BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, aAlr1);
239 BOPDS_BoxBndTreeSelector aSelector;
240 BOPDS_BoxBndTree aBBTree;
241 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
244 const TopoDS_Shape& aS=aSI.Shape();
245 const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aS));
247 // 2.0 Flag bHasImage
248 bHasImage=Standard_False;
250 for (; aIt.More(); aIt.Next()) {
251 const TopoDS_Shape& aShell=aIt.Value();
252 bHasImage=myImages.IsBound(aShell);
258 // 2.1 Compute Bnd_Box for the solid aS [ aBoxS ]
259 BuildBndBox(i, aBoxS);
262 // 2.2 Build Draft Solid [aSD]
265 BuildDraftSolid(aSolid, aSD, aLIF);
266 aNbLIF=aLIF.Extent();
268 BOPTools::MapShapesAndAncestors(aSD, TopAbs_EDGE, TopAbs_FACE, aMEF);
270 // 2.3 Faces from aSD and own internal faces => aMF
271 BOPTools::MapShapes(aSD, TopAbs_FACE, aMF);
273 aItLS.Initialize(aLIF);
274 for (; aItLS.More(); aItLS.Next()) {
275 const TopoDS_Shape& aFI=aItLS.Value();
279 // 2.4. Prepare TreeFiller
280 aItDMISB.Initialize(aDMISB);
281 for (; aItDMISB.More(); aItDMISB.Next()) {
283 const BOPAlgo_ShapeBox& aSBk=aItDMISB.Value();
284 const TopoDS_Shape& aFk=aSBk.Shape();
285 if (aMF.Contains(aFk)) {
289 const Bnd_Box& aBk=aSBk.Box();
291 aTreeFiller.Add(k, aBk);
294 // 2.5. Shake TreeFiller
297 // 2.6. Select boxes of faces that are not out of aBoxS
299 aSelector.SetBox(aBoxS);
301 aNbFP=aBBTree.Select(aSelector);
303 const BOPCol_ListOfInteger& aLIFP=aSelector.Indices();
305 // 2.7. Collect faces that are IN aSolid [ aLFIN ]
306 BOPCol_ListOfShape aLFP(aAlr1);
307 BOPCol_ListOfShape aLCBF(aAlr1);
308 BOPCol_MapOfShape aMFDone(100, aAlr1);
309 BOPCol_IndexedMapOfShape aME(100, aAlr1);
311 BOPTools::MapShapes(aSD, TopAbs_EDGE, aME);
313 aItLI.Initialize(aLIFP);
314 for (; aItLI.More(); aItLI.Next()) {
316 const BOPAlgo_ShapeBox& aSBF=aDMISB.Find(nFP);
317 const TopoDS_Face& aFP=(*(TopoDS_Face*)&aSBF.Shape());
318 if (aMFDone.Contains(aFP)) {
324 iIsIN=BOPTools_AlgoTools::IsInternalFace(aFP, aSD, aMEF, 1.e-14, myContext);
329 aItLI1.Initialize(aLIFP);
330 for (; aItLI1.More(); aItLI1.Next()) {
331 const TopoDS_Shape& aFx=aDMISB.Find(aItLI1.Value()).Shape();
332 if (!aMFDone.Contains(aFx)) {
338 //----------------------------------------
340 Handle(NCollection_IncAllocator) aAlr2;
341 aAlr2=new NCollection_IncAllocator();
343 BOPTools_AlgoTools::MakeConnexityBlock(aLFP, aME, aLCBF, aAlr2);
345 //----------------------------------------
346 aItLS.Initialize(aLCBF);
347 for (; aItLS.More(); aItLS.Next()) {
348 const TopoDS_Shape& aFx=aItLS.Value();
354 }// for (; aItLI.More(); aItLI.Next()) {
356 // 2.8. Store the results in theInParts, theDraftSolids
357 aNbFIN=aLFIN.Extent();
358 if (aNbFIN || aNbLIF) {
359 aItLS.Initialize(aLIF);
360 for (; aItLS.More(); aItLS.Next()) {
361 const TopoDS_Shape& aFI=aItLS.Value();
364 theInParts.Bind(aSolid, aLFIN);
367 if (aNbFIN || bHasImage) {
368 theDraftSolids.Bind(aSolid, aSD);
370 //---------------------------------------------
371 }// for (i=0; i<aNbS; ++i) {
374 //=======================================================================
375 //function : BuildDraftSolid
377 //=======================================================================
378 void BOPAlgo_Builder::BuildDraftSolid(const TopoDS_Shape& theSolid,
379 TopoDS_Shape& theDraftSolid,
380 BOPCol_ListOfShape& theLIF)
384 Standard_Boolean bToReverse;
385 Standard_Integer iFlag;
386 TopAbs_Orientation aOrF, aOrSh, aOrSd;
387 TopoDS_Iterator aIt1, aIt2;
389 TopoDS_Shape aFSDx, aFx;
391 BOPCol_ListIteratorOfListOfShape aItS;
393 aOrSd=theSolid.Orientation();
394 theDraftSolid.Orientation(aOrSd);
396 aIt1.Initialize(theSolid);
397 for (; aIt1.More(); aIt1.Next()) {
398 const TopoDS_Shape& aSh=aIt1.Value();
399 if(aSh.ShapeType()!=TopAbs_SHELL) {
400 continue; // mb internal edges,vertices
403 aOrSh=aSh.Orientation();
405 aShD.Orientation(aOrSh);
408 aIt2.Initialize(aSh);
409 for (; aIt2.More(); aIt2.Next()) {
410 const TopoDS_Shape& aF=aIt2.Value();
411 aOrF=aF.Orientation();
413 if (myImages.IsBound(aF)) {
414 const BOPCol_ListOfShape& aLSp=myImages.Find(aF);
415 aItS.Initialize(aLSp);
416 for (; aItS.More(); aItS.Next()) {
419 if (myShapesSD.IsBound(aFx)) {
420 aFSDx=myShapesSD.Find(aFx);
422 if (aOrF==TopAbs_INTERNAL) {
423 aFSDx.Orientation(aOrF);
424 theLIF.Append(aFSDx);
427 bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aFSDx, aF, myContext);
433 aBB.Add(aShD, aFSDx);
435 }//if (myShapesSD.IsBound(aFx)) {
437 aFx.Orientation(aOrF);
438 if (aOrF==TopAbs_INTERNAL) {
447 } // if (myImages.IsBound(aF)) {
450 if (aOrF==TopAbs_INTERNAL) {
458 } //for (; aIt2.More(); aIt2.Next()) {
461 aBB.Add(theDraftSolid, aShD);
463 } //for (; aIt1.More(); aIt1.Next()) {
465 //=======================================================================
466 //function : BuildSplitSolids
468 //=======================================================================
469 void BOPAlgo_Builder::BuildSplitSolids(BOPCol_DataMapOfShapeListOfShape& theInParts,
470 BOPCol_DataMapOfShapeShape& theDraftSolids,
471 const BOPCol_BaseAllocator& )
475 Standard_Boolean bFlagSD;
476 Standard_Integer i, aNbS, iErr, aNbSFS;
477 TopExp_Explorer aExp;
478 BOPCol_ListIteratorOfListOfShape aIt;
479 BOPCol_DataMapIteratorOfDataMapOfShapeShape aIt1;
481 Handle(NCollection_IncAllocator) aAlr0;
482 aAlr0=new NCollection_IncAllocator();
484 BOPCol_ListOfShape aSFS(aAlr0), aLSEmpty(aAlr0);
485 BOPCol_MapOfShape aMFence(100, aAlr0);
486 BOPTools_MapOfSet aMST(100, aAlr0);
488 // 0. Find same domain solids for non-interferred solids
489 aNbS=myDS->NbSourceShapes();
490 for (i=0; i<aNbS; ++i) {
491 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
493 if (aSI.ShapeType()!=TopAbs_SOLID) {
497 const TopoDS_Shape& aS=aSI.Shape();
498 if (!aMFence.Add(aS)) {
501 if(theDraftSolids.IsBound(aS)) {
507 aST.Add(aS, TopAbs_FACE);
510 } //for (i=1; i<=aNbS; ++i)
512 // 1. Build solids for interferred source solids
513 for (i=0; i<aNbS; ++i) {
514 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
516 if (aSI.ShapeType()!=TopAbs_SOLID) {
520 const TopoDS_Shape& aS=aSI.Shape();
521 if(!theDraftSolids.IsBound(aS)) {
524 const TopoDS_Shape& aSD=theDraftSolids.Find(aS);
525 const BOPCol_ListOfShape& aLFIN=
526 (theInParts.IsBound(aS)) ? theInParts.Find(aS) : aLSEmpty;
528 // 1.1 Fill Shell Faces Set
530 aExp.Init(aSD, TopAbs_FACE);
531 for (; aExp.More(); aExp.Next()) {
532 const TopoDS_Shape& aF=aExp.Current();
536 aIt.Initialize(aLFIN);
537 for (; aIt.More(); aIt.Next()) {
538 TopoDS_Shape aF=aIt.Value();
540 aF.Orientation(TopAbs_FORWARD);
542 aF.Orientation(TopAbs_REVERSED);
546 aNbSFS=aSFS.Extent();
548 // 1.3 Build new solids
549 Handle(NCollection_IncAllocator) aAlr1;
550 aAlr1=new NCollection_IncAllocator();
552 BOPAlgo_BuilderSolid aSB(aAlr1);
554 //aSB.SetContext(myContext);
557 iErr=aSB.ErrorStatus();
559 myErrorStatus=30; // SolidBuilder failed
563 const BOPCol_ListOfShape& aLSR=aSB.Areas();
565 // 1.4 Collect resulting solids and theirs set of faces.
567 if (!myImages.IsBound(aS)) {
568 BOPCol_ListOfShape aLSx;
570 myImages.Bind(aS, aLSx);
571 BOPCol_ListOfShape& aLSIm=myImages.ChangeFind(aS);
573 aIt.Initialize(aLSR);
574 for (; aIt.More(); aIt.Next()) {
577 const TopoDS_Shape& aSR=aIt.Value();
578 aST.Add(aSR, TopAbs_FACE);
580 bFlagSD=aMST.Contains(aST);
582 const BOPTools_Set& aSTx=aMST.Added(aST);
583 const TopoDS_Shape& aSx=aSTx.Shape();
587 myShapesSD.Bind(aSR, aSx);
591 }// for (i=0; i<aNbS; ++i) {
594 //=======================================================================
595 //function :FillInternalShapes
597 //=======================================================================
598 void BOPAlgo_Builder::FillInternalShapes()
602 Standard_Integer i, j, aNbS, aNbSI, aNbSx, aNbSd;
603 TopAbs_ShapeEnum aType;
605 TopoDS_Iterator aItS;
607 BOPCol_MapIteratorOfMapOfShape aItM;
608 BOPCol_ListIteratorOfListOfShape aIt, aIt1;
610 Handle(NCollection_IncAllocator) aAllocator;
611 //-----------------------------------------------------scope f
612 aAllocator=new NCollection_IncAllocator();
614 BOPCol_IndexedDataMapOfShapeListOfShape aMSx(100, aAllocator);
615 BOPCol_IndexedMapOfShape aMx(100, aAllocator);
616 BOPCol_MapOfShape aMSI(100, aAllocator);
617 BOPCol_MapOfShape aMFence(100, aAllocator);
618 BOPCol_MapOfShape aMSOr(100, aAllocator);
619 BOPCol_ListOfShape aLSd(aAllocator);
620 BOPCol_ListOfShape aLArgs(aAllocator);
622 // 1. Shapes to process
624 // 1.1 Shapes from pure arguments aMSI
625 // 1.1.1 vertex, edge, wire
627 aIt.Initialize(myArguments);
628 for (; aIt.More(); aIt.Next()) {
629 const TopoDS_Shape& aS=aIt.Value();
630 if (!aMFence.Add(aS)) {
634 aType=aS.ShapeType();
635 if (aType==TopAbs_WIRE) {
637 for(; aItS.More(); aItS.Next()) {
638 const TopoDS_Shape& aE=aItS.Value();
639 if (aMFence.Add(aE)) {
644 else if (aType==TopAbs_VERTEX || aType==TopAbs_EDGE){
650 aIt.Initialize(aLArgs);
651 for (; aIt.More(); aIt.Next()) {
652 const TopoDS_Shape& aS=aIt.Value();
653 aType=aS.ShapeType();
654 if (aType==TopAbs_VERTEX || aType==TopAbs_EDGE ||aType==TopAbs_WIRE) {
655 if (aMFence.Add(aS)) {
656 if (myImages.IsBound(aS)) {
657 const BOPCol_ListOfShape &aLSp=myImages.Find(aS);
658 aIt1.Initialize(aLSp);
659 for (; aIt1.More(); aIt1.Next()) {
660 const TopoDS_Shape& aSp=aIt1.Value();
673 // 2. Internal vertices, edges from source solids
677 aNbS=myDS->NbSourceShapes();
678 for (i=0; i<aNbS; ++i) {
679 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
681 if (aSI.ShapeType()!=TopAbs_SOLID) {
685 const TopoDS_Shape& aS=aSI.Shape();
688 OwnInternalShapes(aS, aMx);
691 for (j=1; j<=aNbSx; ++j) {
692 const TopoDS_Shape& aSi=aMx(j);
693 if (myImages.IsBound(aSi)) {
694 const BOPCol_ListOfShape &aLSp=myImages.Find(aSi);
695 aIt1.Initialize(aLSp);
696 for (; aIt1.More(); aIt1.Next()) {
697 const TopoDS_Shape& aSp=aIt1.Value();
706 // build aux map from splits of solids
707 if (myImages.IsBound(aS)) {
708 const BOPCol_ListOfShape &aLSp=myImages.Find(aS);
709 aIt.Initialize(aLSp);
710 for (; aIt.More(); aIt.Next()) {
711 const TopoDS_Shape& aSp=aIt.Value();
712 if (aMFence.Add(aSp)) {
713 BOPTools::MapShapesAndAncestors(aSp, TopAbs_VERTEX, TopAbs_EDGE, aMSx);
714 BOPTools::MapShapesAndAncestors(aSp, TopAbs_VERTEX, TopAbs_FACE, aMSx);
715 BOPTools::MapShapesAndAncestors(aSp, TopAbs_EDGE , TopAbs_FACE, aMSx);
721 if (aMFence.Add(aS)) {
722 BOPTools::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_EDGE, aMSx);
723 BOPTools::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_FACE, aMSx);
724 BOPTools::MapShapesAndAncestors(aS, TopAbs_EDGE , TopAbs_FACE, aMSx);
729 }// for (i=0; i<aNbS; ++i) {
733 // 3. Some shapes of aMSI can be already tied with faces of
735 aItM.Initialize(aMSI);
736 for (; aItM.More(); aItM.Next()) {
737 const TopoDS_Shape& aSI=aItM.Key();
738 if (aMSx.Contains(aSI)) {
739 const BOPCol_ListOfShape &aLSx=aMSx.FindFromKey(aSI);
753 // 5 Settle internal vertices and edges into solids
755 aIt.Initialize(aLSd);
756 for (; aIt.More(); aIt.Next()) {
757 TopoDS_Solid aSd=TopoDS::Solid(aIt.Value());
759 aItM.Initialize(aMSI);
760 for (; aItM.More(); aItM.Next()) {
761 TopoDS_Shape aSI=aItM.Key();
762 aSI.Orientation(TopAbs_INTERNAL);
764 aState=BOPTools_AlgoTools::ComputeStateByOnePoint(aSI, aSd, 1.e-11, myContext);
765 if (aState==TopAbs_IN) {
767 if(aMSOr.Contains(aSd)) {
772 aItS.Initialize(aSd);
773 for (; aItS.More(); aItS.Next()) {
774 const TopoDS_Shape& aSh=aItS.Value();
780 if (myImages.IsBound(aSdx)) {
781 BOPCol_ListOfShape& aLS=myImages.ChangeFind(aSdx);
785 BOPCol_ListOfShape aLS;
787 myImages.Bind(aSd, aLS);
798 } //if (aState==TopAbs_IN) {
799 }// for (; aItM.More(); aItM.Next()) {
800 }//for (; aIt1.More(); aIt1.Next()) {
802 //-----------------------------------------------------scope t
811 //=======================================================================
812 //function : BuildBndBox
814 //=======================================================================
815 void BOPAlgo_Builder::BuildBndBox(const Standard_Integer theIndex,
818 Standard_Boolean bIsOpenBox;
819 Standard_Integer nSh, nFc;
820 Standard_Real aTolS, aTolFc;
822 BOPCol_ListIteratorOfListOfInteger aItLI, aItLI1;
824 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(theIndex);
825 const TopoDS_Shape& aS=aSI.Shape();
826 const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aS));
828 bIsOpenBox=Standard_False;
831 const BOPCol_ListOfInteger& aLISh=aSI.SubShapes();
832 aItLI.Initialize(aLISh);
833 for (; aItLI.More(); aItLI.Next()) {
835 const BOPDS_ShapeInfo& aSISh=myDS->ShapeInfo(nSh);
836 if (aSISh.ShapeType()!=TopAbs_SHELL) {
840 const BOPCol_ListOfInteger& aLIFc=aSISh.SubShapes();
841 aItLI1.Initialize(aLIFc);
842 for (; aItLI1.More(); aItLI1.Next()) {
844 const BOPDS_ShapeInfo& aSIFc=myDS->ShapeInfo(nFc);
845 if (aSIFc.ShapeType()!=TopAbs_FACE) {
849 const Bnd_Box& aBFc=aSIFc.Box();
853 bIsOpenBox=(aBFc.IsOpenXmin() || aBFc.IsOpenXmax() ||
854 aBFc.IsOpenYmin() || aBFc.IsOpenYmax() ||
855 aBFc.IsOpenZmin() || aBFc.IsOpenZmax());
861 const TopoDS_Face& aFc=*((TopoDS_Face*)&aSIFc.Shape());
862 aTolFc=BRep_Tool::Tolerance(aFc);
866 }//for (; aItLI1.More(); aItLI1.Next()) {
871 const TopoDS_Shell& aSh=*((TopoDS_Shell*)&aSISh.Shape());
872 bIsOpenBox=IsClosedShell(aSh);
876 }//for (; aItLI.More(); aItLI.Next()) {
882 BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(aSolid);
883 aSC.PerformInfinitePoint(aTolS);
885 if (aState==TopAbs_IN) {
890 //=======================================================================
891 //function : OwnInternalShapes
893 //=======================================================================
894 void OwnInternalShapes(const TopoDS_Shape& theS,
895 BOPCol_IndexedMapOfShape& theMx)
899 aIt.Initialize(theS);
900 for (; aIt.More(); aIt.Next()) {
901 const TopoDS_Shape& aSx=aIt.Value();
902 if (aSx.ShapeType()!=TopAbs_SHELL) {
907 //=======================================================================
908 //function : IsClosedShell
910 //=======================================================================
911 Standard_Boolean IsClosedShell(const TopoDS_Shell& aSh)
913 Standard_Boolean bRet;
914 Standard_Integer i, aNbE, aNbF;
915 TopAbs_Orientation aOrF;
916 BOPCol_IndexedDataMapOfShapeListOfShape aMEF;
917 BOPCol_ListIteratorOfListOfShape aItLS;
921 BOPTools::MapShapesAndAncestors(aSh, TopAbs_EDGE, TopAbs_FACE, aMEF);
924 for (i=1; i<=aNbE; ++i) {
925 const TopoDS_Edge& aE=*((TopoDS_Edge*)&aMEF.FindKey(i));
926 if (BRep_Tool::Degenerated(aE)) {
931 const BOPCol_ListOfShape& aLF=aMEF(i);
932 aItLS.Initialize(aLF);
933 for (; aItLS.More(); aItLS.Next()) {
934 const TopoDS_Shape& aF=aItLS.Value();
935 aOrF=aF.Orientation();
936 if (aOrF==TopAbs_INTERNAL || aOrF==TopAbs_EXTERNAL) {
954 // 30 - SolidBuilder failed