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 <Bnd_Box.hxx>
19 #include <BOPAlgo_PaveFiller.hxx>
20 #include <BOPAlgo_SectionAttribute.hxx>
21 #include <BOPAlgo_Tools.hxx>
22 #include <BOPCol_DataMapOfIntegerReal.hxx>
23 #include <BOPCol_DataMapOfShapeInteger.hxx>
24 #include <BOPCol_ListOfInteger.hxx>
25 #include <BOPCol_ListOfShape.hxx>
26 #include <BOPCol_MapOfInteger.hxx>
27 #include <BOPCol_NCVector.hxx>
28 #include <BOPCol_Parallel.hxx>
29 #include <BOPDS_CommonBlock.hxx>
30 #include <BOPDS_CoupleOfPaveBlocks.hxx>
31 #include <BOPDS_Curve.hxx>
32 #include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
33 #include <BOPDS_DS.hxx>
34 #include <BOPDS_FaceInfo.hxx>
35 #include <BOPDS_Interf.hxx>
36 #include <BOPDS_Iterator.hxx>
37 #include <BOPDS_ListOfPave.hxx>
38 #include <BOPDS_ListOfPaveBlock.hxx>
39 #include <BOPDS_MapOfPaveBlock.hxx>
40 #include <BOPDS_PaveBlock.hxx>
41 #include <BOPDS_Point.hxx>
42 #include <BOPDS_ShapeInfo.hxx>
43 #include <BOPDS_VectorOfCurve.hxx>
44 #include <BOPDS_VectorOfPoint.hxx>
45 #include <BOPTools_AlgoTools.hxx>
46 #include <BOPTools_AlgoTools3D.hxx>
47 #include <BRep_Builder.hxx>
48 #include <BRep_Tool.hxx>
49 #include <BRepAdaptor_Curve.hxx>
50 #include <BRepAdaptor_Surface.hxx>
51 #include <BRepBndLib.hxx>
52 #include <BRepBuilderAPI_MakeVertex.hxx>
53 #include <BRepTools.hxx>
54 #include <Geom2d_Curve.hxx>
55 #include <Geom_Curve.hxx>
56 #include <GeomAPI_ProjectPointOnCurve.hxx>
57 #include <GeomAPI_ProjectPointOnSurf.hxx>
59 #include <IntSurf_ListOfPntOn2S.hxx>
60 #include <IntSurf_PntOn2S.hxx>
61 #include <IntTools_Context.hxx>
62 #include <IntTools_Curve.hxx>
63 #include <IntTools_EdgeFace.hxx>
64 #include <IntTools_FaceFace.hxx>
65 #include <IntTools_PntOn2Faces.hxx>
66 #include <IntTools_SequenceOfCurves.hxx>
67 #include <IntTools_SequenceOfPntOn2Faces.hxx>
68 #include <IntTools_ShrunkRange.hxx>
69 #include <IntTools_Tools.hxx>
70 #include <Precision.hxx>
72 #include <TopExp_Explorer.hxx>
73 #include <TopoDS_Compound.hxx>
74 #include <TopoDS_Edge.hxx>
75 #include <TopoDS_Face.hxx>
76 #include <TopoDS_Vertex.hxx>
79 static void ToleranceFF(const BRepAdaptor_Surface& aBAS1,
80 const BRepAdaptor_Surface& aBAS2,
81 Standard_Real& aTolFF);
83 /////////////////////////////////////////////////////////////////////////
84 //=======================================================================
85 //class : BOPAlgo_FaceFace
87 //=======================================================================
88 class BOPAlgo_FaceFace :
89 public IntTools_FaceFace,
98 myIF1(-1), myIF2(-1), myTolFF(1.e-7) {
101 virtual ~BOPAlgo_FaceFace() {
104 void SetIndices(const Standard_Integer nF1,
105 const Standard_Integer nF2) {
110 void Indices(Standard_Integer& nF1,
111 Standard_Integer& nF2) const {
116 void SetFaces(const TopoDS_Face& aF1,
117 const TopoDS_Face& aF2) {
122 const TopoDS_Face& Face1()const {
126 const TopoDS_Face& Face2()const {
130 void SetTolFF(const Standard_Real aTolFF) {
134 Standard_Real TolFF() const{
138 virtual void Perform() {
139 BOPAlgo_Algo::UserBreak();
140 IntTools_FaceFace::Perform(myF1, myF2);
144 Standard_Integer myIF1;
145 Standard_Integer myIF2;
146 Standard_Real myTolFF;
151 //=======================================================================
152 typedef BOPCol_NCVector
153 <BOPAlgo_FaceFace> BOPAlgo_VectorOfFaceFace;
155 typedef BOPCol_Functor
157 BOPAlgo_VectorOfFaceFace> BOPAlgo_FaceFaceFunctor;
160 <BOPAlgo_FaceFaceFunctor,
161 BOPAlgo_VectorOfFaceFace> BOPAlgo_FaceFaceCnt;
162 /////////////////////////////////////////////////////////////////////////
163 //=======================================================================
164 //function : PerformFF
166 //=======================================================================
167 void BOPAlgo_PaveFiller::PerformFF()
169 Standard_Integer iSize;
170 Standard_Boolean bValid;
174 myIterator->Initialize(TopAbs_FACE, TopAbs_FACE);
175 iSize=myIterator->ExpectedLength();
180 Standard_Boolean bJustAdd, bApp, bCompC2D1, bCompC2D2, bIsDone;
181 Standard_Boolean bToSplit, bTangentFaces;
182 Standard_Integer nF1, nF2, aNbCurves, aNbPoints, i, aNbLP;
183 Standard_Integer aNbFaceFace, k;
184 Standard_Real aApproxTol, aTolR3D, aTolR2D, aTolFF;
185 BRepAdaptor_Surface aBAS1, aBAS2;
186 BOPCol_MapOfInteger aMI;
187 BOPAlgo_VectorOfFaceFace aVFaceFace;
189 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
190 aFFs.SetIncrement(iSize);
192 bApp=mySectionAttribute.Approximation();
193 bCompC2D1=mySectionAttribute.PCurveOnS1();
194 bCompC2D2=mySectionAttribute.PCurveOnS2();
196 bToSplit = Standard_False;
198 for (; myIterator->More(); myIterator->Next()) {
199 myIterator->Value(nF1, nF2, bJustAdd);
204 const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
205 const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
207 aBAS1.Initialize(aF1, Standard_False);
208 aBAS2.Initialize(aF2, Standard_False);
210 if (aBAS1.GetType() == GeomAbs_Plane &&
211 aBAS2.GetType() == GeomAbs_Plane) {
212 Standard_Boolean bToIntersect;
215 myDS->UpdateFaceInfoOn(nF1);
216 myDS->UpdateFaceInfoIn(nF1);
219 myDS->UpdateFaceInfoOn(nF2);
220 myDS->UpdateFaceInfoIn(nF2);
223 bToIntersect = CheckPlanes(nF1, nF2);
225 myDS->AddInterf(nF1, nF2);
226 BOPDS_InterfFF& aFF=aFFs.Append1();
227 aFF.SetIndices(nF1, nF2);
233 ToleranceFF(aBAS1, aBAS2, aTolFF);
235 BOPAlgo_FaceFace& aFaceFace=aVFaceFace.Append1();
237 aFaceFace.SetIndices(nF1, nF2);
238 aFaceFace.SetFaces(aF1, aF2);
239 aFaceFace.SetTolFF(aTolFF);
241 IntSurf_ListOfPntOn2S aListOfPnts;
242 GetEFPnts(nF1, nF2, aListOfPnts);
243 aNbLP = aListOfPnts.Extent();
245 aFaceFace.SetList(aListOfPnts);
248 aFaceFace.SetParameters(bApp, bCompC2D1, bCompC2D2, aApproxTol);
249 aFaceFace.SetProgressIndicator(myProgressIndicator);
250 }//for (; myIterator->More(); myIterator->Next()) {
252 aNbFaceFace=aVFaceFace.Extent();
253 //======================================================
254 BOPAlgo_FaceFaceCnt::Perform(myRunParallel, aVFaceFace);
255 //======================================================
257 for (k=0; k < aNbFaceFace; ++k) {
258 BOPAlgo_FaceFace& aFaceFace=aVFaceFace(k);
260 aFaceFace.Indices(nF1, nF2);
261 aTolFF=aFaceFace.TolFF();
263 bIsDone=aFaceFace.IsDone();
265 aTolR3D=aFaceFace.TolReached3d();
266 aTolR2D=aFaceFace.TolReached2d();
267 bTangentFaces=aFaceFace.TangentFaces();
269 if (aTolR3D < aTolFF){
272 if (aTolR2D < 1.e-7){
276 aFaceFace.PrepareLines3D(bToSplit);
278 const IntTools_SequenceOfCurves& aCvsX=aFaceFace.Lines();
279 const IntTools_SequenceOfPntOn2Faces& aPntsX=aFaceFace.Points();
281 aNbCurves=aCvsX.Length();
282 aNbPoints=aPntsX.Length();
284 if (aNbCurves || aNbPoints) {
285 myDS->AddInterf(nF1, nF2);
288 BOPDS_InterfFF& aFF=aFFs.Append1();
289 aFF.SetIndices(nF1, nF2);
291 aFF.SetTolR3D(aTolR3D);
292 aFF.SetTolR2D(aTolR2D);
293 aFF.SetTangentFaces(bTangentFaces);
296 aFF.Init(aNbCurves, aNbPoints);
300 // Fix bounding box expanding coefficient.
301 Standard_Real aBoxExpandValue = aTolR3D;
304 // Modify geometric expanding coefficient by topology value,
305 // since this bounging box used in sharing (vertex or edge).
306 Standard_Real aMaxVertexTol = Max (BRep_Tool::MaxTolerance(aFaceFace.Face1(), TopAbs_VERTEX),
307 BRep_Tool::MaxTolerance(aFaceFace.Face2(), TopAbs_VERTEX));
308 aBoxExpandValue += aMaxVertexTol;
311 BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves();
312 for (i=1; i<=aNbCurves; ++i) {
315 const IntTools_Curve& aIC=aCvsX(i);
316 const Handle(Geom_Curve)& aC3D= aIC.Curve();
317 bValid=IntTools_Tools::CheckCurve(aC3D, aBoxExpandValue, aBox);
319 BOPDS_Curve& aNC=aVNC.Append1();
326 BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
327 for (i=1; i<=aNbPoints; ++i) {
328 const IntTools_PntOn2Faces& aPi=aPntsX(i);
329 const gp_Pnt& aP=aPi.P1().Pnt();
331 BOPDS_Point& aNP=aVNP.Append1();
334 //}// if (aNbCs || aNbPs)
337 BOPDS_InterfFF& aFF=aFFs.Append1();
338 aFF.SetIndices(nF1, nF2);
341 aFF.Init(aNbCurves, aNbPoints);
343 }// for (k=0; k < aNbFaceFace; ++k) {
345 //=======================================================================
346 //function : MakeBlocks
348 //=======================================================================
349 void BOPAlgo_PaveFiller::MakeBlocks()
351 Standard_Integer aNbFF;
355 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
361 Standard_Boolean bExist, bValid2D;
362 Standard_Integer i, nF1, nF2, aNbC, aNbP, j;
363 Standard_Integer nV1, nV2;
364 Standard_Real aTolR3D, aT1, aT2, aTol;
365 Handle(NCollection_BaseAllocator) aAllocator;
366 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
368 Handle(BOPDS_PaveBlock) aPBOut;
370 //-----------------------------------------------------scope f
372 NCollection_BaseAllocator::CommonBaseAllocator();
374 BOPCol_ListOfInteger aLSE(aAllocator), aLBV(aAllocator);
375 BOPCol_MapOfInteger aMVOnIn(100, aAllocator), aMF(100, aAllocator),
376 aMVStick(100,aAllocator), aMVEF(100, aAllocator),
377 aMI(100, aAllocator);
378 BOPDS_IndexedMapOfPaveBlock aMPBOnIn(100, aAllocator);
379 BOPDS_MapOfPaveBlock aMPBAdd(100, aAllocator);
380 BOPDS_ListOfPaveBlock aLPB(aAllocator);
381 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMSCPB(100, aAllocator);
382 BOPCol_DataMapOfShapeInteger aMVI(100, aAllocator);
383 BOPDS_DataMapOfPaveBlockListOfPaveBlock aDMExEdges(100, aAllocator);
384 BOPCol_DataMapOfIntegerReal aMVTol(100, aAllocator);
385 BOPCol_DataMapOfIntegerInteger aDMI(100, aAllocator);
386 BOPCol_DataMapOfIntegerListOfInteger aDMBV(100, aAllocator);
387 BOPCol_DataMapIteratorOfDataMapOfIntegerReal aItMV;
389 for (i=0; i<aNbFF; ++i) {
393 BOPDS_InterfFF& aFF=aFFs(i);
394 aFF.Indices(nF1, nF2);
396 BOPDS_VectorOfPoint& aVP=aFF.ChangePoints();
398 BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves();
400 if (!aNbP && !aNbC) {
404 const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
405 const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
407 aTolR3D=aFF.TolR3D();
411 myDS->UpdateFaceInfoOn(nF1);
412 myDS->UpdateFaceInfoIn(nF1);
415 myDS->UpdateFaceInfoOn(nF2);
416 myDS->UpdateFaceInfoIn(nF2);
419 BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
420 BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
427 myDS->VerticesOnIn(nF1, nF2, aMVOnIn, aMPBOnIn);
428 myDS->SharedEdges(nF1, nF2, aLSE, aAllocator);
431 for (j=0; j<aNbP; ++j) {
433 BOPDS_CoupleOfPaveBlocks aCPB;
435 BOPDS_Point& aNP=aVP.ChangeValue(j);
436 const gp_Pnt& aP=aNP.Pnt();
438 bExist=IsExistingVertex(aP, aTolR3D, aMVOnIn);
440 BOPTools_AlgoTools::MakeNewVertex(aP, aTolR3D, aV);
442 aCPB.SetIndexInterf(i);
444 aMSCPB.Add(aV, aCPB);
451 GetStickVertices(nF1, nF2, aMVStick, aMVEF, aMI);
453 for (j=0; j<aNbC; ++j) {
454 BOPDS_Curve& aNC=aVC.ChangeValue(j);
455 const IntTools_Curve& aIC=aNC.Curve();
457 aNC.InitPaveBlock1();
459 PutPavesOnCurve(aMVOnIn, aTolR3D, aNC, nF1, nF2, aMI, aMVEF, aMVTol);
461 PutStickPavesOnCurve(aF1, aF2, aMI, aNC, aMVStick, aMVTol);
464 PutEFPavesOnCurve(aNC, aMI, aMVEF, aMVTol);
467 if (aIC.HasBounds()) {
470 PutBoundPaveOnCurve(aF1, aF2, aTolR3D, aNC, aLBV);
472 if (!aLBV.IsEmpty()) {
476 }//for (j=0; j<aNbC; ++j) {
478 // Put closing pave if needed
479 for (j=0; j<aNbC; ++j) {
480 BOPDS_Curve& aNC=aVC.ChangeValue(j);
481 PutClosingPaveOnCurve (aNC);
484 // 3. Make section edges
485 for (j=0; j<aNbC; ++j) {
486 BOPDS_Curve& aNC=aVC.ChangeValue(j);
487 const IntTools_Curve& aIC=aNC.Curve();
489 BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
490 Handle(BOPDS_PaveBlock)& aPB1=aNC.ChangePaveBlock1();
493 aPB1->Update(aLPB, Standard_False);
495 aItLPB.Initialize(aLPB);
496 for (; aItLPB.More(); aItLPB.Next()) {
497 Handle(BOPDS_PaveBlock)& aPB=aItLPB.ChangeValue();
498 aPB->Indices(nV1, nV2);
499 aPB->Range (aT1, aT2);
501 if (fabs(aT1 - aT2) < Precision::PConfusion()) {
505 bValid2D=myContext->IsValidBlockForFaces(aT1, aT2, aIC,
511 bExist=IsExistingPaveBlock(aPB, aNC, aTolR3D, aLSE);
516 bExist=IsExistingPaveBlock(aPB, aNC, aTolR3D, aMPBOnIn, aPBOut);
518 if (aMPBAdd.Add(aPBOut)) {
519 Standard_Boolean bInBothFaces = Standard_True;
520 if (!myDS->IsCommonBlock(aPBOut)) {
525 const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
526 aTolE = BRep_Tool::Tolerance(aE);
527 if (aTolR3D > aTolE) {
528 myDS->UpdateEdgeTolerance(nE, aTolR3D);
530 bInBothFaces = Standard_False;
532 bInBothFaces = (aFI1.PaveBlocksOn().Contains(aPBOut) ||
533 aFI1.PaveBlocksIn().Contains(aPBOut))&&
534 (aFI2.PaveBlocksOn().Contains(aPBOut) ||
535 aFI2.PaveBlocksIn().Contains(aPBOut));
538 PreparePostTreatFF(i, j, aPBOut, aMSCPB, aMVI, aLPBC);
545 const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
546 const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
548 BOPTools_AlgoTools::MakeEdge (aIC, aV1, aT1,
549 aV2, aT2, aTolR3D, aES);
550 BOPTools_AlgoTools::MakePCurve(aES, aF1, aF2, aIC,
551 mySectionAttribute.PCurveOnS1(),
552 mySectionAttribute.PCurveOnS2());
554 if (BOPTools_AlgoTools::IsMicroEdge(aES, myContext)) {
558 // Append the Pave Block to the Curve j
561 // Keep info for post treatment
562 BOPDS_CoupleOfPaveBlocks aCPB;
563 aCPB.SetIndexInterf(i);
565 aCPB.SetPaveBlock1(aPB);
567 aMSCPB.Add(aES, aCPB);
576 }//for (j=0; j<aNbC; ++j) {
577 //back to previous tolerance values for unused vertices
578 aItMV.Initialize(aMVTol);
579 for (; aItMV.More(); aItMV.Next()) {
581 aTol = aItMV.Value();
583 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV1);
584 const Handle(BRep_TVertex)& TV =
585 *((Handle(BRep_TVertex)*)&aV.TShape());
589 ProcessExistingPaveBlocks(i, aMPBOnIn, aDMBV, aMSCPB, aMVI, aMPBAdd);
590 }//for (i=0; i<aNbFF; ++i) {
593 myErrorStatus=PostTreatFF(aMSCPB, aMVI, aDMExEdges, aDMI, aAllocator);
599 UpdateFaceInfo(aDMExEdges, aDMI);
600 //Update all pave blocks
601 UpdatePaveBlocks(aDMI);
602 //-----------------------------------------------------scope t
612 //=======================================================================
613 //function : PostTreatFF
615 //=======================================================================
616 Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
617 (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB,
618 BOPCol_DataMapOfShapeInteger& aMVI,
619 BOPDS_DataMapOfPaveBlockListOfPaveBlock& aDMExEdges,
620 BOPCol_DataMapOfIntegerInteger& aDMI,
621 const Handle(NCollection_BaseAllocator)& theAllocator)
623 Standard_Integer iRet, aNbS;
626 aNbS=theMSCPB.Extent();
631 Standard_Boolean bHasPaveBlocks, bOld;
632 Standard_Integer iErr, nSx, nVSD, iX, iP, iC, j, nV, iV = 0, iE, k;
633 Standard_Integer jx, aNbLPBx;
635 TopAbs_ShapeEnum aType;
637 BOPCol_ListIteratorOfListOfShape aItLS;
638 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
640 Handle(BOPDS_PaveBlock) aPB1;
641 BOPDS_Pave aPave[2], aPave1[2];
644 BOPCol_ListOfShape aLS(theAllocator);
645 BOPAlgo_PaveFiller aPF(theAllocator);
647 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
651 const TopoDS_Shape& aS=theMSCPB.FindKey(1);
652 const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromIndex(1);
655 aType=aS.ShapeType();
656 if (aType==TopAbs_VERTEX) {
657 aSI.SetShapeType(aType);
659 iV=myDS->Append(aSI);
661 iX=aCPB.IndexInterf();
663 BOPDS_InterfFF& aFF=aFFs(iX);
664 BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
665 BOPDS_Point& aNP=aVNP(iP);
668 else if (aType==TopAbs_EDGE) {
669 aPB1=aCPB.PaveBlock1();
671 if (aPB1->HasEdge()) {
672 BOPDS_ListOfPaveBlock aLPBx;
674 aDMExEdges.Bind(aPB1, aLPBx);
676 aSI.SetShapeType(aType);
678 iE=myDS->Append(aSI);
686 // 1 prepare arguments
687 for (k=1; k<=aNbS; ++k) {
688 const TopoDS_Shape& aS=theMSCPB.FindKey(k);
693 aPF.SetProgressIndicator(myProgressIndicator);
694 aPF.SetRunParallel(myRunParallel);
695 aPF.SetArguments(aLS);
697 iErr=aPF.ErrorStatus();
703 aItLS.Initialize(aLS);
704 for (; aItLS.More(); aItLS.Next()) {
705 const TopoDS_Shape& aSx=aItLS.Value();
706 nSx=aPDS->Index(aSx);
707 const BOPDS_ShapeInfo& aSIx=aPDS->ShapeInfo(nSx);
709 aType=aSIx.ShapeType();
711 if (aType==TopAbs_VERTEX) {
712 if (aPDS->HasShapeSD(nSx, nVSD)) {
713 aV=aPDS->Shape(nVSD);
718 // index of new vertex in theDS -> iV
719 if (!aMVI.IsBound(aV)) {
720 aSI.SetShapeType(aType);
722 iV=myDS->Append(aSI);
729 // update FF interference
730 const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx);
731 iX=aCPB.IndexInterf();
733 BOPDS_InterfFF& aFF=aFFs(iX);
734 BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
735 BOPDS_Point& aNP=aVNP(iP);
737 }//if (aType==TopAbs_VERTEX) {
739 else if (aType==TopAbs_EDGE) {
740 bHasPaveBlocks=aPDS->HasPaveBlocks(nSx);
741 const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx);
742 iX=aCPB.IndexInterf();
744 aPB1=aCPB.PaveBlock1();
746 bOld = aPB1->HasEdge();
748 BOPDS_ListOfPaveBlock aLPBx;
749 aDMExEdges.Bind(aPB1, aLPBx);
752 if (!bHasPaveBlocks) {
754 aDMExEdges.ChangeFind(aPB1).Append(aPB1);
757 aSI.SetShapeType(aType);
759 iE=myDS->Append(aSI);
765 BOPDS_InterfFF& aFF=aFFs(iX);
766 BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves();
767 BOPDS_Curve& aNC=aVNC(iC);
768 BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
770 const BOPDS_ListOfPaveBlock& aLPBx=aPDS->PaveBlocks(nSx);
771 aNbLPBx=aLPBx.Extent();
773 if (bOld && !aNbLPBx) {
774 aDMExEdges.ChangeFind(aPB1).Append(aPB1);
779 aItLPB.Initialize(aLPBC);
780 for (; aItLPB.More(); aItLPB.Next()) {
781 const Handle(BOPDS_PaveBlock)& aPBC=aItLPB.Value();
783 aLPBC.Remove(aItLPB);
792 if (!aMVI.IsBound(aE)) {
793 aSI.SetShapeType(aType);
795 iE=myDS->Append(aSI);
801 // append new PaveBlock to aLPBC
807 aItLPB.Initialize(aLPBx);
809 aPave1[0] = aPB1->Pave1();
810 aPave1[1] = aPB1->Pave2();
812 for (; aItLPB.More(); aItLPB.Next()) {
813 const Handle(BOPDS_PaveBlock)& aPBx=aItLPB.Value();
814 const Handle(BOPDS_PaveBlock) aPBRx=aPDS->RealPaveBlock(aPBx);
816 // update vertices of paves
817 aPave[0]=aPBx->Pave1();
818 aPave[1]=aPBx->Pave2();
819 for (j=0; j<2; ++j) {
822 aT = aPave[j].Parameter();
823 if (aT == aPave1[0].Parameter()) {
825 } else if (aT == aPave1[1].Parameter()) {
830 iV = aPave1[jx-1].Index();
837 if (!aMVI.IsBound(aV)) {
838 // index of new vertex in theDS -> iV
839 aSI.SetShapeType(TopAbs_VERTEX);
841 iV=myDS->Append(aSI);
848 const BOPDS_Pave& aP1 = !j ? aPB1->Pave1() : aPB1->Pave2();
849 if (aP1.Parameter() == aPave[j].Parameter() &&
851 aDMI.Bind(aP1.Index(), iV);
852 myDS->AddShapeSD(aP1.Index(), iV);
855 aPave[j].SetIndex(iV);
859 aE=aPDS->Shape(aPBRx->Edge());
861 if (!aMVI.IsBound(aE)) {
862 aSI.SetShapeType(aType);
864 iE=myDS->Append(aSI);
870 // append new PaveBlock to aLPBC
871 Handle(BOPDS_PaveBlock) aPBC=new BOPDS_PaveBlock();
873 aPBC->SetPave1(aPave[0]);
874 aPBC->SetPave2(aPave[1]);
877 aPBC->SetOriginalEdge(aPB1->OriginalEdge());
878 aDMExEdges.ChangeFind(aPB1).Append(aPBC);
886 }//else if (aType==TopAbs_EDGE)
887 }//for (; aItLS.More(); aItLS.Next()) {
891 //=======================================================================
892 //function : UpdateFaceInfo
894 //=======================================================================
895 void BOPAlgo_PaveFiller::UpdateFaceInfo
896 (BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME,
897 const BOPCol_DataMapOfIntegerInteger& theDMV)
899 Standard_Integer i, j, nV1, nF1, nF2,
901 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
902 BOPCol_MapOfInteger aMF;
904 BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
907 //1. Sections (curves, points);
908 for (i=0; i<aNbFF; ++i) {
909 BOPDS_InterfFF& aFF=aFFs(i);
910 aFF.Indices(nF1, nF2);
912 BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
913 BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
915 // 1.1. Section edges
916 BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves();
918 for (j=0; j<aNbC; ++j) {
919 BOPDS_Curve& aNC=aVNC(j);
920 BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
922 // Add section edges to face info
923 aItLPB.Initialize(aLPBC);
924 for (; aItLPB.More(); ) {
925 const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value();
927 // Treat existing pave blocks
928 if (theDME.IsBound(aPB)) {
929 BOPDS_ListOfPaveBlock& aLPB=theDME.ChangeFind(aPB);
930 UpdateExistingPaveBlocks(aPB, aLPB, nF1, nF2);
931 aLPBC.Remove(aItLPB);
935 aFI1.ChangePaveBlocksSc().Add(aPB);
936 aFI2.ChangePaveBlocksSc().Add(aPB);
941 // 1.2. Section vertices
942 const BOPDS_VectorOfPoint& aVNP=aFF.Points();
944 for (j=0; j<aNbP; ++j) {
945 const BOPDS_Point& aNP=aVNP(j);
950 aFI1.ChangeVerticesSc().Add(nV1);
951 aFI2.ChangeVerticesSc().Add(nV1);
958 Standard_Boolean bVerts, bEdges;
960 bVerts = theDMV.Extent() > 0;
961 bEdges = theDME.Extent() > 0;
963 if (!bVerts && !bEdges) {
967 // 2. Update Face Info information with new vertices and new
968 // pave blocks created in PostTreatFF from existing ones
969 Standard_Integer nV2, aNbPB;
970 BOPCol_MapIteratorOfMapOfInteger aItMF;
971 BOPCol_DataMapIteratorOfDataMapOfIntegerInteger aItMV;
973 aItMF.Initialize(aMF);
974 for (; aItMF.More(); aItMF.Next()) {
977 BOPDS_FaceInfo& aFI = myDS->ChangeFaceInfo(nF1);
979 // 2.1. Update information about vertices
981 BOPCol_MapOfInteger& aMVOn = aFI.ChangeVerticesOn();
982 BOPCol_MapOfInteger& aMVIn = aFI.ChangeVerticesIn();
984 aItMV.Initialize(theDMV);
985 for (; aItMV.More(); aItMV.Next()) {
989 if (aMVOn.Remove(nV1)) {
993 if (aMVIn.Remove(nV1)) {
996 } // for (; aItMV.More(); aItMV.Next()) {
999 // 2.2. Update information about pave blocks
1001 BOPDS_IndexedMapOfPaveBlock& aMPBOn = aFI.ChangePaveBlocksOn();
1002 BOPDS_IndexedMapOfPaveBlock& aMPBIn = aFI.ChangePaveBlocksIn();
1004 BOPDS_IndexedMapOfPaveBlock aMPBCopy;
1005 for (i = 0; i < 2; ++i) {
1006 BOPDS_IndexedMapOfPaveBlock& aMPBOnIn = !i ? aMPBOn : aMPBIn;
1007 aMPBCopy = aMPBOnIn;
1010 aNbPB = aMPBCopy.Extent();
1011 for (j = 1; j <= aNbPB; ++j) {
1012 const Handle(BOPDS_PaveBlock)& aPB = aMPBCopy(j);
1013 if (theDME.IsBound(aPB)) {
1014 const BOPDS_ListOfPaveBlock& aLPB = theDME.Find(aPB);
1015 if (aLPB.IsEmpty()) {
1020 aItLPB.Initialize(aLPB);
1021 for (; aItLPB.More(); aItLPB.Next()) {
1022 const Handle(BOPDS_PaveBlock)& aPB1 = aItLPB.Value();
1029 } // for (j = 1; j <= aNbPB; ++j) {
1030 } // for (i = 0; i < 2; ++i) {
1034 //=======================================================================
1035 //function : IsExistingVertex
1037 //=======================================================================
1038 Standard_Boolean BOPAlgo_PaveFiller::IsExistingVertex
1040 const Standard_Real theTolR3D,
1041 const BOPCol_MapOfInteger& aMVOnIn)const
1043 Standard_Boolean bRet;
1044 Standard_Integer nV, iFlag;
1045 Standard_Real aTolV;
1048 BOPCol_MapIteratorOfMapOfInteger aIt;
1053 aBoxP.Enlarge(theTolR3D);
1055 aIt.Initialize(aMVOnIn);
1056 for (; aIt.More(); aIt.Next()) {
1060 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV)));
1061 aPV=BRep_Tool::Pnt(aV);
1062 aTolV=BRep_Tool::Tolerance(aV);
1064 aBoxV.Enlarge(aTolV);
1066 if (!aBoxP.IsOut(aBoxV)) {
1067 iFlag=BOPTools_AlgoTools::ComputeVV(aV, aP, theTolR3D);
1075 //=======================================================================
1076 //function : IsExistingPaveBlock
1078 //=======================================================================
1079 Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
1080 (const Handle(BOPDS_PaveBlock)& thePB,
1081 const BOPDS_Curve& theNC,
1082 const Standard_Real theTolR3D,
1083 const BOPCol_ListOfInteger& theLSE)
1085 Standard_Boolean bRet=Standard_True;
1087 if (theLSE.IsEmpty()) {
1091 Standard_Real aT1, aT2, aTm, aTx, aTol;
1092 Standard_Integer nE, iFlag;
1095 BOPCol_ListIteratorOfListOfInteger aItLI;
1097 thePB->Range(aT1, aT2);
1098 aTm=IntTools_Tools::IntermediatePoint (aT1, aT2);
1099 theNC.Curve().D0(aTm, aPm);
1101 aBoxPm.Enlarge(theTolR3D);
1103 aItLI.Initialize(theLSE);
1104 for (; aItLI.More(); aItLI.Next()) {
1106 const BOPDS_ShapeInfo& aSIE=myDS->ChangeShapeInfo(nE);
1107 const Bnd_Box& aBoxE=aSIE.Box();
1108 if (!aBoxE.IsOut(aBoxPm)) {
1109 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
1110 aTol = BRep_Tool::Tolerance(aE);
1111 aTol = aTol > theTolR3D ? aTol : theTolR3D;
1112 iFlag=myContext->ComputePE(aPm, aTol, aE, aTx);
1121 //=======================================================================
1122 //function : IsExistingPaveBlock
1124 //=======================================================================
1125 Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
1126 (const Handle(BOPDS_PaveBlock)& thePB,
1127 const BOPDS_Curve& theNC,
1128 const Standard_Real theTolR3D,
1129 const BOPDS_IndexedMapOfPaveBlock& theMPBOnIn,
1130 Handle(BOPDS_PaveBlock)& aPBOut)
1132 Standard_Boolean bRet;
1133 Standard_Real aT1, aT2, aTm, aTx;
1134 Standard_Integer nSp, iFlag1, iFlag2, nV11, nV12, nV21, nV22, i, aNbPB;
1135 gp_Pnt aP1, aPm, aP2;
1136 Bnd_Box aBoxP1, aBoxPm, aBoxP2;
1138 bRet=Standard_False;
1139 const IntTools_Curve& aIC=theNC.Curve();
1141 thePB->Range(aT1, aT2);
1142 thePB->Indices(nV11, nV12);
1146 aBoxP1.Enlarge(theTolR3D);
1147 //intermediate point
1148 aTm=IntTools_Tools::IntermediatePoint (aT1, aT2);
1151 aBoxPm.Enlarge(theTolR3D);
1155 aBoxP2.Enlarge(theTolR3D);
1157 aNbPB = theMPBOnIn.Extent();
1158 for (i = 1; i <= aNbPB; ++i) {
1159 const Handle(BOPDS_PaveBlock)& aPB = theMPBOnIn(i);
1160 aPB->Indices(nV21, nV22);
1162 const BOPDS_ShapeInfo& aSISp=myDS->ChangeShapeInfo(nSp);
1163 const TopoDS_Edge& aSp=(*(TopoDS_Edge *)(&aSISp.Shape()));
1164 const Bnd_Box& aBoxSp=aSISp.Box();
1166 iFlag1 = (nV11 == nV21 || nV11 == nV22) ? 2 :
1167 (!aBoxSp.IsOut(aBoxP1) ? 1 : 0);
1168 iFlag2 = (nV12 == nV21 || nV12 == nV22) ? 2 :
1169 (!aBoxSp.IsOut(aBoxP2) ? 1 : 0);
1170 if (iFlag1 && iFlag2) {
1171 if (aBoxSp.IsOut(aBoxPm) || myContext->ComputePE(aPm,
1179 iFlag1 = !myContext->ComputePE(aP1, theTolR3D, aSp, aTx);
1183 iFlag2 = !myContext->ComputePE(aP2, theTolR3D, aSp, aTx);
1186 if (iFlag1 && iFlag2) {
1195 //=======================================================================
1196 //function : PutBoundPaveOnCurve
1198 //=======================================================================
1199 void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1,
1200 const TopoDS_Face& aF2,
1201 const Standard_Real aTolR3D,
1203 BOPCol_ListOfInteger& aLVB)
1205 Standard_Boolean bVF;
1206 Standard_Integer nV, iFlag, nVn, j, aNbEP;
1207 Standard_Real aT[2], aTmin, aTmax, aTV, aTol, aTolVnew;
1210 BOPDS_ListIteratorOfListOfPave aItLP;
1211 BOPDS_Pave aPn, aPMM[2];
1213 aTolVnew = Precision::Confusion();
1215 const IntTools_Curve& aIC=aNC.Curve();
1216 aIC.Bounds(aT[0], aT[1], aP[0], aP[1]);
1218 Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
1219 const BOPDS_ListOfPave& aLP=aPB->ExtPaves();
1226 aItLP.Initialize(aLP);
1227 for (; aItLP.More(); aItLP.Next()) {
1228 const BOPDS_Pave& aPv=aItLP.Value();
1229 aPv.Contents(nV, aTV);
1241 for (j=0; j<2; ++j) {
1242 //if curve is closed, process only one bound
1243 if (j && aP[1].IsEqual(aP[0], aTolVnew)) {
1253 aTol = aTolR3D+Precision::Confusion();
1254 aBoxP.Enlarge(aTol);
1255 const BOPDS_Pave& aPV=aPMM[j];
1257 const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
1258 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&aSIV.Shape()));
1259 const Bnd_Box& aBoxV=aSIV.Box();
1260 if (!aBoxP.IsOut(aBoxV)){
1261 iFlag=BOPTools_AlgoTools::ComputeVV(aV, aP[j], aTol);
1266 bVF=myContext->IsValidPointForFaces (aP[j], aF1, aF2, aTolR3D);
1271 BOPDS_ShapeInfo aSIVn;
1273 BOPTools_AlgoTools::MakeNewVertex(aP[j], aTolR3D, aVn);
1274 aSIVn.SetShapeType(TopAbs_VERTEX);
1275 aSIVn.SetShape(aVn);
1277 nVn=myDS->Append(aSIVn);
1280 aPn.SetParameter(aT[j]);
1281 aPB->AppendExtPave(aPn);
1283 aVn=(*(TopoDS_Vertex *)(&myDS->Shape(nVn)));
1284 BOPTools_AlgoTools::UpdateVertex (aIC, aT[j], aVn);
1286 aTolVnew = BRep_Tool::Tolerance(aVn);
1288 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVn);
1289 Bnd_Box& aBoxDS=aSIDS.ChangeBox();
1290 BRepBndLib::Add(aVn, aBoxDS);
1297 //=======================================================================
1298 //function : PutPavesOnCurve
1300 //=======================================================================
1301 void BOPAlgo_PaveFiller::PutPavesOnCurve
1302 (const BOPCol_MapOfInteger& aMVOnIn,
1303 const Standard_Real aTolR3D,
1305 const Standard_Integer nF1,
1306 const Standard_Integer nF2,
1307 const BOPCol_MapOfInteger& aMI,
1308 const BOPCol_MapOfInteger& aMVEF,
1309 BOPCol_DataMapOfIntegerReal& aMVTol)
1311 Standard_Boolean bInBothFaces;
1312 Standard_Integer nV;
1313 BOPCol_MapIteratorOfMapOfInteger aIt;
1315 const Bnd_Box& aBoxC=aNC.Box();
1317 //Put EF vertices first
1318 aIt.Initialize(aMVEF);
1319 for (; aIt.More(); aIt.Next()) {
1321 PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, 2);
1323 //Put all other vertices
1324 aIt.Initialize(aMVOnIn);
1325 for (; aIt.More(); aIt.Next()) {
1327 if (aMVEF.Contains(nV)) {
1331 const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
1332 const Bnd_Box& aBoxV=aSIV.Box();
1334 if (aBoxC.IsOut(aBoxV)){
1337 if (!myDS->IsNewShape(nV)) {
1338 const BOPDS_FaceInfo& aFI1 = myDS->FaceInfo(nF1);
1339 const BOPDS_FaceInfo& aFI2 = myDS->FaceInfo(nF2);
1341 bInBothFaces = (aFI1.VerticesOn().Contains(nV) ||
1342 aFI1.VerticesIn().Contains(nV))&&
1343 (aFI2.VerticesOn().Contains(nV) ||
1344 aFI2.VerticesIn().Contains(nV));
1345 if (!bInBothFaces) {
1350 PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, 1);
1354 //=======================================================================
1355 //function : ExtendedTolerance
1357 //=======================================================================
1358 Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance
1359 (const Standard_Integer nV,
1360 const BOPCol_MapOfInteger& aMI,
1361 Standard_Real& aTolVExt,
1362 const Standard_Integer aType)
1364 Standard_Boolean bFound = Standard_False;
1365 if (!(myDS->IsNewShape(nV))) {
1369 Standard_Integer i, k, aNbLines, aNbInt;
1370 Standard_Real aT11, aT12, aD1, aD2, aD;
1372 gp_Pnt aPV, aP11, aP12;
1378 } else if (aType == 2) {
1382 aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
1383 aPV=BRep_Tool::Pnt(aV);
1385 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
1386 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
1388 for (; k<aNbInt; ++k) {
1389 aNbLines = !k ? aEEs.Extent() : aEFs.Extent();
1390 for (i = 0; i < aNbLines; ++i) {
1391 BOPDS_Interf *aInt = !k ? (BOPDS_Interf*) (&aEEs(i)) :
1392 (BOPDS_Interf*) (&aEFs(i));
1393 if (aInt->IndexNew() == nV) {
1394 if (aMI.Contains(aInt->Index1()) &&
1395 aMI.Contains(aInt->Index2())) {
1396 const IntTools_CommonPrt& aComPrt = !k ? aEEs(i).CommonPart() :
1397 aEFs(i).CommonPart();
1399 const TopoDS_Edge& aE1=aComPrt.Edge1();
1400 aComPrt.Range1(aT11, aT12);
1401 BOPTools_AlgoTools::PointOnEdge(aE1, aT11, aP11);
1402 BOPTools_AlgoTools::PointOnEdge(aE1, aT12, aP12);
1403 aD1=aPV.Distance(aP11);
1404 aD2=aPV.Distance(aP12);
1405 aD=(aD1>aD2)? aD1 : aD2;
1410 }//if (aMI.Contains(aEF.Index1()) && aMI.Contains(aEF.Index2())) {
1411 }//if (aInt->IndexNew() == nV) {
1412 }//for (i = 0; i < aNbLines; ++i) {
1413 }//for (k=0; k<2; ++k) {
1417 //=======================================================================
1418 //function : GetEFPnts
1420 //=======================================================================
1421 void BOPAlgo_PaveFiller::GetEFPnts(const Standard_Integer nF1,
1422 const Standard_Integer nF2,
1423 IntSurf_ListOfPntOn2S& aListOfPnts)
1425 Standard_Integer nE, nF, nFOpposite, aNbEFs, i;
1426 Standard_Real U1, U2, V1, V2, f, l;
1427 BOPCol_MapOfInteger aMI;
1429 //collect indexes of all shapes from nF1 and nF2.
1430 GetFullShapeMap(nF1, aMI);
1431 GetFullShapeMap(nF2, aMI);
1433 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
1434 aNbEFs = aEFs.Extent();
1436 for(i = 0; i < aNbEFs; ++i) {
1437 const BOPDS_InterfEF& aEF = aEFs(i);
1438 if (aEF.HasIndexNew()) {
1439 aEF.Indices(nE, nFOpposite);
1440 if(aMI.Contains(nE) && aMI.Contains(nFOpposite)) {
1441 const IntTools_CommonPrt& aCP = aEF.CommonPart();
1442 Standard_Real aPar = aCP.VertexParameter1();
1443 const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&myDS->Shape(nE)));
1444 const TopoDS_Face& aFOpposite =
1445 (*(TopoDS_Face*)(&myDS->Shape(nFOpposite)));
1447 const Handle(Geom_Curve)& aCurve = BRep_Tool::Curve(aE, f, l);
1449 nF = (nFOpposite == nF1) ? nF2 : nF1;
1450 const TopoDS_Face& aF = (*(TopoDS_Face*)(&myDS->Shape(nF)));
1451 Handle(Geom2d_Curve) aPCurve =
1452 BRep_Tool::CurveOnSurface(aE, aF, f, l);
1454 GeomAPI_ProjectPointOnSurf& aProj=myContext->ProjPS(aFOpposite);
1457 aCurve->D0(aPar, aPoint);
1458 IntSurf_PntOn2S aPnt;
1459 if(!aPCurve.IsNull()) {
1460 gp_Pnt2d aP2d = aPCurve->Value(aPar);
1461 aProj.Perform(aPoint);
1462 if(aProj.IsDone()) {
1463 aProj.LowerDistanceParameters(U1,V1);
1465 aPnt.SetValue(aP2d.X(),aP2d.Y(),U1,V1);
1467 aPnt.SetValue(U1,V1,aP2d.X(),aP2d.Y());
1469 aListOfPnts.Append(aPnt);
1473 GeomAPI_ProjectPointOnSurf& aProj1 = myContext->ProjPS(aF);
1474 aProj1.Perform(aPoint);
1475 aProj.Perform(aPoint);
1476 if(aProj1.IsDone() && aProj.IsDone()){
1477 aProj1.LowerDistanceParameters(U1,V1);
1478 aProj.LowerDistanceParameters(U2,V2);
1480 aPnt.SetValue(U1,V1,U2,V2);
1482 aPnt.SetValue(U2,V2,U1,V1);
1484 aListOfPnts.Append(aPnt);
1492 //=======================================================================
1493 //function : ProcessUnUsedVertices
1495 //=======================================================================
1496 void BOPAlgo_PaveFiller::PutEFPavesOnCurve
1498 const BOPCol_MapOfInteger& aMI,
1499 const BOPCol_MapOfInteger& aMVEF,
1500 BOPCol_DataMapOfIntegerReal& aMVTol)
1502 if (!aMVEF.Extent()) {
1506 const IntTools_Curve& aIC=aNC.Curve();
1507 GeomAbs_CurveType aTypeC;
1509 if (!(aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve)) {
1513 Standard_Integer nV;
1514 BOPCol_MapOfInteger aMV;
1517 RemoveUsedVertices(aNC, aMV);
1518 if (!aMV.Extent()) {
1522 Standard_Real aDist;
1525 const Handle(Geom_Curve)& aC3D=aIC.Curve();
1526 GeomAPI_ProjectPointOnCurve& aProjPT = myContext->ProjPT(aC3D);
1528 BOPCol_MapIteratorOfMapOfInteger aItMI;
1529 aItMI.Initialize(aMV);
1530 for (; aItMI.More(); aItMI.Next()) {
1532 const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
1533 gp_Pnt aPV = BRep_Tool::Pnt(aV);
1534 aProjPT.Perform(aPV);
1535 Standard_Integer aNbPoints = aProjPT.NbPoints();
1537 aDist = aProjPT.LowerDistance();
1538 PutPaveOnCurve(nV, aDist, aNC, aMI, aMVTol);
1543 //=======================================================================
1544 //function : ProcessUnUsedVertices
1546 //=======================================================================
1547 void BOPAlgo_PaveFiller::PutStickPavesOnCurve
1548 (const TopoDS_Face& aF1,
1549 const TopoDS_Face& aF2,
1550 const BOPCol_MapOfInteger& aMI,
1552 const BOPCol_MapOfInteger& aMVStick,
1553 BOPCol_DataMapOfIntegerReal& aMVTol)
1555 BOPCol_MapOfInteger aMV;
1556 aMV.Assign(aMVStick);
1557 RemoveUsedVertices(aNC, aMV);
1559 if (!aMV.Extent()) {
1563 Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1);
1564 Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2);
1566 const IntTools_Curve& aIC=aNC.Curve();
1567 //if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) {
1568 Handle(Geom2d_Curve) aC2D[2];
1570 aC2D[0]=aIC.FirstCurve2d();
1571 aC2D[1]=aIC.SecondCurve2d();
1572 if (!aC2D[0].IsNull() && !aC2D[1].IsNull()) {
1573 Standard_Integer nV, m, n;
1574 Standard_Real aTC[2], aD, aD2, u, v, aDT2, aScPr, aDScPr;
1578 BOPCol_MapIteratorOfMapOfInteger aItMI, aItMI1;
1580 aDT2=2e-7; // the rich criteria
1581 aDScPr=5.e-9; // the creasing criteria
1582 aIC.Bounds(aTC[0], aTC[1], aPC[0], aPC[1]);
1584 aItMI.Initialize(aMV);
1585 for (; aItMI.More(); aItMI.Next()) {
1587 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&myDS->Shape(nV));
1588 aPV=BRep_Tool::Pnt(aV);
1590 for (m=0; m<2; ++m) {
1591 aD2=aPC[m].SquareDistance(aPV);
1592 if (aD2>aDT2) {// no rich
1596 for (n=0; n<2; ++n) {
1597 Handle(Geom_Surface)& aS=(!n)? aS1 : aS2;
1598 aC2D[n]->D0(aTC[m], aP2D);
1600 BOPTools_AlgoTools3D::GetNormalToSurface(aS, u, v, aDN[n]);
1603 aScPr=aDN[0]*aDN[1];
1613 // The intersection curve aIC is vanishing curve (the crease)
1616 PutPaveOnCurve(nV, aD, aNC, aMI, aMVTol);
1618 }//for (jVU=1; jVU=aNbVU; ++jVU) {
1620 //}//if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) {
1621 //}//if(aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) {
1624 //=======================================================================
1625 //function : GetStickVertices
1627 //=======================================================================
1628 void BOPAlgo_PaveFiller::GetStickVertices(const Standard_Integer nF1,
1629 const Standard_Integer nF2,
1630 BOPCol_MapOfInteger& aMVStick,
1631 BOPCol_MapOfInteger& aMVEF,
1632 BOPCol_MapOfInteger& aMI)
1634 Standard_Integer nS1, nS2, nVNew, aTypeInt, i;
1636 BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
1637 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
1638 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
1639 BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
1640 BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF();
1642 Standard_Integer aNbLines[5] = {
1643 aVVs.Extent(), aVEs.Extent(), aEEs.Extent(),
1644 aVFs.Extent(), aEFs.Extent()
1646 //collect indices of all shapes from nF1 and nF2.
1648 GetFullShapeMap(nF1, aMI);
1649 GetFullShapeMap(nF2, aMI);
1651 //collect VV, VE, EE, VF interferences
1652 for (aTypeInt = 0; aTypeInt < 4; ++aTypeInt) {
1653 for (i = 0; i < aNbLines[aTypeInt]; ++i) {
1654 BOPDS_Interf* aInt = (aTypeInt==0) ? (BOPDS_Interf*)(&aVVs(i)) :
1655 ((aTypeInt==1) ? (BOPDS_Interf*)(&aVEs(i)) :
1656 ((aTypeInt==2) ? (BOPDS_Interf*)(&aEEs(i)) :
1657 (BOPDS_Interf*)(&aVFs(i))));
1658 if (aInt->HasIndexNew()) {
1659 aInt->Indices(nS1, nS2);
1660 if(aMI.Contains(nS1) && aMI.Contains(nS2)) {
1661 nVNew = aInt->IndexNew();
1662 aMVStick.Add(nVNew);
1667 //collect EF interferences
1668 for (i = 0; i < aNbLines[4]; ++i) {
1669 const BOPDS_InterfEF& aInt = aEFs(i);
1670 if (aInt.HasIndexNew()) {
1671 aInt.Indices(nS1, nS2);
1672 if(aMI.Contains(nS1) && aMI.Contains(nS2)) {
1673 nVNew = aInt.IndexNew();
1674 aMVStick.Add(nVNew);
1681 //=======================================================================
1682 // function: GetFullShapeMap
1684 //=======================================================================
1685 void BOPAlgo_PaveFiller::GetFullShapeMap(const Standard_Integer nF,
1686 BOPCol_MapOfInteger& aMI)
1688 BOPCol_ListIteratorOfListOfInteger aIt;
1689 Standard_Integer nS;
1691 const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nF);
1692 const BOPCol_ListOfInteger& aLI = aSI.SubShapes();
1695 aIt.Initialize(aLI);
1696 for (; aIt.More(); aIt.Next()) {
1702 //=======================================================================
1703 // function: RemoveUsedVertices
1705 //=======================================================================
1706 void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
1707 BOPCol_MapOfInteger& aMV)
1709 if (!aMV.Extent()) {
1712 Standard_Integer nV;
1714 BOPDS_ListIteratorOfListOfPave aItLP;
1716 Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
1717 const BOPDS_ListOfPave& aLP = aPB->ExtPaves();
1718 aItLP.Initialize(aLP);
1719 for (;aItLP.More();aItLP.Next()) {
1720 aPave = aItLP.Value();
1726 //=======================================================================
1727 //function : PutPaveOnCurve
1729 //=======================================================================
1730 void BOPAlgo_PaveFiller::PutPaveOnCurve
1731 (const Standard_Integer nV,
1732 const Standard_Real aTolR3D,
1734 const BOPCol_MapOfInteger& aMI,
1735 BOPCol_DataMapOfIntegerReal& aMVTol,
1736 const Standard_Integer iCheckExtend)
1738 Standard_Boolean bIsVertexOnLine;
1739 Standard_Real aT, aTolV;
1741 const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
1742 Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
1743 const IntTools_Curve& aIC = aNC.Curve();
1745 bIsVertexOnLine=myContext->IsVertexOnLine(aV, aIC, aTolR3D, aT);
1746 if (!bIsVertexOnLine && iCheckExtend) {
1747 aTolV = BRep_Tool::Tolerance(aV);
1749 ExtendedTolerance(nV, aMI, aTolV, iCheckExtend);
1750 bIsVertexOnLine=myContext->IsVertexOnLine(aV, aTolV, aIC, aTolR3D, aT);
1753 if (bIsVertexOnLine) {
1754 // check if aPB contains the parameter aT
1755 Standard_Boolean bExist;
1756 Standard_Integer nVToUpdate;
1757 Standard_Real aPTol, aDist, aTolVNew, aTolV2, aDTol;
1758 TopoDS_Vertex aVToUpdate;
1764 GeomAdaptor_Curve aGAC(aIC.Curve());
1765 aPTol = aGAC.Resolution(aTolR3D);
1767 bExist = aPB->ContainsParameter(aT, aPTol, nVToUpdate);
1769 // use existing pave
1770 aP1 = BRep_Tool::Pnt(aV);
1771 aTolV2 = BRep_Tool::Tolerance(aV);
1772 aVToUpdate = (*(TopoDS_Vertex *)(&myDS->Shape(nVToUpdate)));
1778 aPave.SetParameter(aT);
1779 aPB->AppendExtPave(aPave);
1781 aP1 = aGAC.Value(aT);
1786 aTolV = BRep_Tool::Tolerance(aVToUpdate);
1787 aP2 = BRep_Tool::Pnt(aVToUpdate);
1788 aDist = aP1.Distance(aP2);
1789 aTolVNew = aDist - aTolV2;
1791 if (aTolVNew > aTolV) {
1793 aBB.UpdateVertex(aVToUpdate, aTolVNew+aDTol);
1795 if (!aMVTol.IsBound(nVToUpdate)) {
1796 aMVTol.Bind(nVToUpdate, aTolV);
1799 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVToUpdate);
1800 Bnd_Box& aBoxDS=aSIDS.ChangeBox();
1801 BRepBndLib::Add(aVToUpdate, aBoxDS);
1806 //=======================================================================
1807 //function : ProcessOldPaveBlocks
1809 //=======================================================================
1810 void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks
1811 (const Standard_Integer theInt,
1812 const BOPDS_IndexedMapOfPaveBlock& aMPBOnIn,
1813 const BOPCol_DataMapOfIntegerListOfInteger& aDMBV,
1814 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB,
1815 BOPCol_DataMapOfShapeInteger& aMVI,
1816 BOPDS_MapOfPaveBlock& aMPB)
1818 if (aDMBV.IsEmpty()) {
1823 Standard_Integer i, nV, nE, iC, aNbPB, iFlag;
1824 BOPCol_ListIteratorOfListOfInteger aItLI;
1825 BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItBV;
1827 BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
1828 BOPDS_InterfFF& aFF = aFFs(theInt);
1829 BOPDS_VectorOfCurve& aVC = aFF.ChangeCurves();
1831 aNbPB = aMPBOnIn.Extent();
1833 aItBV.Initialize(aDMBV);
1834 for (; aItBV.More(); aItBV.Next()) {
1836 const BOPCol_ListOfInteger& aLBV = aItBV.Value();
1838 BOPDS_Curve& aNC = aVC.ChangeValue(iC);
1839 BOPDS_ListOfPaveBlock& aLPBC = aNC.ChangePaveBlocks();
1841 aItLI.Initialize(aLBV);
1842 for (; aItLI.More(); aItLI.Next()) {
1844 const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
1845 const Bnd_Box& aBoxV=aSIV.Box();
1846 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aSIV.Shape();
1847 if (!aMVI.IsBound(aV)) {
1851 for (i = 1; i <= aNbPB; ++i) {
1852 const Handle(BOPDS_PaveBlock)& aPB = aMPBOnIn(i);
1853 if (aPB->Pave1().Index() == nV || aPB->Pave2().Index() == nV) {
1857 if (aMPB.Contains(aPB)) {
1862 const BOPDS_ShapeInfo& aSIE = myDS->ShapeInfo(nE);
1863 const Bnd_Box& aBoxE = aSIE.Box();
1865 if (aBoxV.IsOut(aBoxE)) {
1869 const TopoDS_Edge& aE = *(TopoDS_Edge*)&aSIE.Shape();
1871 iFlag = myContext->ComputeVE(aV, aE, aT);
1874 PreparePostTreatFF(theInt, iC, aPB, aMSCPB, aMVI, aLPBC);
1880 //=======================================================================
1881 //function : UpdateExistingPaveBlocks
1883 //=======================================================================
1884 void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks
1885 (const Handle(BOPDS_PaveBlock)& aPBf,
1886 BOPDS_ListOfPaveBlock& aLPB,
1887 const Standard_Integer nF1,
1888 const Standard_Integer nF2)
1890 Standard_Integer nE;
1891 Standard_Boolean bCB;
1892 Handle(BOPDS_PaveBlock) aPB, aPB1, aPB2, aPB2n;
1893 Handle(BOPDS_CommonBlock) aCB;
1894 BOPDS_ListIteratorOfListOfPaveBlock aIt, aIt1, aIt2;
1896 // 1. Remove micro edges from aLPB
1897 aIt.Initialize(aLPB);
1898 for (; aIt.More();) {
1900 const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge());
1901 if (BOPTools_AlgoTools::IsMicroEdge(aE, myContext)) {
1908 if (!aLPB.Extent()) {
1912 BOPDS_FaceInfo& aFI1 = myDS->ChangeFaceInfo(nF1);
1913 BOPDS_FaceInfo& aFI2 = myDS->ChangeFaceInfo(nF2);
1915 BOPDS_IndexedMapOfPaveBlock& aMPBOn1 = aFI1.ChangePaveBlocksOn();
1916 BOPDS_IndexedMapOfPaveBlock& aMPBIn1 = aFI1.ChangePaveBlocksIn();
1917 BOPDS_IndexedMapOfPaveBlock& aMPBOn2 = aFI2.ChangePaveBlocksOn();
1918 BOPDS_IndexedMapOfPaveBlock& aMPBIn2 = aFI2.ChangePaveBlocksIn();
1920 // 2. Remove old pave blocks
1921 const Handle(BOPDS_CommonBlock)& aCB1 = myDS->CommonBlock(aPBf);
1922 bCB = !aCB1.IsNull();
1923 BOPDS_ListOfPaveBlock aLPB1;
1926 aLPB1.Assign(aCB1->PaveBlocks());
1930 aIt1.Initialize(aLPB1);
1931 for (; aIt1.More(); aIt1.Next()) {
1932 aPB1 = aIt1.Value();
1933 nE = aPB1->OriginalEdge();
1935 BOPDS_ListOfPaveBlock& aLPB2 = myDS->ChangePaveBlocks(nE);
1936 aIt2.Initialize(aLPB2);
1937 for (; aIt2.More(); aIt2.Next()) {
1938 aPB2 = aIt2.Value();
1946 // 3. Update pave blocks
1948 //create new common blocks
1949 BOPDS_ListOfPaveBlock aLPBNew;
1950 const BOPCol_ListOfInteger& aFaces = aCB1->Faces();
1951 aIt.Initialize(aLPB);
1952 for (; aIt.More(); aIt.Next()) {
1953 const Handle(BOPDS_PaveBlock)& aPBValue = aIt.Value();
1955 aCB = new BOPDS_CommonBlock;
1956 aIt1.Initialize(aLPB1);
1957 for (; aIt1.More(); aIt1.Next()) {
1958 aPB2 = aIt1.Value();
1959 nE = aPB2->OriginalEdge();
1961 aPB2n = new BOPDS_PaveBlock;
1962 aPB2n->SetPave1(aPBValue->Pave1());
1963 aPB2n->SetPave2(aPBValue->Pave2());
1964 aPB2n->SetEdge(aPBValue->Edge());
1965 aPB2n->SetOriginalEdge(nE);
1966 aCB->AddPaveBlock(aPB2n);
1967 myDS->SetCommonBlock(aPB2n, aCB);
1968 myDS->ChangePaveBlocks(nE).Append(aPB2n);
1970 aCB->AddFaces(aFaces);
1971 myDS->SortPaveBlocks(aCB);
1973 const Handle(BOPDS_PaveBlock)& aPBNew = aCB->PaveBlocks().First();
1974 aLPBNew.Append(aPBNew);
1980 nE = aPBf->OriginalEdge();
1981 BOPDS_ListOfPaveBlock& aLPBE = myDS->ChangePaveBlocks(nE);
1982 aIt.Initialize(aLPB);
1983 for (; aIt.More(); aIt.Next()) {
1989 Standard_Boolean bIn1, bIn2;
1991 bIn1 = aMPBOn1.Contains(aPBf) || aMPBIn1.Contains(aPBf);
1992 bIn2 = aMPBOn2.Contains(aPBf) || aMPBIn2.Contains(aPBf);
1998 // 4. Check new pave blocks for coincidence
1999 // with the opposite face.
2000 // In case of coincidence create common blocks
2001 Standard_Integer nF;
2002 Standard_Real aTolE, aTolF;
2004 nF = bIn1 ? nF2 : nF1;
2005 const TopoDS_Face& aF = *(TopoDS_Face*)&myDS->Shape(nF);
2006 BOPDS_IndexedMapOfPaveBlock& aMPBIn = bIn1 ? aMPBIn2 : aMPBIn1;
2007 aTolF = BRep_Tool::Tolerance(aF);
2009 aIt.Initialize(aLPB);
2010 for (; aIt.More(); aIt.Next()) {
2011 Handle(BOPDS_PaveBlock)& aPBChangeValue = aIt.ChangeValue();
2012 const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPBChangeValue->Edge());
2013 aTolE = BRep_Tool::Tolerance(aE);
2015 IntTools_EdgeFace anEF;
2018 anEF.SetTolE(aTolE);
2019 anEF.SetTolF(aTolF);
2020 anEF.SetRange(aPBChangeValue->Pave1().Parameter(), aPBChangeValue->Pave2().Parameter());
2021 anEF.SetContext(myContext);
2024 const IntTools_SequenceOfCommonPrts& aCPrts=anEF.CommonParts();
2025 if (aCPrts.Length() == 1) {
2026 Standard_Boolean bCoinc = (aCPrts(1).Type() == TopAbs_EDGE);
2029 aCB = myDS->CommonBlock(aPBChangeValue);
2031 aCB = new BOPDS_CommonBlock;
2032 aCB->AddPaveBlock(aPBChangeValue);
2033 myDS->SetCommonBlock(aPBChangeValue, aCB);
2037 aMPBIn.Add(aPBChangeValue);
2042 //=======================================================================
2043 // function: PutClosingPaveOnCurve
2045 //=======================================================================
2046 void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC)
2048 Standard_Boolean bIsClosed, bHasBounds, bAdded;
2049 Standard_Integer nVC, j;
2050 Standard_Real aT[2], aTC, dT, aTx;
2053 BOPDS_ListIteratorOfListOfPave aItLP;
2055 const IntTools_Curve& aIC=aNC.Curve();
2056 const Handle(Geom_Curve)& aC3D=aIC.Curve();
2061 bIsClosed=IntTools_Tools::IsClosed(aC3D);
2066 bHasBounds=aIC.HasBounds ();
2071 bAdded=Standard_False;
2072 dT=Precision::PConfusion();
2073 aIC.Bounds (aT[0], aT[1], aP[0], aP[1]);
2075 Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
2076 BOPDS_ListOfPave& aLP=aPB->ChangeExtPaves();
2078 aItLP.Initialize(aLP);
2079 for (; aItLP.More() && !bAdded; aItLP.Next()) {
2080 const BOPDS_Pave& aPC=aItLP.Value();
2082 aTC=aPC.Parameter();
2084 for (j=0; j<2; ++j) {
2085 if (fabs(aTC-aT[j]) < dT) {
2086 aTx=(!j) ? aT[1] : aT[0];
2088 aPVx.SetParameter(aTx);
2091 bAdded=Standard_True;
2097 //=======================================================================
2098 //function : PreparePostTreatFF
2100 //=======================================================================
2101 void BOPAlgo_PaveFiller::PreparePostTreatFF
2102 (const Standard_Integer aInt,
2103 const Standard_Integer aCur,
2104 const Handle(BOPDS_PaveBlock)& aPB,
2105 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB,
2106 BOPCol_DataMapOfShapeInteger& aMVI,
2107 BOPDS_ListOfPaveBlock& aLPBC)
2109 Standard_Integer nV1, nV2;
2113 aPB->Indices(nV1, nV2);
2114 const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
2115 const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
2116 const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge());
2117 // Keep info for post treatment
2118 BOPDS_CoupleOfPaveBlocks aCPB;
2119 aCPB.SetIndexInterf(aInt);
2120 aCPB.SetIndex(aCur);
2121 aCPB.SetPaveBlock1(aPB);
2123 aMSCPB.Add(aE, aCPB);
2124 aMVI.Bind(aV1, nV1);
2125 aMVI.Bind(aV2, nV2);
2128 //=======================================================================
2129 //function : CheckPlanes
2131 //=======================================================================
2132 Standard_Boolean BOPAlgo_PaveFiller::CheckPlanes
2133 (const Standard_Integer nF1,
2134 const Standard_Integer nF2)const
2136 Standard_Boolean bToIntersect;
2137 Standard_Integer i, nV2, iCnt;
2138 BOPCol_MapIteratorOfMapOfInteger aIt;
2140 bToIntersect=Standard_False;
2142 const BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
2143 const BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
2145 const BOPCol_MapOfInteger& aMVIn1=aFI1.VerticesIn();
2146 const BOPCol_MapOfInteger& aMVOn1=aFI1.VerticesOn();
2149 for (i=0; (i<2 && !bToIntersect); ++i) {
2150 const BOPCol_MapOfInteger& aMV2=(!i) ? aFI2.VerticesIn()
2151 : aFI2.VerticesOn();
2153 aIt.Initialize(aMV2);
2154 for (; aIt.More(); aIt.Next()) {
2156 if (aMVIn1.Contains(nV2) || aMVOn1.Contains(nV2)) {
2159 bToIntersect=!bToIntersect;
2166 return bToIntersect;
2168 //=======================================================================
2169 //function : UpdatePaveBlocks
2171 //=======================================================================
2172 void BOPAlgo_PaveFiller::UpdatePaveBlocks
2173 (const BOPCol_DataMapOfIntegerInteger& aDMI)
2175 if (aDMI.IsEmpty()) {
2179 Standard_Integer nSp, aNbPBP, nV[2], i, j;
2180 Standard_Real aT[2];
2181 Standard_Boolean bCB, bRebuild;
2182 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
2183 BOPDS_MapOfPaveBlock aMPB;
2185 BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool();
2186 aNbPBP = aPBP.Extent();
2187 for (i=0; i<aNbPBP; ++i) {
2188 BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
2190 aItPB.Initialize(aLPB);
2191 for (; aItPB.More(); aItPB.Next()) {
2192 Handle(BOPDS_PaveBlock) aPB=aItPB.Value();
2193 const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
2194 bCB = !aCB.IsNull();
2196 aPB=aCB->PaveBlock1();
2199 if (aMPB.Add(aPB)) {
2200 bRebuild = Standard_False;
2201 aPB->Indices(nV[0], nV[1]);
2202 aPB->Range(aT[0], aT[1]);
2204 for (j = 0; j < 2; ++j) {
2205 if (aDMI.IsBound(nV[j])) {
2208 nV[j] = aDMI.Find(nV[j]);
2209 aPave.SetIndex(nV[j]);
2210 aPave.SetParameter(aT[j]);
2212 bRebuild = Standard_True;
2214 aPB->SetPave1(aPave);
2216 aPB->SetPave2(aPave);
2222 nSp = SplitEdge(aPB->OriginalEdge(), nV[0], aT[0], nV[1], aT[1]);
2230 }// if (aMPB.Add(aPB)) {
2231 }// for (; aItPB.More(); aItPB.Next()) {
2232 }// for (i=0; i<aNbPBP; ++i) {
2235 //=======================================================================
2236 //function : ToleranceFF
2237 //purpose : Computes the TolFF according to the tolerance value and
2238 // types of the faces.
2239 //=======================================================================
2240 void ToleranceFF(const BRepAdaptor_Surface& aBAS1,
2241 const BRepAdaptor_Surface& aBAS2,
2242 Standard_Real& aTolFF)
2244 Standard_Real aTol1, aTol2;
2245 Standard_Boolean isAna1, isAna2;
2247 aTol1 = aBAS1.Tolerance();
2248 aTol2 = aBAS2.Tolerance();
2249 aTolFF = Max(aTol1, aTol2);
2251 isAna1 = (aBAS1.GetType() == GeomAbs_Plane ||
2252 aBAS1.GetType() == GeomAbs_Cylinder ||
2253 aBAS1.GetType() == GeomAbs_Cone ||
2254 aBAS1.GetType() == GeomAbs_Sphere ||
2255 aBAS1.GetType() == GeomAbs_Torus);
2257 isAna2 = (aBAS2.GetType() == GeomAbs_Plane ||
2258 aBAS2.GetType() == GeomAbs_Cylinder ||
2259 aBAS2.GetType() == GeomAbs_Cone ||
2260 aBAS2.GetType() == GeomAbs_Sphere ||
2261 aBAS2.GetType() == GeomAbs_Torus);
2263 if (!isAna1 || !isAna2) {
2264 aTolFF = Max(aTolFF, 5.e-6);