1 // File: NMTTools_PaveFiller_6.cxx
2 // Created: Fri Dec 19 10:27:31 2003
3 // Author: Peter KURNEV
6 #include <NMTTools_PaveFiller.ixx>
8 #include <Precision.hxx>
10 #include <TColStd_IndexedMapOfInteger.hxx>
11 #include <TColStd_MapOfInteger.hxx>
13 #include <Geom2d_Curve.hxx>
14 #include <Geom2d_TrimmedCurve.hxx>
15 #include <Geom_TrimmedCurve.hxx>
17 #include <GeomAdaptor_Curve.hxx>
18 #include <BndLib_Add3dCurve.hxx>
20 #include <TopoDS_Face.hxx>
22 #include <TopoDS_Compound.hxx>
26 #include <BRep_Builder.hxx>
27 #include <BRep_Tool.hxx>
28 #include <BRepBndLib.hxx>
29 #include <BRepLib.hxx>
31 #include <TopTools_IndexedMapOfShape.hxx>
33 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
34 #include <BOPTColStd_IndexedDataMapOfIntegerInteger.hxx>
36 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
37 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
38 #include <BooleanOperations_OnceExplorer.hxx>
39 #include <BooleanOperations_ShapesDataStructure.hxx>
41 #include <IntTools_SequenceOfPntOn2Faces.hxx>
42 #include <IntTools_SequenceOfCurves.hxx>
43 #include <IntTools_FaceFace.hxx>
44 #include <IntTools_Tools.hxx>
46 #include <BOPTools_CArray1OfSSInterference.hxx>
47 #include <BOPTools_ListIteratorOfListOfInterference.hxx>
48 #include <BOPTools_CArray1OfInterferenceLine.hxx>
49 #include <BOPTools_InterferenceLine.hxx>
50 #include <BOPTools_ListOfInterference.hxx>
51 #include <BOPTools_Interference.hxx>
52 #include <BOPTools_InterferencePool.hxx>
53 #include <BOPTools_SSInterference.hxx>
54 #include <BOPTools_ListOfPaveBlock.hxx>
55 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
56 #include <BOPTools_PaveBlock.hxx>
57 #include <BOPTools_ListIteratorOfListOfPave.hxx>
58 #include <BOPTools_Tools.hxx>
59 #include <BOPTools_PaveBlockIterator.hxx>
60 #include <BOPTools_Tools2D.hxx>
62 #include <NMTDS_ShapesDataStructure.hxx>
63 #include <NMTTools_IndexedDataMapOfShapePaveBlock.hxx>
64 #include <NMTTools_CommonBlockAPI.hxx>
65 #include <NMTTools_Tools.hxx>
68 Standard_Boolean IsPairFound(const Standard_Integer nF1,
69 const Standard_Integer nF2,
70 BOPTools_InterferencePool* myIntrPool,
71 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
72 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith);
75 void FMapWhat(const Standard_Integer nF,
76 BOPTools_InterferencePool* myIntrPool,
77 TColStd_IndexedMapOfInteger& aMapWhat);
79 void FMapWith(const Standard_Integer nF,
80 BOPTools_InterferencePool* myIntrPool,
81 TColStd_IndexedMapOfInteger& aMapWith);
83 Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
84 const TColStd_IndexedMapOfInteger& aMapWith);
87 //=======================================================================
88 // function: PerformFF
90 //=======================================================================
91 void NMTTools_PaveFiller::PerformFF()
93 myIsDone=Standard_False;
95 Standard_Boolean bIsFound, bJustAdd, bIsComputed;
96 Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs;
97 Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone;
98 Standard_Integer aNbCurves, aNbPoints;
99 Standard_Real anApproxTol, aTolR3D, aTolR2D;
100 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith;
101 IntTools_SequenceOfPntOn2Faces aPnts;
102 IntTools_SequenceOfCurves aCvs;
103 BooleanOperations_KindOfInterference aTypeFF=BooleanOperations_SurfaceSurface;
105 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
107 // F/F Interferences [BooleanOperations_SurfaceSurface]
108 myDSIt.Initialize(TopAbs_FACE, TopAbs_FACE);
110 // BlockLength correction
111 aNbFFs=ExpectedPoolLength();
112 aBlockLength=aFFs.BlockLength();
113 if (aNbFFs > aBlockLength) {
114 aFFs.SetBlockLength(aNbFFs);
117 for (; myDSIt.More(); myDSIt.Next()) {
118 myDSIt.Current(n1, n2, bJustAdd);
120 bIsComputed=myIntrPool->IsComputed(n1, n2);
135 bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith);
139 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
142 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
143 anIndexIn=aFFs.Append(anInterf);
144 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
149 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
150 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
153 bToApproxC3d = mySectionAttribute.Approximation();
154 bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1();
155 bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2();
159 IntTools_FaceFace aFF;
161 aFF.SetParameters (bToApproxC3d, bToApproxC2dOnS1,
162 bToApproxC2dOnS2, anApproxTol);
164 aFF.Perform(aF1, aF2);
166 bIsDone=aFF.IsDone();
170 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
173 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
174 anIndexIn=aFFs.Append(anInterf);
175 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
180 aTolR3D=aFF.TolReached3d();
181 aTolR2D=aFF.TolReached2d();
182 if (aTolR3D < 1.e-7){
186 aFF.PrepareLines3D();
188 const IntTools_SequenceOfCurves& aCvsX=aFF.Lines();
189 const IntTools_SequenceOfPntOn2Faces& aPntsX=aFF.Points();
191 aNbCurves=aCvsX.Length();
192 aNbPoints=aPntsX.Length();
194 if (!aNbCurves && !aNbPoints) {
195 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
196 anIndexIn=aFFs.Append(anInterf);
197 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
202 BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvsX, aPntsX);
203 anIndexIn=aFFs.Append(anInterf);
204 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
207 }// for (; myDSIt.More(); myDSIt.Next())
209 myIsDone=Standard_True;
211 //=======================================================================
212 // function: MakeBlocks
214 //=======================================================================
215 void NMTTools_PaveFiller::MakeBlocks()
217 myIsDone=Standard_False;
219 Standard_Boolean bIsExistingPaveBlock, bIsValidIn2D;
220 Standard_Integer i, aNbFFs, nF1, nF2, aBid=0;
221 Standard_Integer nV1, nV2, j, aNbCurves;
222 Standard_Real aTolR3D, aTol2D, aT1, aT2, aTolPPC=Precision::PConfusion();
223 NMTTools_IndexedDataMapOfShapePaveBlock aMEPB;
224 BooleanOperations_IndexedDataMapOfShapeInteger aMapEI;
225 BOPTools_ListIteratorOfListOfPaveBlock anIt;
227 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
229 // 1. Produce Section Edges from intersection curves
230 // between each pair of faces
232 aNbFFs=aFFs.Extent();
233 for (i=1; i<=aNbFFs; ++i) {
234 BOPTools_SSInterference& aFFi=aFFs(i);
237 aFFi.Indices(nF1, nF2);
238 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
239 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
241 BOPTools_ListOfPaveBlock aLPB, aLPBC;
244 Standard_Integer nFj1, nFj2, nE;
245 TColStd_IndexedMapOfInteger aMFence;
246 BOPTools_ListOfPaveBlock aLPBCx;
248 for (j=1; j<=aNbFFs; ++j) {
249 BOPTools_SSInterference& aFFj=aFFs(j);
250 aFFj.Indices(nFj1, nFj2);
252 if ((nF1==nFj1 && nFj2!=nF2) ||
253 (nF1==nFj2 && nFj1!=nF2) ||
254 (nF2==nFj1 && nFj2!=nF1) ||
255 (nF2==nFj2 && nFj1!=nF1)) {
256 RealSplitsInFace (aBid, nFj1, nFj2, aLPBCx);
257 RealSplitsInFace (aBid, nFj2, nFj1, aLPBCx);
258 RealSplitsOnFace (aBid, nFj1, nFj2, aLPBCx);
262 anIt.Initialize(aLPBCx);
263 for (; anIt.More(); anIt.Next()) {
264 const BOPTools_PaveBlock& aPBCx=anIt.Value();
267 if (!aMFence.Contains(nE)) {
275 RealSplitsInFace (aBid, nF1, nF2, aLPB);
276 RealSplitsInFace (aBid, nF2, nF1, aLPB);
277 RealSplitsOnFace (aBid, nF1, nF2, aLPB);
279 anIt.Initialize(aLPB);
280 for (; anIt.More(); anIt.Next()) {
281 const BOPTools_PaveBlock& aPB=anIt.Value();
282 aFFi.AppendBlock(aPB);
285 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
286 aNbCurves=aSCvs.Length();
291 aTolR3D=aFFi.TolR3D();
292 aTol2D=(aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D;
294 BOPTools_PaveSet aPSF;
296 PrepareSetForFace (nF1, nF2, aLPBC, aPSF);
297 //PrepareSetForFace (nF1, nF2, aPSF);
299 // Put Paves On Curves
300 for (j=1; j<=aNbCurves; ++j) {
301 BOPTools_Curve& aBC=aSCvs(j);
303 const IntTools_Curve& aC=aBC.Curve();
304 Handle (Geom_Curve) aC3D= aC.Curve();
306 PutPaveOnCurve (aPSF, aTolR3D, aBC);
309 // Put bounding paves on curves
310 for (j=1; j<=aNbCurves; ++j) {
311 BOPTools_Curve& aBC=aSCvs(j);
312 PutBoundPaveOnCurve (aBC, aFFi);
315 // Pave Blocks on Curves
316 for (j=1; j<=aNbCurves; ++j) {
317 BOPTools_Curve& aBC=aSCvs(j);
318 const IntTools_Curve& aIC= aBC.Curve();
319 BOPTools_PaveSet& aPaveSet=aBC.Set();
321 BOPTools_PaveBlockIterator aPBIter(0, aPaveSet);
322 for (; aPBIter.More(); aPBIter.Next()) {
323 BOPTools_PaveBlock& aPBNew=aPBIter.Value();
324 aPBNew.SetCurve(aIC);
325 aPBNew.SetFace1(nF1);
326 aPBNew.SetFace2(nF2);
328 nV1=aPBNew.Pave1().Index();
329 nV2=aPBNew.Pave2().Index();
330 aT1=aPBNew.Pave1().Param();
331 aT2=aPBNew.Pave2().Param();
333 if((nV1==nV2) && (Abs(aT2 - aT1) < aTolPPC)) {
338 const BOPTools_ListOfPaveBlock& aLPBFF=aFFi.PaveBlocks();
339 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPBFF, aTolR3D);
340 //bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aFFi);
341 if (bIsExistingPaveBlock) {
345 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPBC, aTolR3D);
346 if (bIsExistingPaveBlock) {
349 // Checking of validity in 2D
351 bIsValidIn2D=myContext.IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D);
356 //aBC.AppendNewBlock(aPBNew);
361 const TopoDS_Vertex& aV1=TopoDS::Vertex(myDS->Shape(nV1));
362 const TopoDS_Vertex& aV2=TopoDS::Vertex(myDS->Shape(nV2));
364 BOPTools_Tools::MakeSectEdge (aIC, aV1, aT1, aV2, aT2, aES);
367 Standard_Real aTolR2D;
369 aTolR2D=aFFi.TolR2D();
370 Handle(Geom2d_Curve) aC2D1=aIC.FirstCurve2d();
371 Handle(Geom2d_Curve) aC2D2=aIC.SecondCurve2d();
373 NMTTools_Tools::MakePCurve(aES, aF1, aC2D1, aTolR2D);
374 NMTTools_Tools::MakePCurve(aES, aF2, aC2D2, aTolR2D);
377 aMEPB.Add(aES, aPBNew);
380 } // end of for (j=1; j<=aNbCurves; ++j)
381 }// for (i=1; i<=aNbFFs; ++i)
382 //=============================================================
384 // II. Post treatment
386 // Input data: aMEPB, aMapEI
387 // Result : section edges in myDS
389 Standard_Integer aNbSE;
391 aNbSE=aMEPB.Extent();
393 // there is nothing to do here
398 TopoDS_Compound aCompound;
400 // 1. Make compound from SE
401 aBB.MakeCompound(aCompound);
402 for (i=1; i<=aNbSE; ++i) {
403 const TopoDS_Shape& aSE=aMEPB.FindKey(i);
404 aBB.Add(aCompound, aSE);
408 // 2. Intersect SE using auxiliary Filler
409 NMTDS_ShapesDataStructure tDS;
411 tDS.SetCompositeShape(aCompound);
414 BOPTools_InterferencePool tIP(tDS);
415 NMTTools_PaveFiller tPF(tIP);
420 tPF.PerformNewVertices();
423 tPF.myPavePool.Resize (tPF.myNbEdges);
431 tPF.myCommonBlockPool.Resize (tPF.myNbEdges);
432 tPF.mySplitShapesPool.Resize (tPF.myNbEdges);
433 tPF.myPavePoolNew .Resize (tPF.myNbEdges);
435 tPF.PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE);
436 tPF.PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE);
440 tPF.RefinePavePool ();
442 tPF.myPavePoolNew.Destroy();
444 tPF.MakeSplitEdges();
445 tPF.UpdateCommonBlocks();
447 // 3. Treatment of the result of intersection
449 Standard_Integer aNbOld, aNbLines, aNbPB, mV1, mV2, nE, mE, iFF;
450 TopAbs_ShapeEnum aType;
451 BOPTools_ListIteratorOfListOfPaveBlock aIt;
452 BOPTColStd_IndexedDataMapOfIntegerInteger aMNewOld;
454 const BOPTools_SplitShapesPool& aSSP=tPF.mySplitShapesPool;
455 const NMTTools_CommonBlockPool& aCBP=tPF.myCommonBlockPool;
457 aNbLines=tDS.NumberOfInsertedShapes();
458 aNbOld=tDS.NumberOfShapesOfTheObject();
460 // 3.1 Links between indices in tDS and DS (kept in aMNewOld)
462 // 3.1.1.Old vertices [ links ]
463 for (i=1; i<=aNbOld; ++i) {
464 const TopoDS_Shape& aV=tDS.Shape(i);
465 aType=aV.ShapeType();
466 if (aType!=TopAbs_VERTEX) {
470 for (j=1; j<=aNbSE; ++j) {
471 const BOPTools_PaveBlock& aPBSE=aMEPB(j);
472 nV1=aPBSE.Pave1().Index();
473 const TopoDS_Shape& aV1=myDS->Shape(nV1);
474 if (aV1.IsSame(aV)) {
475 aMNewOld.Add(i, nV1);
478 nV2=aPBSE.Pave2().Index();
479 const TopoDS_Shape& aV2=myDS->Shape(nV2);
480 if (aV2.IsSame(aV)) {
481 aMNewOld.Add(i, nV2);
487 // 3.1.2. New vertices [ links ]
488 i=tDS.NumberOfSourceShapes()+1;
489 for (; i<=aNbLines; ++i) {
490 const TopoDS_Shape& aV=tDS.Shape(i);
491 aType=aV.ShapeType();
492 if (aType!=TopAbs_VERTEX) {
496 // Insert new vertex in myDS
497 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
498 myDS->InsertShapeAndAncestorsSuccessors(aV, anASSeq);
499 nV1=myDS->NumberOfInsertedShapes();
501 aMNewOld.Add(i, nV1);
504 // 3.2. Treatment of section edges (SE)
505 for (i=1; i<=aNbOld; ++i) {
506 const TopoDS_Shape& aE=tDS.Shape(i);
507 aType=aE.ShapeType();
508 if (aType!=TopAbs_EDGE) {
512 // block of section edge that we already have for this SE
513 BOPTools_PaveBlock& aPBSE=aMEPB.ChangeFromKey(aE);
515 // Corresponding FF-interference
516 iFF=aMapEI.FindFromKey(aE);
517 BOPTools_SSInterference& aFFi=aFFs(iFF);
518 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
520 BOPTools_Curve& aBC=aSCvs(1);
522 const BOPTools_ListOfPaveBlock& aLPB=aSSP(tDS.RefEdge(i));
526 // no pave blocks -> use aPBSE and whole edge aE
527 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
529 nV1=aPBSE.Pave1().Index();
530 const TopoDS_Shape& aV1=myDS->Shape(nV1);
531 nV2=aPBSE.Pave2().Index();
532 const TopoDS_Shape& aV2=myDS->Shape(nV2);
534 anASSeq.SetNewSuccessor(nV1);
535 anASSeq.SetNewOrientation(aV1.Orientation());
536 anASSeq.SetNewSuccessor(nV2);
537 anASSeq.SetNewOrientation(aV2.Orientation());
539 myDS->InsertShapeAndAncestorsSuccessors(aE, anASSeq);
540 nE=myDS->NumberOfInsertedShapes();
543 aBC.AppendNewBlock(aPBSE);
551 //modified by NIZNHY-PKV Thu Jan 26 10:17:04 2006f
552 //const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
553 //const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
554 //modified by NIZNHY-PKV Thu Jan 26 10:17:08 2006t
556 const NMTTools_ListOfCommonBlock& aLCB=aCBP(tDS.RefEdge(i));
557 NMTTools_CommonBlockAPI aCBAPI(aLCB);
559 aIt.Initialize(aLPB);
560 for (; aIt.More(); aIt.Next()) {
561 BOPTools_PaveBlock aPB=aIt.Value();
563 ////modified by NIZNHY-PKV Thu Jan 26 10:16:36 2006f
564 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
565 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
566 ////modified by NIZNHY-PKV Thu Jan 26 10:16:39 2006t
568 if (aCBAPI.IsCommonBlock(aPB)) {
569 // it can be Common Block
570 Standard_Real aTolEx;
571 Handle(Geom2d_Curve) aC2D1, aC2D2;
572 TopoDS_Face aF1FWD, aF2FWD;
574 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
575 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
577 aPB=aCB.PaveBlock1();
578 mE=aPB.Edge(); // index of edge in tDS
579 const TopoDS_Edge& aEx=TopoDS::Edge(tDS.Shape(mE));
580 aTolEx=BRep_Tool::Tolerance(aEx);
582 // <- Block A was here
585 aF1FWD.Orientation(TopAbs_FORWARD);
586 NMTTools_Tools::MakePCurve(aEx, aF1FWD, aC2D1, aTolEx);
589 aF2FWD.Orientation(TopAbs_FORWARD);
590 NMTTools_Tools::MakePCurve(aEx, aF2FWD, aC2D2, aTolEx);
591 } //if (aCBAPI.IsCommonBlock(aPB))
594 mE=aPB.Edge(); // index of edge in tDS
595 const TopoDS_Shape& aSp=tDS.Shape(mE);
597 const BOPTools_Pave& aPave1=aPB.Pave1();
599 mV1=aPave1.Index(); // index in tDS
600 nV1=aMNewOld.FindFromKey(mV1); // index in myDS
601 const TopoDS_Shape& aV1=myDS->Shape(nV1);
603 const BOPTools_Pave& aPave2=aPB.Pave2();
606 nV2=aMNewOld.FindFromKey(mV2);
607 const TopoDS_Shape& aV2=myDS->Shape(nV2);
609 if (!aMNewOld.Contains(mE)) {
610 // add new SE to the myDS
611 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
613 anASSeq.SetNewSuccessor(nV1);
614 anASSeq.SetNewOrientation(aV1.Orientation());
616 anASSeq.SetNewSuccessor(nV2);
617 anASSeq.SetNewOrientation(aV2.Orientation());
619 myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq);
620 nE=myDS->NumberOfInsertedShapes();
622 aMNewOld.Add(mE, nE);
625 nE=aMNewOld.FindFromKey(mE);
628 BOPTools_PaveBlock aPBx;
629 BOPTools_Pave aP1, aP2;
645 aBC.AppendNewBlock(aPBx);
646 }// for (; aIt.More(); aIt.Next())
647 }// for (i=1; i<=aNbOld; ++i)
649 myIsDone=Standard_True;
651 //=======================================================================
652 // function: MakePCurves
654 //=======================================================================
655 void NMTTools_PaveFiller::MakePCurves()
657 Standard_Integer i, aNb, nF1, nF2, nE;
658 TopoDS_Face aF1FWD, aF2FWD;
659 BOPTools_ListIteratorOfListOfPaveBlock anIt;
661 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
664 for (i=1; i<=aNb; i++) {
665 BOPTools_SSInterference& aFF=aFFs(i);
666 aFF.Indices(nF1, nF2);
668 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
669 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
672 aF1FWD.Orientation(TopAbs_FORWARD);
674 aF2FWD.Orientation(TopAbs_FORWARD);
676 // In, On parts processing
677 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
679 anIt.Initialize(aLPBInOn);
680 for (; anIt.More(); anIt.Next()) {
681 const BOPTools_PaveBlock& aPB=anIt.Value();
683 const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE));
685 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
686 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
690 //=======================================================================
691 // function: IsExistingPaveBlock
693 //=======================================================================
694 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
695 const BOPTools_ListOfPaveBlock& aLPBR,
696 const Standard_Real aTolR3D)
698 Standard_Boolean bFlag;
699 Standard_Integer nVNew1, nVNew2, nV1, nV2, iC;
700 BOPTools_ListIteratorOfListOfPaveBlock anIt;
702 bFlag=Standard_False;
703 nVNew1=aPBNew.Pave1().Index();
704 nVNew2=aPBNew.Pave2().Index();
706 anIt.Initialize(aLPBR);
707 for (; anIt.More(); anIt.Next()) {
708 const BOPTools_PaveBlock& aPBR=anIt.Value();
709 nV1=aPBR.Pave1().Index();
710 nV2=aPBR.Pave2().Index();
711 if (nVNew1==nV1 || nVNew1==nV2 || nVNew2==nV1 || nVNew2==nV2) {
713 iC=CheckIntermediatePoint(aPBNew, aPBR, aTolR3D);
721 //=======================================================================
722 // function: CheckIntermediatePoint
724 //=======================================================================
725 Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
726 const BOPTools_PaveBlock& aPBR,
727 const Standard_Real aTolC)
730 Standard_Real aT11, aT12, aTM, aTmp;
731 Standard_Integer iVM, nE2;
737 const BOPTools_Pave& aPave11=aPB.Pave1();
738 aT11=aPave11.Param();
740 const BOPTools_Pave& aPave12=aPB.Pave2();
741 aT12=aPave12.Param();
743 aTM=IntTools_Tools::IntermediatePoint (aT11, aT12);
745 const IntTools_Curve& aIC=aPB.Curve();
748 aBB.MakeVertex (aVM, aPM, aTolC);
752 const TopoDS_Edge& aE2=TopoDS::Edge(myDS->GetShape(nE2));
754 iVM=myContext.ComputeVE(aVM, aE2, aTmp);
758 //=======================================================================
759 // function: PutBoundPaveOnCurve
761 //=======================================================================
762 void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC,
763 BOPTools_SSInterference& aFFi)
765 Standard_Boolean bHasBounds, bVF;
766 Standard_Integer nF1, nF2;
767 Standard_Real aT1, aT2, aTolR3D;
770 const IntTools_Curve& aIC=aBC.Curve();
771 bHasBounds=aIC.HasBounds ();
777 aIC.Bounds (aT1, aT2, aP1, aP2);
780 aFFi.Indices(nF1, nF2);
781 aTolR3D=aFFi.TolR3D();
783 const TopoDS_Face& aF1=TopoDS::Face(myDS->GetShape(nF1));
784 const TopoDS_Face& aF2=TopoDS::Face(myDS->GetShape(nF2));
786 bVF=myContext.IsValidPointForFaces (aP1, aF1, aF2, aTolR3D);
788 PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi);
791 bVF=myContext.IsValidPointForFaces (aP2, aF1, aF2, aTolR3D);
793 PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi);
796 //=======================================================================
797 // function: PutBoundPaveOnCurve
799 //=======================================================================
800 void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP,
801 const Standard_Real aT,
803 BOPTools_SSInterference& aFFi)
805 Standard_Boolean bFound1, bFound2;
807 Standard_Real aTolV=aFFi.TolR3D();
809 BOPTools_Pave aPave1, aPave2, aPave;
810 BOPTools_PaveSet& aCPS=aBC.Set();
811 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
812 const IntTools_Curve& aIC=aBC.Curve();
814 bFound1=FindPave(aP, aTolV, aCPS , aPave1);
815 bFound2=FindPave(aP, aTolV, aFFiPS, aPave2);
817 if (!bFound1 && !bFound2) {
818 TopoDS_Vertex aNewVertex;
819 BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex);
821 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
822 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
823 nV=myDS->NumberOfInsertedShapes();
828 aFFiPS.Append(aPave);
830 // Append Techno Vertex to the Curve
831 TColStd_ListOfInteger& aTVs=aBC.TechnoVertices();
835 if (bFound1 && !bFound2) {
839 aFFiPS.Append(aPave);
841 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
842 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
845 if (!bFound1 && bFound2) {
851 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
852 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
855 //=======================================================================
856 // function: FindPave
858 //=======================================================================
859 Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP,
860 const Standard_Real aTolPV,
861 const BOPTools_PaveSet& aPS,
862 BOPTools_Pave& aPave)
865 Standard_Boolean bIsVertex=Standard_False;
867 const BOPTools_ListOfPave& aLP=aPS.Set();
868 BOPTools_ListIteratorOfListOfPave anIt(aLP);
869 for (; anIt.More(); anIt.Next()) {
870 const BOPTools_Pave& aPC=anIt.Value();
872 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
873 bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV);
881 //=======================================================================
882 // function: PrepareSetForFace
884 //=======================================================================
885 void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer nF1,
886 const Standard_Integer nF2,
887 const BOPTools_ListOfPaveBlock& aLPBC,
888 BOPTools_PaveSet& aPSF)
890 Standard_Integer nV1, nV2;
891 TColStd_MapOfInteger aMap;
892 BOPTools_ListOfPaveBlock aLPB1, aLPB2, aLPBS;
893 BOPTools_ListIteratorOfListOfPaveBlock anIt;
895 RealSplitsFace(nF1, aLPB1);
896 anIt.Initialize(aLPB1);
897 for (; anIt.More(); anIt.Next()) {
898 const BOPTools_PaveBlock& aPB=anIt.Value();
902 RealSplitsFace(nF2, aLPB2);
903 anIt.Initialize(aLPB2);
904 for (; anIt.More(); anIt.Next()) {
905 const BOPTools_PaveBlock& aPB=anIt.Value();
909 anIt.Initialize(aLPBC);
910 for (; anIt.More(); anIt.Next()) {
911 const BOPTools_PaveBlock& aPB=anIt.Value();
915 anIt.Initialize(aLPBS);
916 for (; anIt.More(); anIt.Next()) {
917 const BOPTools_PaveBlock& aPB=anIt.Value();
918 const BOPTools_Pave& aPave1=aPB.Pave1();
920 if (!aMap.Contains(nV1)) {
924 const BOPTools_Pave& aPave2=aPB.Pave2();
926 if (!aMap.Contains(nV2)) {
932 //=======================================================================
933 // function: PutPaveOnCurve
935 //=======================================================================
936 void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
937 const Standard_Real aTolR3D,
941 Standard_Boolean bIsVertexOnLine;
943 BOPTools_ListIteratorOfListOfPave anIt;
945 GeomAdaptor_Curve aGAC;
947 const IntTools_Curve& aC=aBC.Curve();
948 Handle (Geom_Curve) aC3D= aC.Curve();
950 BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBBC);
952 const BOPTools_ListOfPave& aLP=aPaveSet.Set();
953 anIt.Initialize(aLP);
954 for (; anIt.More(); anIt.Next()) {
955 const BOPTools_Pave& aPave=anIt.Value();
958 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
961 BRepBndLib::Add(aV, aBBV);
962 if (aBBC.IsOut(aBBV)){
966 bIsVertexOnLine=myContext.IsVertexOnLine(aV, aC, aTolR3D, aT);
968 if (bIsVertexOnLine) {
969 BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface);
970 BOPTools_PaveSet& aPS=aBC.Set();
971 aPS.Append(aPaveNew);
973 BOPTools_Tools::UpdateVertex (aC, aT, aV);
978 //=======================================================================
979 // function: IsPairFound
981 //=======================================================================
982 Standard_Boolean IsPairFound(const Standard_Integer nF1,
983 const Standard_Integer nF2,
984 BOPTools_InterferencePool* myIntrPool,
985 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
986 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith)
988 Standard_Boolean bIsFound;
990 if (!aMapWhat.Contains(nF1)) {
991 TColStd_IndexedMapOfInteger aMWhat;
992 FMapWhat(nF1, myIntrPool, aMWhat);
993 aMapWhat.Add(nF1, aMWhat);
996 if (!aMapWith.Contains(nF2)) {
997 TColStd_IndexedMapOfInteger aMWith;
998 FMapWith(nF2, myIntrPool, aMWith);
999 aMapWith.Add(nF2, aMWith);
1002 const TColStd_IndexedMapOfInteger& aMWht=aMapWhat.FindFromKey(nF1);
1003 const TColStd_IndexedMapOfInteger& aMWit=aMapWith.FindFromKey(nF2);
1005 bIsFound=IsFound(aMWht, aMWit);
1009 //=======================================================================
1010 // function: FMapWhat
1012 //=======================================================================
1013 void FMapWhat(const Standard_Integer nF,
1014 BOPTools_InterferencePool* myIntrPool,
1015 TColStd_IndexedMapOfInteger& aMapWhat)
1018 Standard_Integer nE, nV;
1022 BooleanOperations_ShapesDataStructure* myDS=myIntrPool->DS();
1023 BooleanOperations_OnceExplorer aExp(*myDS);
1027 aExp.Init(nF, TopAbs_VERTEX);
1028 for (; aExp.More(); aExp.Next()) {
1033 aExp.Init(nF, TopAbs_EDGE);
1034 for (; aExp.More(); aExp.Next()) {
1039 //=======================================================================
1040 // function: FMapWith
1042 //=======================================================================
1043 void FMapWith(const Standard_Integer nF,
1044 BOPTools_InterferencePool* myIntrPool,
1045 TColStd_IndexedMapOfInteger& aMapWith)
1047 TColStd_IndexedMapOfInteger aMapWhat;
1049 FMapWhat(nF, myIntrPool, aMapWhat);
1052 Standard_Integer i, aNb, anIndex, aWhat, aWith;
1053 BOPTools_ListIteratorOfListOfInterference anIt;
1055 const BOPTools_CArray1OfInterferenceLine& anArrIL= myIntrPool->InterferenceTable();
1057 aNb=aMapWhat.Extent();
1058 for (i=1; i<=aNb; i++) {
1061 const BOPTools_InterferenceLine& aWithLine=anArrIL(aWhat);
1063 const BOPTools_ListOfInterference& aLI=aWithLine.List();
1064 anIt.Initialize(aLI);
1065 for (; anIt.More(); anIt.Next()) {
1066 const BOPTools_Interference& anIntf=anIt.Value();
1067 anIndex=anIntf.Index();
1069 aWith=anIntf.With();
1070 aMapWith.Add(aWith);
1075 //=======================================================================
1076 // function: IsFound
1078 //=======================================================================
1079 Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
1080 const TColStd_IndexedMapOfInteger& aMapWith)
1082 Standard_Boolean bFlag=Standard_False;
1083 Standard_Integer i, aNb, aWhat;
1085 aNb=aMapWhat.Extent();
1086 for (i=1; i<=aNb; i++) {
1088 if (aMapWith.Contains(aWhat)) {
1098 // Commented out by EAP in the frame of PAL9151
1100 // Standard_Boolean bHasPCOnF, bFound;
1101 // Standard_Integer nF, k, nEOrx, nF1x, nF2x;
1102 // Standard_Real aTolEx, aT1x, aT2x;
1103 // BOPTools_ListIteratorOfListOfPaveBlock aItPBx;
1105 // for (k=0; k<2; ++k) {
1106 // nF=(!k) ? nF1 : nF2;
1107 // const TopoDS_Face& aF=TopoDS::Face(myDS->Shape(nF));
1109 // bHasPCOnF=BOPTools_Tools2D::HasCurveOnSurface(aEx, aF);
1114 // bFound=Standard_False;
1115 // aItPBx.Initialize(aLPBx);
1116 // for (; aItPBx.More(); aItPBx.Next()) {
1117 // BOPTools_PaveBlock& aPBx=aIt.Value();
1118 // nEOrx=aPBx.OriginalEdge();
1119 // const TopoDS_Shape& aEOrx=tDS.Shape(nEOrx);
1120 // BOPTools_PaveBlock& aPBSEx=aMEPB.ChangeFromKey(aEOrx);
1121 // aT1x=aPBSEx.Pave1().Param();
1122 // aT2x=aPBSEx.Pave2().Param();
1123 // const IntTools_Curve& aICx=aPBSEx.Curve();
1125 // nF1x=aPBSEx.Face1();
1126 // nF2x=aPBSEx.Face2();
1129 // Handle(Geom2d_Curve) aC2D1x=aICx.FirstCurve2d();
1130 // Handle(Geom2d_TrimmedCurve)aC2D1xT =new Geom2d_TrimmedCurve(aC2D1x, aT1x, aT2x);
1131 // aBB.UpdateEdge(aEx, aC2D1xT, aF, aTolEx);
1137 // Handle(Geom2d_Curve) aC2D2x=aICx.SecondCurve2d();
1138 // Handle(Geom2d_TrimmedCurve)aC2D2xT =new Geom2d_TrimmedCurve(aC2D2x, aT1x, aT2x);
1139 // aBB.UpdateEdge(aEx, aC2D2xT, aF, aTolEx);
1145 // BRepLib::SameParameter(aEx, aTolEx, Standard_True);
1149 // The code till the if block end is restored from V2_2_2 revision