1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: NMTTools_PaveFiller_6.cxx
21 // Created: Fri Dec 19 10:27:31 2003
22 // Author: Peter KURNEV
25 #include <NMTTools_PaveFiller.ixx>
27 #include <Precision.hxx>
29 #include <TColStd_IndexedMapOfInteger.hxx>
30 #include <TColStd_MapOfInteger.hxx>
32 #include <Geom2d_Curve.hxx>
33 #include <Geom2d_TrimmedCurve.hxx>
34 #include <Geom_TrimmedCurve.hxx>
36 #include <GeomAdaptor_Curve.hxx>
37 #include <BndLib_Add3dCurve.hxx>
39 #include <TopoDS_Face.hxx>
41 #include <TopoDS_Compound.hxx>
45 #include <BRep_Builder.hxx>
46 #include <BRep_Tool.hxx>
47 #include <BRepBndLib.hxx>
48 #include <BRepLib.hxx>
50 #include <TopTools_IndexedMapOfShape.hxx>
52 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
53 #include <BOPTColStd_IndexedDataMapOfIntegerInteger.hxx>
55 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
56 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
57 #include <BooleanOperations_OnceExplorer.hxx>
58 #include <BooleanOperations_ShapesDataStructure.hxx>
60 #include <IntTools_SequenceOfPntOn2Faces.hxx>
61 #include <IntTools_SequenceOfCurves.hxx>
62 #include <IntTools_FaceFace.hxx>
63 #include <IntTools_Tools.hxx>
65 #include <BOPTools_CArray1OfSSInterference.hxx>
66 #include <BOPTools_ListIteratorOfListOfInterference.hxx>
67 #include <BOPTools_CArray1OfInterferenceLine.hxx>
68 #include <BOPTools_InterferenceLine.hxx>
69 #include <BOPTools_ListOfInterference.hxx>
70 #include <BOPTools_Interference.hxx>
71 #include <BOPTools_InterferencePool.hxx>
72 #include <BOPTools_SSInterference.hxx>
73 #include <BOPTools_ListOfPaveBlock.hxx>
74 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
75 #include <BOPTools_PaveBlock.hxx>
76 #include <BOPTools_ListIteratorOfListOfPave.hxx>
77 #include <BOPTools_Tools.hxx>
78 #include <BOPTools_PaveBlockIterator.hxx>
79 #include <BOPTools_Tools2D.hxx>
81 #include <NMTDS_ShapesDataStructure.hxx>
82 #include <NMTTools_IndexedDataMapOfShapePaveBlock.hxx>
83 #include <NMTTools_CommonBlockAPI.hxx>
84 #include <NMTTools_Tools.hxx>
87 Standard_Boolean IsPairFound(const Standard_Integer nF1,
88 const Standard_Integer nF2,
89 BOPTools_InterferencePool* myIntrPool,
90 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
91 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith);
94 void FMapWhat(const Standard_Integer nF,
95 BOPTools_InterferencePool* myIntrPool,
96 TColStd_IndexedMapOfInteger& aMapWhat);
98 void FMapWith(const Standard_Integer nF,
99 BOPTools_InterferencePool* myIntrPool,
100 TColStd_IndexedMapOfInteger& aMapWith);
102 Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
103 const TColStd_IndexedMapOfInteger& aMapWith);
106 //=======================================================================
107 // function: PerformFF
109 //=======================================================================
110 void NMTTools_PaveFiller::PerformFF()
112 myIsDone=Standard_False;
114 Standard_Boolean bIsFound, bJustAdd, bIsComputed;
115 Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs;
116 Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone;
117 Standard_Integer aNbCurves, aNbPoints;
118 Standard_Real anApproxTol, aTolR3D, aTolR2D;
119 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith;
120 IntTools_SequenceOfPntOn2Faces aPnts;
121 IntTools_SequenceOfCurves aCvs;
122 BooleanOperations_KindOfInterference aTypeFF=BooleanOperations_SurfaceSurface;
124 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
126 // F/F Interferences [BooleanOperations_SurfaceSurface]
127 myDSIt.Initialize(TopAbs_FACE, TopAbs_FACE);
129 // BlockLength correction
130 aNbFFs=ExpectedPoolLength();
131 aBlockLength=aFFs.BlockLength();
132 if (aNbFFs > aBlockLength) {
133 aFFs.SetBlockLength(aNbFFs);
136 for (; myDSIt.More(); myDSIt.Next()) {
137 myDSIt.Current(n1, n2, bJustAdd);
139 bIsComputed=myIntrPool->IsComputed(n1, n2);
154 bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith);
158 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
161 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
162 anIndexIn=aFFs.Append(anInterf);
163 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
168 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
169 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
172 bToApproxC3d = mySectionAttribute.Approximation();
173 bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1();
174 bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2();
178 IntTools_FaceFace aFF;
180 aFF.SetParameters (bToApproxC3d, bToApproxC2dOnS1,
181 bToApproxC2dOnS2, anApproxTol);
183 aFF.Perform(aF1, aF2);
185 bIsDone=aFF.IsDone();
189 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
192 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
193 anIndexIn=aFFs.Append(anInterf);
194 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
199 aTolR3D=aFF.TolReached3d();
200 aTolR2D=aFF.TolReached2d();
201 if (aTolR3D < 1.e-7){
205 aFF.PrepareLines3D();
207 const IntTools_SequenceOfCurves& aCvsX=aFF.Lines();
208 const IntTools_SequenceOfPntOn2Faces& aPntsX=aFF.Points();
210 aNbCurves=aCvsX.Length();
211 aNbPoints=aPntsX.Length();
213 if (!aNbCurves && !aNbPoints) {
214 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
215 anIndexIn=aFFs.Append(anInterf);
216 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
221 BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvsX, aPntsX);
222 anIndexIn=aFFs.Append(anInterf);
223 myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
226 }// for (; myDSIt.More(); myDSIt.Next())
228 myIsDone=Standard_True;
230 //=======================================================================
231 // function: MakeBlocks
233 //=======================================================================
234 void NMTTools_PaveFiller::MakeBlocks()
236 myIsDone=Standard_False;
238 Standard_Boolean bIsExistingPaveBlock, bIsValidIn2D;
239 Standard_Integer i, aNbFFs, nF1, nF2, aBid=0;
240 Standard_Integer nV1, nV2, j, aNbCurves;
241 Standard_Real aTolR3D, aTol2D, aT1, aT2, aTolPPC=Precision::PConfusion();
242 NMTTools_IndexedDataMapOfShapePaveBlock aMEPB;
243 BooleanOperations_IndexedDataMapOfShapeInteger aMapEI;
244 BOPTools_ListIteratorOfListOfPaveBlock anIt;
246 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
248 // 1. Produce Section Edges from intersection curves
249 // between each pair of faces
251 aNbFFs=aFFs.Extent();
252 for (i=1; i<=aNbFFs; ++i) {
253 BOPTools_SSInterference& aFFi=aFFs(i);
256 aFFi.Indices(nF1, nF2);
257 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
258 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
260 BOPTools_ListOfPaveBlock aLPB, aLPBC;
263 Standard_Integer nFj1, nFj2, nE;
264 TColStd_IndexedMapOfInteger aMFence;
265 BOPTools_ListOfPaveBlock aLPBCx;
267 for (j=1; j<=aNbFFs; ++j) {
268 BOPTools_SSInterference& aFFj=aFFs(j);
269 aFFj.Indices(nFj1, nFj2);
271 if ((nF1==nFj1 && nFj2!=nF2) ||
272 (nF1==nFj2 && nFj1!=nF2) ||
273 (nF2==nFj1 && nFj2!=nF1) ||
274 (nF2==nFj2 && nFj1!=nF1)) {
275 RealSplitsInFace (aBid, nFj1, nFj2, aLPBCx);
276 RealSplitsInFace (aBid, nFj2, nFj1, aLPBCx);
277 RealSplitsOnFace (aBid, nFj1, nFj2, aLPBCx);
281 anIt.Initialize(aLPBCx);
282 for (; anIt.More(); anIt.Next()) {
283 const BOPTools_PaveBlock& aPBCx=anIt.Value();
286 if (!aMFence.Contains(nE)) {
294 RealSplitsInFace (aBid, nF1, nF2, aLPB);
295 RealSplitsInFace (aBid, nF2, nF1, aLPB);
296 RealSplitsOnFace (aBid, nF1, nF2, aLPB);
298 anIt.Initialize(aLPB);
299 for (; anIt.More(); anIt.Next()) {
300 const BOPTools_PaveBlock& aPB=anIt.Value();
301 aFFi.AppendBlock(aPB);
304 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
305 aNbCurves=aSCvs.Length();
310 aTolR3D=aFFi.TolR3D();
311 aTol2D=(aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D;
313 BOPTools_PaveSet aPSF;
315 PrepareSetForFace (nF1, nF2, aLPBC, aPSF);
316 //PrepareSetForFace (nF1, nF2, aPSF);
318 // Put Paves On Curves
319 for (j=1; j<=aNbCurves; ++j) {
320 BOPTools_Curve& aBC=aSCvs(j);
322 const IntTools_Curve& aC=aBC.Curve();
323 Handle (Geom_Curve) aC3D= aC.Curve();
325 PutPaveOnCurve (aPSF, aTolR3D, aBC);
328 // Put bounding paves on curves
329 for (j=1; j<=aNbCurves; ++j) {
330 BOPTools_Curve& aBC=aSCvs(j);
331 PutBoundPaveOnCurve (aBC, aFFi);
334 // Pave Blocks on Curves
335 for (j=1; j<=aNbCurves; ++j) {
336 BOPTools_Curve& aBC=aSCvs(j);
337 const IntTools_Curve& aIC= aBC.Curve();
338 BOPTools_PaveSet& aPaveSet=aBC.Set();
340 BOPTools_PaveBlockIterator aPBIter(0, aPaveSet);
341 for (; aPBIter.More(); aPBIter.Next()) {
342 BOPTools_PaveBlock& aPBNew=aPBIter.Value();
343 aPBNew.SetCurve(aIC);
344 aPBNew.SetFace1(nF1);
345 aPBNew.SetFace2(nF2);
347 nV1=aPBNew.Pave1().Index();
348 nV2=aPBNew.Pave2().Index();
349 aT1=aPBNew.Pave1().Param();
350 aT2=aPBNew.Pave2().Param();
352 if((nV1==nV2) && (Abs(aT2 - aT1) < aTolPPC)) {
357 const BOPTools_ListOfPaveBlock& aLPBFF=aFFi.PaveBlocks();
358 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPBFF, aTolR3D);
359 //bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aFFi);
360 if (bIsExistingPaveBlock) {
364 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPBC, aTolR3D);
365 if (bIsExistingPaveBlock) {
368 // Checking of validity in 2D
370 bIsValidIn2D=myContext.IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D);
375 //aBC.AppendNewBlock(aPBNew);
380 const TopoDS_Vertex& aV1=TopoDS::Vertex(myDS->Shape(nV1));
381 const TopoDS_Vertex& aV2=TopoDS::Vertex(myDS->Shape(nV2));
383 BOPTools_Tools::MakeSectEdge (aIC, aV1, aT1, aV2, aT2, aES);
386 Standard_Real aTolR2D;
388 aTolR2D=aFFi.TolR2D();
389 Handle(Geom2d_Curve) aC2D1=aIC.FirstCurve2d();
390 Handle(Geom2d_Curve) aC2D2=aIC.SecondCurve2d();
392 NMTTools_Tools::MakePCurve(aES, aF1, aC2D1, aTolR2D);
393 NMTTools_Tools::MakePCurve(aES, aF2, aC2D2, aTolR2D);
396 aMEPB.Add(aES, aPBNew);
399 } // end of for (j=1; j<=aNbCurves; ++j)
400 }// for (i=1; i<=aNbFFs; ++i)
401 //=============================================================
403 // II. Post treatment
405 // Input data: aMEPB, aMapEI
406 // Result : section edges in myDS
408 Standard_Integer aNbSE;
410 aNbSE=aMEPB.Extent();
412 // there is nothing to do here
417 TopoDS_Compound aCompound;
419 // 1. Make compound from SE
420 aBB.MakeCompound(aCompound);
421 for (i=1; i<=aNbSE; ++i) {
422 const TopoDS_Shape& aSE=aMEPB.FindKey(i);
423 aBB.Add(aCompound, aSE);
427 // 2. Intersect SE using auxiliary Filler
428 NMTDS_ShapesDataStructure tDS;
430 tDS.SetCompositeShape(aCompound);
433 BOPTools_InterferencePool tIP(tDS);
434 NMTTools_PaveFiller tPF(tIP);
439 tPF.PerformNewVertices();
442 tPF.myPavePool.Resize (tPF.myNbEdges);
450 tPF.myCommonBlockPool.Resize (tPF.myNbEdges);
451 tPF.mySplitShapesPool.Resize (tPF.myNbEdges);
452 tPF.myPavePoolNew .Resize (tPF.myNbEdges);
454 tPF.PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE);
455 tPF.PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE);
459 tPF.RefinePavePool ();
461 tPF.myPavePoolNew.Destroy();
463 tPF.MakeSplitEdges();
464 tPF.UpdateCommonBlocks();
466 // 3. Treatment of the result of intersection
468 Standard_Integer aNbOld, aNbLines, aNbPB, mV1, mV2, nE, mE, iFF;
469 TopAbs_ShapeEnum aType;
470 BOPTools_ListIteratorOfListOfPaveBlock aIt;
471 BOPTColStd_IndexedDataMapOfIntegerInteger aMNewOld;
473 const BOPTools_SplitShapesPool& aSSP=tPF.mySplitShapesPool;
474 const NMTTools_CommonBlockPool& aCBP=tPF.myCommonBlockPool;
476 aNbLines=tDS.NumberOfInsertedShapes();
477 aNbOld=tDS.NumberOfShapesOfTheObject();
479 // 3.1 Links between indices in tDS and DS (kept in aMNewOld)
481 // 3.1.1.Old vertices [ links ]
482 for (i=1; i<=aNbOld; ++i) {
483 const TopoDS_Shape& aV=tDS.Shape(i);
484 aType=aV.ShapeType();
485 if (aType!=TopAbs_VERTEX) {
489 for (j=1; j<=aNbSE; ++j) {
490 const BOPTools_PaveBlock& aPBSE=aMEPB(j);
491 nV1=aPBSE.Pave1().Index();
492 const TopoDS_Shape& aV1=myDS->Shape(nV1);
493 if (aV1.IsSame(aV)) {
494 aMNewOld.Add(i, nV1);
497 nV2=aPBSE.Pave2().Index();
498 const TopoDS_Shape& aV2=myDS->Shape(nV2);
499 if (aV2.IsSame(aV)) {
500 aMNewOld.Add(i, nV2);
506 // 3.1.2. New vertices [ links ]
507 i=tDS.NumberOfSourceShapes()+1;
508 for (; i<=aNbLines; ++i) {
509 const TopoDS_Shape& aV=tDS.Shape(i);
510 aType=aV.ShapeType();
511 if (aType!=TopAbs_VERTEX) {
515 // Insert new vertex in myDS
516 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
517 myDS->InsertShapeAndAncestorsSuccessors(aV, anASSeq);
518 nV1=myDS->NumberOfInsertedShapes();
520 aMNewOld.Add(i, nV1);
523 // 3.2. Treatment of section edges (SE)
524 for (i=1; i<=aNbOld; ++i) {
525 const TopoDS_Shape& aE=tDS.Shape(i);
526 aType=aE.ShapeType();
527 if (aType!=TopAbs_EDGE) {
531 // block of section edge that we already have for this SE
532 BOPTools_PaveBlock& aPBSE=aMEPB.ChangeFromKey(aE);
534 // Corresponding FF-interference
535 iFF=aMapEI.FindFromKey(aE);
536 BOPTools_SSInterference& aFFi=aFFs(iFF);
537 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
539 BOPTools_Curve& aBC=aSCvs(1);
541 const BOPTools_ListOfPaveBlock& aLPB=aSSP(tDS.RefEdge(i));
545 // no pave blocks -> use aPBSE and whole edge aE
546 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
548 nV1=aPBSE.Pave1().Index();
549 const TopoDS_Shape& aV1=myDS->Shape(nV1);
550 nV2=aPBSE.Pave2().Index();
551 const TopoDS_Shape& aV2=myDS->Shape(nV2);
553 anASSeq.SetNewSuccessor(nV1);
554 anASSeq.SetNewOrientation(aV1.Orientation());
555 anASSeq.SetNewSuccessor(nV2);
556 anASSeq.SetNewOrientation(aV2.Orientation());
558 myDS->InsertShapeAndAncestorsSuccessors(aE, anASSeq);
559 nE=myDS->NumberOfInsertedShapes();
562 aBC.AppendNewBlock(aPBSE);
570 //modified by NIZNHY-PKV Thu Jan 26 10:17:04 2006f
571 //const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
572 //const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
573 //modified by NIZNHY-PKV Thu Jan 26 10:17:08 2006t
575 const NMTTools_ListOfCommonBlock& aLCB=aCBP(tDS.RefEdge(i));
576 NMTTools_CommonBlockAPI aCBAPI(aLCB);
578 aIt.Initialize(aLPB);
579 for (; aIt.More(); aIt.Next()) {
580 BOPTools_PaveBlock aPB=aIt.Value();
582 ////modified by NIZNHY-PKV Thu Jan 26 10:16:36 2006f
583 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
584 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
585 ////modified by NIZNHY-PKV Thu Jan 26 10:16:39 2006t
587 if (aCBAPI.IsCommonBlock(aPB)) {
588 // it can be Common Block
589 Standard_Real aTolEx;
590 Handle(Geom2d_Curve) aC2D1, aC2D2;
591 TopoDS_Face aF1FWD, aF2FWD;
593 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
594 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
596 aPB=aCB.PaveBlock1();
597 mE=aPB.Edge(); // index of edge in tDS
598 const TopoDS_Edge& aEx=TopoDS::Edge(tDS.Shape(mE));
599 aTolEx=BRep_Tool::Tolerance(aEx);
601 // <- Block A was here
604 aF1FWD.Orientation(TopAbs_FORWARD);
605 NMTTools_Tools::MakePCurve(aEx, aF1FWD, aC2D1, aTolEx);
608 aF2FWD.Orientation(TopAbs_FORWARD);
609 NMTTools_Tools::MakePCurve(aEx, aF2FWD, aC2D2, aTolEx);
610 } //if (aCBAPI.IsCommonBlock(aPB))
613 mE=aPB.Edge(); // index of edge in tDS
614 const TopoDS_Shape& aSp=tDS.Shape(mE);
616 const BOPTools_Pave& aPave1=aPB.Pave1();
618 mV1=aPave1.Index(); // index in tDS
619 nV1=aMNewOld.FindFromKey(mV1); // index in myDS
620 const TopoDS_Shape& aV1=myDS->Shape(nV1);
622 const BOPTools_Pave& aPave2=aPB.Pave2();
625 nV2=aMNewOld.FindFromKey(mV2);
626 const TopoDS_Shape& aV2=myDS->Shape(nV2);
628 if (!aMNewOld.Contains(mE)) {
629 // add new SE to the myDS
630 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
632 anASSeq.SetNewSuccessor(nV1);
633 anASSeq.SetNewOrientation(aV1.Orientation());
635 anASSeq.SetNewSuccessor(nV2);
636 anASSeq.SetNewOrientation(aV2.Orientation());
638 myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq);
639 nE=myDS->NumberOfInsertedShapes();
641 aMNewOld.Add(mE, nE);
644 nE=aMNewOld.FindFromKey(mE);
647 BOPTools_PaveBlock aPBx;
648 BOPTools_Pave aP1, aP2;
664 aBC.AppendNewBlock(aPBx);
665 }// for (; aIt.More(); aIt.Next())
666 }// for (i=1; i<=aNbOld; ++i)
668 myIsDone=Standard_True;
670 //=======================================================================
671 // function: MakePCurves
673 //=======================================================================
674 void NMTTools_PaveFiller::MakePCurves()
676 Standard_Integer i, aNb, nF1, nF2, nE;
677 TopoDS_Face aF1FWD, aF2FWD;
678 BOPTools_ListIteratorOfListOfPaveBlock anIt;
680 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
683 for (i=1; i<=aNb; i++) {
684 BOPTools_SSInterference& aFF=aFFs(i);
685 aFF.Indices(nF1, nF2);
687 const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
688 const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
691 aF1FWD.Orientation(TopAbs_FORWARD);
693 aF2FWD.Orientation(TopAbs_FORWARD);
695 // In, On parts processing
696 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
698 anIt.Initialize(aLPBInOn);
699 for (; anIt.More(); anIt.Next()) {
700 const BOPTools_PaveBlock& aPB=anIt.Value();
702 const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE));
704 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
705 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
709 //=======================================================================
710 // function: IsExistingPaveBlock
712 //=======================================================================
713 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
714 const BOPTools_ListOfPaveBlock& aLPBR,
715 const Standard_Real aTolR3D)
717 Standard_Boolean bFlag;
718 Standard_Integer nVNew1, nVNew2, nV1, nV2, iC;
719 BOPTools_ListIteratorOfListOfPaveBlock anIt;
721 bFlag=Standard_False;
722 nVNew1=aPBNew.Pave1().Index();
723 nVNew2=aPBNew.Pave2().Index();
725 anIt.Initialize(aLPBR);
726 for (; anIt.More(); anIt.Next()) {
727 const BOPTools_PaveBlock& aPBR=anIt.Value();
728 nV1=aPBR.Pave1().Index();
729 nV2=aPBR.Pave2().Index();
730 if (nVNew1==nV1 || nVNew1==nV2 || nVNew2==nV1 || nVNew2==nV2) {
732 iC=CheckIntermediatePoint(aPBNew, aPBR, aTolR3D);
740 //=======================================================================
741 // function: CheckIntermediatePoint
743 //=======================================================================
744 Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
745 const BOPTools_PaveBlock& aPBR,
746 const Standard_Real aTolC)
749 Standard_Real aT11, aT12, aTM, aTmp;
750 Standard_Integer iVM, nE2;
756 const BOPTools_Pave& aPave11=aPB.Pave1();
757 aT11=aPave11.Param();
759 const BOPTools_Pave& aPave12=aPB.Pave2();
760 aT12=aPave12.Param();
762 aTM=IntTools_Tools::IntermediatePoint (aT11, aT12);
764 const IntTools_Curve& aIC=aPB.Curve();
767 aBB.MakeVertex (aVM, aPM, aTolC);
771 const TopoDS_Edge& aE2=TopoDS::Edge(myDS->GetShape(nE2));
773 iVM=myContext.ComputeVE(aVM, aE2, aTmp);
777 //=======================================================================
778 // function: PutBoundPaveOnCurve
780 //=======================================================================
781 void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC,
782 BOPTools_SSInterference& aFFi)
784 Standard_Boolean bHasBounds, bVF;
785 Standard_Integer nF1, nF2;
786 Standard_Real aT1, aT2, aTolR3D;
789 const IntTools_Curve& aIC=aBC.Curve();
790 bHasBounds=aIC.HasBounds ();
796 aIC.Bounds (aT1, aT2, aP1, aP2);
799 aFFi.Indices(nF1, nF2);
800 aTolR3D=aFFi.TolR3D();
802 const TopoDS_Face& aF1=TopoDS::Face(myDS->GetShape(nF1));
803 const TopoDS_Face& aF2=TopoDS::Face(myDS->GetShape(nF2));
805 bVF=myContext.IsValidPointForFaces (aP1, aF1, aF2, aTolR3D);
807 PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi);
810 bVF=myContext.IsValidPointForFaces (aP2, aF1, aF2, aTolR3D);
812 PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi);
815 //=======================================================================
816 // function: PutBoundPaveOnCurve
818 //=======================================================================
819 void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP,
820 const Standard_Real aT,
822 BOPTools_SSInterference& aFFi)
824 Standard_Boolean bFound1, bFound2;
826 Standard_Real aTolV=aFFi.TolR3D();
828 BOPTools_Pave aPave1, aPave2, aPave;
829 BOPTools_PaveSet& aCPS=aBC.Set();
830 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
831 const IntTools_Curve& aIC=aBC.Curve();
833 bFound1=FindPave(aP, aTolV, aCPS , aPave1);
834 bFound2=FindPave(aP, aTolV, aFFiPS, aPave2);
836 if (!bFound1 && !bFound2) {
837 TopoDS_Vertex aNewVertex;
838 BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex);
840 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
841 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
842 nV=myDS->NumberOfInsertedShapes();
847 aFFiPS.Append(aPave);
849 // Append Techno Vertex to the Curve
850 TColStd_ListOfInteger& aTVs=aBC.TechnoVertices();
854 if (bFound1 && !bFound2) {
858 aFFiPS.Append(aPave);
860 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
861 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
864 if (!bFound1 && bFound2) {
870 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
871 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
874 //=======================================================================
875 // function: FindPave
877 //=======================================================================
878 Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP,
879 const Standard_Real aTolPV,
880 const BOPTools_PaveSet& aPS,
881 BOPTools_Pave& aPave)
884 Standard_Boolean bIsVertex=Standard_False;
886 const BOPTools_ListOfPave& aLP=aPS.Set();
887 BOPTools_ListIteratorOfListOfPave anIt(aLP);
888 for (; anIt.More(); anIt.Next()) {
889 const BOPTools_Pave& aPC=anIt.Value();
891 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
892 bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV);
900 //=======================================================================
901 // function: PrepareSetForFace
903 //=======================================================================
904 void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer nF1,
905 const Standard_Integer nF2,
906 const BOPTools_ListOfPaveBlock& aLPBC,
907 BOPTools_PaveSet& aPSF)
909 Standard_Integer nV1, nV2;
910 TColStd_MapOfInteger aMap;
911 BOPTools_ListOfPaveBlock aLPB1, aLPB2, aLPBS;
912 BOPTools_ListIteratorOfListOfPaveBlock anIt;
914 RealSplitsFace(nF1, aLPB1);
915 anIt.Initialize(aLPB1);
916 for (; anIt.More(); anIt.Next()) {
917 const BOPTools_PaveBlock& aPB=anIt.Value();
921 RealSplitsFace(nF2, aLPB2);
922 anIt.Initialize(aLPB2);
923 for (; anIt.More(); anIt.Next()) {
924 const BOPTools_PaveBlock& aPB=anIt.Value();
928 anIt.Initialize(aLPBC);
929 for (; anIt.More(); anIt.Next()) {
930 const BOPTools_PaveBlock& aPB=anIt.Value();
934 anIt.Initialize(aLPBS);
935 for (; anIt.More(); anIt.Next()) {
936 const BOPTools_PaveBlock& aPB=anIt.Value();
937 const BOPTools_Pave& aPave1=aPB.Pave1();
939 if (!aMap.Contains(nV1)) {
943 const BOPTools_Pave& aPave2=aPB.Pave2();
945 if (!aMap.Contains(nV2)) {
951 //=======================================================================
952 // function: PutPaveOnCurve
954 //=======================================================================
955 void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
956 const Standard_Real aTolR3D,
960 Standard_Boolean bIsVertexOnLine;
962 BOPTools_ListIteratorOfListOfPave anIt;
964 GeomAdaptor_Curve aGAC;
966 const IntTools_Curve& aC=aBC.Curve();
967 Handle (Geom_Curve) aC3D= aC.Curve();
969 BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBBC);
971 const BOPTools_ListOfPave& aLP=aPaveSet.Set();
972 anIt.Initialize(aLP);
973 for (; anIt.More(); anIt.Next()) {
974 const BOPTools_Pave& aPave=anIt.Value();
977 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
980 BRepBndLib::Add(aV, aBBV);
981 if (aBBC.IsOut(aBBV)){
985 bIsVertexOnLine=myContext.IsVertexOnLine(aV, aC, aTolR3D, aT);
987 if (bIsVertexOnLine) {
988 BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface);
989 BOPTools_PaveSet& aPS=aBC.Set();
990 aPS.Append(aPaveNew);
992 BOPTools_Tools::UpdateVertex (aC, aT, aV);
997 //=======================================================================
998 // function: IsPairFound
1000 //=======================================================================
1001 Standard_Boolean IsPairFound(const Standard_Integer nF1,
1002 const Standard_Integer nF2,
1003 BOPTools_InterferencePool* myIntrPool,
1004 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
1005 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith)
1007 Standard_Boolean bIsFound;
1009 if (!aMapWhat.Contains(nF1)) {
1010 TColStd_IndexedMapOfInteger aMWhat;
1011 FMapWhat(nF1, myIntrPool, aMWhat);
1012 aMapWhat.Add(nF1, aMWhat);
1015 if (!aMapWith.Contains(nF2)) {
1016 TColStd_IndexedMapOfInteger aMWith;
1017 FMapWith(nF2, myIntrPool, aMWith);
1018 aMapWith.Add(nF2, aMWith);
1021 const TColStd_IndexedMapOfInteger& aMWht=aMapWhat.FindFromKey(nF1);
1022 const TColStd_IndexedMapOfInteger& aMWit=aMapWith.FindFromKey(nF2);
1024 bIsFound=IsFound(aMWht, aMWit);
1028 //=======================================================================
1029 // function: FMapWhat
1031 //=======================================================================
1032 void FMapWhat(const Standard_Integer nF,
1033 BOPTools_InterferencePool* myIntrPool,
1034 TColStd_IndexedMapOfInteger& aMapWhat)
1037 Standard_Integer nE, nV;
1041 BooleanOperations_ShapesDataStructure* myDS=myIntrPool->DS();
1042 BooleanOperations_OnceExplorer aExp(*myDS);
1046 aExp.Init(nF, TopAbs_VERTEX);
1047 for (; aExp.More(); aExp.Next()) {
1052 aExp.Init(nF, TopAbs_EDGE);
1053 for (; aExp.More(); aExp.Next()) {
1058 //=======================================================================
1059 // function: FMapWith
1061 //=======================================================================
1062 void FMapWith(const Standard_Integer nF,
1063 BOPTools_InterferencePool* myIntrPool,
1064 TColStd_IndexedMapOfInteger& aMapWith)
1066 TColStd_IndexedMapOfInteger aMapWhat;
1068 FMapWhat(nF, myIntrPool, aMapWhat);
1071 Standard_Integer i, aNb, anIndex, aWhat, aWith;
1072 BOPTools_ListIteratorOfListOfInterference anIt;
1074 const BOPTools_CArray1OfInterferenceLine& anArrIL= myIntrPool->InterferenceTable();
1076 aNb=aMapWhat.Extent();
1077 for (i=1; i<=aNb; i++) {
1080 const BOPTools_InterferenceLine& aWithLine=anArrIL(aWhat);
1082 const BOPTools_ListOfInterference& aLI=aWithLine.List();
1083 anIt.Initialize(aLI);
1084 for (; anIt.More(); anIt.Next()) {
1085 const BOPTools_Interference& anIntf=anIt.Value();
1086 anIndex=anIntf.Index();
1088 aWith=anIntf.With();
1089 aMapWith.Add(aWith);
1094 //=======================================================================
1095 // function: IsFound
1097 //=======================================================================
1098 Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
1099 const TColStd_IndexedMapOfInteger& aMapWith)
1101 Standard_Boolean bFlag=Standard_False;
1102 Standard_Integer i, aNb, aWhat;
1104 aNb=aMapWhat.Extent();
1105 for (i=1; i<=aNb; i++) {
1107 if (aMapWith.Contains(aWhat)) {
1117 // Commented out by EAP in the frame of PAL9151
1119 // Standard_Boolean bHasPCOnF, bFound;
1120 // Standard_Integer nF, k, nEOrx, nF1x, nF2x;
1121 // Standard_Real aTolEx, aT1x, aT2x;
1122 // BOPTools_ListIteratorOfListOfPaveBlock aItPBx;
1124 // for (k=0; k<2; ++k) {
1125 // nF=(!k) ? nF1 : nF2;
1126 // const TopoDS_Face& aF=TopoDS::Face(myDS->Shape(nF));
1128 // bHasPCOnF=BOPTools_Tools2D::HasCurveOnSurface(aEx, aF);
1133 // bFound=Standard_False;
1134 // aItPBx.Initialize(aLPBx);
1135 // for (; aItPBx.More(); aItPBx.Next()) {
1136 // BOPTools_PaveBlock& aPBx=aIt.Value();
1137 // nEOrx=aPBx.OriginalEdge();
1138 // const TopoDS_Shape& aEOrx=tDS.Shape(nEOrx);
1139 // BOPTools_PaveBlock& aPBSEx=aMEPB.ChangeFromKey(aEOrx);
1140 // aT1x=aPBSEx.Pave1().Param();
1141 // aT2x=aPBSEx.Pave2().Param();
1142 // const IntTools_Curve& aICx=aPBSEx.Curve();
1144 // nF1x=aPBSEx.Face1();
1145 // nF2x=aPBSEx.Face2();
1148 // Handle(Geom2d_Curve) aC2D1x=aICx.FirstCurve2d();
1149 // Handle(Geom2d_TrimmedCurve)aC2D1xT =new Geom2d_TrimmedCurve(aC2D1x, aT1x, aT2x);
1150 // aBB.UpdateEdge(aEx, aC2D1xT, aF, aTolEx);
1156 // Handle(Geom2d_Curve) aC2D2x=aICx.SecondCurve2d();
1157 // Handle(Geom2d_TrimmedCurve)aC2D2xT =new Geom2d_TrimmedCurve(aC2D2x, aT1x, aT2x);
1158 // aBB.UpdateEdge(aEx, aC2D2xT, aF, aTolEx);
1164 // BRepLib::SameParameter(aEx, aTolEx, Standard_True);
1168 // The code till the if block end is restored from V2_2_2 revision