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
8 // under the terms of the GNU Lesser General Public 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.
16 #include <BRepFeat_Builder.ixx>
18 #include <Precision.hxx>
20 #include <TopoDS_Shape.hxx>
21 #include <TopoDS_Face.hxx>
22 #include <TopoDS_Edge.hxx>
24 #include <TopExp_Explorer.hxx>
25 #include <TopTools_ListIteratorOfListOfShape.hxx>
27 #include <Geom_Curve.hxx>
29 #include <BRep_Tool.hxx>
30 #include <BRep_Builder.hxx>
32 #include <BRepBndLib.hxx>
34 #include <IntTools_Tools.hxx>
36 #include <BOPDS_DS.hxx>
37 #include <BOPDS_ShapeInfo.hxx>
38 #include <BOPDS_FaceInfo.hxx>
39 #include <BOPDS_Pave.hxx>
40 #include <BOPDS_ListOfPave.hxx>
41 #include <BOPDS_ListOfPaveBlock.hxx>
42 #include <BOPDS_MapOfPaveBlock.hxx>
44 #include <BOPAlgo_BuilderFace.hxx>
46 #include <BOPTools.hxx>
47 #include <BOPTools_AlgoTools.hxx>
48 #include <BOPTools_AlgoTools2D.hxx>
49 #include <BOPTools_AlgoTools3D.hxx>
50 #include <BOPTools_AlgoTools3D.hxx>
51 #include <BOPTools_MapOfSet.hxx>
53 #include <BOPCol_DataMapOfShapeListOfShape.hxx>
55 //=======================================================================
58 //=======================================================================
59 BRepFeat_Builder::BRepFeat_Builder()
66 //=======================================================================
69 //=======================================================================
70 BRepFeat_Builder::~BRepFeat_Builder()
74 //=======================================================================
77 //=======================================================================
78 void BRepFeat_Builder::Clear()
85 //=======================================================================
88 //=======================================================================
89 void BRepFeat_Builder::Init(const TopoDS_Shape& theShape)
93 AddArgument(theShape);
96 //=======================================================================
99 //=======================================================================
100 void BRepFeat_Builder::Init(const TopoDS_Shape& theShape,
101 const TopoDS_Shape& theTool)
105 AddArgument(theShape);
109 //=======================================================================
110 //function : SetOperation
112 //=======================================================================
113 void BRepFeat_Builder::SetOperation(const Standard_Integer theFuse)
116 myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT;
119 //=======================================================================
120 //function : SetOperation
122 //=======================================================================
123 void BRepFeat_Builder::SetOperation(const Standard_Integer theFuse,
124 const Standard_Boolean theFlag)
128 myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT;
130 myOperation = myFuse ? BOPAlgo_CUT21 : BOPAlgo_COMMON;
134 //=======================================================================
135 //function : PartsOfTool
137 //=======================================================================
138 void BRepFeat_Builder::PartsOfTool(TopTools_ListOfShape& aLT)
140 TopExp_Explorer aExp;
143 aExp.Init(myShape, TopAbs_SOLID);
144 for (;aExp.More(); aExp.Next()) {
145 const TopoDS_Shape& aS = aExp.Current();
150 //=======================================================================
151 //function : KeepPartsOfTool
153 //=======================================================================
154 void BRepFeat_Builder::KeepParts(const TopTools_ListOfShape& theIm)
156 TopTools_ListIteratorOfListOfShape aItT;
157 aItT.Initialize(theIm);
158 for (; aItT.More(); aItT.Next()) {
159 const TopoDS_Shape& aTIm=aItT.Value();
164 //=======================================================================
165 //function : KeepPart
167 //=======================================================================
168 void BRepFeat_Builder::KeepPart(const TopoDS_Shape& thePart)
170 TopoDS_Shape aF, aFOr;
171 TopExp_Explorer aExp;
173 BOPTools::MapShapes(thePart, myShapes);
176 //=======================================================================
179 //=======================================================================
180 void BRepFeat_Builder::Prepare()
186 aBB.MakeCompound(aC);
189 myFlagHistory=Standard_True;
194 //=======================================================================
195 //function : FillRemoved
197 //=======================================================================
198 void BRepFeat_Builder::FillRemoved()
200 TopExp_Explorer aExp;
201 aExp.Init(myArgs[0], TopAbs_SOLID);
202 for (; aExp.More(); aExp.Next()) {
203 const TopoDS_Shape& aS = aExp.Current();
207 if (!myImages.IsBound(myArgs[1])) {
211 BOPCol_ListIteratorOfListOfShape aItIm;
213 BOPCol_ListOfShape& aLS = myImages.ChangeFind(myArgs[1]);
214 aItIm.Initialize(aLS);
215 for (; aItIm.More(); aItIm.Next()) {
216 const TopoDS_Shape& aS = aItIm.Value();
217 FillRemoved(aS, myRemoved);
221 //=======================================================================
222 //function : PerformResult
224 //=======================================================================
225 void BRepFeat_Builder::PerformResult()
227 myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT;
229 if (!myShapes.IsEmpty()) {
235 FillImagesContainers(TopAbs_SHELL);
247 BuildResult(TopAbs_SOLID);
252 FillImagesCompounds();
257 BuildResult(TopAbs_COMPOUND);
266 //=======================================================================
267 //function : RebuildFaces
269 //=======================================================================
270 void BRepFeat_Builder::RebuildFaces()
272 Standard_Integer aNbS, i, iRank, nSp, j;
273 Standard_Boolean bIsClosed, bIsDegenerated, bToReverse,
274 bRem, bIm, bFlagSD, bVInShapes;
275 TopAbs_Orientation anOriF, anOriE;
276 TopoDS_Face aFF, aFSD;
279 TopExp_Explorer aExp, aExpE;
280 BOPCol_MapOfShape aME, aMESplit;
281 BOPCol_ListIteratorOfListOfShape aItIm;
282 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
283 BOPCol_MapIteratorOfMapOfShape aItM;
284 BOPTools_MapOfSet aMST;
285 BOPCol_ListOfShape aLE;
287 aItM.Initialize(myShapes);
288 for (; aItM.More(); aItM.Next()) {
289 const TopoDS_Shape& aS = aItM.Value();
290 if (aS.ShapeType() == TopAbs_FACE) {
292 aST.Add(aS, TopAbs_EDGE);
297 aNbS=myDS->NbSourceShapes();
298 for (i=0; i<aNbS; ++i) {
299 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
301 iRank = myDS->Rank(i);
303 const TopoDS_Shape& aS = aSI.Shape();
305 if (myImages.IsBound(aS)) {
306 BOPCol_ListOfShape& aLIm = myImages.ChangeFind(aS);
307 aItIm.Initialize(aLIm);
308 for (; aItIm.More(); ) {
309 const TopoDS_Shape& aSIm = aItIm.Value();
310 if (!myShapes.Contains(aSIm)) {
320 if (aSI.ShapeType()!=TopAbs_FACE) {
324 const BOPDS_FaceInfo& aFI=myDS->FaceInfo(i);
325 const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape()));
327 if (!myImages.IsBound(aF)) {
331 anOriF=aF.Orientation();
333 aFF.Orientation(TopAbs_FORWARD);
335 const BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn();
336 const BOPDS_IndexedMapOfPaveBlock& aMPBSc=aFI.PaveBlocksSc();
341 aExp.Init(aFF, TopAbs_EDGE);
342 for (; aExp.More(); aExp.Next()) {
343 const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current()));
344 anOriE=aE.Orientation();
345 bIsDegenerated=BRep_Tool::Degenerated(aE);
346 bIsClosed=BRep_Tool::IsClosed(aE, aF);
347 if (myImages.IsBound(aE)) {
348 BOPCol_ListOfShape& aLEIm = myImages.ChangeFind(aE);
350 bRem = Standard_False;
351 bIm = Standard_False;
353 BOPCol_ListOfShape aLEImNew;
355 aItIm.Initialize(aLEIm);
356 for (; aItIm.More(); aItIm.Next()) {
357 const TopoDS_Shape& aS = aItIm.Value();
359 bVInShapes = Standard_False;
360 if (myShapes.Contains(aS)) {
361 bVInShapes = Standard_True;
363 aExpE.Init(aS, TopAbs_VERTEX);
364 for(;aExpE.More(); aExpE.Next()) {
365 const TopoDS_Shape& aV = aExpE.Current();
366 if (myShapes.Contains(aV)) {
367 bVInShapes = Standard_True;
377 bRem = Standard_True;
388 if (aLEIm.Extent() == 2) {
392 if (aMESplit.Add(aE)) {
393 RebuildEdge(aE, aFF, aME, aLEImNew);
394 aLEIm.Assign(aLEImNew);
395 if (aLEIm.Extent() == 1) {
402 aItIm.Initialize(aLEIm);
403 for (; aItIm.More(); aItIm.Next()) {
404 aSp = *(TopoDS_Edge*)&aItIm.Value();
406 if (bIsDegenerated) {
407 aSp.Orientation(anOriE);
412 if (anOriE==TopAbs_INTERNAL) {
413 aSp.Orientation(TopAbs_FORWARD);
415 aSp.Orientation(TopAbs_REVERSED);
421 if (!BRep_Tool::IsClosed(aSp, aFF)){
422 BOPTools_AlgoTools3D::DoSplitSEAMOnFace(aSp, aFF);
425 aSp.Orientation(TopAbs_FORWARD);
427 aSp.Orientation(TopAbs_REVERSED);
432 aSp.Orientation(anOriE);
433 bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, aE, myContext);
445 Standard_Integer aNbPBIn, aNbPBSc;
446 aNbPBIn = aMPBIn.Extent();
447 aNbPBSc = aMPBSc.Extent();
450 for (j=1; j<=aNbPBIn; ++j) {
451 const Handle(BOPDS_PaveBlock)& aPB=aMPBIn(j);
453 aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp)));
454 if (myRemoved.Contains(aSp)) {
458 aSp.Orientation(TopAbs_FORWARD);
460 aSp.Orientation(TopAbs_REVERSED);
464 for (j=1; j<=aNbPBSc; ++j) {
465 const Handle(BOPDS_PaveBlock)& aPB=aMPBSc(j);
467 aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp)));
468 if (myRemoved.Contains(aSp)) {
472 aSp.Orientation(TopAbs_FORWARD);
474 aSp.Orientation(TopAbs_REVERSED);
479 BOPAlgo_BuilderFace aBF;
485 BOPCol_ListOfShape& aLFIm = myImages.ChangeFind(aF);
488 const BOPCol_ListOfShape& aLFR=aBF.Areas();
489 aItIm.Initialize(aLFR);
490 for (; aItIm.More(); aItIm.Next()) {
491 TopoDS_Shape& aFR=aItIm.ChangeValue();
494 aST.Add(aFR, TopAbs_EDGE);
495 bFlagSD=aMST.Contains(aST);
497 const BOPTools_Set& aSTx=aMST.Added(aST);
499 aSx.Orientation(anOriF);
501 myOrigins.Bind(aSx, aF);
504 myShapesSD.Bind(aFR, aSx);
508 mySplits.Bind(aF, aLFIm);
509 if (aLFIm.Extent() == 0) {
516 //=======================================================================
517 //function : RebuildEdge
519 //=======================================================================
520 void BRepFeat_Builder::RebuildEdge(const TopoDS_Shape& theE,
521 const TopoDS_Face& theF,
522 const BOPCol_MapOfShape& aME,
523 BOPCol_ListOfShape& aLIm)
525 Standard_Integer nE, nSp, nV1, nV2, nE1, nV, nVx, nVSD;
526 Standard_Integer nV11, nV21;
527 Standard_Boolean bOld;
528 Standard_Real aT11, aT21;
529 Standard_Real aT1, aT2;
532 TopoDS_Vertex aV1, aV2;
533 Handle(BOPDS_PaveBlock) aPBNew;
534 BOPCol_MapOfInteger aMI, aMAdd, aMV, aMVOr;
535 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
536 BOPCol_ListIteratorOfListOfShape aIt;
537 BOPCol_ListIteratorOfListOfInteger aItLI;
538 BOPCol_MapIteratorOfMapOfShape aItM;
539 BOPDS_MapOfPaveBlock aMPB;
540 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
542 aSI.SetShapeType(TopAbs_EDGE);
544 //1. collect origin vertices to aMV map.
545 nE = myDS->Index(theE);
546 const BOPDS_ShapeInfo& aSIE = myDS->ShapeInfo(nE);
547 const BOPCol_ListOfInteger& aLS = aSIE.SubShapes();
548 aItLI.Initialize(aLS);
549 for(; aItLI.More(); aItLI.Next()) {
552 if (myDS->HasShapeSD(nV, nVSD)) {
559 //2. collect vertices that should be removed to aMI map.
560 aPBNew = new BOPDS_PaveBlock;
561 BOPDS_ListOfPave& aLPExt = aPBNew->ChangeExtPaves();
562 BOPDS_ListOfPaveBlock& aLPB = myDS->ChangePaveBlocks(nE);
564 for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) {
565 const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
567 const TopoDS_Shape& aE1 = myDS->Shape(nE1);
569 if (aME.Contains(aE1)) {
570 aPB->Indices(nV1, nV2);
578 //3. collect vertices that split the source shape.
579 for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) {
580 const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
581 aPB->Indices(nV1, nV2);
583 if (!aMI.Contains(nV1)) {
586 if (!aMI.Contains(nV2)) {
590 //4. collect ext paves.
591 for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) {
592 const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
593 aPB->Indices(nV1, nV2);
595 if (aMV.Contains(nV1)) {
596 if (aMAdd.Add(nV1) || aMVOr.Contains(nV1)) {
597 aLPExt.Append(aPB->Pave1());
601 if (aMV.Contains(nV2)) {
602 if (aMAdd.Add(nV2) || aMVOr.Contains(nV2)) {
603 aLPExt.Append(aPB->Pave2());
608 aE = (*(TopoDS_Edge *)(&theE));
609 aE.Orientation(TopAbs_FORWARD);
613 //5. split edge by new set of vertices.
615 aPBNew->SetOriginalEdge(nE);
616 aPBNew->Update(aLPB, Standard_False);
618 for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) {
619 Handle(BOPDS_PaveBlock)& aPB = aItPB.ChangeValue();
620 const BOPDS_Pave& aPave1=aPB->Pave1();
621 aPave1.Contents(nV1, aT1);
623 const BOPDS_Pave& aPave2=aPB->Pave2();
624 aPave2.Contents(nV2, aT2);
626 aItMPB.Initialize(aMPB);
627 //check if it is the old pave block.
628 bOld = Standard_False;
629 for (; aItMPB.More(); aItMPB.Next()) {
630 const Handle(BOPDS_PaveBlock)& aPB1 = aItMPB.Value();
631 aPB1->Indices(nV11, nV21);
632 aPB1->Range(aT11, aT21);
633 if (nV1 == nV11 && nV2 == nV21 &&
634 aT1 == aT11 && aT2 == aT21) {
635 const TopoDS_Shape& aEIm = myDS->Shape(aPB1->Edge());
637 bOld = Standard_True;
645 aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
646 aV1.Orientation(TopAbs_FORWARD);
648 aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
649 aV2.Orientation(TopAbs_REVERSED);
651 BOPTools_AlgoTools::MakeSplitEdge(aE, aV1, aT1, aV2, aT2, aSp);
652 BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aSp, theF);
656 Bnd_Box& aBox=aSI.ChangeBox();
657 BRepBndLib::Add(aSp, aBox);
659 nSp=myDS->Append(aSI);
666 //=======================================================================
667 //function : CheckSolidImages
669 //=======================================================================
670 void BRepFeat_Builder::CheckSolidImages()
672 BOPTools_MapOfSet aMST;
673 BOPCol_ListOfShape aLSImNew;
674 BOPCol_MapOfShape aMS;
675 BOPCol_ListIteratorOfListOfShape aIt;
676 TopExp_Explorer aExp, aExpF;
677 Standard_Boolean bFlagSD;
679 const BOPCol_ListOfShape& aLSIm = myImages.Find(myArgs[1]);
680 aIt.Initialize(aLSIm);
681 for(;aIt.More();aIt.Next()) {
682 const TopoDS_Shape& aSolIm = aIt.Value();
685 aST.Add(aSolIm, TopAbs_FACE);
689 aExp.Init(myArgs[0], TopAbs_SOLID);
690 for(; aExp.More(); aExp.Next()) {
691 const TopoDS_Shape& aSolid = aExp.Current();
692 if (myImages.IsBound(aSolid)) {
693 BOPCol_ListOfShape& aLSImSol = myImages.ChangeFind(aSolid);
694 aIt.Initialize(aLSImSol);
695 for(;aIt.More();aIt.Next()) {
696 const TopoDS_Shape& aSolIm = aIt.Value();
699 aST.Add(aSolIm, TopAbs_FACE);
700 bFlagSD=aMST.Contains(aST);
702 const BOPTools_Set& aSTx=aMST.Added(aST);
703 const TopoDS_Shape& aSx=aSTx.Shape();
704 aLSImNew.Append(aSx);
707 myShapesSD.Bind(aSolIm, aSx);
710 aLSImSol.Assign(aLSImNew);
715 //=======================================================================
716 //function : MapShapes
718 //=======================================================================
719 void BRepFeat_Builder::FillRemoved(const TopoDS_Shape& S,
720 BOPCol_MapOfShape& M)
722 if (myShapes.Contains(S)) {
727 TopoDS_Iterator It(S);
729 FillRemoved(It.Value(),M);
734 //=======================================================================
735 //function : FillIn3DParts
737 //=======================================================================
738 void BRepFeat_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts,
739 BOPCol_DataMapOfShapeShape& theDraftSolids,
740 const Handle(NCollection_BaseAllocator)& theAllocator)
744 Standard_Boolean bIsIN, bHasImage;
745 Standard_Integer aNbS, i, j, aNbFP, aNbFPx, aNbFIN, aNbLIF, aNbEFP;
746 TopAbs_ShapeEnum aType;
748 TopoDS_Iterator aIt, aItF;
750 TopoDS_Solid aSolidSp;
752 BOPCol_ListIteratorOfListOfShape aItS, aItFP, aItEx;
753 BOPCol_MapIteratorOfMapOfShape aItMS, aItMS1;
755 BOPCol_ListOfShape aLIF(theAllocator);
756 BOPCol_MapOfShape aMFDone(100, theAllocator);
757 BOPCol_MapOfShape aMSolids(100, theAllocator);
758 BOPCol_MapOfShape aMFaces(100, theAllocator);
759 BOPCol_MapOfShape aMFIN(100, theAllocator);
760 BOPCol_IndexedMapOfShape aMS(100, theAllocator);
761 BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, theAllocator);
763 theDraftSolids.Clear();
765 aNbS=myDS->NbSourceShapes();
766 for (i=0; i<aNbS; ++i) {
767 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
768 const TopoDS_Shape& aS=aSI.Shape();
770 aType=aSI.ShapeType();
778 // all faces (originals or images)
779 if (myImages.IsBound(aS)) {
780 const BOPCol_ListOfShape& aLS=myImages.Find(aS);
781 aItS.Initialize(aLS);
782 for (; aItS.More(); aItS.Next()) {
783 const TopoDS_Shape& aFx=aItS.Value();
784 if (!myRemoved.Contains(aFx)) {
790 if (!myRemoved.Contains(aS)) {
802 aItMS.Initialize(aMSolids);
803 for (; aItMS.More(); aItMS.Next()) {
804 const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aItMS.Value()));
810 aBB.MakeSolid(aSolidSp);
812 // Draft solid and its pure internal faces => aSolidSp, aLIF
814 BuildDraftSolid(aSolid, aSolidSp, aLIF);
815 aNbLIF=aLIF.Extent();
817 // 1 all faces/edges from aSolid [ aMS ]
818 bHasImage=Standard_False;
820 aIt.Initialize(aSolid);
821 for (; aIt.More(); aIt.Next()) {
822 const TopoDS_Shape& aShell=aIt.Value();
824 if (myImages.IsBound(aShell)) {
825 bHasImage=Standard_True;
827 const BOPCol_ListOfShape& aLS=myImages.Find(aShell);
828 aItS.Initialize(aLS);
829 for (; aItS.More(); aItS.Next()) {
830 const TopoDS_Shape& aSx=aItS.Value();
832 BOPTools::MapShapes(aSx, TopAbs_FACE, aMS);
833 BOPTools::MapShapes(aSx, TopAbs_EDGE, aMS);
834 BOPTools::MapShapesAndAncestors(aSx, TopAbs_EDGE, TopAbs_FACE, aMEF);
839 BOPTools::MapShapes(aShell, TopAbs_FACE, aMS);
840 BOPTools::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF);
844 // 2 all faces that are not from aSolid [ aLFP1 ]
845 BOPCol_IndexedDataMapOfShapeListOfShape aMEFP(100, theAllocator);
846 BOPCol_ListOfShape aLFP1(theAllocator);
847 BOPCol_ListOfShape aLFP(theAllocator);
848 BOPCol_ListOfShape aLCBF(theAllocator);
849 BOPCol_ListOfShape aLFIN(theAllocator);
850 BOPCol_ListOfShape aLEx(theAllocator);
852 // for all non-solid faces build EF map [ aMEFP ]
853 aItMS1.Initialize(aMFaces);
854 for (; aItMS1.More(); aItMS1.Next()) {
855 const TopoDS_Shape& aFace=aItMS1.Value();
856 if (!aMS.Contains(aFace)) {
857 BOPTools::MapShapesAndAncestors(aFace, TopAbs_EDGE, TopAbs_FACE, aMEFP);
861 // among all faces from aMEFP select these that have same edges
862 // with the solid (i.e aMEF). These faces will be treated first
863 // to prevent the usage of 3D classifier.
864 // The full list of faces to process is aLFP1.
865 aNbEFP=aMEFP.Extent();
866 for (j=1; j<=aNbEFP; ++j) {
867 const TopoDS_Shape& aE=aMEFP.FindKey(j);
869 if (aMEF.Contains(aE)) { // !!
870 const BOPCol_ListOfShape& aLF=aMEFP(j);
871 aItFP.Initialize(aLF);
872 for (; aItFP.More(); aItFP.Next()) {
873 const TopoDS_Shape& aF=aItFP.Value();
874 if (aMFDone.Add(aF)) {
884 aItEx.Initialize(aLEx);
885 for (; aItEx.More(); aItEx.Next()) {
886 const TopoDS_Shape& aE=aItEx.Value();
887 const BOPCol_ListOfShape& aLF=aMEFP.FindFromKey(aE);
888 aItFP.Initialize(aLF);
889 for (; aItFP.More(); aItFP.Next()) {
890 const TopoDS_Shape& aF=aItFP.Value();
891 if (aMFDone.Add(aF)) {
900 // 3 Process faces aLFP1
902 aNbFP=aLFP1.Extent();
903 aItFP.Initialize(aLFP1);
904 for (; aItFP.More(); aItFP.Next()) {
905 const TopoDS_Shape& aSP=aItFP.Value();
906 if (!aMFDone.Add(aSP)) {
911 // first face to process
912 aFP=(*(TopoDS_Face*)(&aSP));
913 bIsIN=BOPTools_AlgoTools::IsInternalFace(aFP, aSolidSp, aMEF, 1.e-14, myContext);
914 aState=(bIsIN) ? TopAbs_IN : TopAbs_OUT;
916 // collect faces to process [ aFP is the first ]
919 aItS.Initialize(aLFP1);
920 for (; aItS.More(); aItS.Next()) {
921 const TopoDS_Shape& aSk=aItS.Value();
922 if (!aMFDone.Contains(aSk)) {
927 // Connexity Block that spreads from aFP the Bound
928 // or till the end of the block itself
930 BOPTools_AlgoTools::MakeConnexityBlock(aLFP, aMS, aLCBF, theAllocator);
932 // fill states for the Connexity Block
933 aItS.Initialize(aLCBF);
934 for (; aItS.More(); aItS.Next()) {
935 const TopoDS_Shape& aSx=aItS.Value();
937 if (aState==TopAbs_IN) {
942 aNbFPx=aMFDone.Extent();
946 }//for (; aItFP.More(); aItFP.Next())
948 // faces Inside aSolid
950 aNbFIN=aMFIN.Extent();
951 if (aNbFIN || aNbLIF) {
952 aItMS1.Initialize(aMFIN);
953 for (; aItMS1.More(); aItMS1.Next()) {
954 const TopoDS_Shape& aFIn=aItMS1.Value();
958 aItS.Initialize(aLIF);
959 for (; aItS.More(); aItS.Next()) {
960 const TopoDS_Shape& aFIN=aItS.Value();
964 theInParts.Bind(aSolid, aLFIN);
966 if (aNbFIN || bHasImage) {
967 theDraftSolids.Bind(aSolid, aSolidSp);
969 }// for (; aItMS.More(); aItMS.Next()) {