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
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>
97 #include <TopTools_DataMapOfShapeInteger.hxx>
100 void UpdateCandidates(const Standard_Integer ,
101 const Standard_Integer ,
102 NMTTools_IndexedDataMapOfIndexedMapOfInteger& );
105 //=======================================================================
106 //function : FillImagesFaces
108 //=======================================================================
109 void GEOMAlgo_Builder::FillImagesFaces()
115 FillSameDomainFaces();
117 FillInternalVertices();
120 //=======================================================================
121 // function: FillIn2DParts
123 //=======================================================================
124 void GEOMAlgo_Builder::FillIn2DParts()
126 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
127 NMTTools_PaveFiller* pPF=myPaveFiller;
128 NMTDS_InterfPool* pIP=pPF->IP();
129 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
130 NMTTools_CommonBlockPool& aCBP=pPF->ChangeCommonBlockPool();
132 Standard_Integer j, nSpIn, nSpSc, aNbCurves;
133 Standard_Integer aNbS, nF, aNbCBP, n1, n2, aNbFFs, aNbSpIn;
134 TopTools_MapOfShape aMFence;
135 TopTools_ListOfShape aLSpIn;
137 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
138 BOPTools_ListIteratorOfListOfPaveBlock aItPB;
142 aNbFFs=aFFs.Extent();
143 aNbCBP=aCBP.Extent();
145 aNbS=aDS.NumberOfShapesOfTheObject();
146 for (nF=1; nF<=aNbS; ++nF) {
147 if (aDS.GetShapeType(nF)!=TopAbs_FACE) {
151 aF=TopoDS::Face(aDS.Shape(nF));
157 BOPTools_ListOfPaveBlock aLPBIn;
159 pPF->RealSplitsInFace(nF, aLPBIn);
161 aItPB.Initialize(aLPBIn);
162 for (; aItPB.More(); aItPB.Next()) {
163 const BOPTools_PaveBlock& aPB1=aItPB.Value();
165 const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn);
166 aLSpIn.Append(aSpIn);
170 for (j=1; j<=aNbFFs; ++j) {
171 BOPTools_SSInterference& aFF=aFFs(j);
173 if (!(n1==nF || n2==nF)) {
176 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
177 aNbCurves=aSC.Length();
182 const BOPTools_Curve& aBC=aSC(1);
183 const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
184 aItPB.Initialize(aLPB);
185 for (; aItPB.More(); aItPB.Next()) {
186 const BOPTools_PaveBlock& aPBSc=aItPB.Value();
188 const TopoDS_Shape& aSpSc=aDS.Shape(nSpSc);
189 if (aMFence.Add(aSpSc)){
190 aLSpIn.Append(aSpSc);
194 aNbSpIn=aLSpIn.Extent();
196 myInParts.Add(aF, aLSpIn);
198 }//for (nF=1; nF<=aNbS; ++nF) {
201 //=======================================================================
202 // function: BuildSplitFaces
204 //=======================================================================
205 void GEOMAlgo_Builder::BuildSplitFaces()
207 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
208 NMTTools_PaveFiller* pPF=myPaveFiller;
209 NMTDS_InterfPool* pIP=pPF->IP();
210 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
211 IntTools_Context& aCtx= pPF->ChangeContext();
213 Standard_Boolean bToReverse, bIsClosed, bIsDegenerated;
214 Standard_Integer i, aNb, aNbF, nF;
215 TopTools_MapOfShape aMFence;
216 TColStd_IndexedMapOfInteger aMFP;
217 TopExp_Explorer anExp;
219 TopoDS_Edge aSp, aEE;
220 TopTools_ListIteratorOfListOfShape aIt;
221 TopAbs_Orientation anOriF, anOriE;
223 mySplitFaces.Clear();
225 // 1. Select Faces to process (MFP)
226 aNb=aDS.NumberOfShapesOfTheObject();
227 for (i=1; i<=aNb; ++i) {
228 const TopoDS_Shape& aF=aDS.Shape(i);
229 if (aF.ShapeType()!=TopAbs_FACE) {
232 if (!aMFence.Add(aF)) {
236 if (myInParts.Contains(aF)) {
241 anExp.Init(aF, TopAbs_EDGE);
242 for (; anExp.More(); anExp.Next()) {
243 const TopoDS_Shape& aE=anExp.Current();
244 if (myImages.HasImage(aE)) {
252 Standard_Integer aNbFFs, aNbSE, j, n1, n2;
254 aNbFFs=aFFs.Extent();
255 for (j=1; j<=aNbFFs; ++j) {
256 BOPTools_SSInterference& aFFj=aFFs(j);
257 aFFj.Indices(n1, n2);
258 if (!(n1==i || n2==i)) {
262 const TColStd_ListOfInteger& aLSE=aFFj.SharedEdges();
272 }// for (i=1; i<=aNb; ++i)
276 for (i=1; i<=aNbF; ++i) {
278 const TopoDS_Face& aF=TopoDS::Face(aDS.Shape(nF));
279 anOriF=aF.Orientation();
281 aFF.Orientation(TopAbs_FORWARD);
286 GEOMAlgo_WireEdgeSet aWES;
289 // 2.1.1. Add Split parts
290 anExp.Init(aFF, TopAbs_EDGE);
291 for (; anExp.More(); anExp.Next()) {
292 const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current());
293 anOriE=aE.Orientation();
295 if (!myImages.HasImage(aE)) {
296 if (anOriE==TopAbs_INTERNAL) {
298 aEE.Orientation(TopAbs_FORWARD);
299 aWES.AddStartElement(aEE);
300 aEE.Orientation(TopAbs_REVERSED);
301 aWES.AddStartElement(aEE);
304 aWES.AddStartElement(aE);
309 bIsDegenerated=BRep_Tool::Degenerated(aE);
310 bIsClosed=BRep_Tool::IsClosed(aE, aF);
312 const TopTools_ListOfShape& aLIE=myImages.Image(aE);
313 aIt.Initialize(aLIE);
314 for (; aIt.More(); aIt.Next()) {
315 aSp=TopoDS::Edge(aIt.Value());
317 if (bIsDegenerated) {
318 aSp.Orientation(anOriE);
319 aWES.AddStartElement(aSp);
323 if (anOriE==TopAbs_INTERNAL) {
324 aSp.Orientation(TopAbs_FORWARD);
325 aWES.AddStartElement(aSp);
326 aSp.Orientation(TopAbs_REVERSED);
327 aWES.AddStartElement(aSp);
332 if (aMFence.Add(aSp)) {
334 if (!BRep_Tool::IsClosed(aSp, aF)){
335 BOPTools_Tools3D::DoSplitSEAMOnFace(aSp, aF);
338 aSp.Orientation(TopAbs_FORWARD);
339 aWES.AddStartElement(aSp);
340 aSp.Orientation(TopAbs_REVERSED);
341 aWES.AddStartElement(aSp);
344 }// if (aMFence.Add(aSp))
346 aSp.Orientation(anOriE);
347 bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, aCtx);
351 aWES.AddStartElement(aSp);
352 }// for (; aIt.More(); aIt.Next()) {
353 }// for (; anExp.More(); anExp.Next()) {
355 // 2.1.2. Add In2D Parts
356 if (myInParts.Contains(aF)) {
357 const TopTools_ListOfShape& aLE=myInParts.FindFromKey(aF);
359 for (; aIt.More(); aIt.Next()) {
360 aSp=TopoDS::Edge(aIt.Value());
362 aSp.Orientation(TopAbs_FORWARD);
363 aWES.AddStartElement(aSp);
365 aSp.Orientation(TopAbs_REVERSED);
366 aWES.AddStartElement(aSp);
370 // 2.2. Build images Faces
371 TopTools_ListOfShape aLFR;
372 GEOMAlgo_ShapeSet aS1, aS2;
374 const TopTools_ListOfShape& aSE=aWES.StartElements();
376 aS2.Add(aFF, TopAbs_EDGE);
377 if (aS1.IsEqual(aS2)) {
381 GEOMAlgo_BuilderFace aBF;
384 aBF.SetContext(aCtx);
389 const TopTools_ListOfShape& aLF=aBF.Areas();
391 for (; aIt.More(); aIt.Next()) {
392 TopoDS_Shape& aFR=aIt.Value();
393 if (anOriF==TopAbs_REVERSED) {
394 aFR.Orientation(TopAbs_REVERSED);
400 // 2.3. Collect draft images Faces
401 mySplitFaces.Bind(aF, aLFR);
402 }//for (i=1; i<=aNbF; ++i)
405 //=======================================================================
406 // function: FillSameDomainFaces
408 //=======================================================================
409 void GEOMAlgo_Builder::FillSameDomainFaces()
411 Standard_Boolean bIsSDF, bHasImage1, bHasImage2, bForward;
412 Standard_Integer i, j, aNbFF, nF1, nF2, aNbPBInOn, aNbC, aNbSE;
413 Standard_Integer aNbF1, aNbF2, i2s, aNbSD;
414 TopTools_MapOfShape aMFence;
415 TopTools_ListOfShape aLX1, aLX2;
416 TopTools_ListIteratorOfListOfShape aItF1, aItF2;
417 NMTTools_ListOfCoupleOfShape aLCS;
419 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
420 NMTTools_PaveFiller* pPF=myPaveFiller;
421 NMTDS_InterfPool* pIP=pPF->IP();
422 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
423 IntTools_Context& aCtx= pPF->ChangeContext();
426 //mySameDomainShapes.Clear();
428 // 1. For each FF find among images of faces
429 // all pairs of same domain faces (SDF) [=> aLCS]
431 for (i=1; i<=aNbFF; ++i) {
432 BOPTools_SSInterference& aFF=aFFs(i);
433 aFF.Indices(nF1, nF2);
435 const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1));
436 const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2));
438 // if there are no in/on 2D split parts the faces nF1, nF2
440 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
441 aNbPBInOn=aLPBInOn.Extent();
444 const TColStd_ListOfInteger& aLSE=aFF.SharedEdges();
446 if (!aNbPBInOn && !aNbSE) {
451 // if there is at least one section edge between faces nF1, nF2
452 // they can not be SDF
453 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
459 // the faces are suspected to be SDF.
460 // Try to find SDF among images of nF1, nF2
463 //--------------------------------------------------------
464 bHasImage1=mySplitFaces.HasImage(aF1);
465 bHasImage2=mySplitFaces.HasImage(aF2);
477 const TopTools_ListOfShape& aLF1r=(bHasImage1)? mySplitFaces.Image(aF1) : aLX1;
478 const TopTools_ListOfShape& aLF2r=(bHasImage2)? mySplitFaces.Image(aF2) : aLX2;
480 TopTools_DataMapOfIntegerShape aMIS;
481 TColStd_ListIteratorOfListOfInteger aItLI;
482 NMTDS_BoxBndTreeSelector aSelector;
483 NMTDS_BoxBndTree aBBTree;
484 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
486 aNbF1=aLF1r.Extent();
487 aNbF2=aLF2r.Extent();
488 bForward=(aNbF1<aNbF2);
490 const TopTools_ListOfShape& aLF1=bForward ? aLF1r : aLF2r;
491 const TopTools_ListOfShape& aLF2=bForward ? aLF2r : aLF1r;
494 aItF2.Initialize(aLF2);
495 for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
498 const TopoDS_Face& aF2s=*((TopoDS_Face*)(&aItF2.Value()));
500 BRepBndLib::Add(aF2s, aBoxF2s);
502 aMIS.Bind(i2s, aF2s);
504 aTreeFiller.Add(i2s, aBoxF2s);
505 }//for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
510 aItF1.Initialize(aLF1);
511 for (j=1; aItF1.More(); aItF1.Next(), ++j) {
514 const TopoDS_Face& aF1x=*((TopoDS_Face*)(&aItF1.Value()));
516 BRepBndLib::Add(aF1x, aBoxF1x);
519 aSelector.SetBox(aBoxF1x);
520 aNbSD=aBBTree.Select(aSelector);
525 const TColStd_ListOfInteger& aLI=aSelector.Indices();
526 aItLI.Initialize(aLI);
527 for (; aItLI.More(); aItLI.Next()) {
529 const TopoDS_Face& aF2y=*((TopoDS_Face*)(&aMIS.Find(i2s)));
531 bIsSDF=NMTTools_Tools::AreFacesSameDomain(aF1x, aF2y, aCtx);
533 if (aMFence.Contains(aF1x) || aMFence.Contains(aF2y)) {
539 NMTTools_CoupleOfShape aCS;
547 if (!mySplitFaces.HasImage(aF1)) {
548 mySplitFaces.Bind(aF1, aF1);
552 if (!mySplitFaces.HasImage(aF2)) {
553 mySplitFaces.Bind(aF2, aF2);
559 if (!mySplitFaces.HasImage(aF2)) {
560 mySplitFaces.Bind(aF2, aF2);
564 if (!mySplitFaces.HasImage(aF1)) {
565 mySplitFaces.Bind(aF1, aF1);
572 }//for (; aItLI.More(); aItLI.Next()) {
573 }//for (; aItF1.More(); aItF1.Next()) {
574 }//for (i=1; i<=aNbFF; ++i)
575 //-------------------------------------------------------------
582 NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMC;
584 NMTTools_Tools::FindChains(aLCS, aMC);
586 Standard_Boolean bIsImage;
587 Standard_Integer aIx, aIxMin, aNbMSDF, k, aNbMFj;
588 TopoDS_Shape aFOld, aFSDmin;
589 TopTools_IndexedMapOfShape aMFj;
590 TopTools_DataMapOfShapeInteger aDMSI;
592 aItF1.Initialize(myShapes);
593 for (j=1; aItF1.More(); aItF1.Next(), ++j) {
594 const TopoDS_Shape& aSj=aItF1.Value();
596 TopExp::MapShapes(aSj, TopAbs_FACE, aMFj);
597 aNbMFj=aMFj.Extent();
598 for (k=1; k<=aNbMFj; ++k) {
599 const TopoDS_Shape& aFk=aMFj(k);
600 if (!aDMSI.IsBound(aFk)) {
606 // 3. Fill the map of SDF mySameDomainFaces
608 for (i=1; i<=aNbC; ++i) {
609 // const TopoDS_Shape& aF=aMC.FindKey(i);
610 const TopTools_IndexedMapOfShape& aMSDF=aMC(i);
612 aNbMSDF=aMSDF.Extent();
613 for (j=1; j<=aNbMSDF; ++j) {
614 const TopoDS_Shape& aFSD=aMSDF(j);
615 bIsImage=mySplitFaces.IsImage(aFSD);
618 aFOld=mySplitFaces.ImageFrom(aFSD);
621 aIx=aDMSI.Find(aFOld);
635 for (j=1; j<=aNbMSDF; ++j) {
636 const TopoDS_Shape& aFSD=aMSDF(j);
637 mySameDomainShapes.Add(aFSD, aFSDmin);
643 //=======================================================================
644 // function: FillImagesFaces1
646 //=======================================================================
647 void GEOMAlgo_Builder::FillImagesFaces1()
649 Standard_Integer i, aNb, iSense, aNbLFx;
650 TopoDS_Face aF, aFSp, aFSD;
651 TopTools_ListOfShape aLFx;
652 TopTools_ListIteratorOfListOfShape aIt;
654 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
656 aNb=aDS.NumberOfShapesOfTheObject();
657 for (i=1; i<=aNb; ++i) {
658 const TopoDS_Shape& aS=aDS.Shape(i);
659 if (aS.ShapeType()!=TopAbs_FACE) {
663 if (!mySplitFaces.HasImage(aS)) {
667 aF=*((TopoDS_Face*)&aS);
670 const TopTools_ListOfShape& aLF=mySplitFaces.Image(aF);
672 for (; aIt.More(); aIt.Next()) {
673 aFSp=*((TopoDS_Face*)(&aIt.Value()));
674 if (!mySameDomainShapes.Contains(aFSp)) {
678 const TopoDS_Shape& aSx=mySameDomainShapes.FindFromKey(aFSp);
679 aFSD=*((TopoDS_Face*)(&aSx));
680 iSense=GEOMAlgo_Tools3D::Sense(aFSp, aFSD);
688 if (!myImages.HasImage(aF)) {
689 aNbLFx=aLFx.Extent();
691 const TopoDS_Shape& aFx=aLFx.First();
692 if (aF.IsSame(aFx)) {
696 myImages.Bind(aF, aLFx);
701 //=======================================================================
702 // function: FillInternalVertices
704 //=======================================================================
705 void GEOMAlgo_Builder::FillInternalVertices()
707 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
708 NMTTools_PaveFiller* pPF=myPaveFiller;
709 NMTDS_InterfPool* pIP=pPF->IP();
710 IntTools_Context& aCtx= pPF->ChangeContext();
712 BOPTools_CArray1OfVSInterference& aVFs=pIP->VSInterferences();
713 BOPTools_CArray1OfESInterference& aEFs=pIP->ESInterferences();
714 const NMTTools_IndexedDataMapOfIndexedMapOfInteger& aMAV=pPF->AloneVertices();
716 Standard_Boolean bHasImage;
717 Standard_Integer i, j, nF, aNbS, nV, nVSD, n1, n2, iFlag;
718 Standard_Integer aNbVFs, aNbAVF, aNbEFs, aNbVC, aNbE, aNbV;
719 Standard_Real aU1, aU2, aTol;
720 NMTTools_IndexedDataMapOfIndexedMapOfInteger aMFMV;
721 TopTools_MapOfShape aMFence;
722 TopTools_ListIteratorOfListOfShape aIt, aItV;
725 // 1. Collect face-vertex candidates [aMFMV]
728 aNbVFs=aVFs.Extent();
729 for (i=1; i<=aNbVFs; ++i) {
730 const BOPTools_VSInterference& aVS=aVFs(i);
734 if (aDS.Shape(n1).ShapeType()==TopAbs_FACE) {
738 nVSD=pPF->FindSDVertex(nV);
743 UpdateCandidates(nF, nV, aMFMV);
747 aNbEFs=aEFs.Extent();
748 for (i=1; i<=aNbEFs; ++i) {
749 const BOPTools_ESInterference& aEF=aEFs(i);
755 const TopoDS_Shape& aSnew=aDS.Shape(nV);
756 if (aSnew.ShapeType()!=TopAbs_VERTEX) {
760 nF=(aDS.Shape(n1).ShapeType()==TopAbs_FACE) ? n1 : n2;
761 nVSD=pPF->FindSDVertex(nV);
765 UpdateCandidates(nF, nV, aMFMV);
768 aNbS=aDS.NumberOfShapesOfTheObject();
769 for (nF=1; nF<=aNbS; ++nF) {
770 const TopoDS_Shape& aF=aDS.Shape(nF);
772 if (aF.ShapeType()!=TopAbs_FACE) {
775 if (!aMFence.Add(aF)) {
779 const TopoDS_Face& aFF=TopoDS::Face(aF);
780 aTol=BRep_Tool::Tolerance(aFF);
783 if (aMAV.Contains(nF)) {
784 const TColStd_IndexedMapOfInteger& aMAVF=aMAV.FindFromKey(nF);
785 aNbAVF=aMAVF.Extent();
786 for (j=1; j<=aNbAVF; ++j) {
788 nVSD=pPF->FindSDVertex(nV);
793 UpdateCandidates(nF, nV, aMFMV);
797 // 1.4 Internal vertices of the face nF
798 BooleanOperations_OnceExplorer aExp(aDS);
799 aExp.Init(nF, TopAbs_VERTEX);
800 for (; aExp.More(); aExp.Next()) {
802 const TopoDS_Shape& aV=aDS.Shape(nV);
803 if (aV.Orientation()==TopAbs_INTERNAL) {
804 nVSD=pPF->FindSDVertex(nV);
809 UpdateCandidates(nF, nV, aMFMV);
813 // 2. Process face nF
814 if (!aMFMV.Contains(nF)) {
818 const TColStd_IndexedMapOfInteger& aMVC=aMFMV.FindFromKey(nF);
824 // 2.1 Refine candidates
825 TopTools_IndexedDataMapOfShapeListOfShape aMVE;
826 TopTools_ListOfShape aLV;
828 bHasImage=myImages.HasImage(aF);
830 const TopTools_ListOfShape& aLFx=myImages.Image(aF);
831 aIt.Initialize(aLFx);
832 for (; aIt.More(); aIt.Next()) {
833 const TopoDS_Shape& aFx=aIt.Value();
834 TopExp::MapShapesAndAncestors(aFx, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
838 Standard_Boolean bFaceToProcess;
840 TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
841 bFaceToProcess=Standard_False;
842 for (j=1; j<=aNbVC; ++j) {
844 const TopoDS_Shape& aV=aDS.Shape(nV);
845 if (!aMVE.Contains(aV)) {
846 bFaceToProcess=!bFaceToProcess;
850 if (!bFaceToProcess) {
855 for (j=1; j<=aNbVC; ++j) {
857 const TopoDS_Shape& aV=aDS.Shape(nV);
858 if (aMVE.Contains(aV)) {
859 const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV);
870 // 3. Try to put vertices into the face(s)
871 aItV.Initialize(aLV);
872 for (; aItV.More(); aItV.Next()) {
873 TopoDS_Vertex aV=TopoDS::Vertex(aItV.Value());
874 aV.Orientation(TopAbs_INTERNAL);
876 bHasImage=myImages.HasImage(aF);
878 const TopTools_ListOfShape& aLFx=myImages.Image(aF);
879 aIt.Initialize(aLFx);
880 for (; aIt.More(); aIt.Next()) {
881 TopoDS_Face aFx=TopoDS::Face(aIt.Value());
883 IntTools_FClass2d& aClsf=aCtx.FClass2d(aFx);
884 aClsf.Init(aFx, aTol);
886 iFlag=aCtx.ComputeVS (aV, aFx, aU1, aU2);
894 const TopoDS_Face& aFx=TopoDS::Face(aF);
896 IntTools_FClass2d& aClsf=aCtx.FClass2d(aFx);
897 aClsf.Init(aFx, aTol);
899 iFlag=aCtx.ComputeVS (aV, aFx, aU1, aU2);
903 GEOMAlgo_Tools3D::CopyFace(aFx, aFz);
905 myImages.Bind(aF, aFz);
908 }// for (; aItV.More(); aItV.Next()) {
910 }// for (nF=1; nF<=aNb; ++nF) {
913 //=======================================================================
914 // function: UpdateCandidates
916 //=======================================================================
917 void UpdateCandidates(const Standard_Integer theNF,
918 const Standard_Integer theNV,
919 NMTTools_IndexedDataMapOfIndexedMapOfInteger& theMFMV)
921 if (theMFMV.Contains(theNF)) {
922 TColStd_IndexedMapOfInteger& aMV=theMFMV.ChangeFromKey(theNF);
926 TColStd_IndexedMapOfInteger aMV;
928 theMFMV.Add(theNF, aMV);
936 TopTools_ListIteratorOfListOfShape aItx;
938 aBBx.MakeCompound(aCx);
940 aItx.Initialize(aSE);
941 for (; aItx.More(); aItx.Next()) {
942 TopoDS_Shape& aEx=aItx.Value();