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 <Basics_OCCTVersion.hxx>
29 #include <GEOMAlgo_Tools3D.hxx>
30 #include <GEOMAlgo_WireEdgeSet.hxx>
31 #include <GEOMAlgo_BuilderFace.hxx>
32 #include <GEOMAlgo_ShapeSet.hxx>
34 #include <NMTTools_PaveFiller.hxx>
35 #include <NMTTools_ListOfCoupleOfShape.hxx>
36 #include <NMTTools_Tools.hxx>
37 #include <NMTTools_CoupleOfShape.hxx>
38 #include <NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
39 #include <NMTTools_Tools.hxx>
40 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
41 #include <NMTTools_ListOfCommonBlock.hxx>
42 #include <NMTTools_CommonBlock.hxx>
43 #include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
45 #include <NMTDS_BoxBndTree.hxx>
46 #include <NMTDS_ShapesDataStructure.hxx>
47 #include <NMTDS_InterfPool.hxx>
49 #include <TopAbs_Orientation.hxx>
52 #include <TopoDS_Face.hxx>
53 #include <TopoDS_Edge.hxx>
54 #include <TopoDS_Shape.hxx>
55 #include <TopoDS_Compound.hxx>
57 #include <TopTools_IndexedMapOfShape.hxx>
58 #include <TopTools_ListOfShape.hxx>
59 #include <TopTools_MapOfShape.hxx>
60 #include <TopTools_ListIteratorOfListOfShape.hxx>
61 #include <TopTools_DataMapOfIntegerShape.hxx>
62 #include <TopTools_DataMapOfShapeInteger.hxx>
65 #include <TopExp_Explorer.hxx>
67 #include <BRep_Tool.hxx>
68 #include <BRep_Builder.hxx>
69 #include <BRepAlgo_Image.hxx>
70 #include <BRepTools.hxx>
72 #include <IntTools_Context.hxx>
73 #include <IntTools_FClass2d.hxx>
75 #include <Bnd_Box.hxx>
76 #include <BRepBndLib.hxx>
78 #include <BooleanOperations_OnceExplorer.hxx>
80 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
82 #include <BOPTools_ListOfPaveBlock.hxx>
83 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
84 #include <BOPTools_CArray1OfSSInterference.hxx>
85 #include <BOPTools_SSInterference.hxx>
86 #include <BOPTools_SequenceOfCurves.hxx>
87 #include <BOPTools_Curve.hxx>
88 #include <BOPTools_ListOfPaveBlock.hxx>
89 #include <BOPTools_PaveBlock.hxx>
90 #include <BOPTools_Tools3D.hxx>
91 #include <BOPTools_CArray1OfVSInterference.hxx>
92 #include <BOPTools_VSInterference.hxx>
93 #include <BOPTools_ESInterference.hxx>
94 #include <BOPTools_CArray1OfESInterference.hxx>
96 #include <NCollection_UBTreeFiller.hxx>
98 #include <TColStd_IndexedMapOfInteger.hxx>
99 #include <TColStd_ListOfInteger.hxx>
100 #include <TColStd_ListIteratorOfListOfInteger.hxx>
103 void UpdateCandidates(const Standard_Integer ,
104 const Standard_Integer ,
105 NMTTools_IndexedDataMapOfIndexedMapOfInteger& );
108 //=======================================================================
109 //function : FillImagesFaces
111 //=======================================================================
112 void GEOMAlgo_Builder::FillImagesFaces()
118 FillSameDomainFaces();
120 FillInternalVertices();
123 //=======================================================================
124 // function: FillIn2DParts
126 //=======================================================================
127 void GEOMAlgo_Builder::FillIn2DParts()
129 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
130 NMTTools_PaveFiller* pPF=myPaveFiller;
131 NMTDS_InterfPool* pIP=pPF->IP();
132 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
133 NMTTools_CommonBlockPool& aCBP=pPF->ChangeCommonBlockPool();
135 Standard_Integer j, nSpIn, nSpSc, aNbCurves;
136 Standard_Integer aNbS, nF, aNbCBP, n1, n2, aNbFFs, aNbSpIn;
137 TopTools_MapOfShape aMFence;
138 TopTools_ListOfShape aLSpIn;
140 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
141 BOPTools_ListIteratorOfListOfPaveBlock aItPB;
145 aNbFFs=aFFs.Extent();
146 aNbCBP=aCBP.Extent();
148 aNbS=aDS.NumberOfShapesOfTheObject();
149 for (nF=1; nF<=aNbS; ++nF) {
150 if (aDS.GetShapeType(nF)!=TopAbs_FACE) {
154 aF=TopoDS::Face(aDS.Shape(nF));
160 BOPTools_ListOfPaveBlock aLPBIn;
162 pPF->RealSplitsInFace(nF, aLPBIn);
164 aItPB.Initialize(aLPBIn);
165 for (; aItPB.More(); aItPB.Next()) {
166 const BOPTools_PaveBlock& aPB1=aItPB.Value();
168 const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn);
169 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 #if OCC_VERSION_LARGE > 0x06050200
215 const Handle(IntTools_Context)& aCtx= pPF->Context();
217 IntTools_Context& aCtx= pPF->ChangeContext();
220 Standard_Boolean bToReverse, bIsClosed, bIsDegenerated;
221 Standard_Integer i, aNb, aNbF, nF;
222 TopTools_MapOfShape aMFence;
223 TColStd_IndexedMapOfInteger aMFP;
224 TopExp_Explorer anExp;
226 TopoDS_Edge aSp, aEE;
227 TopTools_ListIteratorOfListOfShape aIt;
228 TopAbs_Orientation anOriF, anOriE;
230 mySplitFaces.Clear();
232 // 1. Select Faces to process (MFP)
233 aNb=aDS.NumberOfShapesOfTheObject();
234 for (i=1; i<=aNb; ++i) {
235 const TopoDS_Shape& aF=aDS.Shape(i);
236 if (aF.ShapeType()!=TopAbs_FACE) {
239 if (!aMFence.Add(aF)) {
243 if (myInParts.Contains(aF)) {
248 anExp.Init(aF, TopAbs_EDGE);
249 for (; anExp.More(); anExp.Next()) {
250 const TopoDS_Shape& aE=anExp.Current();
251 if (myImages.HasImage(aE)) {
259 Standard_Integer aNbFFs, aNbSE, j, n1, n2;
261 aNbFFs=aFFs.Extent();
262 for (j=1; j<=aNbFFs; ++j) {
263 BOPTools_SSInterference& aFFj=aFFs(j);
264 aFFj.Indices(n1, n2);
265 if (!(n1==i || n2==i)) {
269 const TColStd_ListOfInteger& aLSE=aFFj.SharedEdges();
279 }// for (i=1; i<=aNb; ++i)
283 for (i=1; i<=aNbF; ++i) {
285 const TopoDS_Face& aF=TopoDS::Face(aDS.Shape(nF));
286 anOriF=aF.Orientation();
288 aFF.Orientation(TopAbs_FORWARD);
293 GEOMAlgo_WireEdgeSet aWES;
296 // 2.1.1. Add Split parts
297 anExp.Init(aFF, TopAbs_EDGE);
298 for (; anExp.More(); anExp.Next()) {
299 const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current());
300 anOriE=aE.Orientation();
302 if (!myImages.HasImage(aE)) {
303 if (anOriE==TopAbs_INTERNAL) {
305 aEE.Orientation(TopAbs_FORWARD);
306 aWES.AddStartElement(aEE);
307 aEE.Orientation(TopAbs_REVERSED);
308 aWES.AddStartElement(aEE);
311 aWES.AddStartElement(aE);
316 bIsDegenerated=BRep_Tool::Degenerated(aE);
317 bIsClosed=BRep_Tool::IsClosed(aE, aF);
319 const TopTools_ListOfShape& aLIE=myImages.Image(aE);
320 aIt.Initialize(aLIE);
321 for (; aIt.More(); aIt.Next()) {
322 aSp=TopoDS::Edge(aIt.Value());
324 if (bIsDegenerated) {
325 aSp.Orientation(anOriE);
326 aWES.AddStartElement(aSp);
330 if (anOriE==TopAbs_INTERNAL) {
331 aSp.Orientation(TopAbs_FORWARD);
332 aWES.AddStartElement(aSp);
333 aSp.Orientation(TopAbs_REVERSED);
334 aWES.AddStartElement(aSp);
339 if (aMFence.Add(aSp)) {
341 if (!BRep_Tool::IsClosed(aSp, aF)){
342 BOPTools_Tools3D::DoSplitSEAMOnFace(aSp, aF);
345 aSp.Orientation(TopAbs_FORWARD);
346 aWES.AddStartElement(aSp);
347 aSp.Orientation(TopAbs_REVERSED);
348 aWES.AddStartElement(aSp);
351 }// if (aMFence.Add(aSp))
353 aSp.Orientation(anOriE);
354 bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, aCtx);
358 aWES.AddStartElement(aSp);
359 }// for (; aIt.More(); aIt.Next()) {
360 }// for (; anExp.More(); anExp.Next()) {
362 // 2.1.2. Add In2D Parts
363 if (myInParts.Contains(aF)) {
364 const TopTools_ListOfShape& aLE=myInParts.FindFromKey(aF);
366 for (; aIt.More(); aIt.Next()) {
367 aSp=TopoDS::Edge(aIt.Value());
369 aSp.Orientation(TopAbs_FORWARD);
370 aWES.AddStartElement(aSp);
372 aSp.Orientation(TopAbs_REVERSED);
373 aWES.AddStartElement(aSp);
377 // 2.2. Build images Faces
378 TopTools_ListOfShape aLFR;
379 GEOMAlgo_ShapeSet aS1, aS2;
381 const TopTools_ListOfShape& aSE=aWES.StartElements();
383 aS2.Add(aFF, TopAbs_EDGE);
384 if (aS1.IsEqual(aS2)) {
388 GEOMAlgo_BuilderFace aBF;
391 aBF.SetContext(aCtx);
396 const TopTools_ListOfShape& aLF=aBF.Areas();
398 for (; aIt.More(); aIt.Next()) {
399 TopoDS_Shape& aFR=aIt.Value();
400 if (anOriF==TopAbs_REVERSED) {
401 aFR.Orientation(TopAbs_REVERSED);
407 // 2.3. Collect draft images Faces
408 mySplitFaces.Bind(aF, aLFR);
409 }//for (i=1; i<=aNbF; ++i)
412 //=======================================================================
413 // function: FillSameDomainFaces
415 //=======================================================================
416 void GEOMAlgo_Builder::FillSameDomainFaces()
418 Standard_Boolean bIsSDF, bHasImage1, bHasImage2, bForward;
419 Standard_Integer i, j, aNbFF, nF1, nF2, aNbPBInOn, aNbC, aNbSE;
420 Standard_Integer aNbF1, aNbF2, i2s, aNbSD;
421 TopTools_MapOfShape aMFence;
422 TopTools_ListOfShape aLX1, aLX2;
423 TopTools_ListIteratorOfListOfShape aItF1, aItF2;
424 NMTTools_ListOfCoupleOfShape aLCS;
426 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
427 NMTTools_PaveFiller* pPF=myPaveFiller;
428 NMTDS_InterfPool* pIP=pPF->IP();
429 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
430 #if OCC_VERSION_LARGE > 0x06050200
431 const Handle(IntTools_Context)& aCtx=pPF->Context();
433 IntTools_Context& aCtx=pPF->ChangeContext();
437 //mySameDomainShapes.Clear();
439 // 1. For each FF find among images of faces
440 // all pairs of same domain faces (SDF) [=> aLCS]
442 for (i=1; i<=aNbFF; ++i) {
443 BOPTools_SSInterference& aFF=aFFs(i);
444 aFF.Indices(nF1, nF2);
446 const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1));
447 const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2));
449 // if there are no in/on 2D split parts the faces nF1, nF2
451 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
452 aNbPBInOn=aLPBInOn.Extent();
455 const TColStd_ListOfInteger& aLSE=aFF.SharedEdges();
457 if (!aNbPBInOn && !aNbSE) {
462 // if there is at least one section edge between faces nF1, nF2
463 // they can not be SDF
464 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
470 // the faces are suspected to be SDF.
471 // Try to find SDF among images of nF1, nF2
474 //--------------------------------------------------------
475 bHasImage1=mySplitFaces.HasImage(aF1);
476 bHasImage2=mySplitFaces.HasImage(aF2);
488 const TopTools_ListOfShape& aLF1r=(bHasImage1)? mySplitFaces.Image(aF1) : aLX1;
489 const TopTools_ListOfShape& aLF2r=(bHasImage2)? mySplitFaces.Image(aF2) : aLX2;
491 TopTools_DataMapOfIntegerShape aMIS;
492 TColStd_ListIteratorOfListOfInteger aItLI;
493 NMTDS_BoxBndTreeSelector aSelector;
494 NMTDS_BoxBndTree aBBTree;
495 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
497 aNbF1=aLF1r.Extent();
498 aNbF2=aLF2r.Extent();
499 bForward=(aNbF1<aNbF2);
501 const TopTools_ListOfShape& aLF1=bForward ? aLF1r : aLF2r;
502 const TopTools_ListOfShape& aLF2=bForward ? aLF2r : aLF1r;
505 aItF2.Initialize(aLF2);
506 for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
509 const TopoDS_Face& aF2s=*((TopoDS_Face*)(&aItF2.Value()));
511 BRepBndLib::Add(aF2s, aBoxF2s);
513 aMIS.Bind(i2s, aF2s);
515 aTreeFiller.Add(i2s, aBoxF2s);
516 }//for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
521 aItF1.Initialize(aLF1);
522 for (j=1; aItF1.More(); aItF1.Next(), ++j) {
525 const TopoDS_Face& aF1x=*((TopoDS_Face*)(&aItF1.Value()));
527 BRepBndLib::Add(aF1x, aBoxF1x);
530 aSelector.SetBox(aBoxF1x);
531 aNbSD=aBBTree.Select(aSelector);
536 const TColStd_ListOfInteger& aLI=aSelector.Indices();
537 aItLI.Initialize(aLI);
538 for (; aItLI.More(); aItLI.Next()) {
540 const TopoDS_Face& aF2y=*((TopoDS_Face*)(&aMIS.Find(i2s)));
542 bIsSDF=NMTTools_Tools::AreFacesSameDomain(aF1x, aF2y, aCtx);
544 if (aMFence.Contains(aF1x) || aMFence.Contains(aF2y)) {
550 NMTTools_CoupleOfShape aCS;
558 if (!mySplitFaces.HasImage(aF1)) {
559 mySplitFaces.Bind(aF1, aF1);
563 if (!mySplitFaces.HasImage(aF2)) {
564 mySplitFaces.Bind(aF2, aF2);
570 if (!mySplitFaces.HasImage(aF2)) {
571 mySplitFaces.Bind(aF2, aF2);
575 if (!mySplitFaces.HasImage(aF1)) {
576 mySplitFaces.Bind(aF1, aF1);
583 }//for (; aItLI.More(); aItLI.Next()) {
584 }//for (; aItF1.More(); aItF1.Next()) {
585 }//for (i=1; i<=aNbFF; ++i)
586 //-------------------------------------------------------------
593 NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMC;
595 NMTTools_Tools::FindChains(aLCS, aMC);
597 Standard_Boolean bIsImage;
598 Standard_Integer aIx, aIxMin, aNbMSDF, k, aNbMFj;
599 TopoDS_Shape aFOld, aFSDmin;
600 TopTools_IndexedMapOfShape aMFj;
601 TopTools_DataMapOfShapeInteger aDMSI;
603 aItF1.Initialize(myShapes);
604 for (j=1; aItF1.More(); aItF1.Next(), ++j) {
605 const TopoDS_Shape& aSj=aItF1.Value();
607 TopExp::MapShapes(aSj, TopAbs_FACE, aMFj);
608 aNbMFj=aMFj.Extent();
609 for (k=1; k<=aNbMFj; ++k) {
610 const TopoDS_Shape& aFk=aMFj(k);
611 if (!aDMSI.IsBound(aFk)) {
617 // 3. Fill the map of SDF mySameDomainFaces
619 for (i=1; i<=aNbC; ++i) {
620 // const TopoDS_Shape& aF=aMC.FindKey(i);
621 const TopTools_IndexedMapOfShape& aMSDF=aMC(i);
623 aNbMSDF=aMSDF.Extent();
624 for (j=1; j<=aNbMSDF; ++j) {
625 const TopoDS_Shape& aFSD=aMSDF(j);
626 bIsImage=mySplitFaces.IsImage(aFSD);
629 aFOld=mySplitFaces.ImageFrom(aFSD);
632 aIx=aDMSI.Find(aFOld);
646 for (j=1; j<=aNbMSDF; ++j) {
647 const TopoDS_Shape& aFSD=aMSDF(j);
648 mySameDomainShapes.Add(aFSD, aFSDmin);
654 //=======================================================================
655 // function: FillImagesFaces1
657 //=======================================================================
658 void GEOMAlgo_Builder::FillImagesFaces1()
660 Standard_Integer i, aNb, iSense, aNbLFx;
661 TopoDS_Face aF, aFSp, aFSD;
662 TopTools_ListOfShape aLFx;
663 TopTools_ListIteratorOfListOfShape aIt;
665 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
667 aNb=aDS.NumberOfShapesOfTheObject();
668 for (i=1; i<=aNb; ++i) {
669 const TopoDS_Shape& aS=aDS.Shape(i);
670 if (aS.ShapeType()!=TopAbs_FACE) {
674 if (!mySplitFaces.HasImage(aS)) {
678 aF=*((TopoDS_Face*)&aS);
681 const TopTools_ListOfShape& aLF=mySplitFaces.Image(aF);
683 for (; aIt.More(); aIt.Next()) {
684 aFSp=*((TopoDS_Face*)(&aIt.Value()));
685 if (!mySameDomainShapes.Contains(aFSp)) {
689 const TopoDS_Shape& aSx=mySameDomainShapes.FindFromKey(aFSp);
690 aFSD=*((TopoDS_Face*)(&aSx));
691 iSense=GEOMAlgo_Tools3D::Sense(aFSp, aFSD);
699 if (!myImages.HasImage(aF)) {
700 aNbLFx=aLFx.Extent();
702 const TopoDS_Shape& aFx=aLFx.First();
703 if (aF.IsSame(aFx)) {
707 myImages.Bind(aF, aLFx);
712 //=======================================================================
713 // function: FillInternalVertices
715 //=======================================================================
716 void GEOMAlgo_Builder::FillInternalVertices()
718 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
719 NMTTools_PaveFiller* pPF=myPaveFiller;
720 NMTDS_InterfPool* pIP=pPF->IP();
721 #if OCC_VERSION_LARGE > 0x06050200
722 const Handle(IntTools_Context)& aCtx= pPF->Context();
724 IntTools_Context& aCtx= pPF->ChangeContext();
727 BOPTools_CArray1OfVSInterference& aVFs=pIP->VSInterferences();
728 BOPTools_CArray1OfESInterference& aEFs=pIP->ESInterferences();
729 const NMTTools_IndexedDataMapOfIndexedMapOfInteger& aMAV=pPF->AloneVertices();
731 Standard_Boolean bHasImage;
732 Standard_Integer i, j, nF, aNbS, nV, nVSD, n1, n2, iFlag;
733 Standard_Integer aNbVFs, aNbAVF, aNbEFs, aNbVC, aNbE, aNbV;
734 Standard_Real aU1, aU2, aTol;
735 NMTTools_IndexedDataMapOfIndexedMapOfInteger aMFMV;
736 TopTools_MapOfShape aMFence;
737 TopTools_ListIteratorOfListOfShape aIt, aItV;
740 // 1. Collect face-vertex candidates [aMFMV]
743 aNbVFs=aVFs.Extent();
744 for (i=1; i<=aNbVFs; ++i) {
745 const BOPTools_VSInterference& aVS=aVFs(i);
749 if (aDS.Shape(n1).ShapeType()==TopAbs_FACE) {
753 nVSD=pPF->FindSDVertex(nV);
758 UpdateCandidates(nF, nV, aMFMV);
762 aNbEFs=aEFs.Extent();
763 for (i=1; i<=aNbEFs; ++i) {
764 const BOPTools_ESInterference& aEF=aEFs(i);
770 const TopoDS_Shape& aSnew=aDS.Shape(nV);
771 if (aSnew.ShapeType()!=TopAbs_VERTEX) {
775 nF=(aDS.Shape(n1).ShapeType()==TopAbs_FACE) ? n1 : n2;
776 nVSD=pPF->FindSDVertex(nV);
780 UpdateCandidates(nF, nV, aMFMV);
783 aNbS=aDS.NumberOfShapesOfTheObject();
784 for (nF=1; nF<=aNbS; ++nF) {
785 const TopoDS_Shape& aF=aDS.Shape(nF);
787 if (aF.ShapeType()!=TopAbs_FACE) {
790 if (!aMFence.Add(aF)) {
794 const TopoDS_Face& aFF=TopoDS::Face(aF);
795 aTol=BRep_Tool::Tolerance(aFF);
798 if (aMAV.Contains(nF)) {
799 const TColStd_IndexedMapOfInteger& aMAVF=aMAV.FindFromKey(nF);
800 aNbAVF=aMAVF.Extent();
801 for (j=1; j<=aNbAVF; ++j) {
803 nVSD=pPF->FindSDVertex(nV);
808 UpdateCandidates(nF, nV, aMFMV);
812 // 1.4 Internal vertices of the face nF
813 BooleanOperations_OnceExplorer aExp(aDS);
814 aExp.Init(nF, TopAbs_VERTEX);
815 for (; aExp.More(); aExp.Next()) {
817 const TopoDS_Shape& aV=aDS.Shape(nV);
818 if (aV.Orientation()==TopAbs_INTERNAL) {
819 nVSD=pPF->FindSDVertex(nV);
824 UpdateCandidates(nF, nV, aMFMV);
828 // 2. Process face nF
829 if (!aMFMV.Contains(nF)) {
833 const TColStd_IndexedMapOfInteger& aMVC=aMFMV.FindFromKey(nF);
839 // 2.1 Refine candidates
840 TopTools_IndexedDataMapOfShapeListOfShape aMVE;
841 TopTools_ListOfShape aLV;
843 bHasImage=myImages.HasImage(aF);
845 const TopTools_ListOfShape& aLFx=myImages.Image(aF);
846 aIt.Initialize(aLFx);
847 for (; aIt.More(); aIt.Next()) {
848 const TopoDS_Shape& aFx=aIt.Value();
849 TopExp::MapShapesAndAncestors(aFx, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
853 Standard_Boolean bFaceToProcess;
855 TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
856 bFaceToProcess=Standard_False;
857 for (j=1; j<=aNbVC; ++j) {
859 const TopoDS_Shape& aV=aDS.Shape(nV);
860 if (!aMVE.Contains(aV)) {
861 bFaceToProcess=!bFaceToProcess;
865 if (!bFaceToProcess) {
870 for (j=1; j<=aNbVC; ++j) {
872 const TopoDS_Shape& aV=aDS.Shape(nV);
873 if (aMVE.Contains(aV)) {
874 const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV);
885 // 3. Try to put vertices into the face(s)
886 aItV.Initialize(aLV);
887 for (; aItV.More(); aItV.Next()) {
888 TopoDS_Vertex aV=TopoDS::Vertex(aItV.Value());
889 aV.Orientation(TopAbs_INTERNAL);
891 bHasImage=myImages.HasImage(aF);
893 const TopTools_ListOfShape& aLFx=myImages.Image(aF);
894 aIt.Initialize(aLFx);
895 for (; aIt.More(); aIt.Next()) {
896 TopoDS_Face aFx=TopoDS::Face(aIt.Value());
898 #if OCC_VERSION_LARGE > 0x06050200
899 IntTools_FClass2d& aClsf=aCtx->FClass2d(aFx);
901 IntTools_FClass2d& aClsf=aCtx.FClass2d(aFx);
903 aClsf.Init(aFx, aTol);
905 #if OCC_VERSION_LARGE > 0x06050200
906 iFlag=aCtx->ComputeVS (aV, aFx, aU1, aU2);
908 iFlag=aCtx.ComputeVS (aV, aFx, aU1, aU2);
917 const TopoDS_Face& aFx=TopoDS::Face(aF);
919 #if OCC_VERSION_LARGE > 0x06050200
920 IntTools_FClass2d& aClsf=aCtx->FClass2d(aFx);
922 IntTools_FClass2d& aClsf=aCtx.FClass2d(aFx);
924 aClsf.Init(aFx, aTol);
926 #if OCC_VERSION_LARGE > 0x06050200
927 iFlag=aCtx->ComputeVS (aV, aFx, aU1, aU2);
929 iFlag=aCtx.ComputeVS (aV, aFx, aU1, aU2);
934 GEOMAlgo_Tools3D::CopyFace(aFx, aFz);
936 myImages.Bind(aF, aFz);
939 }// for (; aItV.More(); aItV.Next()) {
941 }// for (nF=1; nF<=aNb; ++nF) {
944 //=======================================================================
945 // function: UpdateCandidates
947 //=======================================================================
948 void UpdateCandidates(const Standard_Integer theNF,
949 const Standard_Integer theNV,
950 NMTTools_IndexedDataMapOfIndexedMapOfInteger& theMFMV)
952 if (theMFMV.Contains(theNF)) {
953 TColStd_IndexedMapOfInteger& aMV=theMFMV.ChangeFromKey(theNF);
957 TColStd_IndexedMapOfInteger aMV;
959 theMFMV.Add(theNF, aMV);
967 TopTools_ListIteratorOfListOfShape aItx;
969 aBBx.MakeCompound(aCx);
971 aItx.Initialize(aSE);
972 for (; aItx.More(); aItx.Next()) {
973 TopoDS_Shape& aEx=aItx.Value();