1 // Copyright (C) 2007-2010 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
22 // File: GEOMAlgo_Builder_2.cxx
23 // Author: Peter KURNEV
25 #include <GEOMAlgo_Builder.hxx>
27 #include <TColStd_IndexedMapOfInteger.hxx>
28 #include <TColStd_ListOfInteger.hxx>
30 #include <TopAbs_Orientation.hxx>
33 #include <TopoDS_Face.hxx>
34 #include <TopoDS_Edge.hxx>
35 #include <TopoDS_Shape.hxx>
36 #include <TopoDS_Compound.hxx>
38 #include <TopTools_IndexedMapOfShape.hxx>
39 #include <TopTools_ListOfShape.hxx>
40 #include <TopTools_MapOfShape.hxx>
41 #include <TopTools_ListIteratorOfListOfShape.hxx>
44 #include <TopExp_Explorer.hxx>
46 #include <BRep_Tool.hxx>
47 #include <BRep_Builder.hxx>
48 #include <BRepAlgo_Image.hxx>
49 #include <BRepTools.hxx>
51 #include <IntTools_Context.hxx>
52 #include <IntTools_FClass2d.hxx>
54 #include <BooleanOperations_OnceExplorer.hxx>
55 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
56 #include <BOPTools_ListOfPaveBlock.hxx>
57 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
58 #include <BOPTools_CArray1OfSSInterference.hxx>
59 #include <BOPTools_SSInterference.hxx>
60 #include <BOPTools_SequenceOfCurves.hxx>
61 #include <BOPTools_Curve.hxx>
62 #include <BOPTools_ListOfPaveBlock.hxx>
63 #include <BOPTools_PaveBlock.hxx>
64 #include <BOPTools_Tools3D.hxx>
65 #include <BOPTools_CArray1OfVSInterference.hxx>
66 #include <BOPTools_VSInterference.hxx>
67 #include <BOPTools_ESInterference.hxx>
68 #include <BOPTools_CArray1OfESInterference.hxx>
70 #include <NMTDS_ShapesDataStructure.hxx>
71 #include <NMTDS_InterfPool.hxx>
73 #include <NMTTools_PaveFiller.hxx>
74 #include <NMTTools_ListOfCoupleOfShape.hxx>
75 #include <NMTTools_Tools.hxx>
76 #include <NMTTools_CoupleOfShape.hxx>
77 #include <NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
78 #include <NMTTools_Tools.hxx>
79 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
80 #include <NMTTools_ListOfCommonBlock.hxx>
81 #include <NMTTools_CommonBlock.hxx>
82 #include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
84 #include <GEOMAlgo_Tools3D.hxx>
85 #include <GEOMAlgo_WireEdgeSet.hxx>
86 #include <GEOMAlgo_BuilderFace.hxx>
88 #include <GEOMAlgo_ShapeSet.hxx>
90 #include <NMTDS_BoxBndTree.hxx>
91 #include <NCollection_UBTreeFiller.hxx>
92 #include <Bnd_Box.hxx>
93 #include <BRepBndLib.hxx>
94 #include <TopTools_DataMapOfIntegerShape.hxx>
95 #include <TColStd_ListOfInteger.hxx>
96 #include <TColStd_ListIteratorOfListOfInteger.hxx>
99 void UpdateCandidates(const Standard_Integer ,
100 const Standard_Integer ,
101 NMTTools_IndexedDataMapOfIndexedMapOfInteger& );
103 //=======================================================================
104 //function : FillImagesFaces
106 //=======================================================================
107 void GEOMAlgo_Builder::FillImagesFaces()
113 FillSameDomainFaces();
115 FillInternalVertices();
118 //=======================================================================
119 // function: FillIn2DParts
121 //=======================================================================
122 void GEOMAlgo_Builder::FillIn2DParts()
124 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
125 NMTTools_PaveFiller* pPF=myPaveFiller;
126 NMTDS_InterfPool* pIP=pPF->IP();
127 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
128 NMTTools_CommonBlockPool& aCBP=pPF->ChangeCommonBlockPool();
130 Standard_Integer j, nSpIn, nSpSc, aNbCurves;
131 Standard_Integer aNbS, nF, aNbCBP, n1, n2, aNbFFs, aNbSpIn;
132 TopTools_MapOfShape aMFence;
133 TopTools_ListOfShape aLSpIn;
135 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
136 BOPTools_ListIteratorOfListOfPaveBlock aItPB;
140 aNbFFs=aFFs.Extent();
141 aNbCBP=aCBP.Extent();
143 aNbS=aDS.NumberOfShapesOfTheObject();
144 for (nF=1; nF<=aNbS; ++nF) {
145 if (aDS.GetShapeType(nF)!=TopAbs_FACE) {
149 aF=TopoDS::Face(aDS.Shape(nF));
155 for (j=1; j<=aNbCBP; ++j) {
156 NMTTools_ListOfCommonBlock& aLCB=aCBP(j);
157 aItCB.Initialize(aLCB);
158 for (; aItCB.More(); aItCB.Next()) {
159 NMTTools_CommonBlock& aCB=aItCB.Value();
160 if (aCB.IsPaveBlockOnFace(nF)) {
161 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1();
163 const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn);
164 if (aMFence.Add(aSpIn)){
165 aLSpIn.Append(aSpIn);
172 for (j=1; j<=aNbFFs; ++j) {
173 BOPTools_SSInterference& aFF=aFFs(j);
175 if (!(n1==nF || n2==nF)) {
178 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
179 aNbCurves=aSC.Length();
184 const BOPTools_Curve& aBC=aSC(1);
185 const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
186 aItPB.Initialize(aLPB);
187 for (; aItPB.More(); aItPB.Next()) {
188 const BOPTools_PaveBlock& aPBSc=aItPB.Value();
190 const TopoDS_Shape& aSpSc=aDS.Shape(nSpSc);
191 if (aMFence.Add(aSpSc)){
192 aLSpIn.Append(aSpSc);
196 aNbSpIn=aLSpIn.Extent();
198 myInParts.Add(aF, aLSpIn);
200 }//for (nF=1; nF<=aNbS; ++nF) {
203 //=======================================================================
204 // function: BuildSplitFaces
206 //=======================================================================
207 void GEOMAlgo_Builder::BuildSplitFaces()
209 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
210 NMTTools_PaveFiller* pPF=myPaveFiller;
211 NMTDS_InterfPool* pIP=pPF->IP();
212 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
213 IntTools_Context& aCtx= pPF->ChangeContext();
215 Standard_Boolean bToReverse, bIsClosed, bIsDegenerated;
216 Standard_Integer i, aNb, aNbF, nF;
217 TopTools_MapOfShape aMFence;
218 TColStd_IndexedMapOfInteger aMFP;
219 TopExp_Explorer anExp;
221 TopoDS_Edge aSp, aEE;
222 TopTools_ListIteratorOfListOfShape aIt;
223 TopAbs_Orientation anOriF, anOriE;
225 mySplitFaces.Clear();
227 // 1. Select Faces to process (MFP)
228 aNb=aDS.NumberOfShapesOfTheObject();
229 for (i=1; i<=aNb; ++i) {
230 const TopoDS_Shape& aF=aDS.Shape(i);
231 if (aF.ShapeType()!=TopAbs_FACE) {
234 if (!aMFence.Add(aF)) {
238 if (myInParts.Contains(aF)) {
243 anExp.Init(aF, TopAbs_EDGE);
244 for (; anExp.More(); anExp.Next()) {
245 const TopoDS_Shape& aE=anExp.Current();
246 if (myImages.HasImage(aE)) {
254 Standard_Integer aNbFFs, aNbSE, j, n1, n2;
256 aNbFFs=aFFs.Extent();
257 for (j=1; j<=aNbFFs; ++j) {
258 BOPTools_SSInterference& aFFj=aFFs(j);
259 aFFj.Indices(n1, n2);
260 if (!(n1==i || n2==i)) {
264 const TColStd_ListOfInteger& aLSE=aFFj.SharedEdges();
274 }// for (i=1; i<=aNb; ++i)
278 for (i=1; i<=aNbF; ++i) {
280 const TopoDS_Face& aF=TopoDS::Face(aDS.Shape(nF));
281 anOriF=aF.Orientation();
283 aFF.Orientation(TopAbs_FORWARD);
288 GEOMAlgo_WireEdgeSet aWES;
291 // 2.1.1. Add Split parts
292 anExp.Init(aFF, TopAbs_EDGE);
293 for (; anExp.More(); anExp.Next()) {
294 const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current());
295 anOriE=aE.Orientation();
297 if (!myImages.HasImage(aE)) {
298 if (anOriE==TopAbs_INTERNAL) {
300 aEE.Orientation(TopAbs_FORWARD);
301 aWES.AddStartElement(aEE);
302 aEE.Orientation(TopAbs_REVERSED);
303 aWES.AddStartElement(aEE);
306 aWES.AddStartElement(aE);
311 bIsDegenerated=BRep_Tool::Degenerated(aE);
312 bIsClosed=BRep_Tool::IsClosed(aE, aF);
314 const TopTools_ListOfShape& aLIE=myImages.Image(aE);
315 aIt.Initialize(aLIE);
316 for (; aIt.More(); aIt.Next()) {
317 aSp=TopoDS::Edge(aIt.Value());
319 if (bIsDegenerated) {
320 aSp.Orientation(anOriE);
321 aWES.AddStartElement(aSp);
325 if (anOriE==TopAbs_INTERNAL) {
326 aSp.Orientation(TopAbs_FORWARD);
327 aWES.AddStartElement(aSp);
328 aSp.Orientation(TopAbs_REVERSED);
329 aWES.AddStartElement(aSp);
334 if (aMFence.Add(aSp)) {
336 if (!BRep_Tool::IsClosed(aSp, aF)){
337 BOPTools_Tools3D::DoSplitSEAMOnFace(aSp, aF);
340 aSp.Orientation(TopAbs_FORWARD);
341 aWES.AddStartElement(aSp);
342 aSp.Orientation(TopAbs_REVERSED);
343 aWES.AddStartElement(aSp);
346 }// if (aMFence.Add(aSp))
348 aSp.Orientation(anOriE);
349 bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, aCtx);
353 aWES.AddStartElement(aSp);
354 }// for (; aIt.More(); aIt.Next()) {
355 }// for (; anExp.More(); anExp.Next()) {
357 // 2.1.2. Add In2D Parts
358 if (myInParts.Contains(aF)) {
359 const TopTools_ListOfShape& aLE=myInParts.FindFromKey(aF);
361 for (; aIt.More(); aIt.Next()) {
362 aSp=TopoDS::Edge(aIt.Value());
364 aSp.Orientation(TopAbs_FORWARD);
365 aWES.AddStartElement(aSp);
367 aSp.Orientation(TopAbs_REVERSED);
368 aWES.AddStartElement(aSp);
372 // 2.2. Build images Faces
373 TopTools_ListOfShape aLFR;
374 GEOMAlgo_ShapeSet aS1, aS2;
376 const TopTools_ListOfShape& aSE=aWES.StartElements();
378 aS2.Add(aFF, TopAbs_EDGE);
379 if (aS1.IsEqual(aS2)) {
383 GEOMAlgo_BuilderFace aBF;
386 aBF.SetContext(aCtx);
391 const TopTools_ListOfShape& aLF=aBF.Areas();
393 for (; aIt.More(); aIt.Next()) {
394 TopoDS_Shape& aFR=aIt.Value();
395 if (anOriF==TopAbs_REVERSED) {
396 aFR.Orientation(TopAbs_REVERSED);
402 // 2.3. Collect draft images Faces
403 mySplitFaces.Bind(aF, aLFR);
404 }//for (i=1; i<=aNbF; ++i)
407 //=======================================================================
408 // function: FillSameDomainFaces
410 //=======================================================================
411 void GEOMAlgo_Builder::FillSameDomainFaces()
413 Standard_Boolean bIsSDF, bHasImage1, bHasImage2, bForward;
414 Standard_Integer i, j, aNbFF, nF1, nF2, aNbPBInOn, aNbC, aNbSE;
415 Standard_Integer aNbF1, aNbF2, i2s, aNbSD;
416 TopTools_MapOfShape aMFence;
417 TopTools_ListOfShape aLX1, aLX2;
418 TopTools_ListIteratorOfListOfShape aItF1, aItF2;
419 NMTTools_ListOfCoupleOfShape aLCS;
421 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
422 NMTTools_PaveFiller* pPF=myPaveFiller;
423 NMTDS_InterfPool* pIP=pPF->IP();
424 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
425 IntTools_Context& aCtx= pPF->ChangeContext();
428 //mySameDomainShapes.Clear();
430 // 1. For each FF find among images of faces
431 // all pairs of same domain faces (SDF) [=> aLCS]
433 for (i=1; i<=aNbFF; ++i) {
434 BOPTools_SSInterference& aFF=aFFs(i);
435 aFF.Indices(nF1, nF2);
437 const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1));
438 const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2));
440 // if there are no in/on 2D split parts the faces nF1, nF2
442 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
443 aNbPBInOn=aLPBInOn.Extent();
446 const TColStd_ListOfInteger& aLSE=aFF.SharedEdges();
448 if (!aNbPBInOn && !aNbSE) {
453 // if there is at least one section edge between faces nF1, nF2
454 // they can not be SDF
455 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
461 // the faces are suspected to be SDF.
462 // Try to find SDF among images of nF1, nF2
465 //--------------------------------------------------------
466 bHasImage1=mySplitFaces.HasImage(aF1);
467 bHasImage2=mySplitFaces.HasImage(aF2);
479 const TopTools_ListOfShape& aLF1r=(bHasImage1)? mySplitFaces.Image(aF1) : aLX1;
480 const TopTools_ListOfShape& aLF2r=(bHasImage2)? mySplitFaces.Image(aF2) : aLX2;
482 TopTools_DataMapOfIntegerShape aMIS;
483 TColStd_ListIteratorOfListOfInteger aItLI;
484 NMTDS_BoxBndTreeSelector aSelector;
485 NMTDS_BoxBndTree aBBTree;
486 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
488 aNbF1=aLF1r.Extent();
489 aNbF2=aLF2r.Extent();
490 bForward=(aNbF1<aNbF2);
492 const TopTools_ListOfShape& aLF1=bForward ? aLF1r : aLF2r;
493 const TopTools_ListOfShape& aLF2=bForward ? aLF2r : aLF1r;
496 aItF2.Initialize(aLF2);
497 for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
500 const TopoDS_Face& aF2s=*((TopoDS_Face*)(&aItF2.Value()));
502 BRepBndLib::Add(aF2s, aBoxF2s);
504 aMIS.Bind(i2s, aF2s);
506 aTreeFiller.Add(i2s, aBoxF2s);
507 }//for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
512 aItF1.Initialize(aLF1);
513 for (j=1; aItF1.More(); aItF1.Next(), ++j) {
516 const TopoDS_Face& aF1x=*((TopoDS_Face*)(&aItF1.Value()));
518 BRepBndLib::Add(aF1x, aBoxF1x);
521 aSelector.SetBox(aBoxF1x);
522 aNbSD=aBBTree.Select(aSelector);
527 const TColStd_ListOfInteger& aLI=aSelector.Indices();
528 aItLI.Initialize(aLI);
529 for (; aItLI.More(); aItLI.Next()) {
531 const TopoDS_Face& aF2y=*((TopoDS_Face*)(&aMIS.Find(i2s)));
533 bIsSDF=NMTTools_Tools::AreFacesSameDomain(aF1x, aF2y, aCtx);
535 if (aMFence.Contains(aF1x) || aMFence.Contains(aF2y)) {
541 NMTTools_CoupleOfShape aCS;
549 if (!mySplitFaces.HasImage(aF1)) {
550 mySplitFaces.Bind(aF1, aF1);
554 if (!mySplitFaces.HasImage(aF2)) {
555 mySplitFaces.Bind(aF2, aF2);
561 if (!mySplitFaces.HasImage(aF2)) {
562 mySplitFaces.Bind(aF2, aF2);
566 if (!mySplitFaces.HasImage(aF1)) {
567 mySplitFaces.Bind(aF1, aF1);
574 }//for (; aItLI.More(); aItLI.Next()) {
575 }//for (; aItF1.More(); aItF1.Next()) {
576 }//for (i=1; i<=aNbFF; ++i)
577 //-------------------------------------------------------------
584 NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMC;
586 NMTTools_Tools::FindChains(aLCS, aMC);
588 // 3. Fill the map of SDF mySameDomainFaces
590 for (i=1; i<=aNbC; ++i) {
591 const TopoDS_Shape& aF=aMC.FindKey(i);
592 const TopTools_IndexedMapOfShape& aMSDF=aMC(i);
594 aNbFF=aMSDF.Extent();
595 for (j=1; j<=aNbFF; ++j) {
596 const TopoDS_Shape& aFSD=aMSDF(j);
597 mySameDomainShapes.Add(aFSD, aF);
603 //=======================================================================
604 // function: FillImagesFaces1
606 //=======================================================================
607 void GEOMAlgo_Builder::FillImagesFaces1()
609 Standard_Integer i, aNb, iSense, aNbLFx;
610 TopoDS_Face aF, aFSp, aFSD;
611 TopTools_ListOfShape aLFx;
612 TopTools_ListIteratorOfListOfShape aIt;
614 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
616 aNb=aDS.NumberOfShapesOfTheObject();
617 for (i=1; i<=aNb; ++i) {
618 const TopoDS_Shape& aS=aDS.Shape(i);
619 if (aS.ShapeType()!=TopAbs_FACE) {
623 if (!mySplitFaces.HasImage(aS)) {
627 aF=*((TopoDS_Face*)&aS);
630 const TopTools_ListOfShape& aLF=mySplitFaces.Image(aF);
632 for (; aIt.More(); aIt.Next()) {
633 aFSp=*((TopoDS_Face*)(&aIt.Value()));
634 if (!mySameDomainShapes.Contains(aFSp)) {
638 const TopoDS_Shape& aSx=mySameDomainShapes.FindFromKey(aFSp);
639 aFSD=*((TopoDS_Face*)(&aSx));
640 iSense=GEOMAlgo_Tools3D::Sense(aFSp, aFSD);
648 if (!myImages.HasImage(aF)) {
649 aNbLFx=aLFx.Extent();
651 const TopoDS_Shape& aFx=aLFx.First();
652 if (aF.IsSame(aFx)) {
656 myImages.Bind(aF, aLFx);
661 //=======================================================================
662 // function: FillInternalVertices
664 //=======================================================================
665 void GEOMAlgo_Builder::FillInternalVertices()
667 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
668 NMTTools_PaveFiller* pPF=myPaveFiller;
669 NMTDS_InterfPool* pIP=pPF->IP();
670 IntTools_Context& aCtx= pPF->ChangeContext();
672 /*BOPTools_CArray1OfSSInterference& aFFs=*/pIP->SSInterferences();
673 BOPTools_CArray1OfVSInterference& aVFs=pIP->VSInterferences();
674 BOPTools_CArray1OfESInterference& aEFs=pIP->ESInterferences();
675 const NMTTools_IndexedDataMapOfIndexedMapOfInteger& aMAV=pPF->AloneVertices();
677 Standard_Boolean bHasImage;
678 Standard_Integer i, j, nF, aNbS, nV, nVSD, n1, n2, iFlag;
679 Standard_Integer aNbVFs, aNbAVF, aNbEFs, aNbVC, aNbE, aNbV;
680 Standard_Real aU1, aU2, aTol;
681 NMTTools_IndexedDataMapOfIndexedMapOfInteger aMFMV;
682 TopTools_MapOfShape aMFence;
683 TopTools_ListIteratorOfListOfShape aIt, aItV;
686 // 1. Collect face-vertex candidates [aMFMV]
689 aNbVFs=aVFs.Extent();
690 for (i=1; i<=aNbVFs; ++i) {
691 const BOPTools_VSInterference& aVS=aVFs(i);
695 if (aDS.Shape(n1).ShapeType()==TopAbs_FACE) {
699 nVSD=pPF->FindSDVertex(nV);
704 UpdateCandidates(nF, nV, aMFMV);
708 aNbEFs=aEFs.Extent();
709 for (i=1; i<=aNbEFs; ++i) {
710 const BOPTools_ESInterference& aEF=aEFs(i);
716 const TopoDS_Shape& aSnew=aDS.Shape(nV);
717 if (aSnew.ShapeType()!=TopAbs_VERTEX) {
721 nF=(aDS.Shape(n1).ShapeType()==TopAbs_FACE) ? n1 : n2;
722 nVSD=pPF->FindSDVertex(nV);
726 UpdateCandidates(nF, nV, aMFMV);
729 aNbS=aDS.NumberOfShapesOfTheObject();
730 for (nF=1; nF<=aNbS; ++nF) {
731 const TopoDS_Shape& aF=aDS.Shape(nF);
733 if (aF.ShapeType()!=TopAbs_FACE) {
736 if (!aMFence.Add(aF)) {
740 const TopoDS_Face& aFF=TopoDS::Face(aF);
741 aTol=BRep_Tool::Tolerance(aFF);
744 if (aMAV.Contains(nF)) {
745 const TColStd_IndexedMapOfInteger& aMAVF=aMAV.FindFromKey(nF);
746 aNbAVF=aMAVF.Extent();
747 for (j=1; j<=aNbAVF; ++j) {
749 nVSD=pPF->FindSDVertex(nV);
754 UpdateCandidates(nF, nV, aMFMV);
758 // 1.4 Internal vertices of the face nF
759 BooleanOperations_OnceExplorer aExp(aDS);
760 aExp.Init(nF, TopAbs_VERTEX);
761 for (; aExp.More(); aExp.Next()) {
763 const TopoDS_Shape& aV=aDS.Shape(nV);
764 if (aV.Orientation()==TopAbs_INTERNAL) {
765 nVSD=pPF->FindSDVertex(nV);
770 UpdateCandidates(nF, nV, aMFMV);
774 // 2. Process face nF
775 if (!aMFMV.Contains(nF)) {
779 const TColStd_IndexedMapOfInteger& aMVC=aMFMV.FindFromKey(nF);
785 // 2.1 Refine candidates
786 TopTools_IndexedDataMapOfShapeListOfShape aMVE;
787 TopTools_ListOfShape aLV;
789 bHasImage=myImages.HasImage(aF);
791 const TopTools_ListOfShape& aLFx=myImages.Image(aF);
792 aIt.Initialize(aLFx);
793 for (; aIt.More(); aIt.Next()) {
794 const TopoDS_Shape& aFx=aIt.Value();
795 TopExp::MapShapesAndAncestors(aFx, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
799 Standard_Boolean bFaceToProcess;
801 TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
802 bFaceToProcess=Standard_False;
803 for (j=1; j<=aNbVC; ++j) {
805 const TopoDS_Shape& aV=aDS.Shape(nV);
806 if (!aMVE.Contains(aV)) {
807 bFaceToProcess=!bFaceToProcess;
811 if (!bFaceToProcess) {
816 for (j=1; j<=aNbVC; ++j) {
818 const TopoDS_Shape& aV=aDS.Shape(nV);
819 if (aMVE.Contains(aV)) {
820 const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV);
831 // 3. Try to put vertices into the face(s)
832 aItV.Initialize(aLV);
833 for (; aItV.More(); aItV.Next()) {
834 TopoDS_Vertex aV=TopoDS::Vertex(aItV.Value());
835 aV.Orientation(TopAbs_INTERNAL);
837 bHasImage=myImages.HasImage(aF);
839 const TopTools_ListOfShape& aLFx=myImages.Image(aF);
840 aIt.Initialize(aLFx);
841 for (; aIt.More(); aIt.Next()) {
842 TopoDS_Face aFx=TopoDS::Face(aIt.Value());
844 IntTools_FClass2d& aClsf=aCtx.FClass2d(aFx);
845 aClsf.Init(aFx, aTol);
847 iFlag=aCtx.ComputeVS (aV, aFx, aU1, aU2);
855 const TopoDS_Face& aFx=TopoDS::Face(aF);
857 IntTools_FClass2d& aClsf=aCtx.FClass2d(aFx);
858 aClsf.Init(aFx, aTol);
860 iFlag=aCtx.ComputeVS (aV, aFx, aU1, aU2);
864 GEOMAlgo_Tools3D::CopyFace(aFx, aFz);
866 myImages.Bind(aF, aFz);
869 }// for (; aItV.More(); aItV.Next()) {
871 }// for (nF=1; nF<=aNb; ++nF) {
874 //=======================================================================
875 // function: UpdateCandidates
877 //=======================================================================
878 void UpdateCandidates(const Standard_Integer theNF,
879 const Standard_Integer theNV,
880 NMTTools_IndexedDataMapOfIndexedMapOfInteger& theMFMV)
882 if (theMFMV.Contains(theNF)) {
883 TColStd_IndexedMapOfInteger& aMV=theMFMV.ChangeFromKey(theNF);
887 TColStd_IndexedMapOfInteger aMV;
889 theMFMV.Add(theNF, aMV);
897 TopTools_ListIteratorOfListOfShape aItx;
899 aBBx.MakeCompound(aCx);
901 aItx.Initialize(aSE);
902 for (; aItx.More(); aItx.Next()) {
903 TopoDS_Shape& aEx=aItx.Value();