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_Boolean bHasPCOnF, bFound;
570 Standard_Integer nF, k, nEOrx, nF1x, nF2x;
571 Standard_Real aTolEx, aT1x, aT2x;
572 BOPTools_ListIteratorOfListOfPaveBlock aItPBx;
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 for (k=0; k<2; ++k) {
584 const TopoDS_Face& aF=TopoDS::Face(myDS->Shape(nF));
586 bHasPCOnF=BOPTools_Tools2D::HasCurveOnSurface(aEx, aF);
591 bFound=Standard_False;
592 aItPBx.Initialize(aLPBx);
593 for (; aItPBx.More(); aItPBx.Next()) {
594 BOPTools_PaveBlock& aPBx=aIt.Value();
595 nEOrx=aPBx.OriginalEdge();
596 const TopoDS_Shape& aEOrx=tDS.Shape(nEOrx);
597 BOPTools_PaveBlock& aPBSEx=aMEPB.ChangeFromKey(aEOrx);
598 aT1x=aPBSEx.Pave1().Param();
599 aT2x=aPBSEx.Pave2().Param();
600 const IntTools_Curve& aICx=aPBSEx.Curve();
606 Handle(Geom2d_Curve) aC2D1x=aICx.FirstCurve2d();
607 Handle(Geom2d_TrimmedCurve)aC2D1xT =new Geom2d_TrimmedCurve(aC2D1x, aT1x, aT2x);
608 aBB.UpdateEdge(aEx, aC2D1xT, aF, aTolEx);
614 Handle(Geom2d_Curve) aC2D2x=aICx.SecondCurve2d();
615 Handle(Geom2d_TrimmedCurve)aC2D2xT =new Geom2d_TrimmedCurve(aC2D2x, aT1x, aT2x);
616 aBB.UpdateEdge(aEx, aC2D2xT, aF, aTolEx);
622 BRepLib::SameParameter(aEx, aTolEx, Standard_True);
625 } //if (aCBAPI.IsCommonBlock(aPB))
628 mE=aPB.Edge(); // index of edge in tDS
629 const TopoDS_Shape& aSp=tDS.Shape(mE);
631 const BOPTools_Pave& aPave1=aPB.Pave1();
633 mV1=aPave1.Index(); // index in tDS
634 nV1=aMNewOld.FindFromKey(mV1); // index in myDS
635 const TopoDS_Shape& aV1=myDS->Shape(nV1);
637 const BOPTools_Pave& aPave2=aPB.Pave2();
640 nV2=aMNewOld.FindFromKey(mV2);
641 const TopoDS_Shape& aV2=myDS->Shape(nV2);
643 if (!aMNewOld.Contains(mE)) {
644 // add new SE to the myDS
645 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
647 anASSeq.SetNewSuccessor(nV1);
648 anASSeq.SetNewOrientation(aV1.Orientation());
650 anASSeq.SetNewSuccessor(nV2);
651 anASSeq.SetNewOrientation(aV2.Orientation());
653 myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq);
654 nE=myDS->NumberOfInsertedShapes();
656 aMNewOld.Add(mE, nE);
659 nE=aMNewOld.FindFromKey(mE);
662 BOPTools_PaveBlock aPBx;
663 BOPTools_Pave aP1, aP2;
679 aBC.AppendNewBlock(aPBx);
680 }// for (; aIt.More(); aIt.Next())
681 }// for (i=1; i<=aNbOld; ++i)
683 myIsDone=Standard_True;
685 //=======================================================================
686 // function: MakePCurves
688 //=======================================================================
689 void NMTTools_PaveFiller::MakePCurves()
691 Standard_Integer i, aNb, nF1, nF2, nE;
692 TopoDS_Face aF1FWD, aF2FWD;
693 BOPTools_ListIteratorOfListOfPaveBlock anIt;
695 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
698 for (i=1; i<=aNb; i++) {
699 BOPTools_SSInterference& aFF=aFFs(i);
700 aFF.Indices(nF1, nF2);
702 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
703 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
706 aF1FWD.Orientation(TopAbs_FORWARD);
708 aF2FWD.Orientation(TopAbs_FORWARD);
710 // In, On parts processing
711 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
713 anIt.Initialize(aLPBInOn);
714 for (; anIt.More(); anIt.Next()) {
715 const BOPTools_PaveBlock& aPB=anIt.Value();
717 const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE));
719 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
720 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
724 //modified by NIZNHY-PKV Fri Apr 1 09:36:06 2005f
725 //=======================================================================
726 // function: IsExistingPaveBlock
728 //=======================================================================
729 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
730 const BOPTools_ListOfPaveBlock& aLPBR,
731 const Standard_Real aTolR3D)
733 Standard_Boolean bFlag;
734 Standard_Integer nVNew1, nVNew2, nV1, nV2, iC;
735 BOPTools_ListIteratorOfListOfPaveBlock anIt;
737 bFlag=Standard_False;
738 nVNew1=aPBNew.Pave1().Index();
739 nVNew2=aPBNew.Pave2().Index();
741 anIt.Initialize(aLPBR);
742 for (; anIt.More(); anIt.Next()) {
743 const BOPTools_PaveBlock& aPBR=anIt.Value();
744 nV1=aPBR.Pave1().Index();
745 nV2=aPBR.Pave2().Index();
746 if (nVNew1==nV1 || nVNew1==nV2 || nVNew2==nV1 || nVNew2==nV2) {
748 iC=CheckIntermediatePoint(aPBNew, aPBR, aTolR3D);
756 //modified by NIZNHY-PKV Fri Apr 1 09:36:06 2005t
757 //=======================================================================
758 // function: CheckIntermediatePoint
760 //=======================================================================
761 Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
762 const BOPTools_PaveBlock& aPBR,
763 const Standard_Real aTolC)
766 Standard_Real aT11, aT12, aTM, aTmp;
767 Standard_Integer iVM, nE2;
773 const BOPTools_Pave& aPave11=aPB.Pave1();
774 aT11=aPave11.Param();
776 const BOPTools_Pave& aPave12=aPB.Pave2();
777 aT12=aPave12.Param();
779 aTM=IntTools_Tools::IntermediatePoint (aT11, aT12);
781 const IntTools_Curve& aIC=aPB.Curve();
784 aBB.MakeVertex (aVM, aPM, aTolC);
788 const TopoDS_Edge& aE2=TopoDS::Edge(myDS->GetShape(nE2));
790 iVM=myContext.ComputeVE(aVM, aE2, aTmp);
794 //=======================================================================
795 // function: PutBoundPaveOnCurve
797 //=======================================================================
798 void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC,
799 BOPTools_SSInterference& aFFi)
801 Standard_Boolean bHasBounds, bVF;
802 Standard_Integer nF1, nF2;
803 Standard_Real aT1, aT2, aTolR3D;
806 const IntTools_Curve& aIC=aBC.Curve();
807 bHasBounds=aIC.HasBounds ();
813 aIC.Bounds (aT1, aT2, aP1, aP2);
816 aFFi.Indices(nF1, nF2);
817 aTolR3D=aFFi.TolR3D();
819 const TopoDS_Face& aF1=TopoDS::Face(myDS->GetShape(nF1));
820 const TopoDS_Face& aF2=TopoDS::Face(myDS->GetShape(nF2));
822 bVF=myContext.IsValidPointForFaces (aP1, aF1, aF2, aTolR3D);
824 PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi);
827 bVF=myContext.IsValidPointForFaces (aP2, aF1, aF2, aTolR3D);
829 PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi);
832 //=======================================================================
833 // function: PutBoundPaveOnCurve
835 //=======================================================================
836 void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP,
837 const Standard_Real aT,
839 BOPTools_SSInterference& aFFi)
841 Standard_Boolean bFound1, bFound2;
843 Standard_Real aTolV=aFFi.TolR3D();
845 BOPTools_Pave aPave1, aPave2, aPave;
846 BOPTools_PaveSet& aCPS=aBC.Set();
847 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
848 const IntTools_Curve& aIC=aBC.Curve();
850 bFound1=FindPave(aP, aTolV, aCPS , aPave1);
851 bFound2=FindPave(aP, aTolV, aFFiPS, aPave2);
853 if (!bFound1 && !bFound2) {
854 TopoDS_Vertex aNewVertex;
855 BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex);
857 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
858 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
859 nV=myDS->NumberOfInsertedShapes();
864 aFFiPS.Append(aPave);
866 // Append Techno Vertex to the Curve
867 TColStd_ListOfInteger& aTVs=aBC.TechnoVertices();
871 if (bFound1 && !bFound2) {
875 aFFiPS.Append(aPave);
877 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
878 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
881 if (!bFound1 && bFound2) {
887 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
888 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
891 //=======================================================================
892 // function: FindPave
894 //=======================================================================
895 Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP,
896 const Standard_Real aTolPV,
897 const BOPTools_PaveSet& aPS,
898 BOPTools_Pave& aPave)
901 Standard_Boolean bIsVertex=Standard_False;
903 const BOPTools_ListOfPave& aLP=aPS.Set();
904 BOPTools_ListIteratorOfListOfPave anIt(aLP);
905 for (; anIt.More(); anIt.Next()) {
906 const BOPTools_Pave& aPC=anIt.Value();
908 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
909 bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV);
917 //=======================================================================
918 // function: PrepareSetForFace
920 //=======================================================================
921 void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer nF1,
922 const Standard_Integer nF2,
923 const BOPTools_ListOfPaveBlock& aLPBC,
924 BOPTools_PaveSet& aPSF)
926 Standard_Integer nV1, nV2;
927 TColStd_MapOfInteger aMap;
928 BOPTools_ListOfPaveBlock aLPB1, aLPB2, aLPBS;
929 BOPTools_ListIteratorOfListOfPaveBlock anIt;
931 RealSplitsFace(nF1, aLPB1);
932 anIt.Initialize(aLPB1);
933 for (; anIt.More(); anIt.Next()) {
934 const BOPTools_PaveBlock& aPB=anIt.Value();
938 RealSplitsFace(nF2, aLPB2);
939 anIt.Initialize(aLPB2);
940 for (; anIt.More(); anIt.Next()) {
941 const BOPTools_PaveBlock& aPB=anIt.Value();
945 anIt.Initialize(aLPBC);
946 for (; anIt.More(); anIt.Next()) {
947 const BOPTools_PaveBlock& aPB=anIt.Value();
951 anIt.Initialize(aLPBS);
952 for (; anIt.More(); anIt.Next()) {
953 const BOPTools_PaveBlock& aPB=anIt.Value();
954 const BOPTools_Pave& aPave1=aPB.Pave1();
956 if (!aMap.Contains(nV1)) {
960 const BOPTools_Pave& aPave2=aPB.Pave2();
962 if (!aMap.Contains(nV2)) {
968 //=======================================================================
969 // function: PutPaveOnCurve
971 //=======================================================================
972 void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
973 const Standard_Real aTolR3D,
977 Standard_Boolean bIsVertexOnLine;
979 BOPTools_ListIteratorOfListOfPave anIt;
981 GeomAdaptor_Curve aGAC;
983 const IntTools_Curve& aC=aBC.Curve();
984 Handle (Geom_Curve) aC3D= aC.Curve();
986 BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBBC);
988 const BOPTools_ListOfPave& aLP=aPaveSet.Set();
989 anIt.Initialize(aLP);
990 for (; anIt.More(); anIt.Next()) {
991 const BOPTools_Pave& aPave=anIt.Value();
994 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
997 BRepBndLib::Add(aV, aBBV);
998 if (aBBC.IsOut(aBBV)){
1002 bIsVertexOnLine=myContext.IsVertexOnLine(aV, aC, aTolR3D, aT);
1004 if (bIsVertexOnLine) {
1005 BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface);
1006 BOPTools_PaveSet& aPS=aBC.Set();
1007 aPS.Append(aPaveNew);
1009 BOPTools_Tools::UpdateVertex (aC, aT, aV);
1014 //=======================================================================
1015 // function: IsPairFound
1017 //=======================================================================
1018 Standard_Boolean IsPairFound(const Standard_Integer nF1,
1019 const Standard_Integer nF2,
1020 BOPTools_InterferencePool* myIntrPool,
1021 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
1022 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith)
1024 Standard_Boolean bIsFound;
1026 if (!aMapWhat.Contains(nF1)) {
1027 TColStd_IndexedMapOfInteger aMWhat;
1028 FMapWhat(nF1, myIntrPool, aMWhat);
1029 aMapWhat.Add(nF1, aMWhat);
1032 if (!aMapWith.Contains(nF2)) {
1033 TColStd_IndexedMapOfInteger aMWith;
1034 FMapWith(nF2, myIntrPool, aMWith);
1035 aMapWith.Add(nF2, aMWith);
1038 const TColStd_IndexedMapOfInteger& aMWht=aMapWhat.FindFromKey(nF1);
1039 const TColStd_IndexedMapOfInteger& aMWit=aMapWith.FindFromKey(nF2);
1041 bIsFound=IsFound(aMWht, aMWit);
1045 //=======================================================================
1046 // function: FMapWhat
1048 //=======================================================================
1049 void FMapWhat(const Standard_Integer nF,
1050 BOPTools_InterferencePool* myIntrPool,
1051 TColStd_IndexedMapOfInteger& aMapWhat)
1054 Standard_Integer nE, nV;
1058 BooleanOperations_ShapesDataStructure* myDS=myIntrPool->DS();
1059 BooleanOperations_OnceExplorer aExp(*myDS);
1063 aExp.Init(nF, TopAbs_VERTEX);
1064 for (; aExp.More(); aExp.Next()) {
1069 aExp.Init(nF, TopAbs_EDGE);
1070 for (; aExp.More(); aExp.Next()) {
1075 //=======================================================================
1076 // function: FMapWith
1078 //=======================================================================
1079 void FMapWith(const Standard_Integer nF,
1080 BOPTools_InterferencePool* myIntrPool,
1081 TColStd_IndexedMapOfInteger& aMapWith)
1083 TColStd_IndexedMapOfInteger aMapWhat;
1085 FMapWhat(nF, myIntrPool, aMapWhat);
1088 Standard_Integer i, aNb, anIndex, aWhat, aWith;
1089 BOPTools_ListIteratorOfListOfInterference anIt;
1091 const BOPTools_CArray1OfInterferenceLine& anArrIL= myIntrPool->InterferenceTable();
1093 aNb=aMapWhat.Extent();
1094 for (i=1; i<=aNb; i++) {
1097 const BOPTools_InterferenceLine& aWithLine=anArrIL(aWhat);
1099 const BOPTools_ListOfInterference& aLI=aWithLine.List();
1100 anIt.Initialize(aLI);
1101 for (; anIt.More(); anIt.Next()) {
1102 const BOPTools_Interference& anIntf=anIt.Value();
1103 anIndex=anIntf.Index();
1105 aWith=anIntf.With();
1106 aMapWith.Add(aWith);
1111 //=======================================================================
1112 // function: IsFound
1114 //=======================================================================
1115 Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
1116 const TColStd_IndexedMapOfInteger& aMapWith)
1118 Standard_Boolean bFlag=Standard_False;
1119 Standard_Integer i, aNb, aWhat;
1121 aNb=aMapWhat.Extent();
1122 for (i=1; i<=aNb; i++) {
1124 if (aMapWith.Contains(aWhat)) {
1131 //=======================================================================
1132 // function: PrepareSetForFace
1134 //=======================================================================
1135 void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer nF1,
1136 const Standard_Integer nF2,
1137 BOPTools_PaveSet& aPSF)
1139 Standard_Integer nV1, nV2;
1140 TColStd_MapOfInteger aMap;
1141 BOPTools_ListOfPaveBlock aLPB1, aLPB2;
1142 BOPTools_ListIteratorOfListOfPaveBlock anIt;
1144 RealSplitsFace(nF1, aLPB1);
1145 RealSplitsFace(nF2, aLPB2);
1147 aLPB1.Append(aLPB2);
1149 anIt.Initialize(aLPB1);
1150 for (; anIt.More(); anIt.Next()) {
1151 const BOPTools_PaveBlock& aPB=anIt.Value();
1152 const BOPTools_Pave& aPave1=aPB.Pave1();
1154 if (!aMap.Contains(nV1)) {
1156 aPSF.Append(aPave1);
1158 const BOPTools_Pave& aPave2=aPB.Pave2();
1160 if (!aMap.Contains(nV2)) {
1162 aPSF.Append(aPave2);
1168 //=======================================================================
1169 // function: IsExistingPaveBlock
1171 //=======================================================================
1172 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
1173 const BOPTools_SSInterference& aFFi)
1175 Standard_Boolean bFlag;
1176 Standard_Real aTolR3D;
1178 aTolR3D=aFFi.TolR3D();
1179 const BOPTools_ListOfPaveBlock& aLPBR=aFFi.PaveBlocks();
1181 bFlag=IsExistingPaveBlock(aPBNew, aLPBR, aTolR3D);