1 // Copyright (C) 2007-2012 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& );
104 //modified by NIZNHY-PKV Thu Feb 16 12:24:52 2012f
106 Standard_Boolean IsClosed(const TopoDS_Edge& ,
107 const TopoDS_Face& );
108 //modified by NIZNHY-PKV Thu Feb 16 12:24:56 2012t
110 //=======================================================================
111 //function : FillImagesFaces
113 //=======================================================================
114 void GEOMAlgo_Builder::FillImagesFaces()
120 FillSameDomainFaces();
122 FillInternalVertices();
125 //=======================================================================
126 // function: FillIn2DParts
128 //=======================================================================
129 void GEOMAlgo_Builder::FillIn2DParts()
131 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
132 NMTTools_PaveFiller* pPF=myPaveFiller;
133 NMTDS_InterfPool* pIP=pPF->IP();
134 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
135 NMTTools_CommonBlockPool& aCBP=pPF->ChangeCommonBlockPool();
137 Standard_Integer j, nSpIn, nSpSc, aNbCurves;
138 Standard_Integer aNbS, nF, aNbCBP, n1, n2, aNbFFs, aNbSpIn;
139 TopTools_MapOfShape aMFence;
140 TopTools_ListOfShape aLSpIn;
142 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
143 BOPTools_ListIteratorOfListOfPaveBlock aItPB;
147 aNbFFs=aFFs.Extent();
148 aNbCBP=aCBP.Extent();
150 aNbS=aDS.NumberOfShapesOfTheObject();
151 for (nF=1; nF<=aNbS; ++nF) {
152 if (aDS.GetShapeType(nF)!=TopAbs_FACE) {
156 aF=TopoDS::Face(aDS.Shape(nF));
162 BOPTools_ListOfPaveBlock aLPBIn;
164 pPF->RealSplitsInFace(nF, aLPBIn);
166 aItPB.Initialize(aLPBIn);
167 for (; aItPB.More(); aItPB.Next()) {
168 const BOPTools_PaveBlock& aPB1=aItPB.Value();
170 const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn);
171 aLSpIn.Append(aSpIn);
175 for (j=1; j<=aNbFFs; ++j) {
176 BOPTools_SSInterference& aFF=aFFs(j);
178 if (!(n1==nF || n2==nF)) {
181 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
182 aNbCurves=aSC.Length();
187 const BOPTools_Curve& aBC=aSC(1);
188 const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
189 aItPB.Initialize(aLPB);
190 for (; aItPB.More(); aItPB.Next()) {
191 const BOPTools_PaveBlock& aPBSc=aItPB.Value();
193 const TopoDS_Shape& aSpSc=aDS.Shape(nSpSc);
194 if (aMFence.Add(aSpSc)){
195 aLSpIn.Append(aSpSc);
199 aNbSpIn=aLSpIn.Extent();
201 myInParts.Add(aF, aLSpIn);
203 }//for (nF=1; nF<=aNbS; ++nF) {
206 //=======================================================================
207 // function: BuildSplitFaces
209 //=======================================================================
210 void GEOMAlgo_Builder::BuildSplitFaces()
212 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
213 NMTTools_PaveFiller* pPF=myPaveFiller;
214 NMTDS_InterfPool* pIP=pPF->IP();
215 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
216 const Handle(IntTools_Context)& aCtx= pPF->Context();
218 Standard_Boolean bToReverse, bIsClosed, bIsDegenerated;
219 Standard_Integer i, aNb, aNbF, nF;
220 TopTools_MapOfShape aMFence;
221 TColStd_IndexedMapOfInteger aMFP;
222 TopExp_Explorer anExp;
224 TopoDS_Edge aSp, aEE;
225 TopTools_ListIteratorOfListOfShape aIt;
226 TopAbs_Orientation anOriF, anOriE;
228 mySplitFaces.Clear();
230 // 1. Select Faces to process (MFP)
231 aNb=aDS.NumberOfShapesOfTheObject();
232 for (i=1; i<=aNb; ++i) {
233 const TopoDS_Shape& aF=aDS.Shape(i);
234 if (aF.ShapeType()!=TopAbs_FACE) {
237 if (!aMFence.Add(aF)) {
241 if (myInParts.Contains(aF)) {
246 anExp.Init(aF, TopAbs_EDGE);
247 for (; anExp.More(); anExp.Next()) {
248 const TopoDS_Shape& aE=anExp.Current();
249 if (myImages.HasImage(aE)) {
257 Standard_Integer aNbFFs, aNbSE, j, n1, n2;
259 aNbFFs=aFFs.Extent();
260 for (j=1; j<=aNbFFs; ++j) {
261 BOPTools_SSInterference& aFFj=aFFs(j);
262 aFFj.Indices(n1, n2);
263 if (!(n1==i || n2==i)) {
267 const TColStd_ListOfInteger& aLSE=aFFj.SharedEdges();
277 }// for (i=1; i<=aNb; ++i)
281 for (i=1; i<=aNbF; ++i) {
283 const TopoDS_Face& aF=TopoDS::Face(aDS.Shape(nF));
284 anOriF=aF.Orientation();
286 aFF.Orientation(TopAbs_FORWARD);
291 GEOMAlgo_WireEdgeSet aWES;
294 // 2.1.1. Add Split parts
295 anExp.Init(aFF, TopAbs_EDGE);
296 for (; anExp.More(); anExp.Next()) {
297 const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current());
298 anOriE=aE.Orientation();
300 if (!myImages.HasImage(aE)) {
301 if (anOriE==TopAbs_INTERNAL) {
303 aEE.Orientation(TopAbs_FORWARD);
304 aWES.AddStartElement(aEE);
305 aEE.Orientation(TopAbs_REVERSED);
306 aWES.AddStartElement(aEE);
309 aWES.AddStartElement(aE);
314 bIsDegenerated=BRep_Tool::Degenerated(aE);
315 //modified by NIZNHY-PKV Wed Mar 07 07:46:09 2012f
316 bIsClosed=IsClosed(aE, aF);
317 //bIsClosed=BRep_Tool::IsClosed(aE, aF);
318 //modified by NIZNHY-PKV Wed Mar 07 07:46:13 2012t
320 const TopTools_ListOfShape& aLIE=myImages.Image(aE);
321 aIt.Initialize(aLIE);
322 for (; aIt.More(); aIt.Next()) {
323 aSp=TopoDS::Edge(aIt.Value());
325 if (bIsDegenerated) {
326 aSp.Orientation(anOriE);
327 aWES.AddStartElement(aSp);
331 if (anOriE==TopAbs_INTERNAL) {
332 aSp.Orientation(TopAbs_FORWARD);
333 aWES.AddStartElement(aSp);
334 aSp.Orientation(TopAbs_REVERSED);
335 aWES.AddStartElement(aSp);
340 if (aMFence.Add(aSp)) {
342 if (!BRep_Tool::IsClosed(aSp, aF)){
343 BOPTools_Tools3D::DoSplitSEAMOnFace(aSp, aF);
346 aSp.Orientation(TopAbs_FORWARD);
347 aWES.AddStartElement(aSp);
348 aSp.Orientation(TopAbs_REVERSED);
349 aWES.AddStartElement(aSp);
352 }// if (aMFence.Add(aSp))
354 aSp.Orientation(anOriE);
355 bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, aCtx);
359 aWES.AddStartElement(aSp);
360 }// for (; aIt.More(); aIt.Next()) {
361 }// for (; anExp.More(); anExp.Next()) {
363 // 2.1.2. Add In2D Parts
364 if (myInParts.Contains(aF)) {
365 const TopTools_ListOfShape& aLE=myInParts.FindFromKey(aF);
367 for (; aIt.More(); aIt.Next()) {
368 aSp=TopoDS::Edge(aIt.Value());
370 aSp.Orientation(TopAbs_FORWARD);
371 aWES.AddStartElement(aSp);
373 aSp.Orientation(TopAbs_REVERSED);
374 aWES.AddStartElement(aSp);
378 // 2.2. Build images Faces
379 TopTools_ListOfShape aLFR;
380 GEOMAlgo_ShapeSet aS1, aS2;
382 const TopTools_ListOfShape& aSE=aWES.StartElements();
384 aS2.Add(aFF, TopAbs_EDGE);
385 if (aS1.IsEqual(aS2)) {
389 GEOMAlgo_BuilderFace aBF;
392 aBF.SetContext(aCtx);
397 const TopTools_ListOfShape& aLF=aBF.Areas();
399 for (; aIt.More(); aIt.Next()) {
400 TopoDS_Shape& aFR=aIt.Value();
401 if (anOriF==TopAbs_REVERSED) {
402 aFR.Orientation(TopAbs_REVERSED);
408 // 2.3. Collect draft images Faces
409 mySplitFaces.Bind(aF, aLFR);
410 }//for (i=1; i<=aNbF; ++i)
413 //=======================================================================
414 // function: FillSameDomainFaces
416 //=======================================================================
417 void GEOMAlgo_Builder::FillSameDomainFaces()
419 Standard_Boolean bIsSDF, bHasImage1, bHasImage2, bForward;
420 Standard_Integer i, j, aNbFF, nF1, nF2, aNbPBInOn, aNbC, aNbSE;
421 Standard_Integer aNbF1, aNbF2, i2s, aNbSD;
422 TopTools_MapOfShape aMFence;
423 TopTools_ListOfShape aLX1, aLX2;
424 TopTools_ListIteratorOfListOfShape aItF1, aItF2;
425 NMTTools_ListOfCoupleOfShape aLCS;
427 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
428 NMTTools_PaveFiller* pPF=myPaveFiller;
429 NMTDS_InterfPool* pIP=pPF->IP();
430 BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
431 const Handle(IntTools_Context)& aCtx= pPF->Context();
434 //mySameDomainShapes.Clear();
436 // 1. For each FF find among images of faces
437 // all pairs of same domain faces (SDF) [=> aLCS]
439 for (i=1; i<=aNbFF; ++i) {
440 BOPTools_SSInterference& aFF=aFFs(i);
441 aFF.Indices(nF1, nF2);
443 const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1));
444 const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2));
446 // if there are no in/on 2D split parts the faces nF1, nF2
448 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
449 aNbPBInOn=aLPBInOn.Extent();
452 const TColStd_ListOfInteger& aLSE=aFF.SharedEdges();
454 if (!aNbPBInOn && !aNbSE) {
459 // if there is at least one section edge between faces nF1, nF2
460 // they can not be SDF
461 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
467 // the faces are suspected to be SDF.
468 // Try to find SDF among images of nF1, nF2
471 //--------------------------------------------------------
472 bHasImage1=mySplitFaces.HasImage(aF1);
473 bHasImage2=mySplitFaces.HasImage(aF2);
485 const TopTools_ListOfShape& aLF1r=(bHasImage1)? mySplitFaces.Image(aF1) : aLX1;
486 const TopTools_ListOfShape& aLF2r=(bHasImage2)? mySplitFaces.Image(aF2) : aLX2;
488 TopTools_DataMapOfIntegerShape aMIS;
489 TColStd_ListIteratorOfListOfInteger aItLI;
490 NMTDS_BoxBndTreeSelector aSelector;
491 NMTDS_BoxBndTree aBBTree;
492 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
494 aNbF1=aLF1r.Extent();
495 aNbF2=aLF2r.Extent();
496 bForward=(aNbF1<aNbF2);
498 const TopTools_ListOfShape& aLF1=bForward ? aLF1r : aLF2r;
499 const TopTools_ListOfShape& aLF2=bForward ? aLF2r : aLF1r;
502 aItF2.Initialize(aLF2);
503 for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
506 const TopoDS_Face& aF2s=*((TopoDS_Face*)(&aItF2.Value()));
508 BRepBndLib::Add(aF2s, aBoxF2s);
510 aMIS.Bind(i2s, aF2s);
512 aTreeFiller.Add(i2s, aBoxF2s);
513 }//for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
518 aItF1.Initialize(aLF1);
519 for (j=1; aItF1.More(); aItF1.Next(), ++j) {
522 const TopoDS_Face& aF1x=*((TopoDS_Face*)(&aItF1.Value()));
524 BRepBndLib::Add(aF1x, aBoxF1x);
527 aSelector.SetBox(aBoxF1x);
528 aNbSD=aBBTree.Select(aSelector);
533 const TColStd_ListOfInteger& aLI=aSelector.Indices();
534 aItLI.Initialize(aLI);
535 for (; aItLI.More(); aItLI.Next()) {
537 const TopoDS_Face& aF2y=*((TopoDS_Face*)(&aMIS.Find(i2s)));
539 bIsSDF=NMTTools_Tools::AreFacesSameDomain(aF1x, aF2y, aCtx);
541 if (aMFence.Contains(aF1x) || aMFence.Contains(aF2y)) {
547 NMTTools_CoupleOfShape aCS;
555 if (!mySplitFaces.HasImage(aF1)) {
556 mySplitFaces.Bind(aF1, aF1);
560 if (!mySplitFaces.HasImage(aF2)) {
561 mySplitFaces.Bind(aF2, aF2);
567 if (!mySplitFaces.HasImage(aF2)) {
568 mySplitFaces.Bind(aF2, aF2);
572 if (!mySplitFaces.HasImage(aF1)) {
573 mySplitFaces.Bind(aF1, aF1);
580 }//for (; aItLI.More(); aItLI.Next()) {
581 }//for (; aItF1.More(); aItF1.Next()) {
582 }//for (i=1; i<=aNbFF; ++i)
583 //-------------------------------------------------------------
590 NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMC;
592 NMTTools_Tools::FindChains(aLCS, aMC);
594 Standard_Boolean bIsImage;
595 Standard_Integer aIx, aIxMin, aNbMSDF, k, aNbMFj;
596 TopoDS_Shape aFOld, aFSDmin;
597 TopTools_IndexedMapOfShape aMFj;
598 TopTools_DataMapOfShapeInteger aDMSI;
600 aItF1.Initialize(myShapes);
601 for (j=1; aItF1.More(); aItF1.Next(), ++j) {
602 const TopoDS_Shape& aSj=aItF1.Value();
604 TopExp::MapShapes(aSj, TopAbs_FACE, aMFj);
605 aNbMFj=aMFj.Extent();
606 for (k=1; k<=aNbMFj; ++k) {
607 const TopoDS_Shape& aFk=aMFj(k);
608 if (!aDMSI.IsBound(aFk)) {
614 // 3. Fill the map of SDF mySameDomainFaces
616 for (i=1; i<=aNbC; ++i) {
617 // const TopoDS_Shape& aF=aMC.FindKey(i);
618 const TopTools_IndexedMapOfShape& aMSDF=aMC(i);
620 aNbMSDF=aMSDF.Extent();
621 for (j=1; j<=aNbMSDF; ++j) {
622 const TopoDS_Shape& aFSD=aMSDF(j);
623 bIsImage=mySplitFaces.IsImage(aFSD);
626 aFOld=mySplitFaces.ImageFrom(aFSD);
629 aIx=aDMSI.Find(aFOld);
643 for (j=1; j<=aNbMSDF; ++j) {
644 const TopoDS_Shape& aFSD=aMSDF(j);
645 mySameDomainShapes.Add(aFSD, aFSDmin);
651 //=======================================================================
652 // function: FillImagesFaces1
654 //=======================================================================
655 void GEOMAlgo_Builder::FillImagesFaces1()
657 Standard_Integer i, aNb, iSense, aNbLFx;
658 TopoDS_Face aF, aFSp, aFSD;
659 TopTools_ListOfShape aLFx;
660 TopTools_ListIteratorOfListOfShape aIt;
662 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
664 aNb=aDS.NumberOfShapesOfTheObject();
665 for (i=1; i<=aNb; ++i) {
666 const TopoDS_Shape& aS=aDS.Shape(i);
667 if (aS.ShapeType()!=TopAbs_FACE) {
671 if (!mySplitFaces.HasImage(aS)) {
675 aF=*((TopoDS_Face*)&aS);
678 const TopTools_ListOfShape& aLF=mySplitFaces.Image(aF);
680 for (; aIt.More(); aIt.Next()) {
681 aFSp=*((TopoDS_Face*)(&aIt.Value()));
682 if (!mySameDomainShapes.Contains(aFSp)) {
686 const TopoDS_Shape& aSx=mySameDomainShapes.FindFromKey(aFSp);
687 aFSD=*((TopoDS_Face*)(&aSx));
688 iSense=GEOMAlgo_Tools3D::Sense(aFSp, aFSD);
696 if (!myImages.HasImage(aF)) {
697 aNbLFx=aLFx.Extent();
699 const TopoDS_Shape& aFx=aLFx.First();
700 if (aF.IsSame(aFx)) {
704 myImages.Bind(aF, aLFx);
709 //=======================================================================
710 // function: FillInternalVertices
712 //=======================================================================
713 void GEOMAlgo_Builder::FillInternalVertices()
715 const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
716 NMTTools_PaveFiller* pPF=myPaveFiller;
717 NMTDS_InterfPool* pIP=pPF->IP();
718 const Handle(IntTools_Context)& aCtx= pPF->Context();
720 BOPTools_CArray1OfVSInterference& aVFs=pIP->VSInterferences();
721 BOPTools_CArray1OfESInterference& aEFs=pIP->ESInterferences();
722 const NMTTools_IndexedDataMapOfIndexedMapOfInteger& aMAV=pPF->AloneVertices();
724 Standard_Boolean bHasImage;
725 Standard_Integer i, j, nF, aNbS, nV, nVSD, n1, n2, iFlag;
726 Standard_Integer aNbVFs, aNbAVF, aNbEFs, aNbVC, aNbE, aNbV;
727 Standard_Real aU1, aU2, aTol;
728 NMTTools_IndexedDataMapOfIndexedMapOfInteger aMFMV;
729 TopTools_MapOfShape aMFence;
730 TopTools_ListIteratorOfListOfShape aIt, aItV;
733 // 1. Collect face-vertex candidates [aMFMV]
736 aNbVFs=aVFs.Extent();
737 for (i=1; i<=aNbVFs; ++i) {
738 const BOPTools_VSInterference& aVS=aVFs(i);
742 if (aDS.Shape(n1).ShapeType()==TopAbs_FACE) {
746 nVSD=pPF->FindSDVertex(nV);
751 UpdateCandidates(nF, nV, aMFMV);
755 aNbEFs=aEFs.Extent();
756 for (i=1; i<=aNbEFs; ++i) {
757 const BOPTools_ESInterference& aEF=aEFs(i);
763 const TopoDS_Shape& aSnew=aDS.Shape(nV);
764 if (aSnew.ShapeType()!=TopAbs_VERTEX) {
768 nF=(aDS.Shape(n1).ShapeType()==TopAbs_FACE) ? n1 : n2;
769 nVSD=pPF->FindSDVertex(nV);
773 UpdateCandidates(nF, nV, aMFMV);
776 aNbS=aDS.NumberOfShapesOfTheObject();
777 for (nF=1; nF<=aNbS; ++nF) {
778 const TopoDS_Shape& aF=aDS.Shape(nF);
780 if (aF.ShapeType()!=TopAbs_FACE) {
783 if (!aMFence.Add(aF)) {
787 const TopoDS_Face& aFF=TopoDS::Face(aF);
788 aTol=BRep_Tool::Tolerance(aFF);
791 if (aMAV.Contains(nF)) {
792 const TColStd_IndexedMapOfInteger& aMAVF=aMAV.FindFromKey(nF);
793 aNbAVF=aMAVF.Extent();
794 for (j=1; j<=aNbAVF; ++j) {
796 nVSD=pPF->FindSDVertex(nV);
801 UpdateCandidates(nF, nV, aMFMV);
805 // 1.4 Internal vertices of the face nF
806 BooleanOperations_OnceExplorer aExp(aDS);
807 aExp.Init(nF, TopAbs_VERTEX);
808 for (; aExp.More(); aExp.Next()) {
810 const TopoDS_Shape& aV=aDS.Shape(nV);
811 if (aV.Orientation()==TopAbs_INTERNAL) {
812 nVSD=pPF->FindSDVertex(nV);
817 UpdateCandidates(nF, nV, aMFMV);
821 // 2. Process face nF
822 if (!aMFMV.Contains(nF)) {
826 const TColStd_IndexedMapOfInteger& aMVC=aMFMV.FindFromKey(nF);
832 // 2.1 Refine candidates
833 TopTools_IndexedDataMapOfShapeListOfShape aMVE;
834 TopTools_ListOfShape aLV;
836 bHasImage=myImages.HasImage(aF);
838 const TopTools_ListOfShape& aLFx=myImages.Image(aF);
839 aIt.Initialize(aLFx);
840 for (; aIt.More(); aIt.Next()) {
841 const TopoDS_Shape& aFx=aIt.Value();
842 TopExp::MapShapesAndAncestors(aFx, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
846 Standard_Boolean bFaceToProcess;
848 TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
849 bFaceToProcess=Standard_False;
850 for (j=1; j<=aNbVC; ++j) {
852 const TopoDS_Shape& aV=aDS.Shape(nV);
853 if (!aMVE.Contains(aV)) {
854 bFaceToProcess=!bFaceToProcess;
858 if (!bFaceToProcess) {
863 for (j=1; j<=aNbVC; ++j) {
865 const TopoDS_Shape& aV=aDS.Shape(nV);
866 if (aMVE.Contains(aV)) {
867 const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV);
878 // 3. Try to put vertices into the face(s)
879 aItV.Initialize(aLV);
880 for (; aItV.More(); aItV.Next()) {
881 TopoDS_Vertex aV=TopoDS::Vertex(aItV.Value());
882 aV.Orientation(TopAbs_INTERNAL);
884 bHasImage=myImages.HasImage(aF);
886 const TopTools_ListOfShape& aLFx=myImages.Image(aF);
887 aIt.Initialize(aLFx);
888 for (; aIt.More(); aIt.Next()) {
889 TopoDS_Face aFx=TopoDS::Face(aIt.Value());
891 IntTools_FClass2d& aClsf=aCtx->FClass2d(aFx);
892 aClsf.Init(aFx, aTol);
894 iFlag=aCtx->ComputeVS (aV, aFx, aU1, aU2);
902 const TopoDS_Face& aFx=TopoDS::Face(aF);
904 IntTools_FClass2d& aClsf=aCtx->FClass2d(aFx);
905 aClsf.Init(aFx, aTol);
907 iFlag=aCtx->ComputeVS (aV, aFx, aU1, aU2);
911 GEOMAlgo_Tools3D::CopyFace(aFx, aFz);
913 myImages.Bind(aF, aFz);
916 }// for (; aItV.More(); aItV.Next()) {
918 }// for (nF=1; nF<=aNb; ++nF) {
921 //=======================================================================
922 // function: UpdateCandidates
924 //=======================================================================
925 void UpdateCandidates(const Standard_Integer theNF,
926 const Standard_Integer theNV,
927 NMTTools_IndexedDataMapOfIndexedMapOfInteger& theMFMV)
929 if (theMFMV.Contains(theNF)) {
930 TColStd_IndexedMapOfInteger& aMV=theMFMV.ChangeFromKey(theNF);
934 TColStd_IndexedMapOfInteger aMV;
936 theMFMV.Add(theNF, aMV);
940 //modified by NIZNHY-PKV Thu Feb 16 12:25:16 2012f
941 //=======================================================================
942 //function : IsClosed
944 //=======================================================================
945 Standard_Boolean IsClosed(const TopoDS_Edge& aE,
946 const TopoDS_Face& aF)
948 Standard_Boolean bRet;
950 bRet=BRep_Tool::IsClosed(aE, aF);
952 TopTools_MapOfShape aM;
953 TopExp_Explorer aExp(aF, TopAbs_EDGE);
954 for (; aExp.More(); aExp.Next()) {
955 const TopoDS_Shape& aEx=aExp.Current();
967 //modified by NIZNHY-PKV Thu Feb 16 12:25:25 2012t
973 TopTools_ListIteratorOfListOfShape aItx;
975 aBBx.MakeCompound(aCx);
977 aItx.Initialize(aSE);
978 for (; aItx.More(); aItx.Next()) {
979 TopoDS_Shape& aEx=aItx.Value();