1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: GEOMAlgo_Builder_2.cxx
24 // Author: Peter KURNEV
26 #include <GEOMAlgo_Builder.hxx>
28 #include <TColStd_IndexedMapOfInteger.hxx>
29 #include <TColStd_ListOfInteger.hxx>
31 #include <TopAbs_Orientation.hxx>
34 #include <TopoDS_Face.hxx>
35 #include <TopoDS_Edge.hxx>
36 #include <TopoDS_Shape.hxx>
37 #include <TopoDS_Compound.hxx>
39 #include <TopTools_IndexedMapOfShape.hxx>
40 #include <TopTools_ListOfShape.hxx>
41 #include <TopTools_MapOfShape.hxx>
42 #include <TopTools_ListIteratorOfListOfShape.hxx>
45 #include <TopExp_Explorer.hxx>
47 #include <BRep_Tool.hxx>
48 #include <BRep_Builder.hxx>
49 #include <BRepAlgo_Image.hxx>
50 #include <BRepTools.hxx>
52 #include <IntTools_Context.hxx>
53 #include <IntTools_FClass2d.hxx>
55 #include <BooleanOperations_OnceExplorer.hxx>
56 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
57 #include <BOPTools_ListOfPaveBlock.hxx>
58 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
59 #include <BOPTools_CArray1OfSSInterference.hxx>
60 #include <BOPTools_SSInterference.hxx>
61 #include <BOPTools_SequenceOfCurves.hxx>
62 #include <BOPTools_Curve.hxx>
63 #include <BOPTools_ListOfPaveBlock.hxx>
64 #include <BOPTools_PaveBlock.hxx>
65 #include <BOPTools_Tools3D.hxx>
66 #include <BOPTools_CArray1OfVSInterference.hxx>
67 #include <BOPTools_VSInterference.hxx>
68 #include <BOPTools_ESInterference.hxx>
69 #include <BOPTools_CArray1OfESInterference.hxx>
71 #include <NMTDS_ShapesDataStructure.hxx>
72 #include <NMTDS_InterfPool.hxx>
74 #include <NMTTools_PaveFiller.hxx>
75 #include <NMTTools_ListOfCoupleOfShape.hxx>
76 #include <NMTTools_Tools.hxx>
77 #include <NMTTools_CoupleOfShape.hxx>
78 #include <NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
79 #include <NMTTools_Tools.hxx>
80 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
81 #include <NMTTools_ListOfCommonBlock.hxx>
82 #include <NMTTools_CommonBlock.hxx>
83 #include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
85 #include <GEOMAlgo_Tools3D.hxx>
86 #include <GEOMAlgo_WireEdgeSet.hxx>
87 #include <GEOMAlgo_BuilderFace.hxx>
89 #include <GEOMAlgo_ShapeSet.hxx>
91 #include <NMTDS_BoxBndTree.hxx>
92 #include <NCollection_UBTreeFiller.hxx>
93 #include <Bnd_Box.hxx>
94 #include <BRepBndLib.hxx>
95 #include <TopTools_DataMapOfIntegerShape.hxx>
96 #include <TColStd_ListOfInteger.hxx>
97 #include <TColStd_ListIteratorOfListOfInteger.hxx>
98 #include <TopTools_DataMapOfShapeInteger.hxx>
101 void UpdateCandidates(const Standard_Integer ,
102 const Standard_Integer ,
103 NMTTools_IndexedDataMapOfIndexedMapOfInteger& );
106 //=======================================================================
107 //function : FillImagesFaces
109 //=======================================================================
110 void GEOMAlgo_Builder::FillImagesFaces()
116 FillSameDomainFaces();
118 FillInternalVertices();
121 //=======================================================================
122 // function: FillIn2DParts
124 //=======================================================================
125 void GEOMAlgo_Builder::FillIn2DParts()
127 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
128 NMTTools_PaveFiller* pPF=myPaveFiller;
129 NMTDS_InterfPool* pIP=pPF->IP();
130 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
131 NMTTools_CommonBlockPool& aCBP=pPF->ChangeCommonBlockPool();
133 Standard_Integer j, nSpIn, nSpSc, aNbCurves;
134 Standard_Integer aNbS, nF, aNbCBP, n1, n2, aNbFFs, aNbSpIn;
135 TopTools_MapOfShape aMFence;
136 TopTools_ListOfShape aLSpIn;
138 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
139 BOPTools_ListIteratorOfListOfPaveBlock aItPB;
143 aNbFFs=aFFs.Extent();
144 aNbCBP=aCBP.Extent();
146 aNbS=aDS.NumberOfShapesOfTheObject();
147 for (nF=1; nF<=aNbS; ++nF) {
148 if (aDS.GetShapeType(nF)!=TopAbs_FACE) {
152 aF=TopoDS::Face(aDS.Shape(nF));
158 //modified by NIZNHY-PKV Fri Oct 14 13:58:00 2011f
159 BOPTools_ListOfPaveBlock aLPBIn;
161 pPF->RealSplitsInFace(nF, aLPBIn);
163 aItPB.Initialize(aLPBIn);
164 for (; aItPB.More(); aItPB.Next()) {
165 const BOPTools_PaveBlock& aPB1=aItPB.Value();
167 const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn);
168 aLSpIn.Append(aSpIn);
171 for (j=1; j<=aNbCBP; ++j) {
172 NMTTools_ListOfCommonBlock& aLCB=aCBP(j);
173 aItCB.Initialize(aLCB);
174 for (; aItCB.More(); aItCB.Next()) {
175 NMTTools_CommonBlock& aCB=aItCB.Value();
176 if (aCB.IsPaveBlockOnFace(nF)) {
177 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1();
179 const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn);
180 if (aMFence.Add(aSpIn)){
181 aLSpIn.Append(aSpIn);
187 //modified by NIZNHY-PKV Fri Oct 14 13:58:08 2011t
190 for (j=1; j<=aNbFFs; ++j) {
191 BOPTools_SSInterference& aFF=aFFs(j);
193 if (!(n1==nF || n2==nF)) {
196 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
197 aNbCurves=aSC.Length();
202 const BOPTools_Curve& aBC=aSC(1);
203 const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
204 aItPB.Initialize(aLPB);
205 for (; aItPB.More(); aItPB.Next()) {
206 const BOPTools_PaveBlock& aPBSc=aItPB.Value();
208 const TopoDS_Shape& aSpSc=aDS.Shape(nSpSc);
209 if (aMFence.Add(aSpSc)){
210 aLSpIn.Append(aSpSc);
214 aNbSpIn=aLSpIn.Extent();
216 myInParts.Add(aF, aLSpIn);
218 }//for (nF=1; nF<=aNbS; ++nF) {
221 //=======================================================================
222 // function: BuildSplitFaces
224 //=======================================================================
225 void GEOMAlgo_Builder::BuildSplitFaces()
227 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
228 NMTTools_PaveFiller* pPF=myPaveFiller;
229 NMTDS_InterfPool* pIP=pPF->IP();
230 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
231 IntTools_Context& aCtx= pPF->ChangeContext();
233 Standard_Boolean bToReverse, bIsClosed, bIsDegenerated;
234 Standard_Integer i, aNb, aNbF, nF;
235 TopTools_MapOfShape aMFence;
236 TColStd_IndexedMapOfInteger aMFP;
237 TopExp_Explorer anExp;
239 TopoDS_Edge aSp, aEE;
240 TopTools_ListIteratorOfListOfShape aIt;
241 TopAbs_Orientation anOriF, anOriE;
243 mySplitFaces.Clear();
245 // 1. Select Faces to process (MFP)
246 aNb=aDS.NumberOfShapesOfTheObject();
247 for (i=1; i<=aNb; ++i) {
248 const TopoDS_Shape& aF=aDS.Shape(i);
249 if (aF.ShapeType()!=TopAbs_FACE) {
252 if (!aMFence.Add(aF)) {
256 if (myInParts.Contains(aF)) {
261 anExp.Init(aF, TopAbs_EDGE);
262 for (; anExp.More(); anExp.Next()) {
263 const TopoDS_Shape& aE=anExp.Current();
264 if (myImages.HasImage(aE)) {
272 Standard_Integer aNbFFs, aNbSE, j, n1, n2;
274 aNbFFs=aFFs.Extent();
275 for (j=1; j<=aNbFFs; ++j) {
276 BOPTools_SSInterference& aFFj=aFFs(j);
277 aFFj.Indices(n1, n2);
278 if (!(n1==i || n2==i)) {
282 const TColStd_ListOfInteger& aLSE=aFFj.SharedEdges();
292 }// for (i=1; i<=aNb; ++i)
296 for (i=1; i<=aNbF; ++i) {
298 const TopoDS_Face& aF=TopoDS::Face(aDS.Shape(nF));
299 anOriF=aF.Orientation();
301 aFF.Orientation(TopAbs_FORWARD);
306 GEOMAlgo_WireEdgeSet aWES;
309 // 2.1.1. Add Split parts
310 anExp.Init(aFF, TopAbs_EDGE);
311 for (; anExp.More(); anExp.Next()) {
312 const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current());
313 anOriE=aE.Orientation();
315 if (!myImages.HasImage(aE)) {
316 if (anOriE==TopAbs_INTERNAL) {
318 aEE.Orientation(TopAbs_FORWARD);
319 aWES.AddStartElement(aEE);
320 aEE.Orientation(TopAbs_REVERSED);
321 aWES.AddStartElement(aEE);
324 aWES.AddStartElement(aE);
329 bIsDegenerated=BRep_Tool::Degenerated(aE);
330 bIsClosed=BRep_Tool::IsClosed(aE, aF);
332 const TopTools_ListOfShape& aLIE=myImages.Image(aE);
333 aIt.Initialize(aLIE);
334 for (; aIt.More(); aIt.Next()) {
335 aSp=TopoDS::Edge(aIt.Value());
337 if (bIsDegenerated) {
338 aSp.Orientation(anOriE);
339 aWES.AddStartElement(aSp);
343 if (anOriE==TopAbs_INTERNAL) {
344 aSp.Orientation(TopAbs_FORWARD);
345 aWES.AddStartElement(aSp);
346 aSp.Orientation(TopAbs_REVERSED);
347 aWES.AddStartElement(aSp);
352 if (aMFence.Add(aSp)) {
354 if (!BRep_Tool::IsClosed(aSp, aF)){
355 BOPTools_Tools3D::DoSplitSEAMOnFace(aSp, aF);
358 aSp.Orientation(TopAbs_FORWARD);
359 aWES.AddStartElement(aSp);
360 aSp.Orientation(TopAbs_REVERSED);
361 aWES.AddStartElement(aSp);
364 }// if (aMFence.Add(aSp))
366 aSp.Orientation(anOriE);
367 bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, aCtx);
371 aWES.AddStartElement(aSp);
372 }// for (; aIt.More(); aIt.Next()) {
373 }// for (; anExp.More(); anExp.Next()) {
375 // 2.1.2. Add In2D Parts
376 if (myInParts.Contains(aF)) {
377 const TopTools_ListOfShape& aLE=myInParts.FindFromKey(aF);
379 for (; aIt.More(); aIt.Next()) {
380 aSp=TopoDS::Edge(aIt.Value());
382 aSp.Orientation(TopAbs_FORWARD);
383 aWES.AddStartElement(aSp);
385 aSp.Orientation(TopAbs_REVERSED);
386 aWES.AddStartElement(aSp);
390 // 2.2. Build images Faces
391 TopTools_ListOfShape aLFR;
392 GEOMAlgo_ShapeSet aS1, aS2;
394 const TopTools_ListOfShape& aSE=aWES.StartElements();
396 aS2.Add(aFF, TopAbs_EDGE);
397 if (aS1.IsEqual(aS2)) {
401 GEOMAlgo_BuilderFace aBF;
404 aBF.SetContext(aCtx);
409 const TopTools_ListOfShape& aLF=aBF.Areas();
411 for (; aIt.More(); aIt.Next()) {
412 TopoDS_Shape& aFR=aIt.Value();
413 if (anOriF==TopAbs_REVERSED) {
414 aFR.Orientation(TopAbs_REVERSED);
420 // 2.3. Collect draft images Faces
421 mySplitFaces.Bind(aF, aLFR);
422 }//for (i=1; i<=aNbF; ++i)
425 //=======================================================================
426 // function: FillSameDomainFaces
428 //=======================================================================
429 void GEOMAlgo_Builder::FillSameDomainFaces()
431 Standard_Boolean bIsSDF, bHasImage1, bHasImage2, bForward;
432 Standard_Integer i, j, aNbFF, nF1, nF2, aNbPBInOn, aNbC, aNbSE;
433 Standard_Integer aNbF1, aNbF2, i2s, aNbSD;
434 TopTools_MapOfShape aMFence;
435 TopTools_ListOfShape aLX1, aLX2;
436 TopTools_ListIteratorOfListOfShape aItF1, aItF2;
437 NMTTools_ListOfCoupleOfShape aLCS;
439 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
440 NMTTools_PaveFiller* pPF=myPaveFiller;
441 NMTDS_InterfPool* pIP=pPF->IP();
442 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
443 IntTools_Context& aCtx= pPF->ChangeContext();
446 //mySameDomainShapes.Clear();
448 // 1. For each FF find among images of faces
449 // all pairs of same domain faces (SDF) [=> aLCS]
451 for (i=1; i<=aNbFF; ++i) {
452 BOPTools_SSInterference& aFF=aFFs(i);
453 aFF.Indices(nF1, nF2);
455 const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1));
456 const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2));
458 // if there are no in/on 2D split parts the faces nF1, nF2
460 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
461 aNbPBInOn=aLPBInOn.Extent();
464 const TColStd_ListOfInteger& aLSE=aFF.SharedEdges();
466 if (!aNbPBInOn && !aNbSE) {
471 // if there is at least one section edge between faces nF1, nF2
472 // they can not be SDF
473 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
479 // the faces are suspected to be SDF.
480 // Try to find SDF among images of nF1, nF2
483 //--------------------------------------------------------
484 bHasImage1=mySplitFaces.HasImage(aF1);
485 bHasImage2=mySplitFaces.HasImage(aF2);
497 const TopTools_ListOfShape& aLF1r=(bHasImage1)? mySplitFaces.Image(aF1) : aLX1;
498 const TopTools_ListOfShape& aLF2r=(bHasImage2)? mySplitFaces.Image(aF2) : aLX2;
500 TopTools_DataMapOfIntegerShape aMIS;
501 TColStd_ListIteratorOfListOfInteger aItLI;
502 NMTDS_BoxBndTreeSelector aSelector;
503 NMTDS_BoxBndTree aBBTree;
504 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
506 aNbF1=aLF1r.Extent();
507 aNbF2=aLF2r.Extent();
508 bForward=(aNbF1<aNbF2);
510 const TopTools_ListOfShape& aLF1=bForward ? aLF1r : aLF2r;
511 const TopTools_ListOfShape& aLF2=bForward ? aLF2r : aLF1r;
514 aItF2.Initialize(aLF2);
515 for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
518 const TopoDS_Face& aF2s=*((TopoDS_Face*)(&aItF2.Value()));
520 BRepBndLib::Add(aF2s, aBoxF2s);
522 aMIS.Bind(i2s, aF2s);
524 aTreeFiller.Add(i2s, aBoxF2s);
525 }//for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
530 aItF1.Initialize(aLF1);
531 for (j=1; aItF1.More(); aItF1.Next(), ++j) {
534 const TopoDS_Face& aF1x=*((TopoDS_Face*)(&aItF1.Value()));
536 BRepBndLib::Add(aF1x, aBoxF1x);
539 aSelector.SetBox(aBoxF1x);
540 aNbSD=aBBTree.Select(aSelector);
545 const TColStd_ListOfInteger& aLI=aSelector.Indices();
546 aItLI.Initialize(aLI);
547 for (; aItLI.More(); aItLI.Next()) {
549 const TopoDS_Face& aF2y=*((TopoDS_Face*)(&aMIS.Find(i2s)));
551 bIsSDF=NMTTools_Tools::AreFacesSameDomain(aF1x, aF2y, aCtx);
553 if (aMFence.Contains(aF1x) || aMFence.Contains(aF2y)) {
559 NMTTools_CoupleOfShape aCS;
567 if (!mySplitFaces.HasImage(aF1)) {
568 mySplitFaces.Bind(aF1, aF1);
572 if (!mySplitFaces.HasImage(aF2)) {
573 mySplitFaces.Bind(aF2, aF2);
579 if (!mySplitFaces.HasImage(aF2)) {
580 mySplitFaces.Bind(aF2, aF2);
584 if (!mySplitFaces.HasImage(aF1)) {
585 mySplitFaces.Bind(aF1, aF1);
592 }//for (; aItLI.More(); aItLI.Next()) {
593 }//for (; aItF1.More(); aItF1.Next()) {
594 }//for (i=1; i<=aNbFF; ++i)
595 //-------------------------------------------------------------
602 NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMC;
604 NMTTools_Tools::FindChains(aLCS, aMC);
606 //modified by NIZNHY-PKV Wed Oct 12 13:33:59 2011f
607 Standard_Boolean bIsImage;
608 Standard_Integer aIx, aIxMin, aNbMSDF, k, aNbMFj;
609 TopoDS_Shape aFOld, aFSDmin;
610 TopTools_IndexedMapOfShape aMFj;
611 TopTools_DataMapOfShapeInteger aDMSI;
613 aItF1.Initialize(myShapes);
614 for (j=1; aItF1.More(); aItF1.Next(), ++j) {
615 const TopoDS_Shape& aSj=aItF1.Value();
617 TopExp::MapShapes(aSj, TopAbs_FACE, aMFj);
618 aNbMFj=aMFj.Extent();
619 for (k=1; k<=aNbMFj; ++k) {
620 const TopoDS_Shape& aFk=aMFj(k);
621 if (!aDMSI.IsBound(aFk)) {
627 //modified by NIZNHY-PKV Wed Oct 12 13:34:01 2011t
629 // 3. Fill the map of SDF mySameDomainFaces
631 for (i=1; i<=aNbC; ++i) {
632 // const TopoDS_Shape& aF=aMC.FindKey(i);
633 const TopTools_IndexedMapOfShape& aMSDF=aMC(i);
635 //modified by NIZNHY-PKV Wed Oct 12 13:25:16 2011f
636 aNbMSDF=aMSDF.Extent();
637 for (j=1; j<=aNbMSDF; ++j) {
638 const TopoDS_Shape& aFSD=aMSDF(j);
639 bIsImage=mySplitFaces.IsImage(aFSD);
642 aFOld=mySplitFaces.ImageFrom(aFSD);
645 aIx=aDMSI.Find(aFOld);
659 for (j=1; j<=aNbMSDF; ++j) {
660 const TopoDS_Shape& aFSD=aMSDF(j);
661 mySameDomainShapes.Add(aFSD, aFSDmin);
664 aNbFF=aMSDF.Extent();
665 for (j=1; j<=aNbFF; ++j) {
666 const TopoDS_Shape& aFSD=aMSDF(j);
667 mySameDomainShapes.Add(aFSD, aF);
670 //modified by NIZNHY-PKV Wed Oct 12 13:25:18 2011t
675 //=======================================================================
676 // function: FillImagesFaces1
678 //=======================================================================
679 void GEOMAlgo_Builder::FillImagesFaces1()
681 Standard_Integer i, aNb, iSense, aNbLFx;
682 TopoDS_Face aF, aFSp, aFSD;
683 TopTools_ListOfShape aLFx;
684 TopTools_ListIteratorOfListOfShape aIt;
686 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
688 aNb=aDS.NumberOfShapesOfTheObject();
689 for (i=1; i<=aNb; ++i) {
690 const TopoDS_Shape& aS=aDS.Shape(i);
691 if (aS.ShapeType()!=TopAbs_FACE) {
695 if (!mySplitFaces.HasImage(aS)) {
699 aF=*((TopoDS_Face*)&aS);
702 const TopTools_ListOfShape& aLF=mySplitFaces.Image(aF);
704 for (; aIt.More(); aIt.Next()) {
705 aFSp=*((TopoDS_Face*)(&aIt.Value()));
706 if (!mySameDomainShapes.Contains(aFSp)) {
710 const TopoDS_Shape& aSx=mySameDomainShapes.FindFromKey(aFSp);
711 aFSD=*((TopoDS_Face*)(&aSx));
712 iSense=GEOMAlgo_Tools3D::Sense(aFSp, aFSD);
720 if (!myImages.HasImage(aF)) {
721 aNbLFx=aLFx.Extent();
723 const TopoDS_Shape& aFx=aLFx.First();
724 if (aF.IsSame(aFx)) {
728 myImages.Bind(aF, aLFx);
733 //=======================================================================
734 // function: FillInternalVertices
736 //=======================================================================
737 void GEOMAlgo_Builder::FillInternalVertices()
739 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
740 NMTTools_PaveFiller* pPF=myPaveFiller;
741 NMTDS_InterfPool* pIP=pPF->IP();
742 IntTools_Context& aCtx= pPF->ChangeContext();
744 /*BOPTools_CArray1OfSSInterference& aFFs=*/pIP->SSInterferences();
745 BOPTools_CArray1OfVSInterference& aVFs=pIP->VSInterferences();
746 BOPTools_CArray1OfESInterference& aEFs=pIP->ESInterferences();
747 const NMTTools_IndexedDataMapOfIndexedMapOfInteger& aMAV=pPF->AloneVertices();
749 Standard_Boolean bHasImage;
750 Standard_Integer i, j, nF, aNbS, nV, nVSD, n1, n2, iFlag;
751 Standard_Integer aNbVFs, aNbAVF, aNbEFs, aNbVC, aNbE, aNbV;
752 Standard_Real aU1, aU2, aTol;
753 NMTTools_IndexedDataMapOfIndexedMapOfInteger aMFMV;
754 TopTools_MapOfShape aMFence;
755 TopTools_ListIteratorOfListOfShape aIt, aItV;
758 // 1. Collect face-vertex candidates [aMFMV]
761 aNbVFs=aVFs.Extent();
762 for (i=1; i<=aNbVFs; ++i) {
763 const BOPTools_VSInterference& aVS=aVFs(i);
767 if (aDS.Shape(n1).ShapeType()==TopAbs_FACE) {
771 nVSD=pPF->FindSDVertex(nV);
776 UpdateCandidates(nF, nV, aMFMV);
780 aNbEFs=aEFs.Extent();
781 for (i=1; i<=aNbEFs; ++i) {
782 const BOPTools_ESInterference& aEF=aEFs(i);
788 const TopoDS_Shape& aSnew=aDS.Shape(nV);
789 if (aSnew.ShapeType()!=TopAbs_VERTEX) {
793 nF=(aDS.Shape(n1).ShapeType()==TopAbs_FACE) ? n1 : n2;
794 nVSD=pPF->FindSDVertex(nV);
798 UpdateCandidates(nF, nV, aMFMV);
801 aNbS=aDS.NumberOfShapesOfTheObject();
802 for (nF=1; nF<=aNbS; ++nF) {
803 const TopoDS_Shape& aF=aDS.Shape(nF);
805 if (aF.ShapeType()!=TopAbs_FACE) {
808 if (!aMFence.Add(aF)) {
812 const TopoDS_Face& aFF=TopoDS::Face(aF);
813 aTol=BRep_Tool::Tolerance(aFF);
816 if (aMAV.Contains(nF)) {
817 const TColStd_IndexedMapOfInteger& aMAVF=aMAV.FindFromKey(nF);
818 aNbAVF=aMAVF.Extent();
819 for (j=1; j<=aNbAVF; ++j) {
821 nVSD=pPF->FindSDVertex(nV);
826 UpdateCandidates(nF, nV, aMFMV);
830 // 1.4 Internal vertices of the face nF
831 BooleanOperations_OnceExplorer aExp(aDS);
832 aExp.Init(nF, TopAbs_VERTEX);
833 for (; aExp.More(); aExp.Next()) {
835 const TopoDS_Shape& aV=aDS.Shape(nV);
836 if (aV.Orientation()==TopAbs_INTERNAL) {
837 nVSD=pPF->FindSDVertex(nV);
842 UpdateCandidates(nF, nV, aMFMV);
846 // 2. Process face nF
847 if (!aMFMV.Contains(nF)) {
851 const TColStd_IndexedMapOfInteger& aMVC=aMFMV.FindFromKey(nF);
857 // 2.1 Refine candidates
858 TopTools_IndexedDataMapOfShapeListOfShape aMVE;
859 TopTools_ListOfShape aLV;
861 bHasImage=myImages.HasImage(aF);
863 const TopTools_ListOfShape& aLFx=myImages.Image(aF);
864 aIt.Initialize(aLFx);
865 for (; aIt.More(); aIt.Next()) {
866 const TopoDS_Shape& aFx=aIt.Value();
867 TopExp::MapShapesAndAncestors(aFx, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
871 Standard_Boolean bFaceToProcess;
873 TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
874 bFaceToProcess=Standard_False;
875 for (j=1; j<=aNbVC; ++j) {
877 const TopoDS_Shape& aV=aDS.Shape(nV);
878 if (!aMVE.Contains(aV)) {
879 bFaceToProcess=!bFaceToProcess;
883 if (!bFaceToProcess) {
888 for (j=1; j<=aNbVC; ++j) {
890 const TopoDS_Shape& aV=aDS.Shape(nV);
891 if (aMVE.Contains(aV)) {
892 const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV);
903 // 3. Try to put vertices into the face(s)
904 aItV.Initialize(aLV);
905 for (; aItV.More(); aItV.Next()) {
906 TopoDS_Vertex aV=TopoDS::Vertex(aItV.Value());
907 aV.Orientation(TopAbs_INTERNAL);
909 bHasImage=myImages.HasImage(aF);
911 const TopTools_ListOfShape& aLFx=myImages.Image(aF);
912 aIt.Initialize(aLFx);
913 for (; aIt.More(); aIt.Next()) {
914 TopoDS_Face aFx=TopoDS::Face(aIt.Value());
916 IntTools_FClass2d& aClsf=aCtx.FClass2d(aFx);
917 aClsf.Init(aFx, aTol);
919 iFlag=aCtx.ComputeVS (aV, aFx, aU1, aU2);
927 const TopoDS_Face& aFx=TopoDS::Face(aF);
929 IntTools_FClass2d& aClsf=aCtx.FClass2d(aFx);
930 aClsf.Init(aFx, aTol);
932 iFlag=aCtx.ComputeVS (aV, aFx, aU1, aU2);
936 GEOMAlgo_Tools3D::CopyFace(aFx, aFz);
938 myImages.Bind(aF, aFz);
941 }// for (; aItV.More(); aItV.Next()) {
943 }// for (nF=1; nF<=aNb; ++nF) {
946 //=======================================================================
947 // function: UpdateCandidates
949 //=======================================================================
950 void UpdateCandidates(const Standard_Integer theNF,
951 const Standard_Integer theNV,
952 NMTTools_IndexedDataMapOfIndexedMapOfInteger& theMFMV)
954 if (theMFMV.Contains(theNF)) {
955 TColStd_IndexedMapOfInteger& aMV=theMFMV.ChangeFromKey(theNF);
959 TColStd_IndexedMapOfInteger aMV;
961 theMFMV.Add(theNF, aMV);
969 TopTools_ListIteratorOfListOfShape aItx;
971 aBBx.MakeCompound(aCx);
973 aItx.Initialize(aSE);
974 for (; aItx.More(); aItx.Next()) {
975 TopoDS_Shape& aEx=aItx.Value();