2 // IMPROVED by NIZNHY-PKV Thu Oct 12 16:03:33 2006
4 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation; either
10 // version 2.1 of the License.
12 // This library is distributed in the hope that it will be useful
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Lesser General Public License for more details.
17 // You should have received a copy of the GNU Lesser General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: NMTTools_PaveFiller_6.cxx
24 // Created: Fri Dec 19 10:27:31 2003
25 // Author: Peter KURNEV
28 #include <NMTTools_PaveFiller.ixx>
30 #include <Precision.hxx>
32 #include <TColStd_IndexedMapOfInteger.hxx>
33 #include <TColStd_MapOfInteger.hxx>
35 #include <Geom2d_Curve.hxx>
36 #include <Geom_TrimmedCurve.hxx>
38 #include <GeomAdaptor_Curve.hxx>
39 #include <BndLib_Add3dCurve.hxx>
41 #include <TopoDS_Face.hxx>
43 #include <TopoDS_Compound.hxx>
47 #include <BRep_Builder.hxx>
48 #include <BRep_Tool.hxx>
49 #include <BRepBndLib.hxx>
51 #include <TopTools_IndexedMapOfShape.hxx>
53 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
54 #include <BOPTColStd_IndexedDataMapOfIntegerInteger.hxx>
56 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
57 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
58 #include <BooleanOperations_OnceExplorer.hxx>
59 #include <BooleanOperations_ShapesDataStructure.hxx>
61 #include <IntTools_SequenceOfPntOn2Faces.hxx>
62 #include <IntTools_SequenceOfCurves.hxx>
63 #include <IntTools_FaceFace.hxx>
64 #include <IntTools_Tools.hxx>
66 #include <BOPTools_CArray1OfSSInterference.hxx>
67 #include <BOPTools_ListIteratorOfListOfInterference.hxx>
68 #include <BOPTools_CArray1OfInterferenceLine.hxx>
69 #include <BOPTools_InterferenceLine.hxx>
70 #include <BOPTools_ListOfInterference.hxx>
71 #include <BOPTools_Interference.hxx>
72 #include <BOPTools_InterferencePool.hxx>
73 #include <BOPTools_SSInterference.hxx>
74 #include <BOPTools_ListOfPaveBlock.hxx>
75 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
76 #include <BOPTools_PaveBlock.hxx>
77 #include <BOPTools_ListIteratorOfListOfPave.hxx>
78 #include <BOPTools_Tools.hxx>
79 #include <BOPTools_PaveBlockIterator.hxx>
80 #include <BOPTools_Tools2D.hxx>
82 #include <NMTDS_ShapesDataStructure.hxx>
83 #include <NMTTools_IndexedDataMapOfShapePaveBlock.hxx>
84 #include <NMTTools_CommonBlockAPI.hxx>
85 #include <Geom2d_Curve.hxx>
86 #include <NMTTools_Tools.hxx>
87 #include <BRepLib.hxx>
88 #include <Geom2d_TrimmedCurve.hxx>
90 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
91 #include <TopTools_ListOfShape.hxx>
92 #include <TopTools_ListIteratorOfListOfShape.hxx>
93 #include <TopoDS_Vertex.hxx>
95 #include <TopoDS_Edge.hxx>
96 #include <TColStd_ListOfInteger.hxx>
98 #include <NMTTools_DataMapOfIntegerListOfPaveBlock.hxx>
99 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
100 #include <TColStd_ListIteratorOfListOfInteger.hxx>
101 #include <NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx>
102 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
103 #include <TColStd_MapOfInteger.hxx>
104 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
105 #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
106 #include <TColStd_ListOfInteger.hxx>
107 #include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
108 #include <TColStd_ListIteratorOfListOfInteger.hxx>
109 #include <NMTTools_MapOfPaveBlock.hxx>
112 Standard_Boolean IsPairFound(const Standard_Integer nF1,
113 const Standard_Integer nF2,
114 BOPTools_InterferencePool* myIntrPool,
115 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
116 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith);
119 void FMapWhat(const Standard_Integer nF,
120 BOPTools_InterferencePool* myIntrPool,
121 TColStd_IndexedMapOfInteger& aMapWhat);
123 void FMapWith(const Standard_Integer nF,
124 BOPTools_InterferencePool* myIntrPool,
125 TColStd_IndexedMapOfInteger& aMapWith);
127 Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
128 const TColStd_IndexedMapOfInteger& aMapWith);
130 // Modified Thu Sep 14 14:35:18 2006
131 // Contribution of Samtech www.samcef.com BEGIN
133 void SharedEdges1(const TopoDS_Face& aF1,
134 const TopoDS_Face& aF2,
135 TopTools_ListOfShape& aLS);
136 // Contribution of Samtech www.samcef.com END
138 //=======================================================================
139 // function: PerformFF
141 //=======================================================================
142 void NMTTools_PaveFiller::PerformFF()
144 myIsDone=Standard_False;
146 Standard_Boolean bIsFound, bJustAdd, bIsComputed;
147 Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs;
148 Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone;
149 Standard_Integer aNbCurves, aNbPoints;
150 Standard_Real anApproxTol, aTolR3D, aTolR2D;
151 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith;
152 IntTools_SequenceOfPntOn2Faces aPnts;
153 IntTools_SequenceOfCurves aCvs;
154 BooleanOperations_KindOfInterference aTypeFF=BooleanOperations_SurfaceSurface;
156 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
158 // F/F Interferences [BooleanOperations_SurfaceSurface]
159 myDSIt.Initialize(TopAbs_FACE, TopAbs_FACE);
161 // BlockLength correction
162 aNbFFs=ExpectedPoolLength();
163 aBlockLength=aFFs.BlockLength();
164 if (aNbFFs > aBlockLength) {
165 aFFs.SetBlockLength(aNbFFs);
168 for (; myDSIt.More(); myDSIt.Next()) {
169 myDSIt.Current(n1, n2, bJustAdd);
171 bIsComputed=myIntrPool->IsComputed(n1, n2);
186 bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith);
190 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
193 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
194 anIndexIn=aFFs.Append(anInterf);
195 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
200 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv
201 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv
204 bToApproxC3d = mySectionAttribute.Approximation();
205 bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1();
206 bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2();
210 IntTools_FaceFace aFF;
212 aFF.SetParameters (bToApproxC3d, bToApproxC2dOnS1,
213 bToApproxC2dOnS2, anApproxTol);
215 aFF.Perform(aF1, aF2);
217 bIsDone=aFF.IsDone();
221 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
224 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
225 anIndexIn=aFFs.Append(anInterf);
226 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
231 aTolR3D=aFF.TolReached3d();
232 aTolR2D=aFF.TolReached2d();
233 if (aTolR3D < 1.e-7){
237 aFF.PrepareLines3D();
239 const IntTools_SequenceOfCurves& aCvsX=aFF.Lines();
240 const IntTools_SequenceOfPntOn2Faces& aPntsX=aFF.Points();
242 aNbCurves=aCvsX.Length();
243 aNbPoints=aPntsX.Length();
245 if (!aNbCurves && !aNbPoints) {
246 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
247 anIndexIn=aFFs.Append(anInterf);
248 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
253 BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvsX, aPntsX);
254 anIndexIn=aFFs.Append(anInterf);
255 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
258 }// for (; myDSIt.More(); myDSIt.Next())
260 myIsDone=Standard_True;
262 //=======================================================================
263 // function: MakeBlocks
265 //=======================================================================
266 void NMTTools_PaveFiller::MakeBlocks()
268 myIsDone=Standard_False;
270 // Modified Thu Sep 14 14:35:18 2006
271 // Contribution of Samtech www.samcef.com BEGIN
272 Standard_Boolean bIsExistingPaveBlock, bIsValidIn2D, bIsCoincided;
273 // Contribution of Samtech www.samcef.com END
275 Standard_Integer i, aNbFFs, nF1, nF2, aBid=0;
276 Standard_Integer nV1, nV2, j, aNbCurves;
277 Standard_Real aTolR3D, aTol2D, aT1, aT2, aTolPPC=Precision::PConfusion();
278 NMTTools_IndexedDataMapOfShapePaveBlock aMEPB;
279 BooleanOperations_IndexedDataMapOfShapeInteger aMapEI;
280 BOPTools_ListIteratorOfListOfPaveBlock anIt;
282 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
284 aNbFFs=aFFs.Extent();
286 NMTTools_DataMapOfIntegerListOfPaveBlock aMFInOn;
287 NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock aItMF;
290 Standard_Integer aNbS, aNbF, nF, aNbOn, nSp;
291 TopAbs_ShapeEnum aType;
292 BOPTools_ListIteratorOfListOfPaveBlock anItPB;
293 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
294 TColStd_ListIteratorOfListOfInteger aItF;
296 aNbS=myDS->NumberOfShapesOfTheObject();
297 for (i=1; i<=aNbS; ++i) {
298 const TopoDS_Shape& aS=myDS->Shape(i);
299 aType=aS.ShapeType();
301 if (aType==TopAbs_EDGE) {
302 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(i));
303 aItCB.Initialize(aLCB);
304 for (; aItCB.More(); aItCB.Next()) {
305 const NMTTools_CommonBlock& aCB=aItCB.Value();
306 const BOPTools_PaveBlock &aPB1=aCB.PaveBlock1();
308 const TColStd_ListOfInteger& aLF=aCB.Faces();
311 aItF.Initialize(aLF);
312 for (; aItF.More(); aItF.Next()) {
314 if (aMFInOn.IsBound(nF)) {
315 BOPTools_ListOfPaveBlock& aLPB=aMFInOn.ChangeFind(nF);
319 BOPTools_ListOfPaveBlock aLPB;
321 aMFInOn.Bind(nF, aLPB);
325 } // for (; aItCB.More(); aItCB.Next()) {
326 }//if (aS.ShapeType()==TopAbs_EDGE) {
328 else if (aType==TopAbs_FACE) {
329 BOPTools_ListOfPaveBlock aLPBOn;
332 RealSplitsFace(nF, aLPBOn);
334 aNbOn=aLPBOn.Extent();
336 if (aMFInOn.IsBound(nF)) {
337 BOPTools_ListOfPaveBlock& aLPB=aMFInOn.ChangeFind(nF);
341 aMFInOn.Bind(nF, aLPBOn);
345 } // for (i=1; i<=aNbS; ++i) {
347 // Refine ListOfPaveBlocks
348 aItMF.Initialize(aMFInOn);
349 for(; aItMF.More(); aItMF.Next()) {
350 TColStd_MapOfInteger aMTmp;
351 BOPTools_ListOfPaveBlock aLPBX;
354 BOPTools_ListOfPaveBlock& aLPB=aMFInOn.ChangeFind(nF);
355 anItPB.Initialize(aLPB);
356 for (; anItPB.More(); anItPB.Next()) {
357 const BOPTools_PaveBlock& aPB=anItPB.Value();
359 if (aMTmp.Add(nSp)) {
369 // 1. Produce Section Edges from intersection curves
370 // between each pair of faces
372 aNbFFs=aFFs.Extent();
374 for (i=1; i<=aNbFFs; ++i) {
376 BOPTools_SSInterference& aFFi=aFFs(i);
379 aFFi.Indices(nF1, nF2);
380 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv
381 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv
383 BOPTools_ListOfPaveBlock aLPB;
387 BOPTools_ListIteratorOfListOfPaveBlock anItPB;
388 NMTTools_MapOfPaveBlock aMPB;
390 if (aMFInOn.IsBound(nF1)) {
391 const BOPTools_ListOfPaveBlock& aLPBF1=aMFInOn.Find(nF1);
392 anItPB.Initialize(aLPBF1);
393 for (; anItPB.More(); anItPB.Next()) {
394 const BOPTools_PaveBlock& aPB=anItPB.Value();
400 if (aMFInOn.IsBound(nF2)) {
401 const BOPTools_ListOfPaveBlock& aLPBF2=aMFInOn.Find(nF2);
402 anItPB.Initialize(aLPBF2);
403 for (; anItPB.More(); anItPB.Next()) {
404 const BOPTools_PaveBlock& aPB=anItPB.Value();
405 if (aMPB.Contains(aPB)) {
406 aFFi.AppendBlock(aPB);
416 TopTools_ListOfShape aLSE;
417 TColStd_ListOfInteger aLNE;
418 SharedEdges(nF1, nF2, aLNE, aLSE);
419 aFFi.SetSharedEdges(aLNE);
421 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
422 aNbCurves=aSCvs.Length();
427 // Contribution of Samtech www.samcef.com END
428 aTolR3D=aFFi.TolR3D();
429 aTol2D=(aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D;
431 BOPTools_PaveSet aPSF;
433 PrepareSetForFace (nF1, nF2, aLPB, aPSF);
435 // Put Paves On Curves
436 for (j=1; j<=aNbCurves; ++j) {
437 BOPTools_Curve& aBC=aSCvs(j);
439 const IntTools_Curve& aC=aBC.Curve();
440 Handle (Geom_Curve) aC3D= aC.Curve();
442 PutPaveOnCurve (aPSF, aTolR3D, aBC);
445 // Put bounding paves on curves
446 for (j=1; j<=aNbCurves; ++j) {
447 BOPTools_Curve& aBC=aSCvs(j);
448 PutBoundPaveOnCurve (aBC, aFFi);
451 // Pave Blocks on Curves
452 for (j=1; j<=aNbCurves; ++j) {
453 BOPTools_Curve& aBC=aSCvs(j);
454 const IntTools_Curve& aIC= aBC.Curve();
455 BOPTools_PaveSet& aPaveSet=aBC.Set();
457 BOPTools_PaveBlockIterator aPBIter(0, aPaveSet);
458 for (; aPBIter.More(); aPBIter.Next()) {
459 BOPTools_PaveBlock& aPBNew=aPBIter.Value();
460 aPBNew.SetCurve(aIC);
461 aPBNew.SetFace1(nF1);
462 aPBNew.SetFace2(nF2);
464 nV1=aPBNew.Pave1().Index();
465 nV2=aPBNew.Pave2().Index();
466 aT1=aPBNew.Pave1().Param();
467 aT2=aPBNew.Pave2().Param();
469 if((nV1==nV2) && (Abs(aT2 - aT1) < aTolPPC)) {
475 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPB, aTolR3D);
476 if (bIsExistingPaveBlock) {
480 bIsCoincided=CheckCoincidence(aPBNew, aLPB);
486 // to provide checking whether aPBNew already exists in list
487 // of section edges aLSE
488 // Thu Sep 14 14:35:18 2006
489 // Contribution of Samtech www.samcef.com BEGIN
491 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLSE, aTolR3D);
492 if (bIsExistingPaveBlock) {
495 // Contribution of Samtech www.samcef.com END
497 // Checking of validity in 2D
499 bIsValidIn2D=myContext.IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D);
508 const TopoDS_Vertex aV1=TopoDS::Vertex(myDS->Shape(nV1));//mpv
509 const TopoDS_Vertex aV2=TopoDS::Vertex(myDS->Shape(nV2));//mpv
511 BOPTools_Tools::MakeSectEdge (aIC, aV1, aT1, aV2, aT2, aES);
513 //modified by NIZNHY-PKV Thu Nov 16 11:13:46 2006f SKL/PartC5
515 Handle(Geom2d_Curve) aC2D1, aC2D2;
517 aC2D1=aIC.FirstCurve2d();
518 aC2D2=aIC.SecondCurve2d();
520 NMTTools_Tools::MakePCurve(aES, aF1, aC2D1);
521 NMTTools_Tools::MakePCurve(aES, aF2, aC2D2);
522 NMTTools_Tools::UpdateEdge (aES, aTolR3D);
528 Standard_Real aTolR2D;
529 Handle(Geom2d_Curve) aC2D1, aC2D2;
531 aTolR2D=aFFi.TolR2D();
532 aC2D1=aIC.FirstCurve2d();
533 aC2D2=aIC.SecondCurve2d();
535 NMTTools_Tools::MakePCurve(aES, aF1, aC2D1, aTolR2D);
536 NMTTools_Tools::MakePCurve(aES, aF2, aC2D2, aTolR2D);
539 //modified by NIZNHY-PKV Thu Nov 16 11:17:34 2006t
541 aMEPB.Add(aES, aPBNew);
545 } // end of for (j=1; j<=aNbCurves; ++j)
546 }// for (i=1; i<=aNbFFs; ++i)
547 //=============================================================
549 // II. Post treatment
551 // Input data: aMEPB, aMapEI
552 // Result : section edges in myDS
554 Standard_Integer aNbSE;
556 aNbSE=aMEPB.Extent();
558 // there is nothing to do here
563 TopoDS_Compound aCompound;
565 // 1. Make compound from SE
566 aBB.MakeCompound(aCompound);
567 for (i=1; i<=aNbSE; ++i) {
568 const TopoDS_Shape& aSE=aMEPB.FindKey(i);
569 aBB.Add(aCompound, aSE);
573 // 2. Intersect SE using auxiliary Filler
574 NMTDS_ShapesDataStructure tDS;
576 tDS.SetCompositeShape(aCompound);
579 BOPTools_InterferencePool tIP(tDS);
580 NMTTools_PaveFiller tPF(tIP);
585 tPF.PerformNewVertices();
588 tPF.myPavePool.Resize (tPF.myNbEdges);
596 tPF.myCommonBlockPool.Resize (tPF.myNbEdges);
597 tPF.mySplitShapesPool.Resize (tPF.myNbEdges);
598 tPF.myPavePoolNew .Resize (tPF.myNbEdges);
600 tPF.PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE);
601 tPF.PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE);
605 tPF.RefinePavePool ();
607 tPF.myPavePoolNew.Destroy();
609 tPF.MakeSplitEdges();
610 tPF.UpdateCommonBlocks();
612 // 3. Treatment of the result of intersection
614 Standard_Integer aNbOld, aNbLines, aNbPB, mV1, mV2, nE, mE, iFF;
615 TopAbs_ShapeEnum aType;
616 BOPTools_ListIteratorOfListOfPaveBlock aIt;
617 BOPTColStd_IndexedDataMapOfIntegerInteger aMNewOld;
619 const BOPTools_SplitShapesPool& aSSP=tPF.mySplitShapesPool;
620 const NMTTools_CommonBlockPool& aCBP=tPF.myCommonBlockPool;
622 aNbLines=tDS.NumberOfInsertedShapes();
623 aNbOld=tDS.NumberOfShapesOfTheObject();
625 // 3.1 Links between indices in tDS and DS (kept in aMNewOld)
627 // 3.1.1.Old vertices [ links ]
628 for (i=1; i<=aNbOld; ++i) {
629 const TopoDS_Shape& aV=tDS.Shape(i);
630 aType=aV.ShapeType();
631 if (aType!=TopAbs_VERTEX) {
635 for (j=1; j<=aNbSE; ++j) {
636 const BOPTools_PaveBlock& aPBSE=aMEPB(j);
637 nV1=aPBSE.Pave1().Index();
638 const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
639 if (aV1.IsSame(aV)) {
640 aMNewOld.Add(i, nV1);
643 nV2=aPBSE.Pave2().Index();
644 const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
645 if (aV2.IsSame(aV)) {
646 aMNewOld.Add(i, nV2);
652 // 3.1.2. New vertices [ links ]
653 i=tDS.NumberOfSourceShapes()+1;
654 for (; i<=aNbLines; ++i) {
655 const TopoDS_Shape& aV=tDS.Shape(i);
656 aType=aV.ShapeType();
657 if (aType!=TopAbs_VERTEX) {
661 // Insert new vertex in myDS
662 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
663 myDS->InsertShapeAndAncestorsSuccessors(aV, anASSeq);
664 nV1=myDS->NumberOfInsertedShapes();
666 aMNewOld.Add(i, nV1);
669 // 3.2. Treatment of section edges (SE)
670 for (i=1; i<=aNbOld; ++i) {
671 const TopoDS_Shape& aE=tDS.Shape(i);
672 aType=aE.ShapeType();
673 if (aType!=TopAbs_EDGE) {
677 // block of section edge that we already have for this SE
678 BOPTools_PaveBlock& aPBSE=aMEPB.ChangeFromKey(aE);
680 // Corresponding FF-interference
681 iFF=aMapEI.FindFromKey(aE);
682 BOPTools_SSInterference& aFFi=aFFs(iFF);
683 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
685 BOPTools_Curve& aBC=aSCvs(1);
687 const BOPTools_ListOfPaveBlock& aLPB=aSSP(tDS.RefEdge(i));
691 // no pave blocks -> use aPBSE and whole edge aE
692 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
694 nV1=aPBSE.Pave1().Index();
695 const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
696 nV2=aPBSE.Pave2().Index();
697 const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
699 anASSeq.SetNewSuccessor(nV1);
700 anASSeq.SetNewOrientation(aV1.Orientation());
701 anASSeq.SetNewSuccessor(nV2);
702 anASSeq.SetNewOrientation(aV2.Orientation());
704 myDS->InsertShapeAndAncestorsSuccessors(aE, anASSeq);
705 nE=myDS->NumberOfInsertedShapes();
708 aBC.AppendNewBlock(aPBSE);
716 const NMTTools_ListOfCommonBlock& aLCB=aCBP(tDS.RefEdge(i));
717 NMTTools_CommonBlockAPI aCBAPI(aLCB);
719 aIt.Initialize(aLPB);
720 for (; aIt.More(); aIt.Next()) {
721 BOPTools_PaveBlock aPB=aIt.Value();
723 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));
724 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));
726 if (aCBAPI.IsCommonBlock(aPB)) {
727 // it can be Common Block
728 Standard_Real aTolEx;
729 Handle(Geom2d_Curve) aC2D1, aC2D2;
730 TopoDS_Face aF1FWD, aF2FWD;
732 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
733 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
735 aPB=aCB.PaveBlock1();
736 mE=aPB.Edge(); // index of edge in tDS
737 const TopoDS_Edge& aEx=TopoDS::Edge(tDS.Shape(mE));
738 aTolEx=BRep_Tool::Tolerance(aEx);
741 aF1FWD.Orientation(TopAbs_FORWARD);
743 aF2FWD.Orientation(TopAbs_FORWARD);
745 //modified by NIZNHY-PKV Thu Nov 16 12:49:13 2006f SKL/PartC5
746 //NMTTools_Tools::MakePCurve(aEx, aF1FWD, aC2D1, aTolEx);
747 //NMTTools_Tools::MakePCurve(aEx, aF2FWD, aC2D2, aTolEx);
748 NMTTools_Tools::MakePCurve(aEx, aF1FWD, aC2D1);
749 NMTTools_Tools::MakePCurve(aEx, aF2FWD, aC2D2);
750 NMTTools_Tools::UpdateEdge (aEx, aTolEx);
751 //modified by NIZNHY-PKV Thu Nov 16 12:49:24 2006t
752 } //if (aCBAPI.IsCommonBlock(aPB))
755 mE=aPB.Edge(); // index of edge in tDS
756 const TopoDS_Shape& aSp=tDS.Shape(mE);
758 const BOPTools_Pave& aPave1=aPB.Pave1();
760 mV1=aPave1.Index(); // index in tDS
761 nV1=aMNewOld.FindFromKey(mV1); // index in myDS
762 const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
764 const BOPTools_Pave& aPave2=aPB.Pave2();
767 nV2=aMNewOld.FindFromKey(mV2);
768 const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
770 if (!aMNewOld.Contains(mE)) {
771 // add new SE to the myDS
772 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
774 anASSeq.SetNewSuccessor(nV1);
775 anASSeq.SetNewOrientation(aV1.Orientation());
777 anASSeq.SetNewSuccessor(nV2);
778 anASSeq.SetNewOrientation(aV2.Orientation());
780 myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq);
781 nE=myDS->NumberOfInsertedShapes();
783 aMNewOld.Add(mE, nE);
786 nE=aMNewOld.FindFromKey(mE);
789 BOPTools_PaveBlock aPBx;
790 BOPTools_Pave aP1, aP2;
806 aBC.AppendNewBlock(aPBx);
807 }// for (; aIt.More(); aIt.Next())
808 }// for (i=1; i<=aNbOld; ++i)
810 myIsDone=Standard_True;
812 //=======================================================================
813 // function: MakePCurves
815 //=======================================================================
816 void NMTTools_PaveFiller::MakePCurves()
818 Standard_Integer i, aNb, nF1, nF2, nE;
819 TopoDS_Face aF1FWD, aF2FWD;
820 BOPTools_ListIteratorOfListOfPaveBlock anIt;
822 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
825 for (i=1; i<=aNb; i++) {
826 BOPTools_SSInterference& aFF=aFFs(i);
827 aFF.Indices(nF1, nF2);
829 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv
830 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv
833 aF1FWD.Orientation(TopAbs_FORWARD);
835 aF2FWD.Orientation(TopAbs_FORWARD);
837 // In, On parts processing
838 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
840 anIt.Initialize(aLPBInOn);
841 for (; anIt.More(); anIt.Next()) {
842 const BOPTools_PaveBlock& aPB=anIt.Value();
844 const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));//mpv
846 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
847 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
851 //=======================================================================
852 // function: IsExistingPaveBlock
854 //=======================================================================
855 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
856 const BOPTools_ListOfPaveBlock& aLPBR,
857 const Standard_Real aTolR3D)
859 Standard_Boolean bFlag;
860 Standard_Integer nVNew1, nVNew2, nV1, nV2, iC;
861 BOPTools_ListIteratorOfListOfPaveBlock anIt;
863 bFlag=Standard_False;
864 nVNew1=aPBNew.Pave1().Index();
865 nVNew2=aPBNew.Pave2().Index();
867 anIt.Initialize(aLPBR);
868 for (; anIt.More(); anIt.Next()) {
869 const BOPTools_PaveBlock& aPBR=anIt.Value();
870 nV1=aPBR.Pave1().Index();
871 nV2=aPBR.Pave2().Index();
872 if (nVNew1==nV1 || nVNew1==nV2 || nVNew2==nV1 || nVNew2==nV2) {
874 iC=CheckIntermediatePoint(aPBNew, aPBR, aTolR3D);
882 //=======================================================================
883 // function: IsExistingPaveBlock
885 //=======================================================================
886 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
887 const TopTools_ListOfShape& aLSE,
888 const Standard_Real aTolR3D)
890 Standard_Boolean bFlag;
891 Standard_Integer aNbSE, iC;
892 TopTools_ListIteratorOfListOfShape anIt;
894 bFlag=Standard_False;
901 anIt.Initialize(aLSE);
902 for (; anIt.More(); anIt.Next()) {
903 const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value());
904 iC=CheckIntermediatePoint(aPBNew, aE, aTolR3D);
911 //=======================================================================
912 // function: CheckIntermediatePoint
914 //=======================================================================
915 Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
916 const BOPTools_PaveBlock& aPBR,
917 const Standard_Real aTolC)
920 Standard_Integer iVM, nE2;
923 const TopoDS_Edge aE2=TopoDS::Edge(myDS->Shape(nE2));//mpv
924 iVM=CheckIntermediatePoint(aPB, aE2, aTolC);
928 //=======================================================================
929 // function: CheckIntermediatePoint
931 //=======================================================================
932 Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
933 const TopoDS_Edge& aE2,
934 const Standard_Real aTolC)
936 Standard_Real aT11, aT12, aTM, aTmp;
937 Standard_Integer iVM;
943 const BOPTools_Pave& aPave11=aPB.Pave1();
944 aT11=aPave11.Param();
946 const BOPTools_Pave& aPave12=aPB.Pave2();
947 aT12=aPave12.Param();
949 aTM=IntTools_Tools::IntermediatePoint (aT11, aT12);
951 const IntTools_Curve& aIC=aPB.Curve();
954 aBB.MakeVertex (aVM, aPM, aTolC);
956 iVM=myContext.ComputeVE(aVM, aE2, aTmp);
960 //=======================================================================
961 // function: PutBoundPaveOnCurve
963 //=======================================================================
964 void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC,
965 BOPTools_SSInterference& aFFi)
967 Standard_Boolean bHasBounds, bVF;
968 Standard_Integer nF1, nF2;
969 Standard_Real aT1, aT2, aTolR3D;
972 const IntTools_Curve& aIC=aBC.Curve();
973 bHasBounds=aIC.HasBounds ();
979 aIC.Bounds (aT1, aT2, aP1, aP2);
982 aFFi.Indices(nF1, nF2);
983 aTolR3D=aFFi.TolR3D();
985 const TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1));//mpv
986 const TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2));//mpv
988 bVF=myContext.IsValidPointForFaces (aP1, aF1, aF2, aTolR3D);
990 PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi);
993 bVF=myContext.IsValidPointForFaces (aP2, aF1, aF2, aTolR3D);
995 PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi);
998 //=======================================================================
999 // function: PutBoundPaveOnCurve
1001 //=======================================================================
1002 void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP,
1003 const Standard_Real aT,
1004 BOPTools_Curve& aBC,
1005 BOPTools_SSInterference& aFFi)
1007 Standard_Boolean bFound1, bFound2;
1008 Standard_Integer nV;
1009 Standard_Real aTolV=aFFi.TolR3D();
1011 BOPTools_Pave aPave1, aPave2, aPave;
1012 BOPTools_PaveSet& aCPS=aBC.Set();
1013 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
1014 const IntTools_Curve& aIC=aBC.Curve();
1016 bFound1=FindPave(aP, aTolV, aCPS , aPave1);
1017 bFound2=FindPave(aP, aTolV, aFFiPS, aPave2);
1019 if (!bFound1 && !bFound2) {
1020 TopoDS_Vertex aNewVertex;
1021 BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex);
1023 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
1024 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
1025 nV=myDS->NumberOfInsertedShapes();
1030 aFFiPS.Append(aPave);
1032 // Append Techno Vertex to the Curve
1033 TColStd_ListOfInteger& aTVs=aBC.TechnoVertices();
1037 if (bFound1 && !bFound2) {
1041 aFFiPS.Append(aPave);
1043 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1044 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
1047 if (!bFound1 && bFound2) {
1053 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1054 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
1057 //=======================================================================
1058 // function: FindPave
1060 //=======================================================================
1061 Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP,
1062 const Standard_Real aTolPV,
1063 const BOPTools_PaveSet& aPS,
1064 BOPTools_Pave& aPave)
1066 Standard_Integer nV;
1067 Standard_Boolean bIsVertex=Standard_False;
1069 const BOPTools_ListOfPave& aLP=aPS.Set();
1070 BOPTools_ListIteratorOfListOfPave anIt(aLP);
1071 for (; anIt.More(); anIt.Next()) {
1072 const BOPTools_Pave& aPC=anIt.Value();
1074 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1075 bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV);
1083 //=======================================================================
1084 // function: PrepareSetForFace
1086 //=======================================================================
1087 void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer ,//nF1,
1088 const Standard_Integer ,//nF2,
1089 const BOPTools_ListOfPaveBlock& aLPBC,
1090 BOPTools_PaveSet& aPSF)
1092 Standard_Integer nV1, nV2;
1093 TColStd_MapOfInteger aMap;
1094 BOPTools_ListIteratorOfListOfPaveBlock anIt;
1096 anIt.Initialize(aLPBC);
1097 for (; anIt.More(); anIt.Next()) {
1098 const BOPTools_PaveBlock& aPB=anIt.Value();
1099 const BOPTools_Pave& aPave1=aPB.Pave1();
1101 if (!aMap.Contains(nV1)) {
1103 aPSF.Append(aPave1);
1105 const BOPTools_Pave& aPave2=aPB.Pave2();
1107 if (!aMap.Contains(nV2)) {
1109 aPSF.Append(aPave2);
1113 //=======================================================================
1114 // function: PutPaveOnCurve
1116 //=======================================================================
1117 void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
1118 const Standard_Real aTolR3D,
1119 BOPTools_Curve& aBC)
1121 Standard_Integer nV;
1122 Standard_Boolean bIsVertexOnLine;
1124 BOPTools_ListIteratorOfListOfPave anIt;
1126 GeomAdaptor_Curve aGAC;
1128 const IntTools_Curve& aC=aBC.Curve();
1129 Handle (Geom_Curve) aC3D= aC.Curve();
1131 BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBBC);
1133 const BOPTools_ListOfPave& aLP=aPaveSet.Set();
1134 anIt.Initialize(aLP);
1135 for (; anIt.More(); anIt.Next()) {
1136 const BOPTools_Pave& aPave=anIt.Value();
1139 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1142 BRepBndLib::Add(aV, aBBV);
1143 if (aBBC.IsOut(aBBV)){
1147 bIsVertexOnLine=myContext.IsVertexOnLine(aV, aC, aTolR3D, aT);
1149 if (bIsVertexOnLine) {
1150 BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface);
1151 BOPTools_PaveSet& aPS=aBC.Set();
1152 aPS.Append(aPaveNew);
1154 BOPTools_Tools::UpdateVertex (aC, aT, aV);
1159 //=======================================================================
1160 // function: IsPairFound
1162 //=======================================================================
1163 Standard_Boolean IsPairFound(const Standard_Integer nF1,
1164 const Standard_Integer nF2,
1165 BOPTools_InterferencePool* myIntrPool,
1166 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
1167 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith)
1169 Standard_Boolean bIsFound;
1171 if (!aMapWhat.Contains(nF1)) {
1172 TColStd_IndexedMapOfInteger aMWhat;
1173 FMapWhat(nF1, myIntrPool, aMWhat);
1174 aMapWhat.Add(nF1, aMWhat);
1177 if (!aMapWith.Contains(nF2)) {
1178 TColStd_IndexedMapOfInteger aMWith;
1179 FMapWith(nF2, myIntrPool, aMWith);
1180 aMapWith.Add(nF2, aMWith);
1183 const TColStd_IndexedMapOfInteger& aMWht=aMapWhat.FindFromKey(nF1);
1184 const TColStd_IndexedMapOfInteger& aMWit=aMapWith.FindFromKey(nF2);
1186 bIsFound=IsFound(aMWht, aMWit);
1190 //=======================================================================
1191 // function: FMapWhat
1193 //=======================================================================
1194 void FMapWhat(const Standard_Integer nF,
1195 BOPTools_InterferencePool* myIntrPool,
1196 TColStd_IndexedMapOfInteger& aMapWhat)
1199 Standard_Integer nE, nV;
1203 BooleanOperations_ShapesDataStructure* myDS=myIntrPool->DS();
1204 BooleanOperations_OnceExplorer aExp(*myDS);
1208 aExp.Init(nF, TopAbs_VERTEX);
1209 for (; aExp.More(); aExp.Next()) {
1214 aExp.Init(nF, TopAbs_EDGE);
1215 for (; aExp.More(); aExp.Next()) {
1220 //=======================================================================
1221 // function: FMapWith
1223 //=======================================================================
1224 void FMapWith(const Standard_Integer nF,
1225 BOPTools_InterferencePool* myIntrPool,
1226 TColStd_IndexedMapOfInteger& aMapWith)
1228 TColStd_IndexedMapOfInteger aMapWhat;
1230 FMapWhat(nF, myIntrPool, aMapWhat);
1233 Standard_Integer i, aNb, anIndex, aWhat, aWith;
1234 BOPTools_ListIteratorOfListOfInterference anIt;
1236 const BOPTools_CArray1OfInterferenceLine& anArrIL= myIntrPool->InterferenceTable();
1238 aNb=aMapWhat.Extent();
1239 for (i=1; i<=aNb; i++) {
1242 const BOPTools_InterferenceLine& aWithLine=anArrIL(aWhat);
1244 const BOPTools_ListOfInterference& aLI=aWithLine.List();
1245 anIt.Initialize(aLI);
1246 for (; anIt.More(); anIt.Next()) {
1247 const BOPTools_Interference& anIntf=anIt.Value();
1248 anIndex=anIntf.Index();
1250 aWith=anIntf.With();
1251 aMapWith.Add(aWith);
1256 //=======================================================================
1257 // function: IsFound
1259 //=======================================================================
1260 Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
1261 const TColStd_IndexedMapOfInteger& aMapWith)
1263 Standard_Boolean bFlag=Standard_False;
1264 Standard_Integer i, aNb, aWhat;
1266 aNb=aMapWhat.Extent();
1267 for (i=1; i<=aNb; i++) {
1269 if (aMapWith.Contains(aWhat)) {
1275 // Modified Thu Sep 14 14:35:18 2006
1276 // Contribution of Samtech www.samcef.com BEGIN
1277 //=======================================================================
1278 //function : SharedEdges1
1280 //=======================================================================
1281 void SharedEdges1(const TopoDS_Face& aF1,
1282 const TopoDS_Face& aF2,
1283 TopTools_ListOfShape& aLS)
1285 Standard_Integer i, aNbE, aNbF;;
1286 TopTools_IndexedDataMapOfShapeListOfShape aMEF;
1288 TopExp::MapShapesAndAncestors(aF1, TopAbs_EDGE, TopAbs_FACE, aMEF);
1289 TopExp::MapShapesAndAncestors(aF2, TopAbs_EDGE, TopAbs_FACE, aMEF);
1292 for (i=1; i<=aNbE; ++i) {
1293 const TopTools_ListOfShape& aLF=aMEF.FindFromIndex(i);
1297 const TopoDS_Shape& aF1x=aLF.First();
1298 const TopoDS_Shape& aF2x=aLF.Last();
1299 if (aF1x.IsSame(aF2x)) {
1303 const TopoDS_Shape& aE=aMEF.FindKey(i);
1309 //=======================================================================
1310 // function: CheckCoincidence
1312 //=======================================================================
1313 Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock& aPBNew,
1314 const BOPTools_ListOfPaveBlock& aLPBFF)
1317 Standard_Boolean bRet;
1319 Standard_Integer nV11, nV12, nV21, nV22, iVV, iVE, nE2;
1320 Standard_Integer iV, iCount, iCountExt;
1321 BOPTools_ListIteratorOfListOfPaveBlock anIt;
1323 const BOPTools_Pave& aPave11=aPBNew.Pave1();
1324 nV11=aPave11.Index();
1325 const TopoDS_Vertex& aV11=TopoDS::Vertex(myDS->Shape(nV11));
1328 const BOPTools_Pave& aPave12=aPBNew.Pave2();
1329 nV12=aPave12.Index();
1330 const TopoDS_Vertex& aV12=TopoDS::Vertex(myDS->Shape(nV12));
1334 anIt.Initialize(aLPBFF);
1335 for (; anIt.More(); anIt.Next()) {
1338 const BOPTools_PaveBlock& aPBR=anIt.Value();
1340 const BOPTools_Pave& aPave21=aPBR.Pave1();
1341 nV21=aPave21.Index();
1344 const BOPTools_Pave& aPave22=aPBR.Pave2();
1345 nV22=aPave22.Index();
1346 //modified by NIZNHY-PKV Wed Nov 15 13:08:13 2006f
1347 if (nV11==nV21 || nV11==nV22 || nV12==nV21 || nV12==nV22) {
1350 //modified by NIZNHY-PKV Wed Nov 15 13:08:15 2006t
1354 const TopoDS_Vertex& aV21=TopoDS::Vertex(myDS->Shape(nV21));
1355 const TopoDS_Vertex& aV22=TopoDS::Vertex(myDS->Shape(nV22));
1356 const TopoDS_Edge& aE2=TopoDS::Edge(myDS->Shape(nE2));
1360 iVV=IntTools_Tools::ComputeVV (aV11, aV21);
1364 if (iCount>iCountExt) {
1369 iVV=IntTools_Tools::ComputeVV (aV11, aV22);
1373 if (iCount>iCountExt) {
1379 iVE=myContext.ComputeVE (aV11, aE2, aTE);
1382 if (iCount>iCountExt) {
1389 iVV=IntTools_Tools::ComputeVV (aV12, aV21);
1393 if (iCount>iCountExt) {
1398 iVV=IntTools_Tools::ComputeVV (aV12, aV22);
1402 if (iCount>iCountExt) {
1408 iVE=myContext.ComputeVE (aV12, aE2, aTE);
1411 if (iCount>iCountExt) {
1417 bRet=(Standard_Boolean)(iCount>iCountExt);
1421 // Contribution of Samtech www.samcef.com END