1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2014 OPEN CASCADE SAS
3 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5 // EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 // This file is part of Open CASCADE Technology software library.
9 // This library is free software; you can redistribute it and/or modify it under
10 // the terms of the GNU Lesser General Public License version 2.1 as published
11 // by the Free Software Foundation, with special exception defined in the file
12 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13 // distribution for complete text of the license and disclaimer of any warranty.
15 // Alternatively, this file may be used under the terms of Open CASCADE
16 // commercial license or contractual agreement.
18 #include <BOPAlgo_PaveFiller.hxx>
19 #include <Bnd_Box.hxx>
20 #include <BOPAlgo_Alerts.hxx>
21 #include <BOPAlgo_SectionAttribute.hxx>
22 #include <BOPAlgo_Tools.hxx>
23 #include <BOPDS_CommonBlock.hxx>
24 #include <BOPDS_CoupleOfPaveBlocks.hxx>
25 #include <BOPDS_Curve.hxx>
26 #include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
27 #include <BOPDS_DS.hxx>
28 #include <BOPDS_FaceInfo.hxx>
29 #include <BOPDS_Interf.hxx>
30 #include <BOPDS_Iterator.hxx>
31 #include <BOPDS_ListOfPave.hxx>
32 #include <BOPDS_ListOfPaveBlock.hxx>
33 #include <BOPDS_MapOfPaveBlock.hxx>
34 #include <BOPDS_PaveBlock.hxx>
35 #include <BOPDS_Point.hxx>
36 #include <BOPDS_ShapeInfo.hxx>
37 #include <BOPDS_VectorOfCurve.hxx>
38 #include <BOPDS_VectorOfPoint.hxx>
39 #include <BOPTools_AlgoTools.hxx>
40 #include <BOPTools_AlgoTools3D.hxx>
41 #include <BOPTools_Parallel.hxx>
42 #include <BRep_Builder.hxx>
43 #include <BRep_TEdge.hxx>
44 #include <BRep_Tool.hxx>
45 #include <BRepAdaptor_Curve.hxx>
46 #include <BRepAdaptor_Surface.hxx>
47 #include <BRepBndLib.hxx>
48 #include <BRepBuilderAPI_MakeVertex.hxx>
49 #include <BRepLib.hxx>
50 #include <BRepTools.hxx>
51 #include <Geom_Curve.hxx>
52 #include <Geom2d_Curve.hxx>
53 #include <GeomAPI_ProjectPointOnCurve.hxx>
54 #include <GeomAPI_ProjectPointOnSurf.hxx>
56 #include <IntSurf_ListOfPntOn2S.hxx>
57 #include <IntSurf_PntOn2S.hxx>
58 #include <IntTools.hxx>
59 #include <IntTools_Context.hxx>
60 #include <IntTools_Curve.hxx>
61 #include <IntTools_EdgeFace.hxx>
62 #include <IntTools_FaceFace.hxx>
63 #include <IntTools_PntOn2Faces.hxx>
64 #include <IntTools_SequenceOfCurves.hxx>
65 #include <IntTools_SequenceOfPntOn2Faces.hxx>
66 #include <IntTools_ShrunkRange.hxx>
67 #include <IntTools_Tools.hxx>
68 #include <NCollection_Vector.hxx>
69 #include <Precision.hxx>
70 #include <TColStd_ListOfInteger.hxx>
71 #include <TColStd_MapOfInteger.hxx>
73 #include <TopExp_Explorer.hxx>
75 #include <TopoDS_Compound.hxx>
76 #include <TopoDS_Edge.hxx>
77 #include <TopoDS_Face.hxx>
78 #include <TopoDS_Vertex.hxx>
79 #include <TopTools_DataMapOfShapeInteger.hxx>
80 #include <TopTools_ListOfShape.hxx>
83 static Standard_Real ToleranceFF(const BRepAdaptor_Surface& aBAS1,
84 const BRepAdaptor_Surface& aBAS2);
86 /////////////////////////////////////////////////////////////////////////
87 //=======================================================================
88 //class : BOPAlgo_FaceFace
90 //=======================================================================
91 class BOPAlgo_FaceFace :
92 public IntTools_FaceFace,
101 myIF1(-1), myIF2(-1), myTolFF(1.e-7) {
104 virtual ~BOPAlgo_FaceFace() {
107 void SetIndices(const Standard_Integer nF1,
108 const Standard_Integer nF2) {
113 void Indices(Standard_Integer& nF1,
114 Standard_Integer& nF2) const {
119 void SetFaces(const TopoDS_Face& aF1,
120 const TopoDS_Face& aF2) {
125 const TopoDS_Face& Face1()const {
129 const TopoDS_Face& Face2()const {
133 void SetTolFF(const Standard_Real aTolFF) {
137 Standard_Real TolFF() const{
141 void SetFuzzyValue(const Standard_Real theFuzz) {
142 IntTools_FaceFace::SetFuzzyValue(theFuzz);
145 virtual void Perform() {
146 BOPAlgo_Algo::UserBreak();
151 IntTools_FaceFace::Perform(myF1, myF2);
153 catch (Standard_Failure)
155 AddError(new BOPAlgo_AlertIntersectionFailed);
160 Standard_Integer myIF1;
161 Standard_Integer myIF2;
162 Standard_Real myTolFF;
167 //=======================================================================
168 typedef NCollection_Vector
169 <BOPAlgo_FaceFace> BOPAlgo_VectorOfFaceFace;
171 typedef BOPTools_Functor
173 BOPAlgo_VectorOfFaceFace> BOPAlgo_FaceFaceFunctor;
176 <BOPAlgo_FaceFaceFunctor,
177 BOPAlgo_VectorOfFaceFace> BOPAlgo_FaceFaceCnt;
178 /////////////////////////////////////////////////////////////////////////
179 //=======================================================================
180 //function : PerformFF
182 //=======================================================================
183 void BOPAlgo_PaveFiller::PerformFF()
185 myIterator->Initialize(TopAbs_FACE, TopAbs_FACE);
186 Standard_Integer iSize = myIterator->ExpectedLength();
191 BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
192 aFFs.SetIncrement(iSize);
194 // Options for the intersection algorithm
195 Standard_Boolean bApprox = mySectionAttribute.Approximation(),
196 bCompC2D1 = mySectionAttribute.PCurveOnS1(),
197 bCompC2D2 = mySectionAttribute.PCurveOnS2();
198 Standard_Real anApproxTol = 1.e-7;
199 // Post-processing options
200 Standard_Boolean bSplitCurve = Standard_False;
202 // Fence map to store faces with updated FaceInfo structure
203 TColStd_MapOfInteger aMIFence;
204 // Prepare the pairs of faces for intersection
205 BOPAlgo_VectorOfFaceFace aVFaceFace;
206 Standard_Integer nF1, nF2;
208 for (; myIterator->More(); myIterator->Next()) {
209 myIterator->Value(nF1, nF2);
211 // Update/Initialize FaceInfo structure for first face
212 if (myDS->HasFaceInfo(nF1))
214 if (aMIFence.Add(nF1))
216 myDS->UpdateFaceInfoOn(nF1);
217 myDS->UpdateFaceInfoIn(nF1);
220 else if (myDS->HasInterfShapeSubShapes(nF2, nF1))
222 myDS->ChangeFaceInfo(nF1);
226 // Update/Initialize FaceInfo structure for second face
227 if (myDS->HasFaceInfo(nF2))
229 if (aMIFence.Add(nF2))
231 myDS->UpdateFaceInfoOn(nF2);
232 myDS->UpdateFaceInfoIn(nF2);
235 else if (myDS->HasInterfShapeSubShapes(nF1, nF2))
237 myDS->ChangeFaceInfo(nF2);
241 if (myGlue == BOPAlgo_GlueOff)
243 const TopoDS_Face& aF1 = (*(TopoDS_Face *)(&myDS->Shape(nF1)));
244 const TopoDS_Face& aF2 = (*(TopoDS_Face *)(&myDS->Shape(nF2)));
246 const BRepAdaptor_Surface& aBAS1 = myContext->SurfaceAdaptor(aF1);
247 const BRepAdaptor_Surface& aBAS2 = myContext->SurfaceAdaptor(aF2);
248 if (aBAS1.GetType() == GeomAbs_Plane &&
249 aBAS2.GetType() == GeomAbs_Plane) {
250 // Check if the planes are really interfering
251 Standard_Boolean bToIntersect = CheckPlanes(nF1, nF2);
253 BOPDS_InterfFF& aFF = aFFs.Appended();
254 aFF.SetIndices(nF1, nF2);
260 BOPAlgo_FaceFace& aFaceFace=aVFaceFace.Appended();
262 aFaceFace.SetIndices(nF1, nF2);
263 aFaceFace.SetFaces(aF1, aF2);
264 // compute minimal tolerance for the curves
265 Standard_Real aTolFF = ToleranceFF(aBAS1, aBAS2);
266 aFaceFace.SetTolFF(aTolFF);
268 IntSurf_ListOfPntOn2S aListOfPnts;
269 GetEFPnts(nF1, nF2, aListOfPnts);
270 Standard_Integer aNbLP = aListOfPnts.Extent();
272 aFaceFace.SetList(aListOfPnts);
275 aFaceFace.SetParameters(bApprox, bCompC2D1, bCompC2D2, anApproxTol);
276 aFaceFace.SetFuzzyValue(myFuzzyValue);
277 aFaceFace.SetProgressIndicator(myProgressIndicator);
280 // for the Glue mode just add all interferences of that type
281 BOPDS_InterfFF& aFF = aFFs.Appended();
282 aFF.SetIndices(nF1, nF2);
283 aFF.SetTangentFaces(Standard_False);
286 }//for (; myIterator->More(); myIterator->Next()) {
288 //======================================================
289 // Perform intersection
290 BOPAlgo_FaceFaceCnt::Perform(myRunParallel, aVFaceFace);
291 //======================================================
292 // Treatment of the results
293 Standard_Integer k, aNbFaceFace = aVFaceFace.Length();
294 for (k = 0; k < aNbFaceFace; ++k) {
295 BOPAlgo_FaceFace& aFaceFace = aVFaceFace(k);
296 aFaceFace.Indices(nF1, nF2);
297 if (!aFaceFace.IsDone() || aFaceFace.HasErrors()) {
298 BOPDS_InterfFF& aFF = aFFs.Appended();
299 aFF.SetIndices(nF1, nF2);
301 // Warn about failed intersection of faces
302 AddIntersectionFailedWarning(aFaceFace.Face1(), aFaceFace.Face2());
306 Standard_Boolean bTangentFaces = aFaceFace.TangentFaces();
307 Standard_Real aTolFF = aFaceFace.TolFF();
309 aFaceFace.PrepareLines3D(bSplitCurve);
311 const IntTools_SequenceOfCurves& aCvsX = aFaceFace.Lines();
312 const IntTools_SequenceOfPntOn2Faces& aPntsX = aFaceFace.Points();
314 Standard_Integer aNbCurves = aCvsX.Length();
315 Standard_Integer aNbPoints = aPntsX.Length();
317 if (aNbCurves || aNbPoints) {
318 myDS->AddInterf(nF1, nF2);
321 BOPDS_InterfFF& aFF = aFFs.Appended();
322 aFF.SetIndices(nF1, nF2);
323 aFF.SetTangentFaces(bTangentFaces);
324 aFF.Init(aNbCurves, aNbPoints);
327 // Fix bounding box expanding coefficient.
328 Standard_Real aBoxExpandValue = aTolFF;
331 // Modify geometric expanding coefficient by topology value,
332 // since this bounding box used in sharing (vertex or edge).
333 Standard_Real aMaxVertexTol = Max(BRep_Tool::MaxTolerance(aFaceFace.Face1(), TopAbs_VERTEX),
334 BRep_Tool::MaxTolerance(aFaceFace.Face2(), TopAbs_VERTEX));
335 aBoxExpandValue += aMaxVertexTol;
338 BOPDS_VectorOfCurve& aVNC = aFF.ChangeCurves();
339 for (Standard_Integer i = 1; i <= aNbCurves; ++i) {
341 const IntTools_Curve& aIC = aCvsX(i);
342 Standard_Boolean bIsValid = IntTools_Tools::CheckCurve(aIC, aBox);
344 BOPDS_Curve& aNC = aVNC.Appended();
346 // make sure that the bounding box has the maximal gap
347 aBox.Enlarge(aBoxExpandValue);
349 aNC.SetTolerance(Max(aIC.Tolerance(), aTolFF));
354 BOPDS_VectorOfPoint& aVNP = aFF.ChangePoints();
355 for (Standard_Integer i = 1; i <= aNbPoints; ++i) {
356 const IntTools_PntOn2Faces& aPi = aPntsX(i);
357 const gp_Pnt& aP = aPi.P1().Pnt();
359 BOPDS_Point& aNP = aVNP.Appended();
364 //=======================================================================
365 //function : MakeBlocks
367 //=======================================================================
368 void BOPAlgo_PaveFiller::MakeBlocks()
370 if (myGlue != BOPAlgo_GlueOff) {
374 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
375 Standard_Integer aNbFF = aFFs.Length();
380 Standard_Boolean bExist, bValid2D;
381 Standard_Integer i, nF1, nF2, aNbC, aNbP, j;
382 Standard_Integer nV1, nV2;
383 Standard_Real aT1, aT2;
384 Handle(NCollection_BaseAllocator) aAllocator;
385 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
387 Handle(BOPDS_PaveBlock) aPBOut;
389 //-----------------------------------------------------scope f
391 NCollection_BaseAllocator::CommonBaseAllocator();
393 TColStd_ListOfInteger aLSE(aAllocator), aLBV(aAllocator);
394 TColStd_MapOfInteger aMVOnIn(100, aAllocator), aMVCommon(100, aAllocator),
395 aMVStick(100,aAllocator), aMVEF(100, aAllocator),
396 aMI(100, aAllocator), aMVBounds(100, aAllocator);
397 BOPDS_IndexedMapOfPaveBlock aMPBOnIn(100, aAllocator);
398 BOPDS_MapOfPaveBlock aMPBAdd(100, aAllocator), aMPBCommon;
399 BOPDS_ListOfPaveBlock aLPB(aAllocator);
400 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMSCPB(100, aAllocator);
401 TopTools_DataMapOfShapeInteger aMVI(100, aAllocator);
402 BOPDS_DataMapOfPaveBlockListOfPaveBlock aDMExEdges(100, aAllocator);
403 TColStd_DataMapOfIntegerReal aMVTol(100, aAllocator);
404 TColStd_DataMapOfIntegerInteger aDMNewSD(100, aAllocator);
405 TColStd_DataMapOfIntegerListOfInteger aDMVLV;
406 TColStd_DataMapOfIntegerListOfInteger aDMBV(100, aAllocator);
407 TColStd_DataMapIteratorOfDataMapOfIntegerReal aItMV;
408 TopTools_IndexedMapOfShape aMicroEdges(100, aAllocator);
409 TopTools_IndexedMapOfShape aVertsOnRejectedPB;
411 for (i=0; i<aNbFF; ++i) {
415 BOPDS_InterfFF& aFF=aFFs(i);
416 aFF.Indices(nF1, nF2);
418 BOPDS_VectorOfPoint& aVP=aFF.ChangePoints();
420 BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves();
422 if (!aNbP && !aNbC) {
426 const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
427 const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
429 Standard_Real aTolFF = Max(BRep_Tool::Tolerance(aF1), BRep_Tool::Tolerance(aF2));
431 BOPDS_FaceInfo& aFI1 = myDS->ChangeFaceInfo(nF1);
432 BOPDS_FaceInfo& aFI2 = myDS->ChangeFaceInfo(nF2);
442 myDS->SubShapesOnIn(nF1, nF2, aMVOnIn, aMVCommon, aMPBOnIn, aMPBCommon);
443 myDS->SharedEdges(nF1, nF2, aLSE, aAllocator);
445 Standard_Boolean bHasRealSectionEdge = Standard_False;
447 for (j=0; j<aNbP; ++j) {
449 BOPDS_CoupleOfPaveBlocks aCPB;
451 BOPDS_Point& aNP=aVP.ChangeValue(j);
452 const gp_Pnt& aP=aNP.Pnt();
454 bExist=IsExistingVertex(aP, aTolFF, aMVOnIn);
456 BOPTools_AlgoTools::MakeNewVertex(aP, aTolFF, aV);
458 aCPB.SetIndexInterf(i);
460 aMSCPB.Add(aV, aCPB);
467 GetStickVertices(nF1, nF2, aMVStick, aMVEF, aMI);
469 for (j = 0; j < aNbC; ++j) {
470 BOPDS_Curve& aNC = aVC.ChangeValue(j);
472 aNC.InitPaveBlock1();
474 // In order to avoid problems connected with
475 // extending tolerance of vertex while putting
476 // (e.g. see "bugs modalg_6 bug26789_1" test case),
477 // all not-common vertices will be checked by
478 // BndBoxes before putting. For common-vertices,
479 // filtering by BndBoxes is not necessary.
480 PutPavesOnCurve(aMVOnIn, aMVCommon, aNC, aMI, aMVEF, aMVTol, aDMVLV);
483 // if some E-F vertex was put on a curve due to large E-F intersection range,
484 // and it also was put on another curve correctly then remove this vertex from
485 // the first curve. Detect such case if the distance to curve exceeds aTolR3D.
486 FilterPavesOnCurves(aVC);
488 for (j = 0; j<aNbC; ++j) {
489 BOPDS_Curve& aNC=aVC.ChangeValue(j);
490 const IntTools_Curve& aIC=aNC.Curve();
492 PutStickPavesOnCurve(aF1, aF2, aMI, aNC, aMVStick, aMVTol, aDMVLV);
495 PutEFPavesOnCurve(aNC, aMI, aMVEF, aMVTol, aDMVLV);
498 if (aIC.HasBounds()) {
501 PutBoundPaveOnCurve(aF1, aF2, aNC, aLBV);
503 if (!aLBV.IsEmpty()) {
505 TColStd_ListIteratorOfListOfInteger aItI(aLBV);
506 for (; aItI.More(); aItI.Next()) {
507 aMVBounds.Add(aItI.Value());
511 }//for (j=0; j<aNbC; ++j) {
513 // Put closing pave if needed
514 for (j=0; j<aNbC; ++j) {
515 BOPDS_Curve& aNC=aVC.ChangeValue(j);
516 PutClosingPaveOnCurve (aNC);
519 // 3. Make section edges
520 for (j=0; j<aNbC; ++j) {
521 BOPDS_Curve& aNC=aVC.ChangeValue(j);
522 const IntTools_Curve& aIC=aNC.Curve();
523 Standard_Real aTolR3D = Max(aNC.Tolerance(), aNC.TangentialTolerance());
525 BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
526 Handle(BOPDS_PaveBlock)& aPB1=aNC.ChangePaveBlock1();
529 aPB1->Update(aLPB, Standard_False);
531 aItLPB.Initialize(aLPB);
532 for (; aItLPB.More(); aItLPB.Next()) {
533 Handle(BOPDS_PaveBlock)& aPB=aItLPB.ChangeValue();
534 aPB->Indices(nV1, nV2);
535 aPB->Range (aT1, aT2);
537 if (fabs(aT1 - aT2) < Precision::PConfusion()) {
541 bValid2D=myContext->IsValidBlockForFaces(aT1, aT2, aIC,
547 bExist=IsExistingPaveBlock(aPB, aNC, aLSE);
552 const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
553 const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
556 BOPTools_AlgoTools::MakeEdge (aIC, aV1, aT1, aV2, aT2, aTolR3D, aES);
558 // check for micro edge
559 if (BOPTools_AlgoTools::IsMicroEdge(aES, myContext, Standard_False)) {
560 // If the section edge is a micro edge, i.e. the whole edge is
561 // covered by the tolerance spheres of its vertices, it will be
562 // passed into post treatment process to fuse its vertices.
563 // The edge itself will not be kept.
564 if (!aMVBounds.Contains(nV1) && !aMVBounds.Contains(nV2)) {
565 aMicroEdges.Add(aES);
566 // keep vertices for post treatment
573 Standard_Real aTolNew;
574 bExist=IsExistingPaveBlock(aPB, aNC, aTolR3D, aMPBOnIn, aMPBCommon, aPBOut, aTolNew);
576 if (!aMPBAdd.Contains(aPBOut)) {
577 Standard_Boolean bInBothFaces = Standard_True;
578 if (!myDS->IsCommonBlock(aPBOut)) {
583 const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
584 aTolE = BRep_Tool::Tolerance(aE);
585 if (aTolNew < aNC.Tolerance())
586 aTolNew = aNC.Tolerance(); // use real tolerance of intersection
587 if (aTolNew > aTolE) {
588 UpdateEdgeTolerance(nE, aTolNew);
590 bInBothFaces = Standard_False;
593 bInBothFaces = (aFI1.PaveBlocksOn().Contains(aPBOut) ||
594 aFI1.PaveBlocksIn().Contains(aPBOut))&&
595 (aFI2.PaveBlocksOn().Contains(aPBOut) ||
596 aFI2.PaveBlocksIn().Contains(aPBOut));
600 PreparePostTreatFF(i, j, aPBOut, aMSCPB, aMVI, aLPBC);
601 // Try fusing the vertices of the existing pave block
602 // with the vertices put on the real section curve (except
603 // for technological vertices, which will be removed)
604 Standard_Integer nVOut1, nVOut2;
605 aPBOut->Indices(nVOut1, nVOut2);
606 if (nV1 != nVOut1 && nV1 != nVOut2 && !aMVBounds.Contains(nV1))
608 aVertsOnRejectedPB.Add(aV1);
610 if (nV2 != nVOut1 && nV2 != nVOut2 && !aMVBounds.Contains(nV2))
612 aVertsOnRejectedPB.Add(aV2);
620 BOPTools_AlgoTools::MakePCurve(aES, aF1, aF2, aIC,
621 mySectionAttribute.PCurveOnS1(),
622 mySectionAttribute.PCurveOnS2(),
625 // Append the Pave Block to the Curve j
628 // Keep info for post treatment
629 BOPDS_CoupleOfPaveBlocks aCPB;
630 aCPB.SetIndexInterf(i);
632 aCPB.SetPaveBlock1(aPB);
634 aMSCPB.Add(aES, aCPB);
641 bHasRealSectionEdge = Standard_True;
645 }//for (j=0; j<aNbC; ++j) {
647 //back to previous tolerance values for unused vertices
648 //and forget about SD groups of such vertices
649 aItMV.Initialize(aMVTol);
650 for (; aItMV.More(); aItMV.Next()) {
652 Standard_Real aTol = aItMV.Value();
654 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV1);
655 const Handle(BRep_TVertex)& TV =
656 *((Handle(BRep_TVertex)*)&aV.TShape());
659 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV1);
660 Bnd_Box& aBoxDS=aSIDS.ChangeBox();
662 BRepBndLib::Add(aV, aBoxDS);
663 aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
665 if (aDMVLV.IsBound(nV1))
669 ProcessExistingPaveBlocks(i, aMPBOnIn, aDMBV, aMSCPB, aMVI, aMPBAdd);
671 // If the pair of faces has produced any real section edges
672 // it is necessary to check if these edges do not intersect
673 // any common IN edges of the faces. For that, all such edges
674 // are added for Post Treatment along with sections edges.
675 if (bHasRealSectionEdge) {
676 const BOPDS_IndexedMapOfPaveBlock& aMPBIn1 = aFI1.PaveBlocksIn();
677 const BOPDS_IndexedMapOfPaveBlock& aMPBIn2 = aFI2.PaveBlocksIn();
679 // For simplicity add all IN edges into the first set of section curves.
680 // These existing edges will be removed from the set on the post treatment
681 // stage in the UpdateFaceInfo function.
682 BOPDS_ListOfPaveBlock& aLPBC = aVC.ChangeValue(0).ChangePaveBlocks();
684 Standard_Integer aNbIn1 = aMPBIn1.Extent();
685 for (j = 1; j <= aNbIn1; ++j) {
686 const Handle(BOPDS_PaveBlock)& aPB = aMPBIn1(j);
687 if (aMPBIn2.Contains(aPB) && aMPBAdd.Add(aPB)) {
688 PreparePostTreatFF(i, 0, aPB, aMSCPB, aMVI, aLPBC);
692 }//for (i=0; i<aNbFF; ++i) {
694 // Remove "micro" section edges
695 RemoveMicroSectionEdges(aMSCPB, aMicroEdges);
698 MakeSDVerticesFF(aDMVLV, aDMNewSD);
699 PostTreatFF(aMSCPB, aDMExEdges, aDMNewSD, aMicroEdges, aVertsOnRejectedPB, aAllocator);
703 // reduce tolerances of section edges where it is appropriate
704 CorrectToleranceOfSE();
707 UpdateFaceInfo(aDMExEdges, aDMNewSD);
708 //Update all pave blocks
709 UpdatePaveBlocks(aDMNewSD);
711 // Treat possible common zones by trying to put each section edge
712 // into all faces, not participated in creation of that edge, as IN edge
715 //-----------------------------------------------------scope t
725 //=======================================================================
726 //function : MakeSDVerticesFF
728 //=======================================================================
729 void BOPAlgo_PaveFiller::MakeSDVerticesFF
730 (const TColStd_DataMapOfIntegerListOfInteger& theDMVLV,
731 TColStd_DataMapOfIntegerInteger& theDMNewSD)
733 // Create a new SD vertex for each group of coinciding vertices
734 // and put new substitutions to theDMNewSD.
735 TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aItG(theDMVLV);
736 for (; aItG.More(); aItG.Next()) {
737 const TColStd_ListOfInteger& aList = aItG.Value();
738 // make SD vertices w/o creation of interfs
739 Standard_Integer nSD = MakeSDVertices(aList, Standard_False);
741 TColStd_ListIteratorOfListOfInteger aItL(aList);
742 for (; aItL.More(); aItL.Next()) {
743 Standard_Integer nV = aItL.Value();
744 theDMNewSD.Bind(nV, nSD);
749 //=======================================================================
750 //function : PostTreatFF
752 //=======================================================================
753 void BOPAlgo_PaveFiller::PostTreatFF
754 (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB,
755 BOPDS_DataMapOfPaveBlockListOfPaveBlock& aDMExEdges,
756 TColStd_DataMapOfIntegerInteger& aDMNewSD,
757 const TopTools_IndexedMapOfShape& theMicroEdges,
758 const TopTools_IndexedMapOfShape& theVertsOnRejectedPB,
759 const Handle(NCollection_BaseAllocator)& theAllocator)
761 Standard_Integer aNbS = theMSCPB.Extent();
766 Standard_Boolean bHasPaveBlocks, bOld;
767 Standard_Integer nSx, nVSD, iX, iP, iC, j, nV, iV = 0, iE, k;
768 Standard_Integer aNbLPBx;
769 TopAbs_ShapeEnum aType;
771 TopTools_ListIteratorOfListOfShape aItLS;
772 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
774 Handle(BOPDS_PaveBlock) aPB1;
778 TopTools_ListOfShape aLS(theAllocator);
779 BOPAlgo_PaveFiller aPF(theAllocator);
780 aPF.SetIsPrimary(Standard_False);
781 aPF.SetNonDestructive(myNonDestructive);
783 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
785 Standard_Integer aNbME = theMicroEdges.Extent();
786 Standard_Integer aNbVOnRPB = theVertsOnRejectedPB.Extent();
788 if (aNbS==1 && (aNbME == 0) && (aNbVOnRPB == 0)) {
789 const TopoDS_Shape& aS=theMSCPB.FindKey(1);
790 const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromIndex(1);
792 aType=aS.ShapeType();
793 if (aType==TopAbs_VERTEX) {
794 aSI.SetShapeType(aType);
796 iV=myDS->Append(aSI);
798 iX=aCPB.IndexInterf();
800 BOPDS_InterfFF& aFF=aFFs(iX);
801 BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
802 BOPDS_Point& aNP=aVNP(iP);
805 else if (aType==TopAbs_EDGE) {
806 aPB1=aCPB.PaveBlock1();
808 if (aPB1->HasEdge()) {
809 BOPDS_ListOfPaveBlock aLPBx;
811 aDMExEdges.Bind(aPB1, aLPBx);
813 aSI.SetShapeType(aType);
815 iE=myDS->Append(aSI);
823 // 1 prepare arguments
824 TopTools_MapOfShape anAddedSD;
825 for (k=1; k<=aNbS; ++k) {
826 const TopoDS_Shape& aS=theMSCPB.FindKey(k);
828 // add vertices-candidates for SD from the map aDMNewSD,
829 // so that they took part in fuse operation.
830 TopoDS_Iterator itV(aS);
831 for (; itV.More(); itV.Next())
833 const TopoDS_Shape& aVer = itV.Value();
834 Standard_Integer iVer = myDS->Index(aVer);
835 const Standard_Integer* pSD = aDMNewSD.Seek(iVer);
838 const TopoDS_Shape& aVSD = myDS->Shape(*pSD);
839 if (anAddedSD.Add(aVSD))
845 // The section edges considered as a micro should be
846 // specially treated - their vertices should be united and
847 // the edge itself should be removed. Thus, we add only
848 // its vertices into operation.
851 for (k = 1; k <= aNbME; ++k) {
852 const TopoDS_Edge& aEM = TopoDS::Edge(theMicroEdges(k));
854 TopoDS_Vertex aVerts[2];
855 TopExp::Vertices(aEM, aVerts[0], aVerts[1]);
856 for (Standard_Integer i = 0; i < 2; ++i) {
857 nV = myDS->Index(aVerts[i]);
858 const Standard_Integer* pSD = aDMNewSD.Seek(nV);
860 aVerts[i] = TopoDS::Vertex(myDS->Shape(*pSD));
863 if (anAddedSD.Add(aVerts[i])) {
864 aLS.Append(aVerts[i]);
868 if (aVerts[0].IsSame(aVerts[1])) {
872 // make sure these vertices will be united
873 const gp_Pnt& aP1 = BRep_Tool::Pnt(aVerts[0]);
874 const gp_Pnt& aP2 = BRep_Tool::Pnt(aVerts[1]);
876 Standard_Real aDist = aP1.Distance(aP2);
877 Standard_Real aTolV1 = BRep_Tool::Tolerance(aVerts[0]);
878 Standard_Real aTolV2 = BRep_Tool::Tolerance(aVerts[1]);
880 aDist -= (aTolV1 + aTolV2);
883 aBB.UpdateVertex(aVerts[0], aTolV1 + aDist);
884 aBB.UpdateVertex(aVerts[1], aTolV2 + aDist);
888 // Add vertices put on the real section curves to unify them with the
889 // vertices of the edges, by which these sections curves have been rejected
890 for (Standard_Integer i = 1; i <= aNbVOnRPB; ++i)
892 TopoDS_Shape aVer = theVertsOnRejectedPB(i);
893 Standard_Integer iVer = myDS->Index(aVer);
894 const Standard_Integer* pSD = aDMNewSD.Seek(iVer);
896 aVer = myDS->Shape(*pSD);
898 if (anAddedSD.Add(aVer))
903 aPF.SetProgressIndicator(myProgressIndicator);
904 aPF.SetRunParallel(myRunParallel);
905 aPF.SetArguments(aLS);
907 if (aPF.HasErrors()) {
908 AddError (new BOPAlgo_AlertPostTreatFF);
913 // Map to store the real tolerance of the common block
914 // and avoid repeated computation of it
915 NCollection_DataMap<Handle(BOPDS_CommonBlock),
917 TColStd_MapTransientHasher> aMCBTol;
918 // Map to avoid creation of different pave blocks for
919 // the same intersection edge
920 NCollection_DataMap<Standard_Integer, Handle(BOPDS_PaveBlock)> aMEPB;
922 aItLS.Initialize(aLS);
923 for (; aItLS.More(); aItLS.Next()) {
924 const TopoDS_Shape& aSx=aItLS.Value();
925 nSx=aPDS->Index(aSx);
926 const BOPDS_ShapeInfo& aSIx=aPDS->ShapeInfo(nSx);
928 aType=aSIx.ShapeType();
930 if (aType==TopAbs_VERTEX) {
931 Standard_Boolean bIntersectionPoint = theMSCPB.Contains(aSx);
933 if (aPDS->HasShapeSD(nSx, nVSD)) {
934 aV=aPDS->Shape(nVSD);
939 // index of new vertex in theDS -> iV
940 iV = myDS->Index(aV);
942 aSI.SetShapeType(aType);
944 iV=myDS->Append(aSI);
947 if (!bIntersectionPoint) {
948 // save SD connection
949 nSx = myDS->Index(aSx);
950 aDMNewSD.Bind(nSx, iV);
951 myDS->AddShapeSD(nSx, iV);
954 // update FF interference
955 const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx);
956 iX=aCPB.IndexInterf();
958 BOPDS_InterfFF& aFF=aFFs(iX);
959 BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
960 BOPDS_Point& aNP=aVNP(iP);
963 }//if (aType==TopAbs_VERTEX) {
965 else if (aType==TopAbs_EDGE) {
966 bHasPaveBlocks=aPDS->HasPaveBlocks(nSx);
967 const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx);
968 iX=aCPB.IndexInterf();
970 aPB1=aCPB.PaveBlock1();
972 bOld = aPB1->HasEdge();
974 BOPDS_ListOfPaveBlock aLPBx;
975 aDMExEdges.Bind(aPB1, aLPBx);
978 if (!bHasPaveBlocks) {
980 aDMExEdges.ChangeFind(aPB1).Append(aPB1);
983 aSI.SetShapeType(aType);
985 iE = myDS->Append(aSI);
991 BOPDS_InterfFF& aFF=aFFs(iX);
992 BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves();
993 BOPDS_Curve& aNC=aVNC(iC);
994 BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
996 // check if edge occured to be micro edge;
997 // note we check not the edge aSx itself, but its image in aPDS
998 const BOPDS_ListOfPaveBlock& aLPBx = aPDS->PaveBlocks(nSx);
999 aNbLPBx = aLPBx.Extent();
1000 if (aPDS->HasPaveBlocks(nSx) &&
1001 (aNbLPBx == 0 || (aNbLPBx == 1 && !aLPBx.First()->HasShrunkData()))) {
1002 BOPDS_ListIteratorOfListOfPaveBlock it(aLPBC);
1003 for (; it.More(); it.Next()) {
1004 if (it.Value() == aPB1) {
1012 if (bOld && !aNbLPBx) {
1013 aDMExEdges.ChangeFind(aPB1).Append(aPB1);
1018 aItLPB.Initialize(aLPBC);
1019 for (; aItLPB.More(); aItLPB.Next()) {
1020 const Handle(BOPDS_PaveBlock)& aPBC=aItLPB.Value();
1022 aLPBC.Remove(aItLPB);
1029 aItLPB.Initialize(aLPBx);
1030 for (; aItLPB.More(); aItLPB.Next()) {
1031 const Handle(BOPDS_PaveBlock)& aPBx=aItLPB.Value();
1032 const Handle(BOPDS_PaveBlock) aPBRx=aPDS->RealPaveBlock(aPBx);
1034 // update vertices of paves
1035 aPave[0] = aPBx->Pave1();
1036 aPave[1] = aPBx->Pave2();
1037 for (j=0; j<2; ++j) {
1038 nV = aPave[j].Index();
1039 aV = aPDS->Shape(nV);
1040 // index of new vertex in myDS -> iV
1041 iV = myDS->Index(aV);
1043 aSI.SetShapeType(TopAbs_VERTEX);
1045 iV = myDS->Append(aSI);
1047 const BOPDS_Pave& aP1 = !j ? aPB1->Pave1() : aPB1->Pave2();
1048 if (aP1.Index() != iV) {
1049 if (aP1.Parameter() == aPave[j].Parameter()) {
1050 aDMNewSD.Bind(aP1.Index(), iV);
1051 myDS->AddShapeSD(aP1.Index(), iV);
1054 // check aPDS to have the SD connection between these vertices
1055 const TopoDS_Shape& aVPave = myDS->Shape(aP1.Index());
1056 Standard_Integer nVnewSD, nVnew = aPDS->Index(aVPave);
1057 if (aPDS->HasShapeSD(nVnew, nVnewSD)) {
1058 if (nVnewSD == nV) {
1059 aDMNewSD.Bind(aP1.Index(), iV);
1060 myDS->AddShapeSD(aP1.Index(), iV);
1066 aPave[j].SetIndex(iV);
1070 aE=aPDS->Shape(aPBRx->Edge());
1071 iE = myDS->Index(aE);
1073 aSI.SetShapeType(aType);
1075 iE=myDS->Append(aSI);
1078 // update real edge tolerance according to distances in common block if any
1079 if (aPDS->IsCommonBlock(aPBRx)) {
1080 const Handle(BOPDS_CommonBlock)& aCB = aPDS->CommonBlock(aPBRx);
1081 Standard_Real *pTol = aMCBTol.ChangeSeek(aCB);
1083 Standard_Real aTol = BOPAlgo_Tools::ComputeToleranceOfCB(aCB, aPDS, aPF.Context());
1084 pTol = aMCBTol.Bound(aCB, aTol);
1087 if (aNC.Tolerance() < *pTol) {
1088 aNC.SetTolerance(*pTol);
1091 // append new PaveBlock to aLPBC
1092 Handle(BOPDS_PaveBlock) *pPBC = aMEPB.ChangeSeek(iE);
1094 pPBC = aMEPB.Bound(iE, new BOPDS_PaveBlock());
1095 BOPDS_Pave aPaveR1, aPaveR2;
1096 aPaveR1 = aPBRx->Pave1();
1097 aPaveR2 = aPBRx->Pave2();
1098 aPaveR1.SetIndex(myDS->Index(aPDS->Shape(aPaveR1.Index())));
1099 aPaveR2.SetIndex(myDS->Index(aPDS->Shape(aPaveR2.Index())));
1101 (*pPBC)->SetPave1(aPaveR1);
1102 (*pPBC)->SetPave2(aPaveR2);
1103 (*pPBC)->SetEdge(iE);
1107 (*pPBC)->SetOriginalEdge(aPB1->OriginalEdge());
1108 aDMExEdges.ChangeFind(aPB1).Append(*pPBC);
1111 aLPBC.Append(*pPBC);
1116 }//else if (aType==TopAbs_EDGE)
1117 }//for (; aItLS.More(); aItLS.Next()) {
1119 // Update SD for vertices that did not participate in operation
1120 TColStd_DataMapOfIntegerInteger::Iterator itDM(aDMNewSD);
1121 for (; itDM.More(); itDM.Next())
1123 const Standard_Integer* pSD = aDMNewSD.Seek(itDM.Value());
1126 itDM.ChangeValue() = *pSD;
1127 myDS->AddShapeSD(itDM.Key(), *pSD);
1133 //=======================================================================
1134 //function : UpdateFaceInfo
1136 //=======================================================================
1137 void BOPAlgo_PaveFiller::UpdateFaceInfo
1138 (BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME,
1139 const TColStd_DataMapOfIntegerInteger& theDMV)
1141 Standard_Integer i, j, nV1, nF1, nF2,
1143 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
1144 TColStd_MapOfInteger aMF;
1146 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
1147 aNbFF=aFFs.Length();
1149 //1. Sections (curves, points);
1150 for (i=0; i<aNbFF; ++i) {
1151 BOPDS_InterfFF& aFF=aFFs(i);
1152 aFF.Indices(nF1, nF2);
1154 BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
1155 BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
1157 // 1.1. Section edges
1158 BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves();
1160 for (j=0; j<aNbC; ++j) {
1161 BOPDS_Curve& aNC=aVNC(j);
1162 BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
1164 // Add section edges to face info
1165 aItLPB.Initialize(aLPBC);
1166 for (; aItLPB.More(); ) {
1167 const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value();
1169 // Treat existing pave blocks
1170 if (theDME.IsBound(aPB)) {
1171 BOPDS_ListOfPaveBlock& aLPB=theDME.ChangeFind(aPB);
1172 UpdateExistingPaveBlocks(aPB, aLPB, nF1, nF2);
1173 aLPBC.Remove(aItLPB);
1177 aFI1.ChangePaveBlocksSc().Add(aPB);
1178 aFI2.ChangePaveBlocksSc().Add(aPB);
1183 // 1.2. Section vertices
1184 const BOPDS_VectorOfPoint& aVNP=aFF.Points();
1186 for (j=0; j<aNbP; ++j) {
1187 const BOPDS_Point& aNP=aVNP(j);
1192 aFI1.ChangeVerticesSc().Add(nV1);
1193 aFI2.ChangeVerticesSc().Add(nV1);
1200 Standard_Boolean bVerts, bEdges;
1202 bVerts = theDMV.Extent() > 0;
1203 bEdges = theDME.Extent() > 0;
1205 if (!bVerts && !bEdges) {
1209 // 2. Update Face Info information with new vertices and new
1210 // pave blocks created in PostTreatFF from existing ones
1211 Standard_Integer nV2, aNbPB;
1212 TColStd_MapIteratorOfMapOfInteger aItMF;
1213 TColStd_DataMapIteratorOfDataMapOfIntegerInteger aItMV;
1215 aItMF.Initialize(aMF);
1216 for (; aItMF.More(); aItMF.Next()) {
1217 nF1 = aItMF.Value();
1219 BOPDS_FaceInfo& aFI = myDS->ChangeFaceInfo(nF1);
1221 // 2.1. Update information about vertices
1223 TColStd_MapOfInteger& aMVOn = aFI.ChangeVerticesOn();
1224 TColStd_MapOfInteger& aMVIn = aFI.ChangeVerticesIn();
1226 aItMV.Initialize(theDMV);
1227 for (; aItMV.More(); aItMV.Next()) {
1229 nV2 = aItMV.Value();
1231 if (aMVOn.Remove(nV1)) {
1235 if (aMVIn.Remove(nV1)) {
1238 } // for (; aItMV.More(); aItMV.Next()) {
1241 // 2.2. Update information about pave blocks
1243 BOPDS_IndexedMapOfPaveBlock& aMPBOn = aFI.ChangePaveBlocksOn();
1244 BOPDS_IndexedMapOfPaveBlock& aMPBIn = aFI.ChangePaveBlocksIn();
1246 BOPDS_IndexedMapOfPaveBlock aMPBCopy;
1247 for (i = 0; i < 2; ++i) {
1248 BOPDS_IndexedMapOfPaveBlock& aMPBOnIn = !i ? aMPBOn : aMPBIn;
1249 aMPBCopy = aMPBOnIn;
1252 aNbPB = aMPBCopy.Extent();
1253 for (j = 1; j <= aNbPB; ++j) {
1254 const Handle(BOPDS_PaveBlock)& aPB = aMPBCopy(j);
1255 if (theDME.IsBound(aPB)) {
1256 const BOPDS_ListOfPaveBlock& aLPB = theDME.Find(aPB);
1257 if (aLPB.IsEmpty()) {
1262 aItLPB.Initialize(aLPB);
1263 for (; aItLPB.More(); aItLPB.Next()) {
1264 const Handle(BOPDS_PaveBlock)& aPB1 = aItLPB.Value();
1271 } // for (j = 1; j <= aNbPB; ++j) {
1272 } // for (i = 0; i < 2; ++i) {
1276 //=======================================================================
1277 //function : IsExistingVertex
1279 //=======================================================================
1280 Standard_Boolean BOPAlgo_PaveFiller::IsExistingVertex
1282 const Standard_Real theTolR3D,
1283 const TColStd_MapOfInteger& aMVOnIn)const
1285 Standard_Boolean bRet;
1286 Standard_Integer nV, iFlag;
1287 Standard_Real aTolCheck;
1290 TColStd_MapIteratorOfMapOfInteger aIt;
1292 aTolCheck = theTolR3D + myFuzzyValue;
1296 aBoxP.Enlarge(theTolR3D);
1298 aIt.Initialize(aMVOnIn);
1299 for (; aIt.More(); aIt.Next()) {
1301 const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
1302 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&aSIV.Shape()));
1303 const Bnd_Box& aBoxV=aSIV.Box();
1305 if (!aBoxP.IsOut(aBoxV)) {
1306 iFlag=BOPTools_AlgoTools::ComputeVV(aV, aP, aTolCheck);
1314 //=======================================================================
1315 //function : IsExistingPaveBlock
1317 //=======================================================================
1318 Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
1319 (const Handle(BOPDS_PaveBlock)& thePB,
1320 const BOPDS_Curve& theNC,
1321 const TColStd_ListOfInteger& theLSE)
1323 Standard_Boolean bRet=Standard_True;
1325 if (theLSE.IsEmpty()) {
1329 Standard_Real aT1, aT2, aTm, aTx, aTolE, aTolCheck, aTol, aDist;
1330 Standard_Integer nE, iFlag, nV1, nV2;
1333 TColStd_ListIteratorOfListOfInteger aItLI;
1335 thePB->Range(aT1, aT2);
1336 thePB->Indices(nV1, nV2);
1337 const TopoDS_Vertex &aV1 = TopoDS::Vertex(myDS->Shape(nV1)),
1338 &aV2 = TopoDS::Vertex(myDS->Shape(nV2));
1339 const Standard_Real aTolV1 = BRep_Tool::Tolerance(aV1),
1340 aTolV2 = BRep_Tool::Tolerance(aV2);
1342 aTol = Max(aTolV1, aTolV2);
1344 aTm=IntTools_Tools::IntermediatePoint (aT1, aT2);
1345 theNC.Curve().D0(aTm, aPm);
1347 aBoxPm.Enlarge(aTol);
1349 aItLI.Initialize(theLSE);
1350 for (; aItLI.More(); aItLI.Next()) {
1354 const BOPDS_ShapeInfo& aSIE=myDS->ChangeShapeInfo(nE);
1355 const Bnd_Box& aBoxE=aSIE.Box();
1356 if (!aBoxE.IsOut(aBoxPm)) {
1357 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
1358 aTolE = BRep_Tool::Tolerance(aE);
1359 aTolCheck = Max(aTolE, aTol) + myFuzzyValue;
1360 iFlag = myContext->ComputePE(aPm, aTolCheck, aE, aTx, aDist);
1363 // Update tolerance of the edge
1364 UpdateEdgeTolerance(nE, aDist);
1372 //=======================================================================
1373 //function : IsExistingPaveBlock
1375 //=======================================================================
1376 Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
1377 (const Handle(BOPDS_PaveBlock)& thePB,
1378 const BOPDS_Curve& theNC,
1379 const Standard_Real theTolR3D,
1380 const BOPDS_IndexedMapOfPaveBlock& theMPBOnIn,
1381 const BOPDS_MapOfPaveBlock& theMPBCommon,
1382 Handle(BOPDS_PaveBlock)& aPBOut,
1383 Standard_Real& theTolNew)
1385 Standard_Boolean bRet;
1386 Standard_Real aT1, aT2, aTm, aTx, aTolCheck;
1387 Standard_Integer nSp, iFlag1, iFlag2, nV11, nV12, nV21, nV22, i, aNbPB;
1388 gp_Pnt aP1, aPm, aP2;
1389 Bnd_Box aBoxP1, aBoxPm, aBoxP2, aBoxTmp;
1391 bRet=Standard_False;
1392 aTolCheck = theTolR3D + myFuzzyValue;
1393 const IntTools_Curve& aIC=theNC.Curve();
1395 thePB->Range(aT1, aT2);
1396 thePB->Indices(nV11, nV12);
1397 const Standard_Real aTolV11 = BRep_Tool::Tolerance(TopoDS::Vertex(myDS->Shape(nV11)));
1398 const Standard_Real aTolV12 = BRep_Tool::Tolerance(TopoDS::Vertex(myDS->Shape(nV12)));
1399 const Standard_Real aTolV1 = Max(aTolV11, aTolV12) + myFuzzyValue;
1404 aBoxP1.Enlarge(aTolV11);
1405 //intermediate point
1406 aTm=IntTools_Tools::IntermediatePoint (aT1, aT2);
1412 aBoxP2.Enlarge(aTolV12);
1415 aNbPB = theMPBOnIn.Extent();
1416 for (i = 1; i <= aNbPB; ++i) {
1417 const Handle(BOPDS_PaveBlock)& aPB = theMPBOnIn(i);
1418 aPB->Indices(nV21, nV22);
1419 const Standard_Real aTolV21 = BRep_Tool::Tolerance(TopoDS::Vertex(myDS->Shape(nV21)));
1420 const Standard_Real aTolV22 = BRep_Tool::Tolerance(TopoDS::Vertex(myDS->Shape(nV22)));
1421 const Standard_Real aTolV2 = Max(aTolV21, aTolV22) + myFuzzyValue;
1425 const BOPDS_ShapeInfo& aSISp=myDS->ChangeShapeInfo(nSp);
1426 const TopoDS_Edge& aSp=(*(TopoDS_Edge *)(&aSISp.Shape()));
1427 const Bnd_Box& aBoxSp=aSISp.Box();
1429 iFlag1 = (nV11 == nV21 || nV11 == nV22) ? 2 :
1430 (!aBoxSp.IsOut(aBoxP1) ? 1 : 0);
1431 iFlag2 = (nV12 == nV21 || nV12 == nV22) ? 2 :
1432 (!aBoxSp.IsOut(aBoxP2) ? 1 : 0);
1433 if (iFlag1 && iFlag2) {
1434 Standard_Real aDist = 0.;
1436 Standard_Real aRealTol = aTolCheck;
1437 if (myDS->IsCommonBlock(aPB))
1439 aRealTol = Max(aRealTol, Max(aTolV1, aTolV2));
1440 if (theMPBCommon.Contains(aPB))
1441 // for an edge, which is a common block with a face,
1442 // increase the chance to coincide with section curve
1447 aBoxTmp.Enlarge(aRealTol);
1449 if (aBoxSp.IsOut(aBoxTmp) || myContext->ComputePE(aPm,
1457 iFlag1 = !myContext->ComputePE(aP1, aRealTol, aSp, aTx, aDist);
1458 if (iFlag1 && theTolNew < aDist)
1463 iFlag2 = !myContext->ComputePE(aP2, aRealTol, aSp, aTx, aDist);
1464 if (iFlag2 && theTolNew < aDist)
1468 if (iFlag1 && iFlag2) {
1477 //=======================================================================
1478 //function : PutBoundPaveOnCurve
1480 //=======================================================================
1481 void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1,
1482 const TopoDS_Face& aF2,
1484 TColStd_ListOfInteger& aLVB)
1486 Standard_Boolean bVF;
1487 Standard_Integer nV, iFlag, nVn, j, aNbEP;
1488 Standard_Real aT[2], aTmin, aTmax, aTV, aTol, aTolVnew;
1491 BOPDS_ListIteratorOfListOfPave aItLP;
1492 BOPDS_Pave aPn, aPMM[2];
1494 aTolVnew = Precision::Confusion();
1496 const IntTools_Curve& aIC=aNC.Curve();
1497 aIC.Bounds(aT[0], aT[1], aP[0], aP[1]);
1498 Standard_Real aTolR3D = Max(aNC.Tolerance(), aNC.TangentialTolerance());
1500 Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
1501 const BOPDS_ListOfPave& aLP=aPB->ExtPaves();
1508 aItLP.Initialize(aLP);
1509 for (; aItLP.More(); aItLP.Next()) {
1510 const BOPDS_Pave& aPv=aItLP.Value();
1511 aPv.Contents(nV, aTV);
1523 for (j=0; j<2; ++j) {
1524 //if curve is closed, process only one bound
1525 if (j && aP[1].IsEqual(aP[0], aTolVnew)) {
1535 aTol = aTolR3D+Precision::Confusion();
1536 aBoxP.Enlarge(aTol);
1537 const BOPDS_Pave& aPV=aPMM[j];
1539 const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
1540 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&aSIV.Shape()));
1541 const Bnd_Box& aBoxV=aSIV.Box();
1542 if (!aBoxP.IsOut(aBoxV)){
1543 iFlag=BOPTools_AlgoTools::ComputeVV(aV, aP[j], aTol);
1548 bVF=myContext->IsValidPointForFaces (aP[j], aF1, aF2, aTolR3D);
1553 BOPDS_ShapeInfo aSIVn;
1555 BOPTools_AlgoTools::MakeNewVertex(aP[j], aTolR3D, aVn);
1556 aSIVn.SetShapeType(TopAbs_VERTEX);
1557 aSIVn.SetShape(aVn);
1559 nVn=myDS->Append(aSIVn);
1562 aPn.SetParameter(aT[j]);
1563 aPB->AppendExtPave(aPn);
1565 aVn=(*(TopoDS_Vertex *)(&myDS->Shape(nVn)));
1566 BOPTools_AlgoTools::UpdateVertex (aIC, aT[j], aVn);
1568 aTolVnew = BRep_Tool::Tolerance(aVn);
1570 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVn);
1571 Bnd_Box& aBoxDS=aSIDS.ChangeBox();
1572 BRepBndLib::Add(aVn, aBoxDS);
1573 aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
1580 //=======================================================================
1581 //function : PutPavesOnCurve
1583 //=======================================================================
1584 void BOPAlgo_PaveFiller::PutPavesOnCurve(const TColStd_MapOfInteger& theMVOnIn,
1585 const TColStd_MapOfInteger& theMVCommon,
1587 const TColStd_MapOfInteger& theMI,
1588 const TColStd_MapOfInteger& theMVEF,
1589 TColStd_DataMapOfIntegerReal& theMVTol,
1590 TColStd_DataMapOfIntegerListOfInteger& theDMVLV)
1592 Standard_Integer nV;
1593 TColStd_MapIteratorOfMapOfInteger aIt;
1595 const Bnd_Box& aBoxC = theNC.Box();
1596 const Standard_Real aTolR3D = Max(theNC.Tolerance(), theNC.TangentialTolerance());
1598 //Put EF vertices first
1599 aIt.Initialize(theMVEF);
1600 for (; aIt.More(); aIt.Next())
1603 PutPaveOnCurve(nV, aTolR3D, theNC, theMI, theMVTol, theDMVLV, 2);
1606 //Put all other vertices
1607 aIt.Initialize(theMVOnIn);
1608 for (; aIt.More(); aIt.Next())
1611 if (theMVEF.Contains(nV))
1616 if (!theMVCommon.Contains(nV))
1618 const BOPDS_ShapeInfo& aSIV = myDS->ShapeInfo(nV);
1619 const Bnd_Box& aBoxV = aSIV.Box();
1621 if (aBoxC.IsOut(aBoxV))
1625 if (!myDS->IsNewShape(nV))
1631 PutPaveOnCurve(nV, aTolR3D, theNC, theMI, theMVTol, theDMVLV, 1);
1635 //=======================================================================
1636 //function : FilterPavesOnCurves
1638 //=======================================================================
1640 struct PaveBlockDist {
1641 Handle(BOPDS_PaveBlock) PB;
1642 Standard_Real Dist; // square distance from vertex to the paveblock
1643 Standard_Real SinAngle; // sinus of angle between projection vector
1644 // and tangent at projection point
1645 Standard_Real Tolerance; // tolerance of the section curve
1648 void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC)
1650 // For each vertex found in ExtPaves of pave blocks of section curves
1651 // collect list of pave blocks with distance to the curve
1652 NCollection_IndexedDataMap<Standard_Integer,NCollection_List<PaveBlockDist> > aIDMVertPBs;
1654 const Standard_Real anEps = gp::Resolution();
1655 for (i = 0; i < theVNC.Length(); ++i)
1657 const BOPDS_Curve& aNC = theVNC(i);
1658 const IntTools_Curve& aIC = aNC.Curve();
1659 const Standard_Real aTolR3D = Max(aNC.Tolerance(), aNC.TangentialTolerance());
1660 GeomAdaptor_Curve aGAC(aIC.Curve());
1661 const Handle(BOPDS_PaveBlock)& aPB = aNC.PaveBlocks().First();
1662 const BOPDS_ListOfPave& aPaves = aPB->ExtPaves();
1663 BOPDS_ListOfPave::Iterator itPaves(aPaves);
1664 for (; itPaves.More(); itPaves.Next())
1666 const BOPDS_Pave& aPave = itPaves.Value();
1667 Standard_Integer nV = aPave.Index();
1668 const TopoDS_Vertex& aV = TopoDS::Vertex(myDS->Shape(nV));
1669 // compute distance from vertex to the point on curve with vertex parameter
1670 gp_Pnt aPV = BRep_Tool::Pnt(aV);
1671 Standard_Real aPar = aPave.Parameter();
1674 aGAC.D1(aPar, aPonC, aD1);
1675 gp_Vec aProjVec(aPV, aPonC);
1676 Standard_Real aSqDist = aProjVec.SquareMagnitude();
1677 Standard_Real aSqD1Mod = aD1.SquareMagnitude();
1678 Standard_Real aSin = aProjVec.CrossSquareMagnitude(aD1);
1679 if (aSqDist > anEps && aSqD1Mod > anEps)
1680 aSin = sqrt(aSin / aSqDist / aSqD1Mod);
1681 NCollection_List<PaveBlockDist>* pList = aIDMVertPBs.ChangeSeek(nV);
1683 pList = &aIDMVertPBs.ChangeFromIndex(aIDMVertPBs.Add(nV, NCollection_List<PaveBlockDist>()));
1684 PaveBlockDist aPBD = { aPB, aSqDist, aSin, aTolR3D };
1685 pList->Append(aPBD);
1689 // Process each vertex
1690 const Standard_Real aSinAngleMin = 0.5; // angle below which projection is suspicious
1691 for (i = 1; i <= aIDMVertPBs.Extent(); i++)
1693 Standard_Integer nV = aIDMVertPBs.FindKey(i);
1694 const NCollection_List<PaveBlockDist>& aList = aIDMVertPBs(i);
1695 // Find a pave with minimal distance
1696 Standard_Real aMinDist = RealLast();
1697 Handle(BOPDS_PaveBlock) aPBMinDist;
1698 NCollection_List<PaveBlockDist>::Iterator itL(aList);
1699 for (; itL.More(); itL.Next())
1701 const PaveBlockDist& aPBD = itL.Value();
1702 if (aPBD.Dist < aMinDist)
1704 aMinDist = aPBD.Dist;
1705 aPBMinDist = aPBD.PB;
1708 // Remove a vertex from a pave block if the distance is greater than the tolerance
1709 // and there are other pave blocks for which the distance is less than the current.
1710 // Do not remove a vertex if it is projected on the curve with quite large angle
1711 // (see test bugs modalg_6 bug27761).
1712 for (itL.Init(aList); itL.More(); itL.Next())
1714 const PaveBlockDist& aPBD = itL.Value();
1715 Standard_Real aCheckDist = 100. * Max(aPBD.Tolerance*aPBD.Tolerance, aMinDist);
1716 if (aPBD.Dist > aCheckDist && aPBD.SinAngle < aSinAngleMin)
1718 aPBD.PB->RemoveExtPave(nV);
1724 //=======================================================================
1725 //function : ExtendedTolerance
1727 //=======================================================================
1728 Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance
1729 (const Standard_Integer nV,
1730 const TColStd_MapOfInteger& aMI,
1731 Standard_Real& aTolVExt,
1732 const Standard_Integer aType)
1734 Standard_Boolean bFound = Standard_False;
1735 if (!(myDS->IsNewShape(nV))) {
1739 Standard_Integer i, k, aNbLines, aNbInt;
1740 Standard_Real aT11, aT12, aD1, aD2, aD;
1742 gp_Pnt aPV, aP11, aP12;
1748 } else if (aType == 2) {
1752 aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
1753 aPV=BRep_Tool::Pnt(aV);
1755 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
1756 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
1758 for (; k<aNbInt; ++k) {
1759 aNbLines = !k ? aEEs.Length() : aEFs.Length();
1760 for (i = 0; i < aNbLines; ++i) {
1761 BOPDS_Interf *aInt = !k ? (BOPDS_Interf*) (&aEEs(i)) :
1762 (BOPDS_Interf*) (&aEFs(i));
1763 if (aInt->IndexNew() == nV) {
1764 if (aMI.Contains(aInt->Index1()) &&
1765 aMI.Contains(aInt->Index2())) {
1766 const IntTools_CommonPrt& aComPrt = !k ? aEEs(i).CommonPart() :
1767 aEFs(i).CommonPart();
1769 const TopoDS_Edge& aE1=aComPrt.Edge1();
1770 aComPrt.Range1(aT11, aT12);
1771 BOPTools_AlgoTools::PointOnEdge(aE1, aT11, aP11);
1772 BOPTools_AlgoTools::PointOnEdge(aE1, aT12, aP12);
1773 aD1=aPV.Distance(aP11);
1774 aD2=aPV.Distance(aP12);
1775 aD=(aD1>aD2)? aD1 : aD2;
1780 }//if (aMI.Contains(aEF.Index1()) && aMI.Contains(aEF.Index2())) {
1781 }//if (aInt->IndexNew() == nV) {
1782 }//for (i = 0; i < aNbLines; ++i) {
1783 }//for (k=0; k<2; ++k) {
1787 //=======================================================================
1788 //function : GetEFPnts
1790 //=======================================================================
1791 void BOPAlgo_PaveFiller::GetEFPnts
1792 (const Standard_Integer nF1,
1793 const Standard_Integer nF2,
1794 IntSurf_ListOfPntOn2S& aListOfPnts)
1796 Standard_Integer nE, nF, nFOpposite, aNbEFs, i;
1797 Standard_Real U1, U2, V1, V2, f, l;
1798 TColStd_MapOfInteger aMI;
1800 //collect indexes of all shapes from nF1 and nF2.
1801 GetFullShapeMap(nF1, aMI);
1802 GetFullShapeMap(nF2, aMI);
1804 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
1805 aNbEFs = aEFs.Length();
1807 for(i = 0; i < aNbEFs; ++i) {
1808 const BOPDS_InterfEF& aEF = aEFs(i);
1809 if (aEF.HasIndexNew()) {
1810 aEF.Indices(nE, nFOpposite);
1811 if(aMI.Contains(nE) && aMI.Contains(nFOpposite)) {
1812 const IntTools_CommonPrt& aCP = aEF.CommonPart();
1813 Standard_Real aPar = aCP.VertexParameter1();
1814 const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&myDS->Shape(nE)));
1815 const TopoDS_Face& aFOpposite =
1816 (*(TopoDS_Face*)(&myDS->Shape(nFOpposite)));
1818 const Handle(Geom_Curve)& aCurve = BRep_Tool::Curve(aE, f, l);
1820 nF = (nFOpposite == nF1) ? nF2 : nF1;
1821 const TopoDS_Face& aF = (*(TopoDS_Face*)(&myDS->Shape(nF)));
1822 Handle(Geom2d_Curve) aPCurve =
1823 BRep_Tool::CurveOnSurface(aE, aF, f, l);
1825 GeomAPI_ProjectPointOnSurf& aProj=myContext->ProjPS(aFOpposite);
1828 aCurve->D0(aPar, aPoint);
1829 IntSurf_PntOn2S aPnt;
1830 if(!aPCurve.IsNull()) {
1831 gp_Pnt2d aP2d = aPCurve->Value(aPar);
1832 aProj.Perform(aPoint);
1833 if(aProj.IsDone()) {
1834 aProj.LowerDistanceParameters(U1,V1);
1836 aPnt.SetValue(aP2d.X(),aP2d.Y(),U1,V1);
1838 aPnt.SetValue(U1,V1,aP2d.X(),aP2d.Y());
1840 aListOfPnts.Append(aPnt);
1844 GeomAPI_ProjectPointOnSurf& aProj1 = myContext->ProjPS(aF);
1845 aProj1.Perform(aPoint);
1846 aProj.Perform(aPoint);
1847 if(aProj1.IsDone() && aProj.IsDone()){
1848 aProj1.LowerDistanceParameters(U1,V1);
1849 aProj.LowerDistanceParameters(U2,V2);
1851 aPnt.SetValue(U1,V1,U2,V2);
1853 aPnt.SetValue(U2,V2,U1,V1);
1855 aListOfPnts.Append(aPnt);
1863 //=======================================================================
1864 //function : PutEFPavesOnCurve
1866 //=======================================================================
1867 void BOPAlgo_PaveFiller::PutEFPavesOnCurve
1869 const TColStd_MapOfInteger& aMI,
1870 const TColStd_MapOfInteger& aMVEF,
1871 TColStd_DataMapOfIntegerReal& aMVTol,
1872 TColStd_DataMapOfIntegerListOfInteger& aDMVLV)
1874 if (!aMVEF.Extent()) {
1878 const IntTools_Curve& aIC=aNC.Curve();
1879 GeomAbs_CurveType aTypeC;
1881 if (!(aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve)) {
1885 Standard_Integer nV;
1886 TColStd_MapOfInteger aMV;
1889 RemoveUsedVertices(aNC, aMV);
1890 if (!aMV.Extent()) {
1894 Standard_Real aDist;
1897 const Handle(Geom_Curve)& aC3D=aIC.Curve();
1898 GeomAPI_ProjectPointOnCurve& aProjPT = myContext->ProjPT(aC3D);
1900 TColStd_MapIteratorOfMapOfInteger aItMI;
1901 aItMI.Initialize(aMV);
1902 for (; aItMI.More(); aItMI.Next()) {
1904 const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
1905 gp_Pnt aPV = BRep_Tool::Pnt(aV);
1906 aProjPT.Perform(aPV);
1907 Standard_Integer aNbPoints = aProjPT.NbPoints();
1909 aDist = aProjPT.LowerDistance();
1910 PutPaveOnCurve(nV, aDist, aNC, aMI, aMVTol, aDMVLV);
1915 //=======================================================================
1916 //function : ProcessUnUsedVertices
1918 //=======================================================================
1919 void BOPAlgo_PaveFiller::PutStickPavesOnCurve
1920 (const TopoDS_Face& aF1,
1921 const TopoDS_Face& aF2,
1922 const TColStd_MapOfInteger& aMI,
1924 const TColStd_MapOfInteger& aMVStick,
1925 TColStd_DataMapOfIntegerReal& aMVTol,
1926 TColStd_DataMapOfIntegerListOfInteger& aDMVLV)
1928 TColStd_MapOfInteger aMV;
1929 aMV.Assign(aMVStick);
1930 RemoveUsedVertices(aNC, aMV);
1932 if (!aMV.Extent()) {
1936 Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1);
1937 Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2);
1939 const IntTools_Curve& aIC=aNC.Curve();
1940 //if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) {
1941 Handle(Geom2d_Curve) aC2D[2];
1943 aC2D[0]=aIC.FirstCurve2d();
1944 aC2D[1]=aIC.SecondCurve2d();
1945 if (!aC2D[0].IsNull() && !aC2D[1].IsNull()) {
1946 Standard_Integer nV, m, n;
1947 Standard_Real aTC[2], aD, aD2, u, v, aDT2, aScPr, aDScPr;
1951 TColStd_MapIteratorOfMapOfInteger aItMI, aItMI1;
1953 aDT2=2e-7; // the rich criteria
1954 aDScPr=5.e-9; // the creasing criteria
1955 aIC.Bounds(aTC[0], aTC[1], aPC[0], aPC[1]);
1957 aItMI.Initialize(aMV);
1958 for (; aItMI.More(); aItMI.Next()) {
1960 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&myDS->Shape(nV));
1961 aPV=BRep_Tool::Pnt(aV);
1963 for (m=0; m<2; ++m) {
1964 aD2=aPC[m].SquareDistance(aPV);
1965 if (aD2>aDT2) {// no rich
1969 for (n=0; n<2; ++n) {
1970 Handle(Geom_Surface)& aS=(!n)? aS1 : aS2;
1971 aC2D[n]->D0(aTC[m], aP2D);
1973 BOPTools_AlgoTools3D::GetNormalToSurface(aS, u, v, aDN[n]);
1976 aScPr=aDN[0]*aDN[1];
1986 // The intersection curve aIC is vanishing curve (the crease)
1989 PutPaveOnCurve(nV, aD, aNC, aMI, aMVTol, aDMVLV);
1991 }//for (jVU=1; jVU=aNbVU; ++jVU) {
1993 //}//if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) {
1994 //}//if(aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) {
1997 //=======================================================================
1998 //function : GetStickVertices
2000 //=======================================================================
2001 void BOPAlgo_PaveFiller::GetStickVertices(const Standard_Integer nF1,
2002 const Standard_Integer nF2,
2003 TColStd_MapOfInteger& aMVStick,
2004 TColStd_MapOfInteger& aMVEF,
2005 TColStd_MapOfInteger& aMI)
2007 Standard_Integer nS1, nS2, nVNew, aTypeInt, i;
2009 BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
2010 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
2011 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
2012 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
2013 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
2015 Standard_Integer aNbLines[5] = {
2016 aVVs.Length(), aVEs.Length(), aEEs.Length(),
2017 aVFs.Length(), aEFs.Length()
2019 //collect indices of all shapes from nF1 and nF2.
2021 GetFullShapeMap(nF1, aMI);
2022 GetFullShapeMap(nF2, aMI);
2024 //collect VV, VE, EE, VF interferences
2025 for (aTypeInt = 0; aTypeInt < 4; ++aTypeInt) {
2026 for (i = 0; i < aNbLines[aTypeInt]; ++i) {
2027 BOPDS_Interf* aInt = (aTypeInt==0) ? (BOPDS_Interf*)(&aVVs(i)) :
2028 ((aTypeInt==1) ? (BOPDS_Interf*)(&aVEs(i)) :
2029 ((aTypeInt==2) ? (BOPDS_Interf*)(&aEEs(i)) :
2030 (BOPDS_Interf*)(&aVFs(i))));
2031 if (aInt->HasIndexNew()) {
2032 aInt->Indices(nS1, nS2);
2033 if(aMI.Contains(nS1) && aMI.Contains(nS2)) {
2034 nVNew = aInt->IndexNew();
2035 aMVStick.Add(nVNew);
2040 //collect EF interferences
2041 for (i = 0; i < aNbLines[4]; ++i) {
2042 const BOPDS_InterfEF& aInt = aEFs(i);
2043 if (aInt.HasIndexNew()) {
2044 aInt.Indices(nS1, nS2);
2045 if(aMI.Contains(nS1) && aMI.Contains(nS2)) {
2046 nVNew = aInt.IndexNew();
2047 aMVStick.Add(nVNew);
2054 //=======================================================================
2055 // function: GetFullShapeMap
2057 //=======================================================================
2058 void BOPAlgo_PaveFiller::GetFullShapeMap(const Standard_Integer nF,
2059 TColStd_MapOfInteger& aMI)
2061 TColStd_ListIteratorOfListOfInteger aIt;
2062 Standard_Integer nS;
2064 const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nF);
2065 const TColStd_ListOfInteger& aLI = aSI.SubShapes();
2068 aIt.Initialize(aLI);
2069 for (; aIt.More(); aIt.Next()) {
2075 //=======================================================================
2076 // function: RemoveUsedVertices
2078 //=======================================================================
2079 void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
2080 TColStd_MapOfInteger& aMV)
2082 if (!aMV.Extent()) {
2085 Standard_Integer nV;
2087 BOPDS_ListIteratorOfListOfPave aItLP;
2089 Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
2090 const BOPDS_ListOfPave& aLP = aPB->ExtPaves();
2091 aItLP.Initialize(aLP);
2092 for (;aItLP.More();aItLP.Next()) {
2093 aPave = aItLP.Value();
2099 //=======================================================================
2100 //function : PutPaveOnCurve
2102 //=======================================================================
2103 void BOPAlgo_PaveFiller::PutPaveOnCurve
2104 (const Standard_Integer nV,
2105 const Standard_Real aTolR3D,
2106 const BOPDS_Curve& aNC,
2107 const TColStd_MapOfInteger& aMI,
2108 TColStd_DataMapOfIntegerReal& aMVTol,
2109 TColStd_DataMapOfIntegerListOfInteger& aDMVLV,
2110 const Standard_Integer iCheckExtend)
2112 Standard_Boolean bIsVertexOnLine;
2115 const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
2116 const Handle(BOPDS_PaveBlock)& aPB = aNC.PaveBlocks().First();
2117 const IntTools_Curve& aIC = aNC.Curve();
2119 Standard_Real aTolV = (aMVTol.IsBound(nV) ? aMVTol(nV) : BRep_Tool::Tolerance(aV));
2121 bIsVertexOnLine = myContext->IsVertexOnLine(aV, aTolV, aIC, aTolR3D + myFuzzyValue, aT);
2122 if (!bIsVertexOnLine && iCheckExtend) {
2123 ExtendedTolerance(nV, aMI, aTolV, iCheckExtend);
2124 bIsVertexOnLine = myContext->IsVertexOnLine(aV, aTolV, aIC, aTolR3D + myFuzzyValue, aT);
2127 if (bIsVertexOnLine) {
2128 // check if aPB contains the parameter aT
2129 Standard_Boolean bExist;
2130 Standard_Integer nVUsed;
2131 Standard_Real aPTol, aDTol;
2135 GeomAdaptor_Curve aGAC(aIC.Curve());
2136 aPTol = aGAC.Resolution(Max(aTolR3D, aTolV));
2138 bExist = aPB->ContainsParameter(aT, aPTol, nVUsed);
2140 // use existing pave
2141 TColStd_ListOfInteger* pList = aDMVLV.ChangeSeek(nVUsed);
2143 pList = aDMVLV.Bound(nVUsed, TColStd_ListOfInteger());
2144 pList->Append(nVUsed);
2145 if (!aMVTol.IsBound(nVUsed)) {
2146 const TopoDS_Vertex& aVUsed = (*(TopoDS_Vertex *)(&myDS->Shape(nVUsed)));
2147 aTolV = BRep_Tool::Tolerance(aVUsed);
2148 aMVTol.Bind(nVUsed, aTolV);
2151 // avoid repeated elements in the list
2152 TColStd_ListIteratorOfListOfInteger aItLI(*pList);
2153 for (; aItLI.More(); aItLI.Next()) {
2154 if (aItLI.Value() == nV) {
2158 if (!aItLI.More()) {
2161 // save initial tolerance for the vertex
2162 if (!aMVTol.IsBound(nV)) {
2163 aTolV = BRep_Tool::Tolerance(aV);
2164 aMVTol.Bind(nV, aTolV);
2171 aPave.SetParameter(aT);
2172 aPB->AppendExtPave(aPave);
2174 gp_Pnt aP1 = aGAC.Value(aT);
2175 aTolV = BRep_Tool::Tolerance(aV);
2176 gp_Pnt aP2 = BRep_Tool::Pnt(aV);
2177 Standard_Real aDist = aP1.Distance(aP2);
2178 if (aDist > aTolV) {
2179 BRep_Builder().UpdateVertex(aV, aDist + aDTol);
2181 if (!aMVTol.IsBound(nV)) {
2182 aMVTol.Bind(nV, aTolV);
2185 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
2186 Bnd_Box& aBoxDS=aSIDS.ChangeBox();
2187 BRepBndLib::Add(aV, aBoxDS);
2188 aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
2194 //=======================================================================
2195 //function : ProcessExistingPaveBlocks
2197 //=======================================================================
2198 void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks
2199 (const Standard_Integer theInt,
2200 const BOPDS_IndexedMapOfPaveBlock& aMPBOnIn,
2201 const TColStd_DataMapOfIntegerListOfInteger& aDMBV,
2202 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB,
2203 TopTools_DataMapOfShapeInteger& aMVI,
2204 BOPDS_MapOfPaveBlock& aMPB)
2206 if (aDMBV.IsEmpty()) {
2210 Standard_Real aT, dummy;
2211 Standard_Integer i, nV, nE, iC, aNbPB, iFlag;
2212 TColStd_ListIteratorOfListOfInteger aItLI;
2213 TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aItBV;
2215 BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
2216 BOPDS_InterfFF& aFF = aFFs(theInt);
2217 BOPDS_VectorOfCurve& aVC = aFF.ChangeCurves();
2219 aNbPB = aMPBOnIn.Extent();
2221 aItBV.Initialize(aDMBV);
2222 for (; aItBV.More(); aItBV.Next()) {
2224 const TColStd_ListOfInteger& aLBV = aItBV.Value();
2226 BOPDS_Curve& aNC = aVC.ChangeValue(iC);
2227 BOPDS_ListOfPaveBlock& aLPBC = aNC.ChangePaveBlocks();
2229 aItLI.Initialize(aLBV);
2230 for (; aItLI.More(); aItLI.Next()) {
2232 const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
2233 const Bnd_Box& aBoxV=aSIV.Box();
2234 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aSIV.Shape();
2235 if (!aMVI.IsBound(aV)) {
2239 for (i = 1; i <= aNbPB; ++i) {
2240 const Handle(BOPDS_PaveBlock)& aPB = aMPBOnIn(i);
2241 if (aPB->Pave1().Index() == nV || aPB->Pave2().Index() == nV) {
2245 if (aMPB.Contains(aPB)) {
2248 if (myDS->ShapeInfo(aPB->OriginalEdge()).HasFlag()) { // skip degenerated edges
2253 const BOPDS_ShapeInfo& aSIE = myDS->ShapeInfo(nE);
2254 const Bnd_Box& aBoxE = aSIE.Box();
2256 if (aBoxV.IsOut(aBoxE)) {
2260 const TopoDS_Edge& aE = *(TopoDS_Edge*)&aSIE.Shape();
2262 iFlag = myContext->ComputeVE(aV, aE, aT, dummy, myFuzzyValue);
2265 PreparePostTreatFF(theInt, iC, aPB, aMSCPB, aMVI, aLPBC);
2271 //=======================================================================
2272 //function : UpdateExistingPaveBlocks
2274 //=======================================================================
2275 void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks
2276 (const Handle(BOPDS_PaveBlock)& aPBf,
2277 BOPDS_ListOfPaveBlock& aLPB,
2278 const Standard_Integer nF1,
2279 const Standard_Integer nF2)
2281 if (!aLPB.Extent()) {
2285 Standard_Integer nE;
2286 Standard_Boolean bCB;
2287 Handle(BOPDS_PaveBlock) aPB, aPB1, aPB2, aPB2n;
2288 Handle(BOPDS_CommonBlock) aCB;
2289 BOPDS_ListIteratorOfListOfPaveBlock aIt, aIt1, aIt2;
2291 BOPDS_FaceInfo& aFI1 = myDS->ChangeFaceInfo(nF1);
2292 BOPDS_FaceInfo& aFI2 = myDS->ChangeFaceInfo(nF2);
2294 BOPDS_IndexedMapOfPaveBlock& aMPBOn1 = aFI1.ChangePaveBlocksOn();
2295 BOPDS_IndexedMapOfPaveBlock& aMPBIn1 = aFI1.ChangePaveBlocksIn();
2296 BOPDS_IndexedMapOfPaveBlock& aMPBOn2 = aFI2.ChangePaveBlocksOn();
2297 BOPDS_IndexedMapOfPaveBlock& aMPBIn2 = aFI2.ChangePaveBlocksIn();
2299 // 1. Remove old pave blocks
2300 const Handle(BOPDS_CommonBlock)& aCB1 = myDS->CommonBlock(aPBf);
2301 bCB = !aCB1.IsNull();
2302 BOPDS_ListOfPaveBlock aLPB1;
2305 aLPB1.Assign(aCB1->PaveBlocks());
2309 aIt1.Initialize(aLPB1);
2310 for (; aIt1.More(); aIt1.Next()) {
2311 aPB1 = aIt1.Value();
2312 nE = aPB1->OriginalEdge();
2314 BOPDS_ListOfPaveBlock& aLPB2 = myDS->ChangePaveBlocks(nE);
2315 aIt2.Initialize(aLPB2);
2316 for (; aIt2.More(); aIt2.Next()) {
2317 aPB2 = aIt2.Value();
2325 // 2. Update pave blocks
2327 // Create new common blocks
2328 BOPDS_ListOfPaveBlock aLPBNew;
2329 const TColStd_ListOfInteger& aFaces = aCB1->Faces();
2330 aIt.Initialize(aLPB);
2331 for (; aIt.More(); aIt.Next()) {
2332 const Handle(BOPDS_PaveBlock)& aPBValue = aIt.Value();
2333 BOPDS_Pave aPBValuePaves[2] = {aPBValue->Pave1(), aPBValue->Pave2()};
2335 aCB = new BOPDS_CommonBlock;
2336 aIt1.Initialize(aLPB1);
2337 for (; aIt1.More(); aIt1.Next()) {
2338 aPB2 = aIt1.Value();
2339 nE = aPB2->OriginalEdge();
2341 // Create new pave block
2342 aPB2n = new BOPDS_PaveBlock;
2343 if (aPBValue->OriginalEdge() == nE) {
2344 aPB2n->SetPave1(aPBValuePaves[0]);
2345 aPB2n->SetPave2(aPBValuePaves[1]);
2348 // For the different original edge compute the parameters of paves
2349 BOPDS_Pave aPave[2];
2350 for (Standard_Integer i = 0; i < 2; ++i) {
2351 Standard_Integer nV = aPBValuePaves[i].Index();
2352 aPave[i].SetIndex(nV);
2353 if (nV == aPB2->Pave1().Index()) {
2354 aPave[i].SetParameter(aPB2->Pave1().Parameter());
2356 else if (nV == aPB2->Pave2().Index()) {
2357 aPave[i].SetParameter(aPB2->Pave2().Parameter());
2360 // Compute the parameter by projecting the point
2361 const TopoDS_Vertex& aV = TopoDS::Vertex(myDS->Shape(nV));
2362 const TopoDS_Edge& aEOr = TopoDS::Edge(myDS->Shape(nE));
2363 Standard_Real aTOut, aDist;
2364 Standard_Integer iErr = myContext->ComputeVE(aV, aEOr, aTOut, aDist, myFuzzyValue);
2366 aPave[i].SetParameter(aTOut);
2369 // Unable to project - set the parameter of the closest boundary
2370 const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(aPB2->Pave1().Index()));
2371 const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(aPB2->Pave2().Index()));
2373 gp_Pnt aP = BRep_Tool::Pnt(aV);
2374 gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
2375 gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
2377 Standard_Real aDist1 = aP.SquareDistance(aP1);
2378 Standard_Real aDist2 = aP.SquareDistance(aP2);
2380 aPave[i].SetParameter(aDist1 < aDist2 ? aPB2->Pave1().Parameter() : aPB2->Pave2().Parameter());
2385 if (aPave[1].Parameter() < aPave[0].Parameter()) {
2386 BOPDS_Pave aPaveTmp = aPave[0];
2387 aPave[0] = aPave[1];
2388 aPave[1] = aPaveTmp;
2391 aPB2n->SetPave1(aPave[0]);
2392 aPB2n->SetPave2(aPave[1]);
2395 aPB2n->SetEdge(aPBValue->Edge());
2396 aPB2n->SetOriginalEdge(nE);
2397 aCB->AddPaveBlock(aPB2n);
2398 myDS->SetCommonBlock(aPB2n, aCB);
2399 myDS->ChangePaveBlocks(nE).Append(aPB2n);
2401 aCB->SetFaces(aFaces);
2403 const Handle(BOPDS_PaveBlock)& aPBNew = aCB->PaveBlocks().First();
2404 aLPBNew.Append(aPBNew);
2410 nE = aPBf->OriginalEdge();
2411 BOPDS_ListOfPaveBlock& aLPBE = myDS->ChangePaveBlocks(nE);
2412 aIt.Initialize(aLPB);
2413 for (; aIt.More(); aIt.Next()) {
2419 Standard_Boolean bIn1, bIn2;
2421 bIn1 = aMPBOn1.Contains(aPBf) || aMPBIn1.Contains(aPBf);
2422 bIn2 = aMPBOn2.Contains(aPBf) || aMPBIn2.Contains(aPBf);
2428 // 3. Check new pave blocks for coincidence
2429 // with the opposite face.
2430 // In case of coincidence create common blocks
2431 Standard_Integer nF;
2433 nF = bIn1 ? nF2 : nF1;
2434 const TopoDS_Face& aF = *(TopoDS_Face*)&myDS->Shape(nF);
2435 BOPDS_IndexedMapOfPaveBlock& aMPBIn = bIn1 ? aMPBIn2 : aMPBIn1;
2437 aIt.Initialize(aLPB);
2438 for (; aIt.More(); aIt.Next()) {
2439 Handle(BOPDS_PaveBlock)& aPBChangeValue = aIt.ChangeValue();
2440 const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPBChangeValue->Edge());
2442 IntTools_EdgeFace anEF;
2445 anEF.SetFuzzyValue(myFuzzyValue);
2446 anEF.SetRange(aPBChangeValue->Pave1().Parameter(), aPBChangeValue->Pave2().Parameter());
2447 anEF.SetContext(myContext);
2450 const IntTools_SequenceOfCommonPrts& aCPrts=anEF.CommonParts();
2451 if (aCPrts.Length() == 1) {
2452 Standard_Boolean bCoinc = (aCPrts(1).Type() == TopAbs_EDGE);
2455 aCB = myDS->CommonBlock(aPBChangeValue);
2457 aCB = new BOPDS_CommonBlock;
2458 aCB->AddPaveBlock(aPBChangeValue);
2459 myDS->SetCommonBlock(aPBChangeValue, aCB);
2463 aMPBIn.Add(aPBChangeValue);
2468 //=======================================================================
2469 // function: PutClosingPaveOnCurve
2471 //=======================================================================
2472 void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC)
2474 const IntTools_Curve& aIC = aNC.Curve();
2475 const Handle(Geom_Curve)& aC3D = aIC.Curve();
2481 if (!aIC.HasBounds())
2485 Standard_Real aT[2];
2487 aIC.Bounds(aT[0], aT[1], aP[0], aP[1]);
2489 // Find the pave which has been put at one of the ends
2490 Standard_Integer nV = -1;
2491 // Keep the opposite parameter
2492 Standard_Real aTOp = 0.;
2494 Standard_Boolean bFound = Standard_False;
2496 Handle(BOPDS_PaveBlock)& aPB = aNC.ChangePaveBlock1();
2497 BOPDS_ListOfPave& aLP = aPB->ChangeExtPaves();
2498 BOPDS_ListIteratorOfListOfPave aItLP(aLP);
2499 for (; aItLP.More() && !bFound; aItLP.Next())
2501 const BOPDS_Pave& aPC = aItLP.Value();
2502 Standard_Real aTC = aPC.Parameter();
2503 for (Standard_Integer j = 0; j < 2; ++j)
2505 if (Abs(aTC - aT[j]) < Precision::PConfusion())
2508 aTOp = (!j) ? aT[1] : aT[0];
2509 bFound = Standard_True;
2518 // Check if the curve is closed using the tolerance
2520 const TopoDS_Vertex& aV = TopoDS::Vertex(myDS->Shape(nV));
2521 const Standard_Real aTolV = BRep_Tool::Tolerance(aV);
2523 Standard_Real aDist = aP[0].Distance(aP[1]);
2527 // Check if there will be valid range on the curve
2528 Standard_Real aFirst, aLast;
2529 if (!BRepLib::FindValidRange(GeomAdaptor_Curve(aIC.Curve()), aIC.Tolerance(),
2530 aT[0], aP[0], aTolV,
2531 aT[1], aP[1], aTolV,
2537 // Add closing pave to the curve
2540 aPave.SetParameter(aTOp);
2543 //=======================================================================
2544 //function : PreparePostTreatFF
2546 //=======================================================================
2547 void BOPAlgo_PaveFiller::PreparePostTreatFF
2548 (const Standard_Integer aInt,
2549 const Standard_Integer aCur,
2550 const Handle(BOPDS_PaveBlock)& aPB,
2551 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB,
2552 TopTools_DataMapOfShapeInteger& aMVI,
2553 BOPDS_ListOfPaveBlock& aLPBC)
2555 Standard_Integer nV1, nV2;
2559 aPB->Indices(nV1, nV2);
2560 const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
2561 const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
2562 const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge());
2563 // Keep info for post treatment
2564 BOPDS_CoupleOfPaveBlocks aCPB;
2565 aCPB.SetIndexInterf(aInt);
2566 aCPB.SetIndex(aCur);
2567 aCPB.SetPaveBlock1(aPB);
2569 aMSCPB.Add(aE, aCPB);
2570 aMVI.Bind(aV1, nV1);
2571 aMVI.Bind(aV2, nV2);
2574 //=======================================================================
2575 //function : CheckPlanes
2577 //=======================================================================
2578 Standard_Boolean BOPAlgo_PaveFiller::CheckPlanes
2579 (const Standard_Integer nF1,
2580 const Standard_Integer nF2)const
2582 Standard_Boolean bToIntersect;
2583 Standard_Integer i, nV2, iCnt;
2584 TColStd_MapIteratorOfMapOfInteger aIt;
2586 bToIntersect=Standard_False;
2588 const BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
2589 const BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
2591 const TColStd_MapOfInteger& aMVIn1=aFI1.VerticesIn();
2592 const TColStd_MapOfInteger& aMVOn1=aFI1.VerticesOn();
2595 for (i=0; (i<2 && !bToIntersect); ++i) {
2596 const TColStd_MapOfInteger& aMV2=(!i) ? aFI2.VerticesIn()
2597 : aFI2.VerticesOn();
2599 aIt.Initialize(aMV2);
2600 for (; aIt.More(); aIt.Next()) {
2602 if (aMVIn1.Contains(nV2) || aMVOn1.Contains(nV2)) {
2605 bToIntersect=!bToIntersect;
2612 return bToIntersect;
2614 //=======================================================================
2615 //function : UpdatePaveBlocks
2617 //=======================================================================
2618 void BOPAlgo_PaveFiller::UpdatePaveBlocks
2619 (const TColStd_DataMapOfIntegerInteger& aDMNewSD)
2621 if (aDMNewSD.IsEmpty()) {
2625 Standard_Integer nSp, aNbPBP, nV[2], i, j;
2626 Standard_Real aT[2];
2627 Standard_Boolean bCB, bRebuild;
2628 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
2629 BOPDS_MapOfPaveBlock aMPB;
2630 TColStd_MapOfInteger aMicroEdges;
2632 BOPDS_ListOfPaveBlock anAllPBs;
2634 // Get pave blocks of section edges
2635 BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
2636 Standard_Integer aNbFF = aFFs.Length();
2637 for (i = 0; i < aNbFF; ++i)
2639 const BOPDS_InterfFF& aFF = aFFs(i);
2640 const BOPDS_VectorOfCurve& aVNC = aFF.Curves();
2641 Standard_Integer aNbC = aVNC.Length();
2642 for (j = 0; j < aNbC; ++j)
2644 const BOPDS_Curve& aNC = aVNC(j);
2645 const BOPDS_ListOfPaveBlock& aLPBC = aNC.PaveBlocks();
2646 aItPB.Initialize(aLPBC);
2647 for (; aItPB.More(); aItPB.Next())
2648 anAllPBs.Append(aItPB.Value());
2652 // Get pave blocks from the pool
2653 BOPDS_VectorOfListOfPaveBlock& aPBP = myDS->ChangePaveBlocksPool();
2654 aNbPBP = aPBP.Length();
2655 for (i = 0; i < aNbPBP; ++i) {
2656 BOPDS_ListOfPaveBlock& aLPB = aPBP(i);
2657 aItPB.Initialize(aLPB);
2658 for (; aItPB.More(); aItPB.Next())
2659 anAllPBs.Append(aItPB.Value());
2662 // Process all pave blocks
2663 aItPB.Initialize(anAllPBs);
2664 for (; aItPB.More(); aItPB.Next())
2666 Handle(BOPDS_PaveBlock) aPB = aItPB.Value();
2667 const Handle(BOPDS_CommonBlock)& aCB = myDS->CommonBlock(aPB);
2668 bCB = !aCB.IsNull();
2670 aPB = aCB->PaveBlock1();
2673 if (aMPB.Add(aPB)) {
2674 bRebuild = Standard_False;
2675 aPB->Indices(nV[0], nV[1]);
2676 aPB->Range(aT[0], aT[1]);
2677 // remember the fact if the edge had different vertices before substitution
2678 Standard_Boolean wasRegularEdge = (nV[0] != nV[1]);
2680 for (j = 0; j < 2; ++j) {
2681 if (aDMNewSD.IsBound(nV[j])) {
2684 nV[j] = aDMNewSD.Find(nV[j]);
2685 aPave.SetIndex(nV[j]);
2686 aPave.SetParameter(aT[j]);
2688 bRebuild = Standard_True;
2690 aPB->SetPave1(aPave);
2693 aPB->SetPave2(aPave);
2699 Standard_Integer nE = aPB->Edge();
2700 // Check if the Pave Block has the edge set
2703 nE = aPB->OriginalEdge();
2705 Standard_Boolean isDegEdge = myDS->ShapeInfo(nE).HasFlag();
2706 if (wasRegularEdge && !isDegEdge && nV[0] == nV[1]) {
2707 // now edge has the same vertex on both ends;
2708 // check if it is not a regular closed curve.
2709 const TopoDS_Edge& aE = TopoDS::Edge(myDS->Shape(nE));
2710 const TopoDS_Vertex& aV = TopoDS::Vertex(myDS->Shape(nV[0]));
2711 Standard_Real aLength = IntTools::Length(aE);
2712 Standard_Real aTolV = BRep_Tool::Tolerance(aV);
2713 if (aLength <= aTolV * 2.) {
2714 // micro edge, so mark it for removal
2715 aMicroEdges.Add(nE);
2719 nSp = SplitEdge(nE, nV[0], aT[0], nV[1], aT[1]);
2725 }// if (aMPB.Add(aPB)) {
2726 }// for (; aItPB.More(); aItPB.Next()) {
2729 if (aMicroEdges.Extent())
2730 RemovePaveBlocks(aMicroEdges);
2732 //=======================================================================
2733 //function : RemovePaveBlocks
2735 //=======================================================================
2736 void BOPAlgo_PaveFiller::RemovePaveBlocks(const TColStd_MapOfInteger theEdges)
2738 // Remove all pave blocks referring to input edges:
2740 // 1. from the Pave Blocks Pool
2741 BOPDS_VectorOfListOfPaveBlock& aPBP = myDS->ChangePaveBlocksPool();
2742 Standard_Integer aNbPBP = aPBP.Length(), i;
2743 for (i = 0; i < aNbPBP; ++i) {
2744 BOPDS_ListOfPaveBlock& aLPB = aPBP(i);
2746 BOPDS_ListIteratorOfListOfPaveBlock aItPB(aLPB);
2747 while (aItPB.More()) {
2748 const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
2749 if (theEdges.Contains(aPB->Edge()))
2756 // 2. from Face Info and section curves
2757 TColStd_MapOfInteger aMPassed;
2758 BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
2759 Standard_Integer aNbFF = aFFs.Length(), j;
2760 for (i = 0; i < aNbFF; ++i) {
2761 BOPDS_InterfFF& aFF = aFFs(i);
2762 Standard_Integer nF1, nF2;
2763 aFF.Indices(nF1, nF2);
2765 // rebuild pave block maps of face info
2766 for (j = 0; j < 2; j++) {
2767 Standard_Integer nF = (j == 0 ? nF1 : nF2);
2768 if (!aMPassed.Add(nF))
2770 BOPDS_FaceInfo& aFI = myDS->ChangeFaceInfo(nF);
2771 BOPDS_IndexedMapOfPaveBlock* aIMPB[] = { &aFI.ChangePaveBlocksIn(),
2772 &aFI.ChangePaveBlocksOn(), &aFI.ChangePaveBlocksSc() };
2773 for (Standard_Integer k = 0; k < 3; k++) {
2774 Standard_Integer aNbPB = aIMPB[k]->Extent(), m;
2775 for (m = 1; m <= aNbPB; ++m) {
2776 const Handle(BOPDS_PaveBlock)& aPB = aIMPB[k]->FindKey(m);
2777 if (theEdges.Contains(aPB->Edge()))
2781 BOPDS_IndexedMapOfPaveBlock aMPBCopy = *aIMPB[k];
2783 for (m = 1; m <= aNbPB; ++m) {
2784 const Handle(BOPDS_PaveBlock)& aPB = aMPBCopy(m);
2785 if (!theEdges.Contains(aPB->Edge()))
2791 // remove from Section pave blocks
2792 BOPDS_VectorOfCurve& aVNC = aFF.ChangeCurves();
2793 Standard_Integer aNbC = aVNC.Length();
2794 for (j = 0; j < aNbC; ++j) {
2795 BOPDS_Curve& aNC = aVNC(j);
2796 BOPDS_ListOfPaveBlock& aLPB = aNC.ChangePaveBlocks();
2797 BOPDS_ListIteratorOfListOfPaveBlock aItPB(aLPB);
2798 while (aItPB.More()) {
2799 const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
2800 if (theEdges.Contains(aPB->Edge()))
2808 //=======================================================================
2809 //function : ToleranceFF
2810 //purpose : Computes the TolFF according to the tolerance value and
2811 // types of the faces.
2812 //=======================================================================
2813 Standard_Real ToleranceFF(const BRepAdaptor_Surface& aBAS1,
2814 const BRepAdaptor_Surface& aBAS2)
2816 Standard_Real aTol1 = aBAS1.Tolerance();
2817 Standard_Real aTol2 = aBAS2.Tolerance();
2818 Standard_Real aTolFF = Max(aTol1, aTol2);
2820 Standard_Boolean isAna1, isAna2;
2821 isAna1 = (aBAS1.GetType() == GeomAbs_Plane ||
2822 aBAS1.GetType() == GeomAbs_Cylinder ||
2823 aBAS1.GetType() == GeomAbs_Cone ||
2824 aBAS1.GetType() == GeomAbs_Sphere ||
2825 aBAS1.GetType() == GeomAbs_Torus);
2827 isAna2 = (aBAS2.GetType() == GeomAbs_Plane ||
2828 aBAS2.GetType() == GeomAbs_Cylinder ||
2829 aBAS2.GetType() == GeomAbs_Cone ||
2830 aBAS2.GetType() == GeomAbs_Sphere ||
2831 aBAS2.GetType() == GeomAbs_Torus);
2833 if (!isAna1 || !isAna2) {
2834 aTolFF = Max(aTolFF, 5.e-6);
2838 //=======================================================================
2839 //function : UpdateBlocksWithSharedVertices
2841 //=======================================================================
2842 void BOPAlgo_PaveFiller::UpdateBlocksWithSharedVertices()
2844 if (!myNonDestructive) {
2848 Standard_Integer aNbFF;
2850 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
2851 aNbFF=aFFs.Length();
2856 Standard_Boolean bOnCurve, bHasShapeSD;
2857 Standard_Integer i, nF1, nF2, aNbC, j, nV, nVSD;
2858 Standard_Real aTolV;
2859 TColStd_MapOfInteger aMF;
2861 for (i=0; i<aNbFF; ++i) {
2862 BOPDS_InterfFF& aFF=aFFs(i);
2864 BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves();
2870 aFF.Indices(nF1, nF2);
2873 myDS->UpdateFaceInfoOn(nF1);
2876 myDS->UpdateFaceInfoOn(nF2);
2879 // Collect old vertices that are shared for nF1, nF2 ->aMI;
2880 TColStd_MapOfInteger aMI;
2881 TColStd_MapIteratorOfMapOfInteger aItMI;
2883 BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
2884 BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
2886 const TColStd_MapOfInteger& aMVOn1=aFI1.VerticesOn();
2887 const TColStd_MapOfInteger& aMVIn1=aFI1.VerticesIn();
2888 const TColStd_MapOfInteger& aMVOn2=aFI2.VerticesOn();
2889 const TColStd_MapOfInteger& aMVIn2=aFI2.VerticesIn();
2891 for (j=0; j<2; ++j) {
2892 const TColStd_MapOfInteger& aMV1=(!j) ? aMVOn1 : aMVIn1;
2893 aItMI.Initialize(aMV1);
2894 for (; aItMI.More(); aItMI.Next()) {
2896 if (myDS->IsNewShape(nV)) {
2899 if (aMVOn2.Contains(nV) || aMVIn2.Contains(nV)) {
2905 // Try to put vertices aMI on curves
2906 for (j=0; j<aNbC; ++j) {
2907 BOPDS_Curve& aNC=aVC.ChangeValue(j);
2908 Standard_Real aTolR3D = Max(aNC.Tolerance(), aNC.TangentialTolerance());
2910 aItMI.Initialize(aMI);
2911 for (; aItMI.More(); aItMI.Next()) {
2914 bHasShapeSD=myDS->HasShapeSD(nV, nVSD);
2919 bOnCurve=EstimatePaveOnCurve(nV, aNC, aTolR3D);
2924 const TopoDS_Vertex& aV=*((TopoDS_Vertex *)&myDS->Shape(nV));
2925 aTolV=BRep_Tool::Tolerance(aV);
2927 UpdateVertex(nV, aTolV);
2929 }//for (j=0; j<aNbC; ++j) {
2930 }//for (i=0; i<aNbFF; ++i) {
2932 UpdateCommonBlocksWithSDVertices();
2934 //=======================================================================
2935 //function : EstimatePaveOnCurve
2937 //=======================================================================
2938 Standard_Boolean BOPAlgo_PaveFiller::EstimatePaveOnCurve
2939 (const Standard_Integer nV,
2940 const BOPDS_Curve& aNC,
2941 const Standard_Real aTolR3D)
2943 Standard_Boolean bIsVertexOnLine;
2946 const TopoDS_Vertex& aV=*((TopoDS_Vertex *)&myDS->Shape(nV));
2947 const IntTools_Curve& aIC=aNC.Curve();
2949 bIsVertexOnLine=myContext->IsVertexOnLine(aV, aIC, aTolR3D, aT);
2950 return bIsVertexOnLine;
2953 //=======================================================================
2954 //function : CorrectToleranceOfSE
2956 //=======================================================================
2957 void BOPAlgo_PaveFiller::CorrectToleranceOfSE()
2959 BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
2960 NCollection_IndexedDataMap<Standard_Integer,BOPDS_ListOfPaveBlock> aMVIPBs;
2961 TColStd_MapOfInteger aMVIToReduce;
2962 // Fence map to avoid repeated checking of the same edge
2963 BOPDS_MapOfPaveBlock aMPB;
2965 // 1. iterate on all sections F-F
2966 Standard_Integer aNb = aFFs.Length(), i;
2967 for (i = 0; i < aNb; ++i) {
2968 BOPDS_InterfFF& aFF = aFFs(i);
2970 BOPDS_VectorOfCurve& aVNC = aFF.ChangeCurves();
2971 Standard_Integer aNbC = aVNC.Length(), k;
2972 for (k = 0; k < aNbC; ++k) {
2973 BOPDS_Curve& aNC = aVNC(k);
2974 BOPDS_ListOfPaveBlock& aLPB = aNC.ChangePaveBlocks();
2975 BOPDS_ListIteratorOfListOfPaveBlock aItLPB(aLPB);
2976 for (; aItLPB.More(); ) {
2977 const Handle(BOPDS_PaveBlock)& aPB = aItLPB.Value();
2978 Standard_Integer nE;
2979 if (!aPB->HasEdge(nE)) {
2980 aLPB.Remove(aItLPB);
2984 if (!aMPB.Add(aPB)) {
2989 Standard_Boolean bIsReduced = Standard_False;
2990 if (aPB->OriginalEdge() < 0) {
2991 // It is possible that due to small angle between faces the
2992 // common zone between faces can be large and the tangential
2993 // tolerance of the curve will be large as well.
2994 // Here we're trying to reduce the tolerance of the section
2995 // edge using the valid tolerance of the edge.
2996 // Note, that if the pave block has created common block with
2997 // other edges its valid tolerance could have been changed to
2998 // cover all edges in common block (see PostTreatFF() method).
2999 Standard_Real aTolC = aNC.Tolerance();
3000 Standard_Real aTolTang = aNC.TangentialTolerance();
3001 if (aTolC < aTolTang) {
3002 const TopoDS_Edge& aE = TopoDS::Edge(myDS->Shape(nE));
3003 Standard_Real aTolE = BRep_Tool::Tolerance(aE);
3004 if (aTolC < aTolE) {
3005 // reduce edge tolerance
3006 reinterpret_cast<BRep_TEdge*>(aE.TShape().operator->())->Tolerance(aTolC);
3007 bIsReduced = Standard_True;
3012 // fill in the map vertex index - pave blocks
3013 for (Standard_Integer j=0; j < 2; j++) {
3014 Standard_Integer nV = (j == 0 ? aPB->Pave1().Index() : aPB->Pave2().Index());
3015 myDS->HasShapeSD(nV, nV);
3016 BOPDS_ListOfPaveBlock *pPBList = aMVIPBs.ChangeSeek(nV);
3018 pPBList = &aMVIPBs.ChangeFromIndex(aMVIPBs.Add(nV, BOPDS_ListOfPaveBlock()));
3020 pPBList->Append(aPB);
3022 aMVIToReduce.Add(nV);
3030 if (aMVIToReduce.IsEmpty()) {
3034 // 2. try to reduce tolerances of connected vertices
3035 // 2.1 find all other edges containing these connected vertices to avoid
3036 // reducing the tolerance to the value less than the tolerances of edges,
3037 // i.e. minimal tolerance for the vertex is the max tolerance of the
3038 // edges containing this vertex
3039 TColStd_DataMapOfIntegerReal aMVITol;
3040 BOPDS_VectorOfListOfPaveBlock& aPBP = myDS->ChangePaveBlocksPool();
3041 aNb = aPBP.Length();
3042 for (i = 0; i < aNb; ++i) {
3043 const BOPDS_ListOfPaveBlock& aLPB = aPBP(i);
3044 BOPDS_ListIteratorOfListOfPaveBlock aItLPB(aLPB);
3045 for (; aItLPB.More(); aItLPB.Next()) {
3046 const Handle(BOPDS_PaveBlock)& aPB = aItLPB.Value();
3047 Standard_Integer nE;
3048 if (!aPB->HasEdge(nE)) {
3051 const TopoDS_Edge& aE = TopoDS::Edge(myDS->Shape(nE));
3052 Standard_Real aTolE = BRep_Tool::Tolerance(aE);
3054 Standard_Integer nV[2];
3055 aPB->Indices(nV[0], nV[1]);
3057 for (Standard_Integer j = 0; j < 2; j++) {
3058 if (aMVIToReduce.Contains(nV[j])) {
3059 Standard_Real *aMaxTol = aMVITol.ChangeSeek(nV[j]);
3061 aMVITol.Bind(nV[j], aTolE);
3063 else if (aTolE > *aMaxTol) {
3071 // 2.2 reduce tolerances if possible
3072 aNb = aMVIPBs.Extent();
3073 for (i = 1; i <= aNb; ++i) {
3074 Standard_Integer nV = aMVIPBs.FindKey(i);
3075 if (!aMVIToReduce.Contains(nV)) {
3079 const TopoDS_Vertex& aV = TopoDS::Vertex(myDS->Shape(nV));
3080 Standard_Real aTolV = BRep_Tool::Tolerance(aV);
3081 Standard_Real aMaxTol = aMVITol.IsBound(nV) ? aMVITol.Find(nV) : 0.;
3082 // it makes no sense to compute the real tolerance if it is
3083 // impossible to reduce the tolerance at least 0.1% of the current value
3084 if (aTolV - aMaxTol < 0.001 * aTolV) {
3088 // compute the maximal distance from the vertex to the adjacent edges
3089 gp_Pnt aP = BRep_Tool::Pnt(aV);
3091 // Avoid repeated checks
3092 BOPDS_MapOfPaveBlock aMPBFence;
3094 const BOPDS_ListOfPaveBlock& aLPB = aMVIPBs.FindFromIndex(i);
3095 BOPDS_ListIteratorOfListOfPaveBlock aItLPB(aLPB);
3096 for (; aItLPB.More(); aItLPB.Next()) {
3097 const Handle(BOPDS_PaveBlock)& aPB = aItLPB.Value();
3098 if (!aMPBFence.Add(aPB)) {
3101 Standard_Integer nE = aPB->Edge();
3102 const TopoDS_Edge& aE = TopoDS::Edge(myDS->Shape(nE));
3103 BRepAdaptor_Curve aC(aE);
3104 for (Standard_Integer iPave = 0; iPave < 2; ++iPave) {
3105 const BOPDS_Pave& aPave = !iPave ? aPB->Pave1() : aPB->Pave2();
3106 Standard_Integer nVSD = aPave.Index();
3107 myDS->HasShapeSD(nVSD, nVSD);
3112 gp_Pnt aPonE = aC.Value(aPave.Parameter());
3113 Standard_Real aDist = aP.Distance(aPonE);
3114 aDist += BRep_Tool::Tolerance(aE);
3115 if (aDist > aMaxTol) {
3121 if (aMaxTol < aTolV) {
3122 reinterpret_cast<BRep_TVertex*>(aV.TShape().operator->())->Tolerance(aMaxTol);
3127 //=======================================================================
3128 //function : PutSEInOtherFaces
3130 //=======================================================================
3131 void BOPAlgo_PaveFiller::PutSEInOtherFaces()
3133 // Try to intersect each section edge with the faces
3134 // not participated in its creation
3136 // 1. Get all section edges
3137 BOPDS_IndexedMapOfPaveBlock aMPBScAll;
3139 BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
3140 Standard_Integer i, j, aNbFF = aFFs.Length();
3142 for (i = 0; i < aNbFF; ++i) {
3143 const BOPDS_VectorOfCurve& aVNC = aFFs(i).Curves();
3144 Standard_Integer aNbC = aVNC.Length();
3145 for (j = 0; j < aNbC; ++j) {
3146 const BOPDS_ListOfPaveBlock& aLPBC = aVNC(j).PaveBlocks();
3147 BOPDS_ListIteratorOfListOfPaveBlock aItPB(aLPBC);
3148 for (; aItPB.More(); aItPB.Next()) {
3149 aMPBScAll.Add(aItPB.Value());
3154 Standard_Integer aNbPBSc = aMPBScAll.Extent();
3156 // 2. Loop for all faces and check each section curve
3157 Standard_Integer aNbS = myDS->NbSourceShapes();
3158 for (i = 0; i < aNbS; ++i) {
3159 const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
3160 if (aSI.ShapeType() != TopAbs_FACE) {
3164 const TopoDS_Face& aF = (*(TopoDS_Face*)(&aSI.Shape()));
3165 BOPDS_FaceInfo& aFI = myDS->ChangeFaceInfo(i);
3167 // IN edges to add new ones
3168 BOPDS_IndexedMapOfPaveBlock& aMFPBIn = aFI.ChangePaveBlocksIn();
3169 // Section edges to check the participation of the face
3170 const BOPDS_IndexedMapOfPaveBlock& aMFPBSc = aFI.PaveBlocksSc();
3172 // Get vertices of the face to check that vertices of the
3173 // processed section edge belong to the face
3174 TColStd_MapOfInteger aMFVerts;
3175 // Get vertices from ON, IN and Sc pave blocks of the face
3176 for (j = 0; j < 3; ++j) {
3177 const BOPDS_IndexedMapOfPaveBlock& aMPB =
3178 !j ? aFI.PaveBlocksOn() : (j == 1 ? aMFPBIn : aMFPBSc);
3179 Standard_Integer aNbPB = aMPB.Extent();
3180 for (Standard_Integer k = 1; k <= aNbPB; ++k) {
3181 const Handle(BOPDS_PaveBlock)& aPB = aMPB(k);
3182 aMFVerts.Add(aPB->Pave1().Index());
3183 aMFVerts.Add(aPB->Pave2().Index());
3186 // Add ON, IN and Sc vertices of the face
3187 for (j = 0; j < 3; ++j) {
3188 const TColStd_MapOfInteger& aMFV = !j ? aFI.VerticesOn() :
3189 (j == 1 ? aFI.VerticesIn() : aFI.VerticesSc());
3190 TColStd_MapIteratorOfMapOfInteger aItMI(aMFV);
3191 for (; aItMI.More(); aItMI.Next()) {
3192 aMFVerts.Add(aItMI.Value());
3196 // Check each section edge for possible belonging to the face
3197 for (j = 1; j <= aNbPBSc; ++j) {
3198 const Handle(BOPDS_PaveBlock)& aPB = aMPBScAll(j);
3199 if (aMFPBSc.Contains(aPB)) {
3203 // Both vertices of the section edge should belong to the face
3204 if (!aMFVerts.Contains(aPB->Pave1().Index()) ||
3205 !aMFVerts.Contains(aPB->Pave2().Index())) {
3209 // Perform intersection
3210 const TopoDS_Edge& aE = TopoDS::Edge(myDS->Shape(aPB->Edge()));
3212 IntTools_EdgeFace anEFInt;
3213 anEFInt.SetEdge(aE);
3214 anEFInt.SetFace(aF);
3215 anEFInt.SetFuzzyValue(myFuzzyValue);
3216 anEFInt.SetRange(aPB->Pave1().Parameter(), aPB->Pave2().Parameter());
3217 anEFInt.SetContext(myContext);
3218 anEFInt.UseQuickCoincidenceCheck(Standard_True);
3221 const IntTools_SequenceOfCommonPrts& aCPrts = anEFInt.CommonParts();
3222 if ((aCPrts.Length() == 1) && (aCPrts(1).Type() == TopAbs_EDGE)) {
3223 Handle(BOPDS_CommonBlock) aCB;
3224 if (myDS->IsCommonBlock(aPB)) {
3225 aCB = myDS->CommonBlock(aPB);
3228 aCB = new BOPDS_CommonBlock;
3229 aCB->AddPaveBlock(aPB);
3240 //=======================================================================
3241 //function : RemoveMicroSectionEdges
3243 //=======================================================================
3244 void BOPAlgo_PaveFiller::RemoveMicroSectionEdges
3245 (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB,
3246 TopTools_IndexedMapOfShape& theMicroEdges)
3248 if (theMSCPB.IsEmpty())
3252 // Get all F/F interferences
3253 BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
3255 // Build the new map of section edges avoiding the micro edges
3256 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aSEPBMap;
3257 // Analyze all section edges
3258 Standard_Integer aNbCPB = theMSCPB.Extent();
3259 for (Standard_Integer i = 1; i <= aNbCPB; ++i)
3261 const TopoDS_Shape& aSI = theMSCPB.FindKey(i);
3262 const BOPDS_CoupleOfPaveBlocks& aCPB = theMSCPB(i);
3264 if (aSI.ShapeType() != TopAbs_EDGE)
3267 aSEPBMap.Add(aSI, aCPB);
3271 // Get pave block for analysis
3272 const Handle(BOPDS_PaveBlock)& aPB = aCPB.PaveBlock1();
3275 // Not a real section edge
3276 aSEPBMap.Add(aSI, aCPB);
3280 if (!BOPTools_AlgoTools::IsMicroEdge(TopoDS::Edge(aSI), myContext, Standard_False))
3283 aSEPBMap.Add(aSI, aCPB);
3287 // Micro edge is found, avoid it in the <theMSCPB> map
3288 // and remove from the F/F Intersection info structure
3290 // Get F/F interference which created this micro edge
3291 BOPDS_InterfFF& aFF = aFFs(aCPB.IndexInterf());
3292 // Get curve from which this edge has been created
3293 BOPDS_Curve& aCurve = aFF.ChangeCurves().ChangeValue(aCPB.Index());
3294 // Get all section pave blocks created from this curve
3295 BOPDS_ListOfPaveBlock& aLPBC = aCurve.ChangePaveBlocks();
3296 // Remove pave block from the list
3297 for (BOPDS_ListIteratorOfListOfPaveBlock it(aLPBC); it.More(); it.Next())
3299 if (it.Value() == aPB)
3306 // Add the "micro" edge to the map of "micro" edges for
3307 // unification of its vertices in the PostTreatFF method
3308 theMicroEdges.Add(aSI);
3311 // Overwrite the old map if necessary
3312 if (aSEPBMap.Extent() != theMSCPB.Extent())
3313 theMSCPB = aSEPBMap;