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>
100 void UpdateCandidates(const Standard_Integer ,
101 const Standard_Integer ,
102 NMTTools_IndexedDataMapOfIndexedMapOfInteger& );
104 //=======================================================================
105 //function : FillImagesFaces
107 //=======================================================================
108 void GEOMAlgo_Builder::FillImagesFaces()
114 FillSameDomainFaces();
116 FillInternalVertices();
119 //=======================================================================
120 // function: FillIn2DParts
122 //=======================================================================
123 void GEOMAlgo_Builder::FillIn2DParts()
125 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
126 NMTTools_PaveFiller* pPF=myPaveFiller;
127 NMTDS_InterfPool* pIP=pPF->IP();
128 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
129 NMTTools_CommonBlockPool& aCBP=pPF->ChangeCommonBlockPool();
131 Standard_Integer j, nSpIn, nSpSc, aNbCurves;
132 Standard_Integer aNbS, nF, aNbCBP, n1, n2, aNbFFs, aNbSpIn;
133 TopTools_MapOfShape aMFence;
134 TopTools_ListOfShape aLSpIn;
136 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
137 BOPTools_ListIteratorOfListOfPaveBlock aItPB;
141 aNbFFs=aFFs.Extent();
142 aNbCBP=aCBP.Extent();
144 aNbS=aDS.NumberOfShapesOfTheObject();
145 for (nF=1; nF<=aNbS; ++nF) {
146 if (aDS.GetShapeType(nF)!=TopAbs_FACE) {
150 aF=TopoDS::Face(aDS.Shape(nF));
156 for (j=1; j<=aNbCBP; ++j) {
157 NMTTools_ListOfCommonBlock& aLCB=aCBP(j);
158 aItCB.Initialize(aLCB);
159 for (; aItCB.More(); aItCB.Next()) {
160 NMTTools_CommonBlock& aCB=aItCB.Value();
161 if (aCB.IsPaveBlockOnFace(nF)) {
162 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1();
164 const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn);
165 if (aMFence.Add(aSpIn)){
166 aLSpIn.Append(aSpIn);
173 for (j=1; j<=aNbFFs; ++j) {
174 BOPTools_SSInterference& aFF=aFFs(j);
176 if (!(n1==nF || n2==nF)) {
179 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
180 aNbCurves=aSC.Length();
185 const BOPTools_Curve& aBC=aSC(1);
186 const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
187 aItPB.Initialize(aLPB);
188 for (; aItPB.More(); aItPB.Next()) {
189 const BOPTools_PaveBlock& aPBSc=aItPB.Value();
191 const TopoDS_Shape& aSpSc=aDS.Shape(nSpSc);
192 if (aMFence.Add(aSpSc)){
193 aLSpIn.Append(aSpSc);
197 aNbSpIn=aLSpIn.Extent();
199 myInParts.Add(aF, aLSpIn);
201 }//for (nF=1; nF<=aNbS; ++nF) {
204 //=======================================================================
205 // function: BuildSplitFaces
207 //=======================================================================
208 void GEOMAlgo_Builder::BuildSplitFaces()
210 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
211 NMTTools_PaveFiller* pPF=myPaveFiller;
212 NMTDS_InterfPool* pIP=pPF->IP();
213 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
214 IntTools_Context& aCtx= pPF->ChangeContext();
216 Standard_Boolean bToReverse, bIsClosed, bIsDegenerated;
217 Standard_Integer i, aNb, aNbF, nF;
218 TopTools_MapOfShape aMFence;
219 TColStd_IndexedMapOfInteger aMFP;
220 TopExp_Explorer anExp;
222 TopoDS_Edge aSp, aEE;
223 TopTools_ListIteratorOfListOfShape aIt;
224 TopAbs_Orientation anOriF, anOriE;
226 mySplitFaces.Clear();
228 // 1. Select Faces to process (MFP)
229 aNb=aDS.NumberOfShapesOfTheObject();
230 for (i=1; i<=aNb; ++i) {
231 const TopoDS_Shape& aF=aDS.Shape(i);
232 if (aF.ShapeType()!=TopAbs_FACE) {
235 if (!aMFence.Add(aF)) {
239 if (myInParts.Contains(aF)) {
244 anExp.Init(aF, TopAbs_EDGE);
245 for (; anExp.More(); anExp.Next()) {
246 const TopoDS_Shape& aE=anExp.Current();
247 if (myImages.HasImage(aE)) {
255 Standard_Integer aNbFFs, aNbSE, j, n1, n2;
257 aNbFFs=aFFs.Extent();
258 for (j=1; j<=aNbFFs; ++j) {
259 BOPTools_SSInterference& aFFj=aFFs(j);
260 aFFj.Indices(n1, n2);
261 if (!(n1==i || n2==i)) {
265 const TColStd_ListOfInteger& aLSE=aFFj.SharedEdges();
275 }// for (i=1; i<=aNb; ++i)
279 for (i=1; i<=aNbF; ++i) {
281 const TopoDS_Face& aF=TopoDS::Face(aDS.Shape(nF));
282 anOriF=aF.Orientation();
284 aFF.Orientation(TopAbs_FORWARD);
289 GEOMAlgo_WireEdgeSet aWES;
292 // 2.1.1. Add Split parts
293 anExp.Init(aFF, TopAbs_EDGE);
294 for (; anExp.More(); anExp.Next()) {
295 const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current());
296 anOriE=aE.Orientation();
298 if (!myImages.HasImage(aE)) {
299 if (anOriE==TopAbs_INTERNAL) {
301 aEE.Orientation(TopAbs_FORWARD);
302 aWES.AddStartElement(aEE);
303 aEE.Orientation(TopAbs_REVERSED);
304 aWES.AddStartElement(aEE);
307 aWES.AddStartElement(aE);
312 bIsDegenerated=BRep_Tool::Degenerated(aE);
313 bIsClosed=BRep_Tool::IsClosed(aE, aF);
315 const TopTools_ListOfShape& aLIE=myImages.Image(aE);
316 aIt.Initialize(aLIE);
317 for (; aIt.More(); aIt.Next()) {
318 aSp=TopoDS::Edge(aIt.Value());
320 if (bIsDegenerated) {
321 aSp.Orientation(anOriE);
322 aWES.AddStartElement(aSp);
326 if (anOriE==TopAbs_INTERNAL) {
327 aSp.Orientation(TopAbs_FORWARD);
328 aWES.AddStartElement(aSp);
329 aSp.Orientation(TopAbs_REVERSED);
330 aWES.AddStartElement(aSp);
335 if (aMFence.Add(aSp)) {
337 if (!BRep_Tool::IsClosed(aSp, aF)){
338 BOPTools_Tools3D::DoSplitSEAMOnFace(aSp, aF);
341 aSp.Orientation(TopAbs_FORWARD);
342 aWES.AddStartElement(aSp);
343 aSp.Orientation(TopAbs_REVERSED);
344 aWES.AddStartElement(aSp);
347 }// if (aMFence.Add(aSp))
349 aSp.Orientation(anOriE);
350 bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, aCtx);
354 aWES.AddStartElement(aSp);
355 }// for (; aIt.More(); aIt.Next()) {
356 }// for (; anExp.More(); anExp.Next()) {
358 // 2.1.2. Add In2D Parts
359 if (myInParts.Contains(aF)) {
360 const TopTools_ListOfShape& aLE=myInParts.FindFromKey(aF);
362 for (; aIt.More(); aIt.Next()) {
363 aSp=TopoDS::Edge(aIt.Value());
365 aSp.Orientation(TopAbs_FORWARD);
366 aWES.AddStartElement(aSp);
368 aSp.Orientation(TopAbs_REVERSED);
369 aWES.AddStartElement(aSp);
373 // 2.2. Build images Faces
374 TopTools_ListOfShape aLFR;
375 GEOMAlgo_ShapeSet aS1, aS2;
377 const TopTools_ListOfShape& aSE=aWES.StartElements();
379 aS2.Add(aFF, TopAbs_EDGE);
380 if (aS1.IsEqual(aS2)) {
384 GEOMAlgo_BuilderFace aBF;
387 aBF.SetContext(aCtx);
392 const TopTools_ListOfShape& aLF=aBF.Areas();
394 for (; aIt.More(); aIt.Next()) {
395 TopoDS_Shape& aFR=aIt.Value();
396 if (anOriF==TopAbs_REVERSED) {
397 aFR.Orientation(TopAbs_REVERSED);
403 // 2.3. Collect draft images Faces
404 mySplitFaces.Bind(aF, aLFR);
405 }//for (i=1; i<=aNbF; ++i)
408 //=======================================================================
409 // function: FillSameDomainFaces
411 //=======================================================================
412 void GEOMAlgo_Builder::FillSameDomainFaces()
414 Standard_Boolean bIsSDF, bHasImage1, bHasImage2, bForward;
415 Standard_Integer i, j, aNbFF, nF1, nF2, aNbPBInOn, aNbC, aNbSE;
416 Standard_Integer aNbF1, aNbF2, i2s, aNbSD;
417 TopTools_MapOfShape aMFence;
418 TopTools_ListOfShape aLX1, aLX2;
419 TopTools_ListIteratorOfListOfShape aItF1, aItF2;
420 NMTTools_ListOfCoupleOfShape aLCS;
422 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
423 NMTTools_PaveFiller* pPF=myPaveFiller;
424 NMTDS_InterfPool* pIP=pPF->IP();
425 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
426 IntTools_Context& aCtx= pPF->ChangeContext();
429 //mySameDomainShapes.Clear();
431 // 1. For each FF find among images of faces
432 // all pairs of same domain faces (SDF) [=> aLCS]
434 for (i=1; i<=aNbFF; ++i) {
435 BOPTools_SSInterference& aFF=aFFs(i);
436 aFF.Indices(nF1, nF2);
438 const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1));
439 const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2));
441 // if there are no in/on 2D split parts the faces nF1, nF2
443 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
444 aNbPBInOn=aLPBInOn.Extent();
447 const TColStd_ListOfInteger& aLSE=aFF.SharedEdges();
449 if (!aNbPBInOn && !aNbSE) {
454 // if there is at least one section edge between faces nF1, nF2
455 // they can not be SDF
456 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
462 // the faces are suspected to be SDF.
463 // Try to find SDF among images of nF1, nF2
466 //--------------------------------------------------------
467 bHasImage1=mySplitFaces.HasImage(aF1);
468 bHasImage2=mySplitFaces.HasImage(aF2);
480 const TopTools_ListOfShape& aLF1r=(bHasImage1)? mySplitFaces.Image(aF1) : aLX1;
481 const TopTools_ListOfShape& aLF2r=(bHasImage2)? mySplitFaces.Image(aF2) : aLX2;
483 TopTools_DataMapOfIntegerShape aMIS;
484 TColStd_ListIteratorOfListOfInteger aItLI;
485 NMTDS_BoxBndTreeSelector aSelector;
486 NMTDS_BoxBndTree aBBTree;
487 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
489 aNbF1=aLF1r.Extent();
490 aNbF2=aLF2r.Extent();
491 bForward=(aNbF1<aNbF2);
493 const TopTools_ListOfShape& aLF1=bForward ? aLF1r : aLF2r;
494 const TopTools_ListOfShape& aLF2=bForward ? aLF2r : aLF1r;
497 aItF2.Initialize(aLF2);
498 for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
501 const TopoDS_Face& aF2s=*((TopoDS_Face*)(&aItF2.Value()));
503 BRepBndLib::Add(aF2s, aBoxF2s);
505 aMIS.Bind(i2s, aF2s);
507 aTreeFiller.Add(i2s, aBoxF2s);
508 }//for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
513 aItF1.Initialize(aLF1);
514 for (j=1; aItF1.More(); aItF1.Next(), ++j) {
517 const TopoDS_Face& aF1x=*((TopoDS_Face*)(&aItF1.Value()));
519 BRepBndLib::Add(aF1x, aBoxF1x);
522 aSelector.SetBox(aBoxF1x);
523 aNbSD=aBBTree.Select(aSelector);
528 const TColStd_ListOfInteger& aLI=aSelector.Indices();
529 aItLI.Initialize(aLI);
530 for (; aItLI.More(); aItLI.Next()) {
532 const TopoDS_Face& aF2y=*((TopoDS_Face*)(&aMIS.Find(i2s)));
534 bIsSDF=NMTTools_Tools::AreFacesSameDomain(aF1x, aF2y, aCtx);
536 if (aMFence.Contains(aF1x) || aMFence.Contains(aF2y)) {
542 NMTTools_CoupleOfShape aCS;
550 if (!mySplitFaces.HasImage(aF1)) {
551 mySplitFaces.Bind(aF1, aF1);
555 if (!mySplitFaces.HasImage(aF2)) {
556 mySplitFaces.Bind(aF2, aF2);
562 if (!mySplitFaces.HasImage(aF2)) {
563 mySplitFaces.Bind(aF2, aF2);
567 if (!mySplitFaces.HasImage(aF1)) {
568 mySplitFaces.Bind(aF1, aF1);
575 }//for (; aItLI.More(); aItLI.Next()) {
576 }//for (; aItF1.More(); aItF1.Next()) {
577 }//for (i=1; i<=aNbFF; ++i)
578 //-------------------------------------------------------------
585 NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMC;
587 NMTTools_Tools::FindChains(aLCS, aMC);
589 // 3. Fill the map of SDF mySameDomainFaces
591 for (i=1; i<=aNbC; ++i) {
592 const TopoDS_Shape& aF=aMC.FindKey(i);
593 const TopTools_IndexedMapOfShape& aMSDF=aMC(i);
595 aNbFF=aMSDF.Extent();
596 for (j=1; j<=aNbFF; ++j) {
597 const TopoDS_Shape& aFSD=aMSDF(j);
598 mySameDomainShapes.Add(aFSD, aF);
604 //=======================================================================
605 // function: FillImagesFaces1
607 //=======================================================================
608 void GEOMAlgo_Builder::FillImagesFaces1()
610 Standard_Integer i, aNb, iSense, aNbLFx;
611 TopoDS_Face aF, aFSp, aFSD;
612 TopTools_ListOfShape aLFx;
613 TopTools_ListIteratorOfListOfShape aIt;
615 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
617 aNb=aDS.NumberOfShapesOfTheObject();
618 for (i=1; i<=aNb; ++i) {
619 const TopoDS_Shape& aS=aDS.Shape(i);
620 if (aS.ShapeType()!=TopAbs_FACE) {
624 if (!mySplitFaces.HasImage(aS)) {
628 aF=*((TopoDS_Face*)&aS);
631 const TopTools_ListOfShape& aLF=mySplitFaces.Image(aF);
633 for (; aIt.More(); aIt.Next()) {
634 aFSp=*((TopoDS_Face*)(&aIt.Value()));
635 if (!mySameDomainShapes.Contains(aFSp)) {
639 const TopoDS_Shape& aSx=mySameDomainShapes.FindFromKey(aFSp);
640 aFSD=*((TopoDS_Face*)(&aSx));
641 iSense=GEOMAlgo_Tools3D::Sense(aFSp, aFSD);
649 if (!myImages.HasImage(aF)) {
650 aNbLFx=aLFx.Extent();
652 const TopoDS_Shape& aFx=aLFx.First();
653 if (aF.IsSame(aFx)) {
657 myImages.Bind(aF, aLFx);
662 //=======================================================================
663 // function: FillInternalVertices
665 //=======================================================================
666 void GEOMAlgo_Builder::FillInternalVertices()
668 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
669 NMTTools_PaveFiller* pPF=myPaveFiller;
670 NMTDS_InterfPool* pIP=pPF->IP();
671 IntTools_Context& aCtx= pPF->ChangeContext();
673 /*BOPTools_CArray1OfSSInterference& aFFs=*/pIP->SSInterferences();
674 BOPTools_CArray1OfVSInterference& aVFs=pIP->VSInterferences();
675 BOPTools_CArray1OfESInterference& aEFs=pIP->ESInterferences();
676 const NMTTools_IndexedDataMapOfIndexedMapOfInteger& aMAV=pPF->AloneVertices();
678 Standard_Boolean bHasImage;
679 Standard_Integer i, j, nF, aNbS, nV, nVSD, n1, n2, iFlag;
680 Standard_Integer aNbVFs, aNbAVF, aNbEFs, aNbVC, aNbE, aNbV;
681 Standard_Real aU1, aU2, aTol;
682 NMTTools_IndexedDataMapOfIndexedMapOfInteger aMFMV;
683 TopTools_MapOfShape aMFence;
684 TopTools_ListIteratorOfListOfShape aIt, aItV;
687 // 1. Collect face-vertex candidates [aMFMV]
690 aNbVFs=aVFs.Extent();
691 for (i=1; i<=aNbVFs; ++i) {
692 const BOPTools_VSInterference& aVS=aVFs(i);
696 if (aDS.Shape(n1).ShapeType()==TopAbs_FACE) {
700 nVSD=pPF->FindSDVertex(nV);
705 UpdateCandidates(nF, nV, aMFMV);
709 aNbEFs=aEFs.Extent();
710 for (i=1; i<=aNbEFs; ++i) {
711 const BOPTools_ESInterference& aEF=aEFs(i);
717 const TopoDS_Shape& aSnew=aDS.Shape(nV);
718 if (aSnew.ShapeType()!=TopAbs_VERTEX) {
722 nF=(aDS.Shape(n1).ShapeType()==TopAbs_FACE) ? n1 : n2;
723 nVSD=pPF->FindSDVertex(nV);
727 UpdateCandidates(nF, nV, aMFMV);
730 aNbS=aDS.NumberOfShapesOfTheObject();
731 for (nF=1; nF<=aNbS; ++nF) {
732 const TopoDS_Shape& aF=aDS.Shape(nF);
734 if (aF.ShapeType()!=TopAbs_FACE) {
737 if (!aMFence.Add(aF)) {
741 const TopoDS_Face& aFF=TopoDS::Face(aF);
742 aTol=BRep_Tool::Tolerance(aFF);
745 if (aMAV.Contains(nF)) {
746 const TColStd_IndexedMapOfInteger& aMAVF=aMAV.FindFromKey(nF);
747 aNbAVF=aMAVF.Extent();
748 for (j=1; j<=aNbAVF; ++j) {
750 nVSD=pPF->FindSDVertex(nV);
755 UpdateCandidates(nF, nV, aMFMV);
759 // 1.4 Internal vertices of the face nF
760 BooleanOperations_OnceExplorer aExp(aDS);
761 aExp.Init(nF, TopAbs_VERTEX);
762 for (; aExp.More(); aExp.Next()) {
764 const TopoDS_Shape& aV=aDS.Shape(nV);
765 if (aV.Orientation()==TopAbs_INTERNAL) {
766 nVSD=pPF->FindSDVertex(nV);
771 UpdateCandidates(nF, nV, aMFMV);
775 // 2. Process face nF
776 if (!aMFMV.Contains(nF)) {
780 const TColStd_IndexedMapOfInteger& aMVC=aMFMV.FindFromKey(nF);
786 // 2.1 Refine candidates
787 TopTools_IndexedDataMapOfShapeListOfShape aMVE;
788 TopTools_ListOfShape aLV;
790 bHasImage=myImages.HasImage(aF);
792 const TopTools_ListOfShape& aLFx=myImages.Image(aF);
793 aIt.Initialize(aLFx);
794 for (; aIt.More(); aIt.Next()) {
795 const TopoDS_Shape& aFx=aIt.Value();
796 TopExp::MapShapesAndAncestors(aFx, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
800 Standard_Boolean bFaceToProcess;
802 TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
803 bFaceToProcess=Standard_False;
804 for (j=1; j<=aNbVC; ++j) {
806 const TopoDS_Shape& aV=aDS.Shape(nV);
807 if (!aMVE.Contains(aV)) {
808 bFaceToProcess=!bFaceToProcess;
812 if (!bFaceToProcess) {
817 for (j=1; j<=aNbVC; ++j) {
819 const TopoDS_Shape& aV=aDS.Shape(nV);
820 if (aMVE.Contains(aV)) {
821 const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV);
832 // 3. Try to put vertices into the face(s)
833 aItV.Initialize(aLV);
834 for (; aItV.More(); aItV.Next()) {
835 TopoDS_Vertex aV=TopoDS::Vertex(aItV.Value());
836 aV.Orientation(TopAbs_INTERNAL);
838 bHasImage=myImages.HasImage(aF);
840 const TopTools_ListOfShape& aLFx=myImages.Image(aF);
841 aIt.Initialize(aLFx);
842 for (; aIt.More(); aIt.Next()) {
843 TopoDS_Face aFx=TopoDS::Face(aIt.Value());
845 IntTools_FClass2d& aClsf=aCtx.FClass2d(aFx);
846 aClsf.Init(aFx, aTol);
848 iFlag=aCtx.ComputeVS (aV, aFx, aU1, aU2);
856 const TopoDS_Face& aFx=TopoDS::Face(aF);
858 IntTools_FClass2d& aClsf=aCtx.FClass2d(aFx);
859 aClsf.Init(aFx, aTol);
861 iFlag=aCtx.ComputeVS (aV, aFx, aU1, aU2);
865 GEOMAlgo_Tools3D::CopyFace(aFx, aFz);
867 myImages.Bind(aF, aFz);
870 }// for (; aItV.More(); aItV.Next()) {
872 }// for (nF=1; nF<=aNb; ++nF) {
875 //=======================================================================
876 // function: UpdateCandidates
878 //=======================================================================
879 void UpdateCandidates(const Standard_Integer theNF,
880 const Standard_Integer theNV,
881 NMTTools_IndexedDataMapOfIndexedMapOfInteger& theMFMV)
883 if (theMFMV.Contains(theNF)) {
884 TColStd_IndexedMapOfInteger& aMV=theMFMV.ChangeFromKey(theNF);
888 TColStd_IndexedMapOfInteger aMV;
890 theMFMV.Add(theNF, aMV);
898 TopTools_ListIteratorOfListOfShape aItx;
900 aBBx.MakeCompound(aCx);
902 aItx.Initialize(aSE);
903 for (; aItx.More(); aItx.Next()) {
904 TopoDS_Shape& aEx=aItx.Value();