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 <Geom_TrimmedCurve.hxx>
16 #include <GeomAdaptor_Curve.hxx>
17 #include <BndLib_Add3dCurve.hxx>
19 #include <TopoDS_Face.hxx>
21 #include <TopoDS_Compound.hxx>
25 #include <BRep_Builder.hxx>
26 #include <BRep_Tool.hxx>
27 #include <BRepBndLib.hxx>
29 #include <TopTools_IndexedMapOfShape.hxx>
31 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
32 #include <BOPTColStd_IndexedDataMapOfIntegerInteger.hxx>
34 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
35 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
36 #include <BooleanOperations_OnceExplorer.hxx>
37 #include <BooleanOperations_ShapesDataStructure.hxx>
39 #include <IntTools_SequenceOfPntOn2Faces.hxx>
40 #include <IntTools_SequenceOfCurves.hxx>
41 #include <IntTools_FaceFace.hxx>
42 #include <IntTools_Tools.hxx>
44 #include <BOPTools_CArray1OfSSInterference.hxx>
45 #include <BOPTools_ListIteratorOfListOfInterference.hxx>
46 #include <BOPTools_CArray1OfInterferenceLine.hxx>
47 #include <BOPTools_InterferenceLine.hxx>
48 #include <BOPTools_ListOfInterference.hxx>
49 #include <BOPTools_Interference.hxx>
50 #include <BOPTools_InterferencePool.hxx>
51 #include <BOPTools_SSInterference.hxx>
52 #include <BOPTools_ListOfPaveBlock.hxx>
53 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
54 #include <BOPTools_PaveBlock.hxx>
55 #include <BOPTools_ListIteratorOfListOfPave.hxx>
56 #include <BOPTools_Tools.hxx>
57 #include <BOPTools_PaveBlockIterator.hxx>
58 #include <BOPTools_Tools2D.hxx>
60 #include <NMTDS_ShapesDataStructure.hxx>
61 #include <NMTTools_IndexedDataMapOfShapePaveBlock.hxx>
62 #include <NMTTools_CommonBlockAPI.hxx>
63 #include <Geom2d_Curve.hxx>
64 #include <NMTTools_Tools.hxx>
65 #include <BRepLib.hxx>
66 #include <Geom2d_TrimmedCurve.hxx>
69 Standard_Boolean IsPairFound(const Standard_Integer nF1,
70 const Standard_Integer nF2,
71 BOPTools_InterferencePool* myIntrPool,
72 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
73 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith);
76 void FMapWhat(const Standard_Integer nF,
77 BOPTools_InterferencePool* myIntrPool,
78 TColStd_IndexedMapOfInteger& aMapWhat);
80 void FMapWith(const Standard_Integer nF,
81 BOPTools_InterferencePool* myIntrPool,
82 TColStd_IndexedMapOfInteger& aMapWith);
84 Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
85 const TColStd_IndexedMapOfInteger& aMapWith);
88 //=======================================================================
89 // function: PerformFF
91 //=======================================================================
92 void NMTTools_PaveFiller::PerformFF()
94 myIsDone=Standard_False;
96 Standard_Boolean bIsFound, bJustAdd, bIsComputed;
97 Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs;
98 Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone;
99 Standard_Integer aNbCurves, aNbPoints;
100 Standard_Real anApproxTol, aTolR3D, aTolR2D;
101 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith;
102 IntTools_SequenceOfPntOn2Faces aPnts;
103 IntTools_SequenceOfCurves aCvs;
104 BooleanOperations_KindOfInterference aTypeFF=BooleanOperations_SurfaceSurface;
106 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
108 // F/F Interferences [BooleanOperations_SurfaceSurface]
109 myDSIt.Initialize(TopAbs_FACE, TopAbs_FACE);
111 // BlockLength correction
112 aNbFFs=ExpectedPoolLength();
113 aBlockLength=aFFs.BlockLength();
114 if (aNbFFs > aBlockLength) {
115 aFFs.SetBlockLength(aNbFFs);
118 for (; myDSIt.More(); myDSIt.Next()) {
119 myDSIt.Current(n1, n2, bJustAdd);
121 bIsComputed=myIntrPool->IsComputed(n1, n2);
136 bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith);
140 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
143 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
144 anIndexIn=aFFs.Append(anInterf);
145 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
150 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
151 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
154 bToApproxC3d = mySectionAttribute.Approximation();
155 bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1();
156 bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2();
160 IntTools_FaceFace aFF;
162 aFF.SetParameters (bToApproxC3d, bToApproxC2dOnS1,
163 bToApproxC2dOnS2, anApproxTol);
165 aFF.Perform(aF1, aF2);
167 bIsDone=aFF.IsDone();
171 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
174 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
175 anIndexIn=aFFs.Append(anInterf);
176 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
181 aTolR3D=aFF.TolReached3d();
182 aTolR2D=aFF.TolReached2d();
183 if (aTolR3D < 1.e-7){
187 aFF.PrepareLines3D();
189 const IntTools_SequenceOfCurves& aCvsX=aFF.Lines();
190 const IntTools_SequenceOfPntOn2Faces& aPntsX=aFF.Points();
192 aNbCurves=aCvsX.Length();
193 aNbPoints=aPntsX.Length();
195 if (!aNbCurves && !aNbPoints) {
196 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
197 anIndexIn=aFFs.Append(anInterf);
198 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
203 BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvsX, aPntsX);
204 anIndexIn=aFFs.Append(anInterf);
205 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
208 }// for (; myDSIt.More(); myDSIt.Next())
210 myIsDone=Standard_True;
212 //=======================================================================
213 // function: MakeBlocks
215 //=======================================================================
216 void NMTTools_PaveFiller::MakeBlocks()
218 myIsDone=Standard_False;
220 Standard_Boolean bIsExistingPaveBlock, bIsValidIn2D;
221 Standard_Integer i, aNbFFs, nF1, nF2, aBid=0;
222 Standard_Integer nV1, nV2, j, aNbCurves;
223 Standard_Real aTolR3D, aTol2D, aT1, aT2, aTolPPC=Precision::PConfusion();
224 NMTTools_IndexedDataMapOfShapePaveBlock aMEPB;
225 BooleanOperations_IndexedDataMapOfShapeInteger aMapEI;
226 BOPTools_ListIteratorOfListOfPaveBlock anIt;
228 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
230 // 1. Produce Section Edges from intersection curves
231 // between each pair of faces
233 aNbFFs=aFFs.Extent();
234 for (i=1; i<=aNbFFs; ++i) {
235 BOPTools_SSInterference& aFFi=aFFs(i);
238 aFFi.Indices(nF1, nF2);
239 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
240 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
242 BOPTools_ListOfPaveBlock aLPB, aLPBC;
244 //modified by NIZNHY-PKV Fri Mar 11 15:43:02 2005 f
246 Standard_Integer nFj1, nFj2, nE;
247 TColStd_IndexedMapOfInteger aMFence;
248 BOPTools_ListOfPaveBlock aLPBCx;
250 for (j=1; j<=aNbFFs; ++j) {
251 BOPTools_SSInterference& aFFj=aFFs(j);
252 aFFj.Indices(nFj1, nFj2);
254 if ((nF1==nFj1 && nFj2!=nF2) ||
255 (nF1==nFj2 && nFj1!=nF2) ||
256 (nF2==nFj1 && nFj2!=nF1) ||
257 (nF2==nFj2 && nFj1!=nF1)) {
258 RealSplitsInFace (aBid, nFj1, nFj2, aLPBCx);
259 RealSplitsInFace (aBid, nFj2, nFj1, aLPBCx);
260 RealSplitsOnFace (aBid, nFj1, nFj2, aLPBCx);
264 anIt.Initialize(aLPBCx);
265 for (; anIt.More(); anIt.Next()) {
266 const BOPTools_PaveBlock& aPBCx=anIt.Value();
269 if (!aMFence.Contains(nE)) {
276 //modified by NIZNHY-PKV Fri Apr 1 09:49:57 2005t
278 RealSplitsInFace (aBid, nF1, nF2, aLPB);
279 RealSplitsInFace (aBid, nF2, nF1, aLPB);
280 RealSplitsOnFace (aBid, nF1, nF2, aLPB);
282 anIt.Initialize(aLPB);
283 for (; anIt.More(); anIt.Next()) {
284 const BOPTools_PaveBlock& aPB=anIt.Value();
285 aFFi.AppendBlock(aPB);
288 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
289 aNbCurves=aSCvs.Length();
294 aTolR3D=aFFi.TolR3D();
295 aTol2D=(aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D;
297 BOPTools_PaveSet aPSF;
299 //modified by NIZNHY-PKV Fri Apr 1 10:53:09 2005f
300 PrepareSetForFace (nF1, nF2, aLPBC, aPSF);
301 //PrepareSetForFace (nF1, nF2, aPSF);
302 //modified by NIZNHY-PKV Thu Mar 31 16:16:47 2005t
304 // Put Paves On Curves
305 for (j=1; j<=aNbCurves; ++j) {
306 BOPTools_Curve& aBC=aSCvs(j);
308 const IntTools_Curve& aC=aBC.Curve();
309 Handle (Geom_Curve) aC3D= aC.Curve();
311 PutPaveOnCurve (aPSF, aTolR3D, aBC);
314 // Put bounding paves on curves
315 for (j=1; j<=aNbCurves; ++j) {
316 BOPTools_Curve& aBC=aSCvs(j);
317 PutBoundPaveOnCurve (aBC, aFFi);
320 // Pave Blocks on Curves
321 for (j=1; j<=aNbCurves; ++j) {
322 BOPTools_Curve& aBC=aSCvs(j);
323 const IntTools_Curve& aIC= aBC.Curve();
324 BOPTools_PaveSet& aPaveSet=aBC.Set();
326 BOPTools_PaveBlockIterator aPBIter(0, aPaveSet);
327 for (; aPBIter.More(); aPBIter.Next()) {
328 BOPTools_PaveBlock& aPBNew=aPBIter.Value();
329 aPBNew.SetCurve(aIC);
330 aPBNew.SetFace1(nF1);
331 aPBNew.SetFace2(nF2);
333 nV1=aPBNew.Pave1().Index();
334 nV2=aPBNew.Pave2().Index();
335 aT1=aPBNew.Pave1().Param();
336 aT2=aPBNew.Pave2().Param();
338 if((nV1==nV2) && (Abs(aT2 - aT1) < aTolPPC)) {
342 //modified by NIZNHY-PKV Fri Apr 1 09:56:11 2005f
344 const BOPTools_ListOfPaveBlock& aLPBFF=aFFi.PaveBlocks();
345 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPBFF, aTolR3D);
346 //bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aFFi);
347 if (bIsExistingPaveBlock) {
351 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPBC, aTolR3D);
352 if (bIsExistingPaveBlock) {
355 //modified by NIZNHY-PKV Fri Apr 1 09:56:14 2005t
356 // Checking of validity in 2D
358 bIsValidIn2D=myContext.IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D);
363 //aBC.AppendNewBlock(aPBNew);
368 const TopoDS_Vertex& aV1=TopoDS::Vertex(myDS->Shape(nV1));
369 const TopoDS_Vertex& aV2=TopoDS::Vertex(myDS->Shape(nV2));
371 BOPTools_Tools::MakeSectEdge (aIC, aV1, aT1, aV2, aT2, aES);
374 Standard_Real aTolR2D;
376 aTolR2D=aFFi.TolR2D();
377 Handle(Geom2d_Curve) aC2D1=aIC.FirstCurve2d();
378 Handle(Geom2d_Curve) aC2D2=aIC.SecondCurve2d();
380 NMTTools_Tools::MakePCurve(aES, aF1, aC2D1, aTolR2D);
381 NMTTools_Tools::MakePCurve(aES, aF2, aC2D2, aTolR2D);
384 aMEPB.Add(aES, aPBNew);
387 } // end of for (j=1; j<=aNbCurves; ++j)
388 }// for (i=1; i<=aNbFFs; ++i)
389 //=============================================================
391 // II. Post treatment
393 // Input data: aMEPB, aMapEI
394 // Result : section edges in myDS
396 Standard_Integer aNbSE;
398 aNbSE=aMEPB.Extent();
400 // there is nothing to do here
405 TopoDS_Compound aCompound;
407 // 1. Make compound from SE
408 aBB.MakeCompound(aCompound);
409 for (i=1; i<=aNbSE; ++i) {
410 const TopoDS_Shape& aSE=aMEPB.FindKey(i);
411 aBB.Add(aCompound, aSE);
415 // 2. Intersect SE using auxiliary Filler
416 NMTDS_ShapesDataStructure tDS;
418 tDS.SetCompositeShape(aCompound);
421 BOPTools_InterferencePool tIP(tDS);
422 NMTTools_PaveFiller tPF(tIP);
427 tPF.PerformNewVertices();
430 tPF.myPavePool.Resize (tPF.myNbEdges);
438 tPF.myCommonBlockPool.Resize (tPF.myNbEdges);
439 tPF.mySplitShapesPool.Resize (tPF.myNbEdges);
440 tPF.myPavePoolNew .Resize (tPF.myNbEdges);
442 tPF.PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE);
443 tPF.PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE);
447 tPF.RefinePavePool ();
449 tPF.myPavePoolNew.Destroy();
451 tPF.MakeSplitEdges();
452 tPF.UpdateCommonBlocks();
454 // 3. Treatment of the result of intersection
456 Standard_Integer aNbOld, aNbLines, aNbPB, mV1, mV2, nE, mE, iFF;
457 TopAbs_ShapeEnum aType;
458 BOPTools_ListIteratorOfListOfPaveBlock aIt;
459 BOPTColStd_IndexedDataMapOfIntegerInteger aMNewOld;
461 const BOPTools_SplitShapesPool& aSSP=tPF.mySplitShapesPool;
462 const NMTTools_CommonBlockPool& aCBP=tPF.myCommonBlockPool;
464 aNbLines=tDS.NumberOfInsertedShapes();
465 aNbOld=tDS.NumberOfShapesOfTheObject();
467 // 3.1 Links between indices in tDS and DS (kept in aMNewOld)
469 // 3.1.1.Old vertices [ links ]
470 for (i=1; i<=aNbOld; ++i) {
471 const TopoDS_Shape& aV=tDS.Shape(i);
472 aType=aV.ShapeType();
473 if (aType!=TopAbs_VERTEX) {
477 for (j=1; j<=aNbSE; ++j) {
478 const BOPTools_PaveBlock& aPBSE=aMEPB(j);
479 nV1=aPBSE.Pave1().Index();
480 const TopoDS_Shape& aV1=myDS->Shape(nV1);
481 if (aV1.IsSame(aV)) {
482 aMNewOld.Add(i, nV1);
485 nV2=aPBSE.Pave2().Index();
486 const TopoDS_Shape& aV2=myDS->Shape(nV2);
487 if (aV2.IsSame(aV)) {
488 aMNewOld.Add(i, nV2);
494 // 3.1.2. New vertices [ links ]
495 i=tDS.NumberOfSourceShapes()+1;
496 for (; i<=aNbLines; ++i) {
497 const TopoDS_Shape& aV=tDS.Shape(i);
498 aType=aV.ShapeType();
499 if (aType!=TopAbs_VERTEX) {
503 // Insert new vertex in myDS
504 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
505 myDS->InsertShapeAndAncestorsSuccessors(aV, anASSeq);
506 nV1=myDS->NumberOfInsertedShapes();
508 aMNewOld.Add(i, nV1);
511 // 3.2. Treatment of section edges (SE)
512 for (i=1; i<=aNbOld; ++i) {
513 const TopoDS_Shape& aE=tDS.Shape(i);
514 aType=aE.ShapeType();
515 if (aType!=TopAbs_EDGE) {
519 // block of section edge that we already have for this SE
520 BOPTools_PaveBlock& aPBSE=aMEPB.ChangeFromKey(aE);
522 // Corresponding FF-interference
523 iFF=aMapEI.FindFromKey(aE);
524 BOPTools_SSInterference& aFFi=aFFs(iFF);
525 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
527 BOPTools_Curve& aBC=aSCvs(1);
529 const BOPTools_ListOfPaveBlock& aLPB=aSSP(tDS.RefEdge(i));
533 // no pave blocks -> use aPBSE and whole edge aE
534 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
536 nV1=aPBSE.Pave1().Index();
537 const TopoDS_Shape& aV1=myDS->Shape(nV1);
538 nV2=aPBSE.Pave2().Index();
539 const TopoDS_Shape& aV2=myDS->Shape(nV2);
541 anASSeq.SetNewSuccessor(nV1);
542 anASSeq.SetNewOrientation(aV1.Orientation());
543 anASSeq.SetNewSuccessor(nV2);
544 anASSeq.SetNewOrientation(aV2.Orientation());
546 myDS->InsertShapeAndAncestorsSuccessors(aE, anASSeq);
547 nE=myDS->NumberOfInsertedShapes();
550 aBC.AppendNewBlock(aPBSE);
557 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
558 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
560 const NMTTools_ListOfCommonBlock& aLCB=aCBP(tDS.RefEdge(i));
561 NMTTools_CommonBlockAPI aCBAPI(aLCB);
563 aIt.Initialize(aLPB);
564 for (; aIt.More(); aIt.Next()) {
565 BOPTools_PaveBlock aPB=aIt.Value();
567 if (aCBAPI.IsCommonBlock(aPB)) {
568 // it can be Common Block
569 Standard_Real aTolEx;
570 Handle(Geom2d_Curve) aC2D1, aC2D2;
571 TopoDS_Face aF1FWD, aF2FWD;
573 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
574 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
576 aPB=aCB.PaveBlock1();
577 mE=aPB.Edge(); // index of edge in tDS
578 const TopoDS_Edge& aEx=TopoDS::Edge(tDS.Shape(mE));
579 aTolEx=BRep_Tool::Tolerance(aEx);
581 // Commented out by EAP in the frame of PAL9151
583 // Standard_Boolean bHasPCOnF, bFound;
584 // Standard_Integer nF, k, nEOrx, nF1x, nF2x;
585 // Standard_Real aTolEx, aT1x, aT2x;
586 // BOPTools_ListIteratorOfListOfPaveBlock aItPBx;
588 // for (k=0; k<2; ++k) {
589 // nF=(!k) ? nF1 : nF2;
590 // const TopoDS_Face& aF=TopoDS::Face(myDS->Shape(nF));
592 // bHasPCOnF=BOPTools_Tools2D::HasCurveOnSurface(aEx, aF);
597 // bFound=Standard_False;
598 // aItPBx.Initialize(aLPBx);
599 // for (; aItPBx.More(); aItPBx.Next()) {
600 // BOPTools_PaveBlock& aPBx=aIt.Value();
601 // nEOrx=aPBx.OriginalEdge();
602 // const TopoDS_Shape& aEOrx=tDS.Shape(nEOrx);
603 // BOPTools_PaveBlock& aPBSEx=aMEPB.ChangeFromKey(aEOrx);
604 // aT1x=aPBSEx.Pave1().Param();
605 // aT2x=aPBSEx.Pave2().Param();
606 // const IntTools_Curve& aICx=aPBSEx.Curve();
608 // nF1x=aPBSEx.Face1();
609 // nF2x=aPBSEx.Face2();
612 // Handle(Geom2d_Curve) aC2D1x=aICx.FirstCurve2d();
613 // Handle(Geom2d_TrimmedCurve)aC2D1xT =new Geom2d_TrimmedCurve(aC2D1x, aT1x, aT2x);
614 // aBB.UpdateEdge(aEx, aC2D1xT, aF, aTolEx);
620 // Handle(Geom2d_Curve) aC2D2x=aICx.SecondCurve2d();
621 // Handle(Geom2d_TrimmedCurve)aC2D2xT =new Geom2d_TrimmedCurve(aC2D2x, aT1x, aT2x);
622 // aBB.UpdateEdge(aEx, aC2D2xT, aF, aTolEx);
628 // BRepLib::SameParameter(aEx, aTolEx, Standard_True);
632 // The code till the if block end is restored from V2_2_2 revision
635 aF1FWD.Orientation(TopAbs_FORWARD);
636 NMTTools_Tools::MakePCurve(aEx, aF1FWD, aC2D1, aTolEx);
639 aF2FWD.Orientation(TopAbs_FORWARD);
640 NMTTools_Tools::MakePCurve(aEx, aF2FWD, aC2D2, aTolEx);
641 } //if (aCBAPI.IsCommonBlock(aPB))
644 mE=aPB.Edge(); // index of edge in tDS
645 const TopoDS_Shape& aSp=tDS.Shape(mE);
647 const BOPTools_Pave& aPave1=aPB.Pave1();
649 mV1=aPave1.Index(); // index in tDS
650 nV1=aMNewOld.FindFromKey(mV1); // index in myDS
651 const TopoDS_Shape& aV1=myDS->Shape(nV1);
653 const BOPTools_Pave& aPave2=aPB.Pave2();
656 nV2=aMNewOld.FindFromKey(mV2);
657 const TopoDS_Shape& aV2=myDS->Shape(nV2);
659 if (!aMNewOld.Contains(mE)) {
660 // add new SE to the myDS
661 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
663 anASSeq.SetNewSuccessor(nV1);
664 anASSeq.SetNewOrientation(aV1.Orientation());
666 anASSeq.SetNewSuccessor(nV2);
667 anASSeq.SetNewOrientation(aV2.Orientation());
669 myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq);
670 nE=myDS->NumberOfInsertedShapes();
672 aMNewOld.Add(mE, nE);
675 nE=aMNewOld.FindFromKey(mE);
678 BOPTools_PaveBlock aPBx;
679 BOPTools_Pave aP1, aP2;
695 aBC.AppendNewBlock(aPBx);
696 }// for (; aIt.More(); aIt.Next())
697 }// for (i=1; i<=aNbOld; ++i)
699 myIsDone=Standard_True;
701 //=======================================================================
702 // function: MakePCurves
704 //=======================================================================
705 void NMTTools_PaveFiller::MakePCurves()
707 Standard_Integer i, aNb, nF1, nF2, nE;
708 TopoDS_Face aF1FWD, aF2FWD;
709 BOPTools_ListIteratorOfListOfPaveBlock anIt;
711 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
714 for (i=1; i<=aNb; i++) {
715 BOPTools_SSInterference& aFF=aFFs(i);
716 aFF.Indices(nF1, nF2);
718 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
719 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
722 aF1FWD.Orientation(TopAbs_FORWARD);
724 aF2FWD.Orientation(TopAbs_FORWARD);
726 // In, On parts processing
727 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
729 anIt.Initialize(aLPBInOn);
730 for (; anIt.More(); anIt.Next()) {
731 const BOPTools_PaveBlock& aPB=anIt.Value();
733 const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE));
735 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
736 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
740 //modified by NIZNHY-PKV Fri Apr 1 09:36:06 2005f
741 //=======================================================================
742 // function: IsExistingPaveBlock
744 //=======================================================================
745 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
746 const BOPTools_ListOfPaveBlock& aLPBR,
747 const Standard_Real aTolR3D)
749 Standard_Boolean bFlag;
750 Standard_Integer nVNew1, nVNew2, nV1, nV2, iC;
751 BOPTools_ListIteratorOfListOfPaveBlock anIt;
753 bFlag=Standard_False;
754 nVNew1=aPBNew.Pave1().Index();
755 nVNew2=aPBNew.Pave2().Index();
757 anIt.Initialize(aLPBR);
758 for (; anIt.More(); anIt.Next()) {
759 const BOPTools_PaveBlock& aPBR=anIt.Value();
760 nV1=aPBR.Pave1().Index();
761 nV2=aPBR.Pave2().Index();
762 if (nVNew1==nV1 || nVNew1==nV2 || nVNew2==nV1 || nVNew2==nV2) {
764 iC=CheckIntermediatePoint(aPBNew, aPBR, aTolR3D);
772 //modified by NIZNHY-PKV Fri Apr 1 09:36:06 2005t
773 //=======================================================================
774 // function: CheckIntermediatePoint
776 //=======================================================================
777 Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
778 const BOPTools_PaveBlock& aPBR,
779 const Standard_Real aTolC)
782 Standard_Real aT11, aT12, aTM, aTmp;
783 Standard_Integer iVM, nE2;
789 const BOPTools_Pave& aPave11=aPB.Pave1();
790 aT11=aPave11.Param();
792 const BOPTools_Pave& aPave12=aPB.Pave2();
793 aT12=aPave12.Param();
795 aTM=IntTools_Tools::IntermediatePoint (aT11, aT12);
797 const IntTools_Curve& aIC=aPB.Curve();
800 aBB.MakeVertex (aVM, aPM, aTolC);
804 const TopoDS_Edge& aE2=TopoDS::Edge(myDS->GetShape(nE2));
806 iVM=myContext.ComputeVE(aVM, aE2, aTmp);
810 //=======================================================================
811 // function: PutBoundPaveOnCurve
813 //=======================================================================
814 void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC,
815 BOPTools_SSInterference& aFFi)
817 Standard_Boolean bHasBounds, bVF;
818 Standard_Integer nF1, nF2;
819 Standard_Real aT1, aT2, aTolR3D;
822 const IntTools_Curve& aIC=aBC.Curve();
823 bHasBounds=aIC.HasBounds ();
829 aIC.Bounds (aT1, aT2, aP1, aP2);
832 aFFi.Indices(nF1, nF2);
833 aTolR3D=aFFi.TolR3D();
835 const TopoDS_Face& aF1=TopoDS::Face(myDS->GetShape(nF1));
836 const TopoDS_Face& aF2=TopoDS::Face(myDS->GetShape(nF2));
838 bVF=myContext.IsValidPointForFaces (aP1, aF1, aF2, aTolR3D);
840 PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi);
843 bVF=myContext.IsValidPointForFaces (aP2, aF1, aF2, aTolR3D);
845 PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi);
848 //=======================================================================
849 // function: PutBoundPaveOnCurve
851 //=======================================================================
852 void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP,
853 const Standard_Real aT,
855 BOPTools_SSInterference& aFFi)
857 Standard_Boolean bFound1, bFound2;
859 Standard_Real aTolV=aFFi.TolR3D();
861 BOPTools_Pave aPave1, aPave2, aPave;
862 BOPTools_PaveSet& aCPS=aBC.Set();
863 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
864 const IntTools_Curve& aIC=aBC.Curve();
866 bFound1=FindPave(aP, aTolV, aCPS , aPave1);
867 bFound2=FindPave(aP, aTolV, aFFiPS, aPave2);
869 if (!bFound1 && !bFound2) {
870 TopoDS_Vertex aNewVertex;
871 BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex);
873 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
874 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
875 nV=myDS->NumberOfInsertedShapes();
880 aFFiPS.Append(aPave);
882 // Append Techno Vertex to the Curve
883 TColStd_ListOfInteger& aTVs=aBC.TechnoVertices();
887 if (bFound1 && !bFound2) {
891 aFFiPS.Append(aPave);
893 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
894 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
897 if (!bFound1 && bFound2) {
903 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
904 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
907 //=======================================================================
908 // function: FindPave
910 //=======================================================================
911 Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP,
912 const Standard_Real aTolPV,
913 const BOPTools_PaveSet& aPS,
914 BOPTools_Pave& aPave)
917 Standard_Boolean bIsVertex=Standard_False;
919 const BOPTools_ListOfPave& aLP=aPS.Set();
920 BOPTools_ListIteratorOfListOfPave anIt(aLP);
921 for (; anIt.More(); anIt.Next()) {
922 const BOPTools_Pave& aPC=anIt.Value();
924 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
925 bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV);
933 //=======================================================================
934 // function: PrepareSetForFace
936 //=======================================================================
937 void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer nF1,
938 const Standard_Integer nF2,
939 const BOPTools_ListOfPaveBlock& aLPBC,
940 BOPTools_PaveSet& aPSF)
942 Standard_Integer nV1, nV2;
943 TColStd_MapOfInteger aMap;
944 BOPTools_ListOfPaveBlock aLPB1, aLPB2, aLPBS;
945 BOPTools_ListIteratorOfListOfPaveBlock anIt;
947 RealSplitsFace(nF1, aLPB1);
948 anIt.Initialize(aLPB1);
949 for (; anIt.More(); anIt.Next()) {
950 const BOPTools_PaveBlock& aPB=anIt.Value();
954 RealSplitsFace(nF2, aLPB2);
955 anIt.Initialize(aLPB2);
956 for (; anIt.More(); anIt.Next()) {
957 const BOPTools_PaveBlock& aPB=anIt.Value();
961 anIt.Initialize(aLPBC);
962 for (; anIt.More(); anIt.Next()) {
963 const BOPTools_PaveBlock& aPB=anIt.Value();
967 anIt.Initialize(aLPBS);
968 for (; anIt.More(); anIt.Next()) {
969 const BOPTools_PaveBlock& aPB=anIt.Value();
970 const BOPTools_Pave& aPave1=aPB.Pave1();
972 if (!aMap.Contains(nV1)) {
976 const BOPTools_Pave& aPave2=aPB.Pave2();
978 if (!aMap.Contains(nV2)) {
984 //=======================================================================
985 // function: PutPaveOnCurve
987 //=======================================================================
988 void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
989 const Standard_Real aTolR3D,
993 Standard_Boolean bIsVertexOnLine;
995 BOPTools_ListIteratorOfListOfPave anIt;
997 GeomAdaptor_Curve aGAC;
999 const IntTools_Curve& aC=aBC.Curve();
1000 Handle (Geom_Curve) aC3D= aC.Curve();
1002 BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBBC);
1004 const BOPTools_ListOfPave& aLP=aPaveSet.Set();
1005 anIt.Initialize(aLP);
1006 for (; anIt.More(); anIt.Next()) {
1007 const BOPTools_Pave& aPave=anIt.Value();
1010 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
1013 BRepBndLib::Add(aV, aBBV);
1014 if (aBBC.IsOut(aBBV)){
1018 bIsVertexOnLine=myContext.IsVertexOnLine(aV, aC, aTolR3D, aT);
1020 if (bIsVertexOnLine) {
1021 BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface);
1022 BOPTools_PaveSet& aPS=aBC.Set();
1023 aPS.Append(aPaveNew);
1025 BOPTools_Tools::UpdateVertex (aC, aT, aV);
1030 //=======================================================================
1031 // function: IsPairFound
1033 //=======================================================================
1034 Standard_Boolean IsPairFound(const Standard_Integer nF1,
1035 const Standard_Integer nF2,
1036 BOPTools_InterferencePool* myIntrPool,
1037 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
1038 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith)
1040 Standard_Boolean bIsFound;
1042 if (!aMapWhat.Contains(nF1)) {
1043 TColStd_IndexedMapOfInteger aMWhat;
1044 FMapWhat(nF1, myIntrPool, aMWhat);
1045 aMapWhat.Add(nF1, aMWhat);
1048 if (!aMapWith.Contains(nF2)) {
1049 TColStd_IndexedMapOfInteger aMWith;
1050 FMapWith(nF2, myIntrPool, aMWith);
1051 aMapWith.Add(nF2, aMWith);
1054 const TColStd_IndexedMapOfInteger& aMWht=aMapWhat.FindFromKey(nF1);
1055 const TColStd_IndexedMapOfInteger& aMWit=aMapWith.FindFromKey(nF2);
1057 bIsFound=IsFound(aMWht, aMWit);
1061 //=======================================================================
1062 // function: FMapWhat
1064 //=======================================================================
1065 void FMapWhat(const Standard_Integer nF,
1066 BOPTools_InterferencePool* myIntrPool,
1067 TColStd_IndexedMapOfInteger& aMapWhat)
1070 Standard_Integer nE, nV;
1074 BooleanOperations_ShapesDataStructure* myDS=myIntrPool->DS();
1075 BooleanOperations_OnceExplorer aExp(*myDS);
1079 aExp.Init(nF, TopAbs_VERTEX);
1080 for (; aExp.More(); aExp.Next()) {
1085 aExp.Init(nF, TopAbs_EDGE);
1086 for (; aExp.More(); aExp.Next()) {
1091 //=======================================================================
1092 // function: FMapWith
1094 //=======================================================================
1095 void FMapWith(const Standard_Integer nF,
1096 BOPTools_InterferencePool* myIntrPool,
1097 TColStd_IndexedMapOfInteger& aMapWith)
1099 TColStd_IndexedMapOfInteger aMapWhat;
1101 FMapWhat(nF, myIntrPool, aMapWhat);
1104 Standard_Integer i, aNb, anIndex, aWhat, aWith;
1105 BOPTools_ListIteratorOfListOfInterference anIt;
1107 const BOPTools_CArray1OfInterferenceLine& anArrIL= myIntrPool->InterferenceTable();
1109 aNb=aMapWhat.Extent();
1110 for (i=1; i<=aNb; i++) {
1113 const BOPTools_InterferenceLine& aWithLine=anArrIL(aWhat);
1115 const BOPTools_ListOfInterference& aLI=aWithLine.List();
1116 anIt.Initialize(aLI);
1117 for (; anIt.More(); anIt.Next()) {
1118 const BOPTools_Interference& anIntf=anIt.Value();
1119 anIndex=anIntf.Index();
1121 aWith=anIntf.With();
1122 aMapWith.Add(aWith);
1127 //=======================================================================
1128 // function: IsFound
1130 //=======================================================================
1131 Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
1132 const TColStd_IndexedMapOfInteger& aMapWith)
1134 Standard_Boolean bFlag=Standard_False;
1135 Standard_Integer i, aNb, aWhat;
1137 aNb=aMapWhat.Extent();
1138 for (i=1; i<=aNb; i++) {
1140 if (aMapWith.Contains(aWhat)) {
1147 //=======================================================================
1148 // function: PrepareSetForFace
1150 //=======================================================================
1151 void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer nF1,
1152 const Standard_Integer nF2,
1153 BOPTools_PaveSet& aPSF)
1155 Standard_Integer nV1, nV2;
1156 TColStd_MapOfInteger aMap;
1157 BOPTools_ListOfPaveBlock aLPB1, aLPB2;
1158 BOPTools_ListIteratorOfListOfPaveBlock anIt;
1160 RealSplitsFace(nF1, aLPB1);
1161 RealSplitsFace(nF2, aLPB2);
1163 aLPB1.Append(aLPB2);
1165 anIt.Initialize(aLPB1);
1166 for (; anIt.More(); anIt.Next()) {
1167 const BOPTools_PaveBlock& aPB=anIt.Value();
1168 const BOPTools_Pave& aPave1=aPB.Pave1();
1170 if (!aMap.Contains(nV1)) {
1172 aPSF.Append(aPave1);
1174 const BOPTools_Pave& aPave2=aPB.Pave2();
1176 if (!aMap.Contains(nV2)) {
1178 aPSF.Append(aPave2);
1184 //=======================================================================
1185 // function: IsExistingPaveBlock
1187 //=======================================================================
1188 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
1189 const BOPTools_SSInterference& aFFi)
1191 Standard_Boolean bFlag;
1192 Standard_Real aTolR3D;
1194 aTolR3D=aFFi.TolR3D();
1195 const BOPTools_ListOfPaveBlock& aLPBR=aFFi.PaveBlocks();
1197 bFlag=IsExistingPaveBlock(aPBNew, aLPBR, aTolR3D);