1 // Created on: 2012-06-01
2 // Created by: Eugeny MALTCHIKOV
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <BOPAlgo_BuilderFace.hxx>
18 #include <BOPDS_DS.hxx>
19 #include <BOPDS_FaceInfo.hxx>
20 #include <BOPDS_ListOfPave.hxx>
21 #include <BOPDS_ListOfPaveBlock.hxx>
22 #include <BOPDS_MapOfPaveBlock.hxx>
23 #include <BOPDS_Pave.hxx>
24 #include <BOPDS_ShapeInfo.hxx>
25 #include <BOPTools_AlgoTools.hxx>
26 #include <BOPTools_AlgoTools2D.hxx>
27 #include <BOPTools_AlgoTools3D.hxx>
28 #include <BOPTools_MapOfSet.hxx>
29 #include <BRep_Builder.hxx>
30 #include <BRep_Tool.hxx>
31 #include <BRepBndLib.hxx>
32 #include <BRepFeat_Builder.hxx>
33 #include <Geom_Curve.hxx>
34 #include <IntTools_Tools.hxx>
35 #include <Precision.hxx>
37 #include <TopExp_Explorer.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <TopoDS_Face.hxx>
40 #include <TopoDS_Shape.hxx>
41 #include <TopTools_ListIteratorOfListOfShape.hxx>
42 #include <TopTools_DataMapOfShapeListOfShape.hxx>
44 //=======================================================================
47 //=======================================================================
48 BRepFeat_Builder::BRepFeat_Builder()
55 //=======================================================================
58 //=======================================================================
59 BRepFeat_Builder::~BRepFeat_Builder()
63 //=======================================================================
66 //=======================================================================
67 void BRepFeat_Builder::Clear()
74 //=======================================================================
77 //=======================================================================
78 void BRepFeat_Builder::Init(const TopoDS_Shape& theShape)
82 AddArgument(theShape);
85 //=======================================================================
88 //=======================================================================
89 void BRepFeat_Builder::Init(const TopoDS_Shape& theShape,
90 const TopoDS_Shape& theTool)
94 AddArgument(theShape);
98 //=======================================================================
99 //function : SetOperation
101 //=======================================================================
102 void BRepFeat_Builder::SetOperation(const Standard_Integer theFuse)
105 myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT;
108 //=======================================================================
109 //function : SetOperation
111 //=======================================================================
112 void BRepFeat_Builder::SetOperation(const Standard_Integer theFuse,
113 const Standard_Boolean theFlag)
117 myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT;
119 myOperation = myFuse ? BOPAlgo_CUT21 : BOPAlgo_COMMON;
123 //=======================================================================
124 //function : PartsOfTool
126 //=======================================================================
127 void BRepFeat_Builder::PartsOfTool(TopTools_ListOfShape& aLT)
129 TopExp_Explorer aExp;
132 aExp.Init(myShape, TopAbs_SOLID);
133 for (;aExp.More(); aExp.Next()) {
134 const TopoDS_Shape& aS = aExp.Current();
139 //=======================================================================
140 //function : KeepPartsOfTool
142 //=======================================================================
143 void BRepFeat_Builder::KeepParts(const TopTools_ListOfShape& theIm)
145 TopTools_ListIteratorOfListOfShape aItT;
146 aItT.Initialize(theIm);
147 for (; aItT.More(); aItT.Next()) {
148 const TopoDS_Shape& aTIm=aItT.Value();
153 //=======================================================================
154 //function : KeepPart
156 //=======================================================================
157 void BRepFeat_Builder::KeepPart(const TopoDS_Shape& thePart)
159 TopoDS_Shape aF, aFOr;
160 TopExp_Explorer aExp;
162 TopExp::MapShapes(thePart, myShapes);
165 //=======================================================================
168 //=======================================================================
169 void BRepFeat_Builder::Prepare()
171 GetReport()->Clear();
175 aBB.MakeCompound(aC);
181 //=======================================================================
182 //function : FillRemoved
184 //=======================================================================
185 void BRepFeat_Builder::FillRemoved()
187 TopExp_Explorer aExp;
189 const TopoDS_Shape& aArgs0=myArguments.First();
190 const TopoDS_Shape& aArgs1=myTools.First();
192 aExp.Init(aArgs0, TopAbs_SOLID);
193 for (; aExp.More(); aExp.Next()) {
194 const TopoDS_Shape& aS = aExp.Current();
198 if (!myImages.IsBound(aArgs1)) {
202 TopTools_ListIteratorOfListOfShape aItIm;
204 TopTools_ListOfShape& aLS = myImages.ChangeFind(aArgs1);
205 aItIm.Initialize(aLS);
206 for (; aItIm.More(); aItIm.Next()) {
207 const TopoDS_Shape& aS = aItIm.Value();
208 FillRemoved(aS, myRemoved);
212 //=======================================================================
213 //function : PerformResult
215 //=======================================================================
216 void BRepFeat_Builder::PerformResult()
218 myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT;
220 if (!myShapes.IsEmpty()) {
226 FillImagesContainers(TopAbs_SHELL);
238 BuildResult(TopAbs_SOLID);
243 FillImagesCompounds();
248 BuildResult(TopAbs_COMPOUND);
257 //=======================================================================
258 //function : RebuildFaces
260 //=======================================================================
261 void BRepFeat_Builder::RebuildFaces()
263 Standard_Integer aNbS, i, iRank, nSp, j;
264 Standard_Boolean bIsClosed, bIsDegenerated, bToReverse,
265 bRem, bIm, bFlagSD, bVInShapes;
266 TopAbs_Orientation anOriF, anOriE;
267 TopoDS_Face aFF, aFSD;
270 TopExp_Explorer aExp, aExpE;
271 TopTools_MapOfShape aME, aMESplit;
272 TopTools_ListIteratorOfListOfShape aItIm;
273 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
274 TopTools_MapIteratorOfMapOfShape aItM;
275 BOPTools_MapOfSet aMST;
276 TopTools_ListOfShape aLE;
278 aItM.Initialize(myShapes);
279 for (; aItM.More(); aItM.Next()) {
280 const TopoDS_Shape& aS = aItM.Value();
281 if (aS.ShapeType() == TopAbs_FACE) {
283 aST.Add(aS, TopAbs_EDGE);
288 aNbS=myDS->NbSourceShapes();
289 for (i=0; i<aNbS; ++i) {
290 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
292 iRank = myDS->Rank(i);
294 const TopoDS_Shape& aS = aSI.Shape();
296 if (myImages.IsBound(aS)) {
297 TopTools_ListOfShape& aLIm = myImages.ChangeFind(aS);
298 aItIm.Initialize(aLIm);
299 for (; aItIm.More(); ) {
300 const TopoDS_Shape& aSIm = aItIm.Value();
301 if (!myShapes.Contains(aSIm)) {
311 if (aSI.ShapeType()!=TopAbs_FACE) {
315 const BOPDS_FaceInfo& aFI=myDS->FaceInfo(i);
316 const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape()));
318 if (!myImages.IsBound(aF)) {
322 anOriF=aF.Orientation();
324 aFF.Orientation(TopAbs_FORWARD);
326 const BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn();
327 const BOPDS_IndexedMapOfPaveBlock& aMPBSc=aFI.PaveBlocksSc();
332 aExp.Init(aFF, TopAbs_EDGE);
333 for (; aExp.More(); aExp.Next()) {
334 const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current()));
335 anOriE=aE.Orientation();
336 bIsDegenerated=BRep_Tool::Degenerated(aE);
337 bIsClosed=BRep_Tool::IsClosed(aE, aF);
338 if (myImages.IsBound(aE)) {
339 TopTools_ListOfShape& aLEIm = myImages.ChangeFind(aE);
341 bRem = Standard_False;
342 bIm = Standard_False;
344 TopTools_ListOfShape aLEImNew;
346 aItIm.Initialize(aLEIm);
347 for (; aItIm.More(); aItIm.Next()) {
348 const TopoDS_Shape& aS = aItIm.Value();
350 bVInShapes = Standard_False;
351 if (myShapes.Contains(aS)) {
352 bVInShapes = Standard_True;
354 aExpE.Init(aS, TopAbs_VERTEX);
355 for(;aExpE.More(); aExpE.Next()) {
356 const TopoDS_Shape& aV = aExpE.Current();
357 if (myShapes.Contains(aV)) {
358 bVInShapes = Standard_True;
368 bRem = Standard_True;
379 if (aLEIm.Extent() == 2) {
383 if (aMESplit.Add(aE)) {
384 RebuildEdge(aE, aFF, aME, aLEImNew);
385 aLEIm.Assign(aLEImNew);
386 if (aLEIm.Extent() == 1) {
393 aItIm.Initialize(aLEIm);
394 for (; aItIm.More(); aItIm.Next()) {
395 aSp = *(TopoDS_Edge*)&aItIm.Value();
397 if (bIsDegenerated) {
398 aSp.Orientation(anOriE);
403 if (anOriE==TopAbs_INTERNAL) {
404 aSp.Orientation(TopAbs_FORWARD);
406 aSp.Orientation(TopAbs_REVERSED);
412 if (!BRep_Tool::IsClosed(aSp, aFF)){
413 BOPTools_AlgoTools3D::DoSplitSEAMOnFace(aSp, aFF);
416 aSp.Orientation(TopAbs_FORWARD);
418 aSp.Orientation(TopAbs_REVERSED);
423 aSp.Orientation(anOriE);
424 bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, aE, myContext);
436 Standard_Integer aNbPBIn, aNbPBSc;
437 aNbPBIn = aMPBIn.Extent();
438 aNbPBSc = aMPBSc.Extent();
441 for (j=1; j<=aNbPBIn; ++j) {
442 const Handle(BOPDS_PaveBlock)& aPB=aMPBIn(j);
444 aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp)));
445 if (myRemoved.Contains(aSp)) {
449 aSp.Orientation(TopAbs_FORWARD);
451 aSp.Orientation(TopAbs_REVERSED);
455 for (j=1; j<=aNbPBSc; ++j) {
456 const Handle(BOPDS_PaveBlock)& aPB=aMPBSc(j);
458 aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp)));
459 if (myRemoved.Contains(aSp)) {
463 aSp.Orientation(TopAbs_FORWARD);
465 aSp.Orientation(TopAbs_REVERSED);
470 BOPAlgo_BuilderFace aBF;
476 TopTools_ListOfShape& aLFIm = myImages.ChangeFind(aF);
479 const TopTools_ListOfShape& aLFR=aBF.Areas();
480 aItIm.Initialize(aLFR);
481 for (; aItIm.More(); aItIm.Next()) {
482 TopoDS_Shape& aFR=aItIm.ChangeValue();
485 aST.Add(aFR, TopAbs_EDGE);
486 bFlagSD=aMST.Contains(aST);
488 const BOPTools_Set& aSTx=aMST.Added(aST);
490 aSx.Orientation(anOriF);
493 TopTools_ListOfShape* pLOr = myOrigins.ChangeSeek(aSx);
495 pLOr = myOrigins.Bound(aSx, TopTools_ListOfShape());
500 myShapesSD.Bind(aFR, aSx);
504 if (aLFIm.Extent() == 0) {
510 //=======================================================================
511 //function : RebuildEdge
513 //=======================================================================
514 void BRepFeat_Builder::RebuildEdge(const TopoDS_Shape& theE,
515 const TopoDS_Face& theF,
516 const TopTools_MapOfShape& aME,
517 TopTools_ListOfShape& aLIm)
519 Standard_Integer nE, nSp, nV1, nV2, nE1, nV, nVx, nVSD;
520 Standard_Integer nV11, nV21;
521 Standard_Boolean bOld;
522 Standard_Real aT11, aT21;
523 Standard_Real aT1, aT2;
526 TopoDS_Vertex aV1, aV2;
527 Handle(BOPDS_PaveBlock) aPBNew;
528 TColStd_MapOfInteger aMI, aMAdd, aMV, aMVOr;
529 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
530 TopTools_ListIteratorOfListOfShape aIt;
531 TColStd_ListIteratorOfListOfInteger aItLI;
532 TopTools_MapIteratorOfMapOfShape aItM;
533 BOPDS_MapOfPaveBlock aMPB;
534 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
536 aSI.SetShapeType(TopAbs_EDGE);
538 //1. collect origin vertices to aMV map.
539 nE = myDS->Index(theE);
540 const BOPDS_ShapeInfo& aSIE = myDS->ShapeInfo(nE);
541 const TColStd_ListOfInteger& aLS = aSIE.SubShapes();
542 aItLI.Initialize(aLS);
543 for(; aItLI.More(); aItLI.Next()) {
546 if (myDS->HasShapeSD(nV, nVSD)) {
553 //2. collect vertices that should be removed to aMI map.
554 aPBNew = new BOPDS_PaveBlock;
555 BOPDS_ListOfPave& aLPExt = aPBNew->ChangeExtPaves();
556 BOPDS_ListOfPaveBlock& aLPB = myDS->ChangePaveBlocks(nE);
558 for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) {
559 const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
561 const TopoDS_Shape& aE1 = myDS->Shape(nE1);
563 if (aME.Contains(aE1)) {
564 aPB->Indices(nV1, nV2);
572 //3. collect vertices that split the source shape.
573 for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) {
574 const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
575 aPB->Indices(nV1, nV2);
577 if (!aMI.Contains(nV1)) {
580 if (!aMI.Contains(nV2)) {
584 //4. collect ext paves.
585 for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) {
586 const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
587 aPB->Indices(nV1, nV2);
589 if (aMV.Contains(nV1)) {
590 if (aMAdd.Add(nV1) || aMVOr.Contains(nV1)) {
591 aLPExt.Append(aPB->Pave1());
595 if (aMV.Contains(nV2)) {
596 if (aMAdd.Add(nV2) || aMVOr.Contains(nV2)) {
597 aLPExt.Append(aPB->Pave2());
602 aE = (*(TopoDS_Edge *)(&theE));
603 aE.Orientation(TopAbs_FORWARD);
607 //5. split edge by new set of vertices.
609 aPBNew->SetOriginalEdge(nE);
610 aPBNew->Update(aLPB, Standard_False);
612 for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) {
613 Handle(BOPDS_PaveBlock)& aPB = aItPB.ChangeValue();
614 const BOPDS_Pave& aPave1=aPB->Pave1();
615 aPave1.Contents(nV1, aT1);
617 const BOPDS_Pave& aPave2=aPB->Pave2();
618 aPave2.Contents(nV2, aT2);
620 aItMPB.Initialize(aMPB);
621 //check if it is the old pave block.
622 bOld = Standard_False;
623 for (; aItMPB.More(); aItMPB.Next()) {
624 const Handle(BOPDS_PaveBlock)& aPB1 = aItMPB.Value();
625 aPB1->Indices(nV11, nV21);
626 aPB1->Range(aT11, aT21);
627 if (nV1 == nV11 && nV2 == nV21 &&
628 aT1 == aT11 && aT2 == aT21) {
629 const TopoDS_Shape& aEIm = myDS->Shape(aPB1->Edge());
631 bOld = Standard_True;
639 aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
640 aV1.Orientation(TopAbs_FORWARD);
642 aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
643 aV2.Orientation(TopAbs_REVERSED);
645 BOPTools_AlgoTools::MakeSplitEdge(aE, aV1, aT1, aV2, aT2, aSp);
646 BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aSp, theF, myContext);
650 Bnd_Box& aBox=aSI.ChangeBox();
651 BRepBndLib::Add(aSp, aBox);
653 nSp=myDS->Append(aSI);
660 //=======================================================================
661 //function : CheckSolidImages
663 //=======================================================================
664 void BRepFeat_Builder::CheckSolidImages()
666 BOPTools_MapOfSet aMST;
667 TopTools_ListOfShape aLSImNew;
668 TopTools_MapOfShape aMS;
669 TopTools_ListIteratorOfListOfShape aIt;
670 TopExp_Explorer aExp, aExpF;
671 Standard_Boolean bFlagSD;
673 const TopoDS_Shape& aArgs0=myArguments.First();
674 const TopoDS_Shape& aArgs1=myTools.First();
676 const TopTools_ListOfShape& aLSIm = myImages.Find(aArgs1);
677 aIt.Initialize(aLSIm);
678 for(;aIt.More();aIt.Next()) {
679 const TopoDS_Shape& aSolIm = aIt.Value();
682 aST.Add(aSolIm, TopAbs_FACE);
686 aExp.Init(aArgs0, TopAbs_SOLID);
687 for(; aExp.More(); aExp.Next()) {
688 const TopoDS_Shape& aSolid = aExp.Current();
689 if (myImages.IsBound(aSolid)) {
690 TopTools_ListOfShape& aLSImSol = myImages.ChangeFind(aSolid);
691 aIt.Initialize(aLSImSol);
692 for(;aIt.More();aIt.Next()) {
693 const TopoDS_Shape& aSolIm = aIt.Value();
696 aST.Add(aSolIm, TopAbs_FACE);
697 bFlagSD=aMST.Contains(aST);
699 const BOPTools_Set& aSTx=aMST.Added(aST);
700 const TopoDS_Shape& aSx=aSTx.Shape();
701 aLSImNew.Append(aSx);
704 myShapesSD.Bind(aSolIm, aSx);
707 aLSImSol.Assign(aLSImNew);
712 //=======================================================================
713 //function : MapShapes
715 //=======================================================================
716 void BRepFeat_Builder::FillRemoved(const TopoDS_Shape& S,
717 TopTools_MapOfShape& M)
719 if (myShapes.Contains(S)) {
724 TopoDS_Iterator It(S);
726 FillRemoved(It.Value(),M);
731 //=======================================================================
732 //function : FillIn3DParts
734 //=======================================================================
735 void BRepFeat_Builder::FillIn3DParts(TopTools_DataMapOfShapeListOfShape& theInParts,
736 TopTools_DataMapOfShapeShape& theDraftSolids,
737 const Handle(NCollection_BaseAllocator)& theAllocator)
739 GetReport()->Clear();
741 Standard_Boolean bIsIN, bHasImage;
742 Standard_Integer aNbS, i, j, aNbFP, aNbFPx, aNbFIN, aNbLIF, aNbEFP;
743 TopAbs_ShapeEnum aType;
745 TopoDS_Iterator aIt, aItF;
747 TopoDS_Solid aSolidSp;
749 TopTools_ListIteratorOfListOfShape aItS, aItFP, aItEx;
750 TopTools_MapIteratorOfMapOfShape aItMS, aItMS1;
752 TopTools_ListOfShape aLIF(theAllocator);
753 TopTools_MapOfShape aMFDone(100, theAllocator);
754 TopTools_MapOfShape aMSolids(100, theAllocator);
755 TopTools_MapOfShape aMFaces(100, theAllocator);
756 TopTools_MapOfShape aMFIN(100, theAllocator);
757 TopTools_IndexedMapOfShape aMS(100, theAllocator);
758 TopTools_IndexedDataMapOfShapeListOfShape aMEF(100, theAllocator);
760 theDraftSolids.Clear();
762 aNbS=myDS->NbSourceShapes();
763 for (i=0; i<aNbS; ++i) {
764 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
765 const TopoDS_Shape& aS=aSI.Shape();
767 aType=aSI.ShapeType();
775 // all faces (originals or images)
776 if (myImages.IsBound(aS)) {
777 const TopTools_ListOfShape& aLS=myImages.Find(aS);
778 aItS.Initialize(aLS);
779 for (; aItS.More(); aItS.Next()) {
780 const TopoDS_Shape& aFx=aItS.Value();
781 if (!myRemoved.Contains(aFx)) {
787 if (!myRemoved.Contains(aS)) {
799 aItMS.Initialize(aMSolids);
800 for (; aItMS.More(); aItMS.Next()) {
801 const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aItMS.Value()));
807 aBB.MakeSolid(aSolidSp);
809 // Draft solid and its pure internal faces => aSolidSp, aLIF
811 BuildDraftSolid(aSolid, aSolidSp, aLIF);
812 aNbLIF=aLIF.Extent();
814 // 1 all faces/edges from aSolid [ aMS ]
815 bHasImage=Standard_False;
817 aIt.Initialize(aSolid);
818 for (; aIt.More(); aIt.Next()) {
819 const TopoDS_Shape& aShell=aIt.Value();
821 if (myImages.IsBound(aShell)) {
822 bHasImage=Standard_True;
824 const TopTools_ListOfShape& aLS=myImages.Find(aShell);
825 aItS.Initialize(aLS);
826 for (; aItS.More(); aItS.Next()) {
827 const TopoDS_Shape& aSx=aItS.Value();
829 TopExp::MapShapes(aSx, TopAbs_FACE, aMS);
830 TopExp::MapShapes(aSx, TopAbs_EDGE, aMS);
831 TopExp::MapShapesAndAncestors(aSx, TopAbs_EDGE, TopAbs_FACE, aMEF);
836 TopExp::MapShapes(aShell, TopAbs_FACE, aMS);
837 TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF);
841 // 2 all faces that are not from aSolid [ aLFP1 ]
842 TopTools_IndexedDataMapOfShapeListOfShape aMEFP(100, theAllocator);
843 TopTools_ListOfShape aLFP1(theAllocator);
844 TopTools_ListOfShape aLFP(theAllocator);
845 TopTools_ListOfShape aLCBF(theAllocator);
846 TopTools_ListOfShape aLFIN(theAllocator);
847 TopTools_ListOfShape aLEx(theAllocator);
849 // for all non-solid faces build EF map [ aMEFP ]
850 aItMS1.Initialize(aMFaces);
851 for (; aItMS1.More(); aItMS1.Next()) {
852 const TopoDS_Shape& aFace=aItMS1.Value();
853 if (!aMS.Contains(aFace)) {
854 TopExp::MapShapesAndAncestors(aFace, TopAbs_EDGE, TopAbs_FACE, aMEFP);
858 // among all faces from aMEFP select these that have same edges
859 // with the solid (i.e aMEF). These faces will be treated first
860 // to prevent the usage of 3D classifier.
861 // The full list of faces to process is aLFP1.
862 aNbEFP=aMEFP.Extent();
863 for (j=1; j<=aNbEFP; ++j) {
864 const TopoDS_Shape& aE=aMEFP.FindKey(j);
866 if (aMEF.Contains(aE)) { // !!
867 const TopTools_ListOfShape& aLF=aMEFP(j);
868 aItFP.Initialize(aLF);
869 for (; aItFP.More(); aItFP.Next()) {
870 const TopoDS_Shape& aF=aItFP.Value();
871 if (aMFDone.Add(aF)) {
881 aItEx.Initialize(aLEx);
882 for (; aItEx.More(); aItEx.Next()) {
883 const TopoDS_Shape& aE=aItEx.Value();
884 const TopTools_ListOfShape& aLF=aMEFP.FindFromKey(aE);
885 aItFP.Initialize(aLF);
886 for (; aItFP.More(); aItFP.Next()) {
887 const TopoDS_Shape& aF=aItFP.Value();
888 if (aMFDone.Add(aF)) {
897 // 3 Process faces aLFP1
899 aNbFP=aLFP1.Extent();
900 aItFP.Initialize(aLFP1);
901 for (; aItFP.More(); aItFP.Next()) {
902 const TopoDS_Shape& aSP=aItFP.Value();
903 if (!aMFDone.Add(aSP)) {
908 // first face to process
909 aFP=(*(TopoDS_Face*)(&aSP));
910 bIsIN=BOPTools_AlgoTools::IsInternalFace(aFP, aSolidSp, aMEF, 1.e-14, myContext);
911 aState=(bIsIN) ? TopAbs_IN : TopAbs_OUT;
913 // collect faces to process [ aFP is the first ]
916 aItS.Initialize(aLFP1);
917 for (; aItS.More(); aItS.Next()) {
918 const TopoDS_Shape& aSk=aItS.Value();
919 if (!aMFDone.Contains(aSk)) {
924 // Connexity Block that spreads from aFP the Bound
925 // or till the end of the block itself
927 BOPTools_AlgoTools::MakeConnexityBlock(aLFP, aMS, aLCBF, theAllocator);
929 // fill states for the Connexity Block
930 aItS.Initialize(aLCBF);
931 for (; aItS.More(); aItS.Next()) {
932 const TopoDS_Shape& aSx=aItS.Value();
934 if (aState==TopAbs_IN) {
939 aNbFPx=aMFDone.Extent();
943 }//for (; aItFP.More(); aItFP.Next())
945 // faces Inside aSolid
947 aNbFIN=aMFIN.Extent();
948 if (aNbFIN || aNbLIF) {
949 aItMS1.Initialize(aMFIN);
950 for (; aItMS1.More(); aItMS1.Next()) {
951 const TopoDS_Shape& aFIn=aItMS1.Value();
955 aItS.Initialize(aLIF);
956 for (; aItS.More(); aItS.Next()) {
957 const TopoDS_Shape& aFIN=aItS.Value();
961 theInParts.Bind(aSolid, aLFIN);
963 if (aNbFIN || bHasImage) {
964 theDraftSolids.Bind(aSolid, aSolidSp);
966 }// for (; aItMS.More(); aItMS.Next()) {