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 <BOPCol_DataMapOfShapeListOfShape.hxx>
19 #include <BOPDS_DS.hxx>
20 #include <BOPDS_FaceInfo.hxx>
21 #include <BOPDS_ListOfPave.hxx>
22 #include <BOPDS_ListOfPaveBlock.hxx>
23 #include <BOPDS_MapOfPaveBlock.hxx>
24 #include <BOPDS_Pave.hxx>
25 #include <BOPDS_ShapeInfo.hxx>
26 #include <BOPTools.hxx>
27 #include <BOPTools_AlgoTools.hxx>
28 #include <BOPTools_AlgoTools2D.hxx>
29 #include <BOPTools_AlgoTools3D.hxx>
30 #include <BOPTools_MapOfSet.hxx>
31 #include <BRep_Builder.hxx>
32 #include <BRep_Tool.hxx>
33 #include <BRepBndLib.hxx>
34 #include <BRepFeat_Builder.hxx>
35 #include <Geom_Curve.hxx>
36 #include <IntTools_Tools.hxx>
37 #include <Precision.hxx>
38 #include <TopExp_Explorer.hxx>
39 #include <TopoDS_Edge.hxx>
40 #include <TopoDS_Face.hxx>
41 #include <TopoDS_Shape.hxx>
42 #include <TopTools_ListIteratorOfListOfShape.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 BOPTools::MapShapes(thePart, myShapes);
165 //=======================================================================
168 //=======================================================================
169 void BRepFeat_Builder::Prepare()
171 GetReport()->Clear();
175 aBB.MakeCompound(aC);
178 myFlagHistory=Standard_True;
183 //=======================================================================
184 //function : FillRemoved
186 //=======================================================================
187 void BRepFeat_Builder::FillRemoved()
189 TopExp_Explorer aExp;
191 const TopoDS_Shape& aArgs0=myArguments.First();
192 const TopoDS_Shape& aArgs1=myTools.First();
194 aExp.Init(aArgs0, TopAbs_SOLID);
195 for (; aExp.More(); aExp.Next()) {
196 const TopoDS_Shape& aS = aExp.Current();
200 if (!myImages.IsBound(aArgs1)) {
204 BOPCol_ListIteratorOfListOfShape aItIm;
206 BOPCol_ListOfShape& aLS = myImages.ChangeFind(aArgs1);
207 aItIm.Initialize(aLS);
208 for (; aItIm.More(); aItIm.Next()) {
209 const TopoDS_Shape& aS = aItIm.Value();
210 FillRemoved(aS, myRemoved);
214 //=======================================================================
215 //function : PerformResult
217 //=======================================================================
218 void BRepFeat_Builder::PerformResult()
220 myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT;
222 if (!myShapes.IsEmpty()) {
228 FillImagesContainers(TopAbs_SHELL);
240 BuildResult(TopAbs_SOLID);
245 FillImagesCompounds();
250 BuildResult(TopAbs_COMPOUND);
259 //=======================================================================
260 //function : RebuildFaces
262 //=======================================================================
263 void BRepFeat_Builder::RebuildFaces()
265 Standard_Integer aNbS, i, iRank, nSp, j;
266 Standard_Boolean bIsClosed, bIsDegenerated, bToReverse,
267 bRem, bIm, bFlagSD, bVInShapes;
268 TopAbs_Orientation anOriF, anOriE;
269 TopoDS_Face aFF, aFSD;
272 TopExp_Explorer aExp, aExpE;
273 BOPCol_MapOfShape aME, aMESplit;
274 BOPCol_ListIteratorOfListOfShape aItIm;
275 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
276 BOPCol_MapIteratorOfMapOfShape aItM;
277 BOPTools_MapOfSet aMST;
278 BOPCol_ListOfShape aLE;
280 aItM.Initialize(myShapes);
281 for (; aItM.More(); aItM.Next()) {
282 const TopoDS_Shape& aS = aItM.Value();
283 if (aS.ShapeType() == TopAbs_FACE) {
285 aST.Add(aS, TopAbs_EDGE);
290 aNbS=myDS->NbSourceShapes();
291 for (i=0; i<aNbS; ++i) {
292 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
294 iRank = myDS->Rank(i);
296 const TopoDS_Shape& aS = aSI.Shape();
298 if (myImages.IsBound(aS)) {
299 BOPCol_ListOfShape& aLIm = myImages.ChangeFind(aS);
300 aItIm.Initialize(aLIm);
301 for (; aItIm.More(); ) {
302 const TopoDS_Shape& aSIm = aItIm.Value();
303 if (!myShapes.Contains(aSIm)) {
313 if (aSI.ShapeType()!=TopAbs_FACE) {
317 const BOPDS_FaceInfo& aFI=myDS->FaceInfo(i);
318 const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape()));
320 if (!myImages.IsBound(aF)) {
324 anOriF=aF.Orientation();
326 aFF.Orientation(TopAbs_FORWARD);
328 const BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn();
329 const BOPDS_IndexedMapOfPaveBlock& aMPBSc=aFI.PaveBlocksSc();
334 aExp.Init(aFF, TopAbs_EDGE);
335 for (; aExp.More(); aExp.Next()) {
336 const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current()));
337 anOriE=aE.Orientation();
338 bIsDegenerated=BRep_Tool::Degenerated(aE);
339 bIsClosed=BRep_Tool::IsClosed(aE, aF);
340 if (myImages.IsBound(aE)) {
341 BOPCol_ListOfShape& aLEIm = myImages.ChangeFind(aE);
343 bRem = Standard_False;
344 bIm = Standard_False;
346 BOPCol_ListOfShape aLEImNew;
348 aItIm.Initialize(aLEIm);
349 for (; aItIm.More(); aItIm.Next()) {
350 const TopoDS_Shape& aS = aItIm.Value();
352 bVInShapes = Standard_False;
353 if (myShapes.Contains(aS)) {
354 bVInShapes = Standard_True;
356 aExpE.Init(aS, TopAbs_VERTEX);
357 for(;aExpE.More(); aExpE.Next()) {
358 const TopoDS_Shape& aV = aExpE.Current();
359 if (myShapes.Contains(aV)) {
360 bVInShapes = Standard_True;
370 bRem = Standard_True;
381 if (aLEIm.Extent() == 2) {
385 if (aMESplit.Add(aE)) {
386 RebuildEdge(aE, aFF, aME, aLEImNew);
387 aLEIm.Assign(aLEImNew);
388 if (aLEIm.Extent() == 1) {
395 aItIm.Initialize(aLEIm);
396 for (; aItIm.More(); aItIm.Next()) {
397 aSp = *(TopoDS_Edge*)&aItIm.Value();
399 if (bIsDegenerated) {
400 aSp.Orientation(anOriE);
405 if (anOriE==TopAbs_INTERNAL) {
406 aSp.Orientation(TopAbs_FORWARD);
408 aSp.Orientation(TopAbs_REVERSED);
414 if (!BRep_Tool::IsClosed(aSp, aFF)){
415 BOPTools_AlgoTools3D::DoSplitSEAMOnFace(aSp, aFF);
418 aSp.Orientation(TopAbs_FORWARD);
420 aSp.Orientation(TopAbs_REVERSED);
425 aSp.Orientation(anOriE);
426 bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, aE, myContext);
438 Standard_Integer aNbPBIn, aNbPBSc;
439 aNbPBIn = aMPBIn.Extent();
440 aNbPBSc = aMPBSc.Extent();
443 for (j=1; j<=aNbPBIn; ++j) {
444 const Handle(BOPDS_PaveBlock)& aPB=aMPBIn(j);
446 aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp)));
447 if (myRemoved.Contains(aSp)) {
451 aSp.Orientation(TopAbs_FORWARD);
453 aSp.Orientation(TopAbs_REVERSED);
457 for (j=1; j<=aNbPBSc; ++j) {
458 const Handle(BOPDS_PaveBlock)& aPB=aMPBSc(j);
460 aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp)));
461 if (myRemoved.Contains(aSp)) {
465 aSp.Orientation(TopAbs_FORWARD);
467 aSp.Orientation(TopAbs_REVERSED);
472 BOPAlgo_BuilderFace aBF;
478 BOPCol_ListOfShape& aLFIm = myImages.ChangeFind(aF);
481 const BOPCol_ListOfShape& aLFR=aBF.Areas();
482 aItIm.Initialize(aLFR);
483 for (; aItIm.More(); aItIm.Next()) {
484 TopoDS_Shape& aFR=aItIm.ChangeValue();
487 aST.Add(aFR, TopAbs_EDGE);
488 bFlagSD=aMST.Contains(aST);
490 const BOPTools_Set& aSTx=aMST.Added(aST);
492 aSx.Orientation(anOriF);
495 BOPCol_ListOfShape* pLOr = myOrigins.ChangeSeek(aSx);
497 pLOr = myOrigins.Bound(aSx, BOPCol_ListOfShape());
502 myShapesSD.Bind(aFR, aSx);
506 mySplits.Bind(aF, aLFIm);
507 if (aLFIm.Extent() == 0) {
514 //=======================================================================
515 //function : RebuildEdge
517 //=======================================================================
518 void BRepFeat_Builder::RebuildEdge(const TopoDS_Shape& theE,
519 const TopoDS_Face& theF,
520 const BOPCol_MapOfShape& aME,
521 BOPCol_ListOfShape& aLIm)
523 Standard_Integer nE, nSp, nV1, nV2, nE1, nV, nVx, nVSD;
524 Standard_Integer nV11, nV21;
525 Standard_Boolean bOld;
526 Standard_Real aT11, aT21;
527 Standard_Real aT1, aT2;
530 TopoDS_Vertex aV1, aV2;
531 Handle(BOPDS_PaveBlock) aPBNew;
532 BOPCol_MapOfInteger aMI, aMAdd, aMV, aMVOr;
533 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
534 BOPCol_ListIteratorOfListOfShape aIt;
535 BOPCol_ListIteratorOfListOfInteger aItLI;
536 BOPCol_MapIteratorOfMapOfShape aItM;
537 BOPDS_MapOfPaveBlock aMPB;
538 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
540 aSI.SetShapeType(TopAbs_EDGE);
542 //1. collect origin vertices to aMV map.
543 nE = myDS->Index(theE);
544 const BOPDS_ShapeInfo& aSIE = myDS->ShapeInfo(nE);
545 const BOPCol_ListOfInteger& aLS = aSIE.SubShapes();
546 aItLI.Initialize(aLS);
547 for(; aItLI.More(); aItLI.Next()) {
550 if (myDS->HasShapeSD(nV, nVSD)) {
557 //2. collect vertices that should be removed to aMI map.
558 aPBNew = new BOPDS_PaveBlock;
559 BOPDS_ListOfPave& aLPExt = aPBNew->ChangeExtPaves();
560 BOPDS_ListOfPaveBlock& aLPB = myDS->ChangePaveBlocks(nE);
562 for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) {
563 const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
565 const TopoDS_Shape& aE1 = myDS->Shape(nE1);
567 if (aME.Contains(aE1)) {
568 aPB->Indices(nV1, nV2);
576 //3. collect vertices that split the source shape.
577 for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) {
578 const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
579 aPB->Indices(nV1, nV2);
581 if (!aMI.Contains(nV1)) {
584 if (!aMI.Contains(nV2)) {
588 //4. collect ext paves.
589 for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) {
590 const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
591 aPB->Indices(nV1, nV2);
593 if (aMV.Contains(nV1)) {
594 if (aMAdd.Add(nV1) || aMVOr.Contains(nV1)) {
595 aLPExt.Append(aPB->Pave1());
599 if (aMV.Contains(nV2)) {
600 if (aMAdd.Add(nV2) || aMVOr.Contains(nV2)) {
601 aLPExt.Append(aPB->Pave2());
606 aE = (*(TopoDS_Edge *)(&theE));
607 aE.Orientation(TopAbs_FORWARD);
611 //5. split edge by new set of vertices.
613 aPBNew->SetOriginalEdge(nE);
614 aPBNew->Update(aLPB, Standard_False);
616 for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) {
617 Handle(BOPDS_PaveBlock)& aPB = aItPB.ChangeValue();
618 const BOPDS_Pave& aPave1=aPB->Pave1();
619 aPave1.Contents(nV1, aT1);
621 const BOPDS_Pave& aPave2=aPB->Pave2();
622 aPave2.Contents(nV2, aT2);
624 aItMPB.Initialize(aMPB);
625 //check if it is the old pave block.
626 bOld = Standard_False;
627 for (; aItMPB.More(); aItMPB.Next()) {
628 const Handle(BOPDS_PaveBlock)& aPB1 = aItMPB.Value();
629 aPB1->Indices(nV11, nV21);
630 aPB1->Range(aT11, aT21);
631 if (nV1 == nV11 && nV2 == nV21 &&
632 aT1 == aT11 && aT2 == aT21) {
633 const TopoDS_Shape& aEIm = myDS->Shape(aPB1->Edge());
635 bOld = Standard_True;
643 aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
644 aV1.Orientation(TopAbs_FORWARD);
646 aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
647 aV2.Orientation(TopAbs_REVERSED);
649 BOPTools_AlgoTools::MakeSplitEdge(aE, aV1, aT1, aV2, aT2, aSp);
650 BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aSp, theF, myContext);
654 Bnd_Box& aBox=aSI.ChangeBox();
655 BRepBndLib::Add(aSp, aBox);
657 nSp=myDS->Append(aSI);
664 //=======================================================================
665 //function : CheckSolidImages
667 //=======================================================================
668 void BRepFeat_Builder::CheckSolidImages()
670 BOPTools_MapOfSet aMST;
671 BOPCol_ListOfShape aLSImNew;
672 BOPCol_MapOfShape aMS;
673 BOPCol_ListIteratorOfListOfShape aIt;
674 TopExp_Explorer aExp, aExpF;
675 Standard_Boolean bFlagSD;
677 const TopoDS_Shape& aArgs0=myArguments.First();
678 const TopoDS_Shape& aArgs1=myTools.First();
680 const BOPCol_ListOfShape& aLSIm = myImages.Find(aArgs1);
681 aIt.Initialize(aLSIm);
682 for(;aIt.More();aIt.Next()) {
683 const TopoDS_Shape& aSolIm = aIt.Value();
686 aST.Add(aSolIm, TopAbs_FACE);
690 aExp.Init(aArgs0, TopAbs_SOLID);
691 for(; aExp.More(); aExp.Next()) {
692 const TopoDS_Shape& aSolid = aExp.Current();
693 if (myImages.IsBound(aSolid)) {
694 BOPCol_ListOfShape& aLSImSol = myImages.ChangeFind(aSolid);
695 aIt.Initialize(aLSImSol);
696 for(;aIt.More();aIt.Next()) {
697 const TopoDS_Shape& aSolIm = aIt.Value();
700 aST.Add(aSolIm, TopAbs_FACE);
701 bFlagSD=aMST.Contains(aST);
703 const BOPTools_Set& aSTx=aMST.Added(aST);
704 const TopoDS_Shape& aSx=aSTx.Shape();
705 aLSImNew.Append(aSx);
708 myShapesSD.Bind(aSolIm, aSx);
711 aLSImSol.Assign(aLSImNew);
716 //=======================================================================
717 //function : MapShapes
719 //=======================================================================
720 void BRepFeat_Builder::FillRemoved(const TopoDS_Shape& S,
721 BOPCol_MapOfShape& M)
723 if (myShapes.Contains(S)) {
728 TopoDS_Iterator It(S);
730 FillRemoved(It.Value(),M);
735 //=======================================================================
736 //function : FillIn3DParts
738 //=======================================================================
739 void BRepFeat_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts,
740 BOPCol_DataMapOfShapeShape& theDraftSolids,
741 const Handle(NCollection_BaseAllocator)& theAllocator)
743 GetReport()->Clear();
745 Standard_Boolean bIsIN, bHasImage;
746 Standard_Integer aNbS, i, j, aNbFP, aNbFPx, aNbFIN, aNbLIF, aNbEFP;
747 TopAbs_ShapeEnum aType;
749 TopoDS_Iterator aIt, aItF;
751 TopoDS_Solid aSolidSp;
753 BOPCol_ListIteratorOfListOfShape aItS, aItFP, aItEx;
754 BOPCol_MapIteratorOfMapOfShape aItMS, aItMS1;
756 BOPCol_ListOfShape aLIF(theAllocator);
757 BOPCol_MapOfShape aMFDone(100, theAllocator);
758 BOPCol_MapOfShape aMSolids(100, theAllocator);
759 BOPCol_MapOfShape aMFaces(100, theAllocator);
760 BOPCol_MapOfShape aMFIN(100, theAllocator);
761 BOPCol_IndexedMapOfShape aMS(100, theAllocator);
762 BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, theAllocator);
764 theDraftSolids.Clear();
766 aNbS=myDS->NbSourceShapes();
767 for (i=0; i<aNbS; ++i) {
768 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
769 const TopoDS_Shape& aS=aSI.Shape();
771 aType=aSI.ShapeType();
779 // all faces (originals or images)
780 if (myImages.IsBound(aS)) {
781 const BOPCol_ListOfShape& aLS=myImages.Find(aS);
782 aItS.Initialize(aLS);
783 for (; aItS.More(); aItS.Next()) {
784 const TopoDS_Shape& aFx=aItS.Value();
785 if (!myRemoved.Contains(aFx)) {
791 if (!myRemoved.Contains(aS)) {
803 aItMS.Initialize(aMSolids);
804 for (; aItMS.More(); aItMS.Next()) {
805 const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aItMS.Value()));
811 aBB.MakeSolid(aSolidSp);
813 // Draft solid and its pure internal faces => aSolidSp, aLIF
815 BuildDraftSolid(aSolid, aSolidSp, aLIF);
816 aNbLIF=aLIF.Extent();
818 // 1 all faces/edges from aSolid [ aMS ]
819 bHasImage=Standard_False;
821 aIt.Initialize(aSolid);
822 for (; aIt.More(); aIt.Next()) {
823 const TopoDS_Shape& aShell=aIt.Value();
825 if (myImages.IsBound(aShell)) {
826 bHasImage=Standard_True;
828 const BOPCol_ListOfShape& aLS=myImages.Find(aShell);
829 aItS.Initialize(aLS);
830 for (; aItS.More(); aItS.Next()) {
831 const TopoDS_Shape& aSx=aItS.Value();
833 BOPTools::MapShapes(aSx, TopAbs_FACE, aMS);
834 BOPTools::MapShapes(aSx, TopAbs_EDGE, aMS);
835 BOPTools::MapShapesAndAncestors(aSx, TopAbs_EDGE, TopAbs_FACE, aMEF);
840 BOPTools::MapShapes(aShell, TopAbs_FACE, aMS);
841 BOPTools::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF);
845 // 2 all faces that are not from aSolid [ aLFP1 ]
846 BOPCol_IndexedDataMapOfShapeListOfShape aMEFP(100, theAllocator);
847 BOPCol_ListOfShape aLFP1(theAllocator);
848 BOPCol_ListOfShape aLFP(theAllocator);
849 BOPCol_ListOfShape aLCBF(theAllocator);
850 BOPCol_ListOfShape aLFIN(theAllocator);
851 BOPCol_ListOfShape aLEx(theAllocator);
853 // for all non-solid faces build EF map [ aMEFP ]
854 aItMS1.Initialize(aMFaces);
855 for (; aItMS1.More(); aItMS1.Next()) {
856 const TopoDS_Shape& aFace=aItMS1.Value();
857 if (!aMS.Contains(aFace)) {
858 BOPTools::MapShapesAndAncestors(aFace, TopAbs_EDGE, TopAbs_FACE, aMEFP);
862 // among all faces from aMEFP select these that have same edges
863 // with the solid (i.e aMEF). These faces will be treated first
864 // to prevent the usage of 3D classifier.
865 // The full list of faces to process is aLFP1.
866 aNbEFP=aMEFP.Extent();
867 for (j=1; j<=aNbEFP; ++j) {
868 const TopoDS_Shape& aE=aMEFP.FindKey(j);
870 if (aMEF.Contains(aE)) { // !!
871 const BOPCol_ListOfShape& aLF=aMEFP(j);
872 aItFP.Initialize(aLF);
873 for (; aItFP.More(); aItFP.Next()) {
874 const TopoDS_Shape& aF=aItFP.Value();
875 if (aMFDone.Add(aF)) {
885 aItEx.Initialize(aLEx);
886 for (; aItEx.More(); aItEx.Next()) {
887 const TopoDS_Shape& aE=aItEx.Value();
888 const BOPCol_ListOfShape& aLF=aMEFP.FindFromKey(aE);
889 aItFP.Initialize(aLF);
890 for (; aItFP.More(); aItFP.Next()) {
891 const TopoDS_Shape& aF=aItFP.Value();
892 if (aMFDone.Add(aF)) {
901 // 3 Process faces aLFP1
903 aNbFP=aLFP1.Extent();
904 aItFP.Initialize(aLFP1);
905 for (; aItFP.More(); aItFP.Next()) {
906 const TopoDS_Shape& aSP=aItFP.Value();
907 if (!aMFDone.Add(aSP)) {
912 // first face to process
913 aFP=(*(TopoDS_Face*)(&aSP));
914 bIsIN=BOPTools_AlgoTools::IsInternalFace(aFP, aSolidSp, aMEF, 1.e-14, myContext);
915 aState=(bIsIN) ? TopAbs_IN : TopAbs_OUT;
917 // collect faces to process [ aFP is the first ]
920 aItS.Initialize(aLFP1);
921 for (; aItS.More(); aItS.Next()) {
922 const TopoDS_Shape& aSk=aItS.Value();
923 if (!aMFDone.Contains(aSk)) {
928 // Connexity Block that spreads from aFP the Bound
929 // or till the end of the block itself
931 BOPTools_AlgoTools::MakeConnexityBlock(aLFP, aMS, aLCBF, theAllocator);
933 // fill states for the Connexity Block
934 aItS.Initialize(aLCBF);
935 for (; aItS.More(); aItS.Next()) {
936 const TopoDS_Shape& aSx=aItS.Value();
938 if (aState==TopAbs_IN) {
943 aNbFPx=aMFDone.Extent();
947 }//for (; aItFP.More(); aItFP.Next())
949 // faces Inside aSolid
951 aNbFIN=aMFIN.Extent();
952 if (aNbFIN || aNbLIF) {
953 aItMS1.Initialize(aMFIN);
954 for (; aItMS1.More(); aItMS1.Next()) {
955 const TopoDS_Shape& aFIn=aItMS1.Value();
959 aItS.Initialize(aLIF);
960 for (; aItS.More(); aItS.Next()) {
961 const TopoDS_Shape& aFIN=aItS.Value();
965 theInParts.Bind(aSolid, aLFIN);
967 if (aNbFIN || bHasImage) {
968 theDraftSolids.Bind(aSolid, aSolidSp);
970 }// for (; aItMS.More(); aItMS.Next()) {