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.
19 #include <Bnd_Box.hxx>
20 #include <BOPAlgo_PaveFiller.hxx>
21 #include <BOPAlgo_SectionAttribute.hxx>
22 #include <BOPAlgo_Tools.hxx>
23 #include <BOPCol_BoxBndTree.hxx>
24 #include <BOPCol_DataMapOfIntegerShape.hxx>
25 #include <BOPCol_DataMapOfShapeInteger.hxx>
26 #include <BOPCol_DataMapOfShapeListOfShape.hxx>
27 #include <BOPCol_IndexedDataMapOfShapeBox.hxx>
28 #include <BOPCol_NCVector.hxx>
29 #include <BOPCol_Parallel.hxx>
30 #include <BOPDS_CommonBlock.hxx>
31 #include <BOPDS_CoupleOfPaveBlocks.hxx>
32 #include <BOPDS_Curve.hxx>
33 #include <BOPDS_DataMapOfPaveBlockListOfInteger.hxx>
34 #include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
35 #include <BOPDS_DS.hxx>
36 #include <BOPDS_Interf.hxx>
37 #include <BOPDS_Iterator.hxx>
38 #include <BOPDS_MapOfPaveBlock.hxx>
39 #include <BOPDS_Pave.hxx>
40 #include <BOPDS_PaveBlock.hxx>
41 #include <BOPDS_VectorOfInterfEE.hxx>
42 #include <BOPTools_AlgoTools.hxx>
43 #include <BndLib_Add3dCurve.hxx>
44 #include <BRep_Tool.hxx>
45 #include <BRepBndLib.hxx>
46 #include <BRepTools.hxx>
47 #include <BRepAdaptor_Curve.hxx>
48 #include <GeomAPI_ProjectPointOnCurve.hxx>
50 #include <IntTools_CommonPrt.hxx>
51 #include <IntTools_Context.hxx>
52 #include <IntTools_EdgeEdge.hxx>
53 #include <IntTools_Range.hxx>
54 #include <IntTools_SequenceOfCommonPrts.hxx>
55 #include <IntTools_SequenceOfRanges.hxx>
56 #include <IntTools_ShrunkRange.hxx>
57 #include <IntTools_Tools.hxx>
58 #include <NCollection_UBTreeFiller.hxx>
59 #include <Precision.hxx>
60 #include <TopoDS_Compound.hxx>
61 #include <TopoDS_Edge.hxx>
62 #include <TopoDS_Face.hxx>
63 #include <TopoDS_Vertex.hxx>
65 /////////////////////////////////////////////////////////////////////////
66 //=======================================================================
67 //class : BOPAlgo_EdgeEdge
69 //=======================================================================
70 class BOPAlgo_EdgeEdge :
71 public IntTools_EdgeEdge,
83 virtual ~BOPAlgo_EdgeEdge(){
86 void SetPaveBlock1(const Handle(BOPDS_PaveBlock)& aPB) {
90 Handle(BOPDS_PaveBlock)& PaveBlock1() {
94 void SetPaveBlock2(const Handle(BOPDS_PaveBlock)& aPB) {
98 Handle(BOPDS_PaveBlock)& PaveBlock2() {
102 virtual void Perform() {
103 BOPAlgo_Algo::UserBreak();
104 IntTools_EdgeEdge::Perform();
108 Handle(BOPDS_PaveBlock) myPB1;
109 Handle(BOPDS_PaveBlock) myPB2;
112 //=======================================================================
113 typedef BOPCol_NCVector
114 <BOPAlgo_EdgeEdge> BOPAlgo_VectorOfEdgeEdge;
116 typedef BOPCol_Functor
118 BOPAlgo_VectorOfEdgeEdge> BOPAlgo_EdgeEdgeFunctor;
121 <BOPAlgo_EdgeEdgeFunctor,
122 BOPAlgo_VectorOfEdgeEdge> BOPAlgo_EdgeEdgeCnt;
124 /////////////////////////////////////////////////////////////////////////
125 //=======================================================================
126 //class : BOPAlgo_TNV
128 //=======================================================================
129 class BOPAlgo_TNV : public BOPCol_BoxBndTreeSelector{
132 : BOPCol_BoxBndTreeSelector(), myTree(NULL) {
138 void SetVertex(const TopoDS_Vertex& aV) {
142 const TopoDS_Vertex& Vertex()const {
146 void SetTree(BOPCol_BoxBndTree& aTree) {
151 myTree->Select(*this);
156 BOPCol_BoxBndTree *myTree;
159 //=======================================================================
160 typedef BOPCol_NCVector
161 <BOPAlgo_TNV> BOPAlgo_VectorOfTNV;
163 typedef BOPCol_Functor
165 BOPAlgo_VectorOfTNV> BOPAlgo_TNVFunctor;
169 BOPAlgo_VectorOfTNV> BOPAlgo_TNVCnt;
170 /////////////////////////////////////////////////////////////////////////
171 //=======================================================================
172 //class : BOPAlgo_PVE
174 //=======================================================================
178 : myIV(-1), myIE(-1), myFlag(-1), myT(-1.) {
184 void SetIndices(const Standard_Integer nV,
185 const Standard_Integer nE){
190 void Indices(Standard_Integer& nV,
191 Standard_Integer& nE) const {
196 void SetVertex(const TopoDS_Vertex& aV) {
200 const TopoDS_Vertex& Vertex()const {
204 void SetEdge(const TopoDS_Edge& aE) {
208 const TopoDS_Edge& Edge()const {
212 void SetPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) {
216 Handle(BOPDS_PaveBlock)& PaveBlock() {
220 Standard_Integer Flag()const {
224 Standard_Real Parameter()const {
228 void SetContext(const Handle(IntTools_Context)& aContext) {
232 const Handle(IntTools_Context)& Context()const {
238 myFlag = myContext->ComputeVE(myV, myE, myT, dummy);
242 Standard_Integer myIV;
243 Standard_Integer myIE;
244 Standard_Integer myFlag;
248 Handle(BOPDS_PaveBlock) myPB;
249 Handle(IntTools_Context) myContext;
251 //=======================================================================
252 typedef BOPCol_NCVector
253 <BOPAlgo_PVE> BOPAlgo_VectorOfPVE;
255 typedef BOPCol_ContextFunctor
258 Handle(IntTools_Context),
259 IntTools_Context> BOPAlgo_PVEFunctor;
261 typedef BOPCol_ContextCnt
264 Handle(IntTools_Context)> BOPAlgo_PVECnt;
265 /////////////////////////////////////////////////////////////////////////
266 //=======================================================================
267 // function: PerformEE
269 //=======================================================================
270 void BOPAlgo_PaveFiller::PerformEE()
272 Standard_Integer iSize;
276 FillShrunkData(TopAbs_EDGE, TopAbs_EDGE);
278 myIterator->Initialize(TopAbs_EDGE, TopAbs_EDGE);
279 iSize=myIterator->ExpectedLength();
284 Standard_Boolean bJustAdd, bExpressCompute, bIsPBSplittable1, bIsPBSplittable2;
285 Standard_Integer i, iX, nE1, nE2, aNbCPrts, k, aNbEdgeEdge;
286 Standard_Integer nV11, nV12, nV21, nV22;
287 Standard_Real aTS11, aTS12, aTS21, aTS22, aT11, aT12, aT21, aT22;
288 TopAbs_ShapeEnum aType;
289 BOPDS_ListIteratorOfListOfPaveBlock aIt1, aIt2;
290 Handle(NCollection_BaseAllocator) aAllocator;
291 BOPDS_MapOfPaveBlock aMPBToUpdate;
292 BOPAlgo_VectorOfEdgeEdge aVEdgeEdge;
293 BOPDS_MapIteratorOfMapOfPaveBlock aItPB;
295 aAllocator=NCollection_BaseAllocator::CommonBaseAllocator();
296 //-----------------------------------------------------scope f
297 BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock aMPBLPB(100, aAllocator);
298 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator);
299 BOPAlgo_DataMapOfPaveBlockBndBox aDMPBBox(100, aAllocator);
301 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
302 aEEs.SetIncrement(iSize);
304 for (; myIterator->More(); myIterator->Next()) {
305 myIterator->Value(nE1, nE2, bJustAdd);
310 const BOPDS_ShapeInfo& aSIE1=myDS->ShapeInfo(nE1);
311 if (aSIE1.HasFlag()){
314 const BOPDS_ShapeInfo& aSIE2=myDS->ShapeInfo(nE2);
315 if (aSIE2.HasFlag()){
319 const TopoDS_Edge& aE1=(*(TopoDS_Edge *)(&aSIE1.Shape()));
320 const TopoDS_Edge& aE2=(*(TopoDS_Edge *)(&aSIE2.Shape()));
322 BOPDS_ListOfPaveBlock& aLPB1=myDS->ChangePaveBlocks(nE1);
323 BOPDS_ListOfPaveBlock& aLPB2=myDS->ChangePaveBlocks(nE2);
325 aIt1.Initialize(aLPB1);
326 for (; aIt1.More(); aIt1.Next()) {
329 Handle(BOPDS_PaveBlock)& aPB1=aIt1.ChangeValue();
331 if (!GetPBBox(aE1, aPB1, aDMPBBox, aT11, aT12, aTS11, aTS12, aBB1)) {
335 aPB1->Indices(nV11, nV12);
337 aIt2.Initialize(aLPB2);
338 for (; aIt2.More(); aIt2.Next()) {
341 Handle(BOPDS_PaveBlock)& aPB2=aIt2.ChangeValue();
343 if (!GetPBBox(aE2, aPB2, aDMPBBox, aT21, aT22, aTS21, aTS22, aBB2)) {
347 if (aBB1.IsOut(aBB2)) {
351 aPB2->Indices(nV21, nV22);
353 bExpressCompute=((nV11==nV21 && nV12==nV22) ||
354 (nV12==nV21 && nV11==nV22));
356 BOPAlgo_EdgeEdge& anEdgeEdge=aVEdgeEdge.Append1();
358 anEdgeEdge.UseQuickCoincidenceCheck(bExpressCompute);
360 anEdgeEdge.SetPaveBlock1(aPB1);
361 anEdgeEdge.SetPaveBlock2(aPB2);
363 anEdgeEdge.SetEdge1(aE1, aT11, aT12);
364 anEdgeEdge.SetEdge2(aE2, aT21, aT22);
365 anEdgeEdge.SetProgressIndicator(myProgressIndicator);
366 }//for (; aIt2.More(); aIt2.Next()) {
367 }//for (; aIt1.More(); aIt1.Next()) {
368 }//for (; myIterator->More(); myIterator->Next()) {
370 aNbEdgeEdge=aVEdgeEdge.Extent();
371 //======================================================
372 BOPAlgo_EdgeEdgeCnt::Perform(myRunParallel, aVEdgeEdge);
373 //======================================================
375 for (k = 0; k < aNbEdgeEdge; ++k) {
378 BOPAlgo_EdgeEdge& anEdgeEdge=aVEdgeEdge(k);
379 if (!anEdgeEdge.IsDone()) {
383 //--------------------------------------------
384 Handle(BOPDS_PaveBlock)& aPB1=anEdgeEdge.PaveBlock1();
385 nE1=aPB1->OriginalEdge();
386 aPB1->Range(aT11, aT12);
387 if (!aPB1->HasShrunkData()) {
390 bIsPBSplittable1 = Standard_False;
393 aPB1->ShrunkData(aTS11, aTS12, aBB1, bIsPBSplittable1);
396 Handle(BOPDS_PaveBlock)& aPB2=anEdgeEdge.PaveBlock2();
397 nE2=aPB2->OriginalEdge();
398 aPB2->Range(aT21, aT22);
399 if (!aPB2->HasShrunkData()) {
402 bIsPBSplittable2 = Standard_False;
405 aPB2->ShrunkData(aTS21, aTS22, aBB2, bIsPBSplittable2);
408 //--------------------------------------------
409 IntTools_Range aR11(aT11, aTS11), aR12(aTS12, aT12),
410 aR21(aT21, aTS21), aR22(aTS22, aT22);
412 const IntTools_SequenceOfCommonPrts& aCPrts = anEdgeEdge.CommonParts();
413 aNbCPrts = aCPrts.Length();
415 Standard_Boolean bLineLine = Standard_False;
417 const TopoDS_Edge& aOE1 = *(TopoDS_Edge*)&myDS->Shape(nE1);
418 const TopoDS_Edge& aOE2 = *(TopoDS_Edge*)&myDS->Shape(nE2);
420 BRepAdaptor_Curve aBAC1(aOE1), aBAC2(aOE2);
422 bLineLine = (aBAC1.GetType() == GeomAbs_Line &&
423 aBAC2.GetType() == GeomAbs_Line);
426 for (i=1; i<=aNbCPrts; ++i) {
427 const IntTools_CommonPrt& aCPart=aCPrts(i);
429 const TopoDS_Edge& aE1=aCPart.Edge1();
430 const TopoDS_Edge& aE2=aCPart.Edge2();
434 case TopAbs_VERTEX: {
435 if (!bIsPBSplittable1 || !bIsPBSplittable2) {
439 Standard_Boolean bIsOnPave[4], bFlag;
440 Standard_Integer nV[4], j;
441 Standard_Real aT1, aT2, aTol;
443 IntTools_Range aCR1, aCR2;
445 IntTools_Tools::VertexParameters(aCPart, aT1, aT2);
446 aTol = Precision::Confusion();
447 aCR1 = aCPart.Range1();
448 aCR2 = aCPart.Ranges2()(1);
450 //decide to keep the pave or not
451 bIsOnPave[0] = IntTools_Tools::IsOnPave1(aT1, aR11, aTol) ||
452 IntTools_Tools::IsOnPave1(aR11.First(), aCR1, aTol);
453 bIsOnPave[1] = IntTools_Tools::IsOnPave1(aT1, aR12, aTol) ||
454 IntTools_Tools::IsOnPave1(aR12.Last(), aCR1, aTol);
455 bIsOnPave[2] = IntTools_Tools::IsOnPave1(aT2, aR21, aTol) ||
456 IntTools_Tools::IsOnPave1(aR21.First(), aCR2, aTol);
457 bIsOnPave[3] = IntTools_Tools::IsOnPave1(aT2, aR22, aTol) ||
458 IntTools_Tools::IsOnPave1(aR22.Last(), aCR2, aTol);
460 aPB1->Indices(nV[0], nV[1]);
461 aPB2->Indices(nV[2], nV[3]);
463 if((bIsOnPave[0] && bIsOnPave[2]) ||
464 (bIsOnPave[0] && bIsOnPave[3]) ||
465 (bIsOnPave[1] && bIsOnPave[2]) ||
466 (bIsOnPave[1] && bIsOnPave[3])) {
470 bFlag = Standard_False;
471 for (j = 0; j < 4; ++j) {
473 //add interf VE(nV[j], nE)
474 Handle(BOPDS_PaveBlock)& aPB = (j < 2) ? aPB2 : aPB1;
475 ForceInterfVE(nV[j], aPB, aMPBToUpdate);
476 bFlag = Standard_True;
484 BOPTools_AlgoTools::MakeNewVertex(aE1, aT1, aE2, aT2, aVnew);
485 Standard_Real aTolVnew = BRep_Tool::Tolerance(aVnew);
487 // increase tolerance for Line/Line intersection, but do not update
488 // the vertex till its intersection with some other shape
489 Standard_Real aTolMin = (aCR1.Last() - aCR1.First()) / 2.;
490 if (aTolMin > aTolVnew) {
496 Standard_Integer nVS[2], iFound;
497 Standard_Real aTolVx, aD2, aDT2;
498 BOPCol_MapOfInteger aMV;
506 if (aMV.Contains(nV[2])) {
510 if (aMV.Contains(nV[3])) {
515 aPnew=BRep_Tool::Pnt(aVnew);
517 for (Standard_Integer k1=0; k1<=j; ++k1) {
518 const TopoDS_Vertex& aVx= *(TopoDS_Vertex*)&(myDS->Shape(nVS[k1]));
519 aTolVx=BRep_Tool::Tolerance(aVx);
520 aPx=BRep_Tool::Pnt(aVx);
521 aD2=aPnew.SquareDistance(aPx);
523 aDT2=100.*(aTolVnew+aTolVx)*(aTolVnew+aTolVx);
537 BOPDS_InterfEE& aEE=aEEs.Append1();
539 aEE.SetIndices(nE1, nE2);
540 aEE.SetCommonPart(aCPart);
542 myDS->AddInterf(nE1, nE2);
544 BOPDS_CoupleOfPaveBlocks aCPB;
546 aCPB.SetPaveBlocks(aPB1, aPB2);
547 aCPB.SetIndexInterf(iX);
548 aCPB.SetTolerance(aTolVnew);
549 aMVCPB.Add(aVnew, aCPB);
550 }//case TopAbs_VERTEX:
558 Standard_Boolean bHasSameBounds;
559 bHasSameBounds=aPB1->HasSameBounds(aPB2);
560 if (!bHasSameBounds) {
564 BOPDS_InterfEE& aEE=aEEs.Append1();
566 aEE.SetIndices(nE1, nE2);
567 aEE.SetCommonPart(aCPart);
569 myDS->AddInterf(nE1, nE2);
571 BOPAlgo_Tools::FillMap(aPB1, aPB2, aMPBLPB, aAllocator);
577 }//for (i=1; i<=aNbCPrts; i++) {
578 }//for (k=0; k < aNbFdgeEdge; ++k) {
580 //=========================================
582 //=========================================
584 Standard_Integer aNbV;
585 Handle(BOPDS_PaveBlock) aPB1, aPB2;
587 aNbV=aMVCPB.Extent();
588 for (i=1; i<=aNbV; ++i) {
589 const BOPDS_CoupleOfPaveBlocks& aCPB=aMVCPB.FindFromIndex(i);
590 aCPB.PaveBlocks(aPB1, aPB2);
592 aMPBToUpdate.Remove(aPB1);
593 aMPBToUpdate.Remove(aPB2);
597 aItPB.Initialize(aMPBToUpdate);
598 for (; aItPB.More(); aItPB.Next()) {
599 Handle(BOPDS_PaveBlock) aPB=aItPB.Value();
600 if (!myDS->IsCommonBlock(aPB)) {
601 myDS->UpdatePaveBlock(aPB);
604 const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
605 myDS->UpdateCommonBlock(aCB);
609 BOPAlgo_Tools::PerformCommonBlocks(aMPBLPB, aAllocator, myDS);
610 PerformVerticesEE(aMVCPB, aAllocator);
611 //-----------------------------------------------------scope t
614 aMPBToUpdate.Clear();
616 //=======================================================================
617 //function : PerformVerticesEE
619 //=======================================================================
620 Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE
621 (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
622 const Handle(NCollection_BaseAllocator)& theAllocator)
624 Standard_Integer aNbV, iRet;
627 aNbV=theMVCPB.Extent();
632 Standard_Integer nVx, iV, j, nE, iFlag, iX, i, aNb;
634 BOPCol_ListIteratorOfListOfShape aItLS;
635 BOPCol_ListIteratorOfListOfInteger aItLI;
636 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
640 BOPDS_IndexedDataMapOfPaveBlockListOfInteger aMPBLI(100, theAllocator);
641 BOPCol_ListOfShape aLS(theAllocator);
642 BOPCol_IndexedDataMapOfShapeInteger aMVI(100, theAllocator);
643 BOPCol_IndexedDataMapOfShapeListOfShape aImages;
645 aSI.SetShapeType(TopAbs_VERTEX);
646 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
648 // 1 prepare arguments
650 TreatNewVertices(theMVCPB, aImages);
652 // 3 Add new vertices to myDS;
653 // connect indices to CPB structure
654 aNb = aImages.Extent();
655 for (i=1; i<=aNb; ++i) {
656 const TopoDS_Vertex& aV=(*(TopoDS_Vertex*)(&aImages.FindKey(i)));
657 const BOPCol_ListOfShape& aLVSD=aImages.FindFromIndex(i);
660 iV=myDS->Append(aSI);
662 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(iV);
663 Bnd_Box& aBox=aSIDS.ChangeBox();
664 BRepBndLib::Add(aV, aBox);
665 aBox.SetGap(aBox.GetGap() + Precision::Confusion());
667 aItLS.Initialize(aLVSD);
668 for (; aItLS.More(); aItLS.Next()) {
669 const TopoDS_Shape& aVx = aItLS.Value();
670 BOPDS_CoupleOfPaveBlocks &aCPB=theMVCPB.ChangeFromKey(aVx);
672 // update EE interference
673 iX=aCPB.IndexInterf();
674 BOPDS_InterfEE& aEE=aEEs(iX);
679 // 4 Map PaveBlock/ListOfVertices to add to this PaveBlock ->aMPBLI
681 Handle(BOPDS_PaveBlock) aPB[2];
683 for (i=1; i<=aNbV; ++i) {
684 const BOPDS_CoupleOfPaveBlocks& aCPB=theMVCPB.FindFromIndex(i);
686 aCPB.PaveBlocks(aPB[0], aPB[1]);
687 for (j=0; j<2; ++j) {
688 if (aMPBLI.Contains(aPB[j])) {
689 BOPCol_ListOfInteger& aLI=aMPBLI.ChangeFromKey(aPB[j]);
693 BOPCol_ListOfInteger aLI(theAllocator);
695 aMPBLI.Add(aPB[j], aLI);
701 // 5.1 Compute Extra Paves and
702 // 5.2. Add Extra Paves to the PaveBlocks
703 //-------------------------------------------------------------
704 Standard_Integer k, aNbVPVE;
705 BOPAlgo_VectorOfPVE aVPVE;
708 for(i=1; i<=aNb; ++i) {
709 Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
710 nE=aPB->OriginalEdge();
711 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
713 const BOPCol_ListOfInteger& aLI=aMPBLI.FindFromIndex(i);
714 aItLI.Initialize(aLI);
715 for (; aItLI.More(); aItLI.Next()) {
717 const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
719 BOPAlgo_PVE& aPVE=aVPVE.Append1();
720 aPVE.SetIndices(nVx, nE);
723 aPVE.SetPaveBlock(aPB);
727 aNbVPVE=aVPVE.Extent();
728 //=============================================================
729 BOPAlgo_PVECnt::Perform(myRunParallel, aVPVE, myContext);
730 //=============================================================
732 for (k=0; k < aNbVPVE; ++k) {
733 BOPAlgo_PVE& aPVE=aVPVE(k);
736 aPVE.Indices(nVx, nE);
738 Handle(BOPDS_PaveBlock)& aPB=aPVE.PaveBlock();
741 aPave.SetParameter(aT);
742 aPB->AppendExtPave(aPave);
745 // 6 Split PaveBlocksa
747 for(i=1; i<=aNb; ++i) {
748 Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
749 nE=aPB->OriginalEdge();
751 if (!myDS->IsCommonBlock(aPB)) {
752 myDS->UpdatePaveBlock(aPB);
755 const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
756 myDS->UpdateCommonBlock(aCB);
758 }//for (; aItMPBLI.More(); aItMPBLI.Next()) {
762 //=======================================================================
763 //function : TreatNewVertices
765 //=======================================================================
766 void BOPAlgo_PaveFiller::TreatNewVertices
767 (const BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
768 BOPCol_IndexedDataMapOfShapeListOfShape& myImages)
770 Standard_Integer i, aNbV;//, aNbVSD;
773 BOPCol_IndexedMapOfShape aMVProcessed;
774 BOPCol_MapOfInteger aMFence;
775 BOPCol_ListIteratorOfListOfInteger aIt;
776 NCollection_Vector<BOPCol_ListOfShape> aVecOfLVSD;
778 BOPCol_BoxBndTree aBBTree;
779 NCollection_UBTreeFiller <Standard_Integer,
780 Bnd_Box> aTreeFiller(aBBTree);
781 BOPAlgo_VectorOfTNV aVTNV;
783 aNbV = theMVCPB.Extent();
784 for (i=1; i<=aNbV; ++i) {
785 const TopoDS_Vertex& aV = *((TopoDS_Vertex*)&theMVCPB.FindKey(i));
788 aTol = theMVCPB.FindFromIndex(i).Tolerance();
789 aBox.Add(BRep_Tool::Pnt(aV));
792 aTreeFiller.Add(i, aBox);
794 BOPAlgo_TNV& aTNV=aVTNV.Append1();
795 aTNV.SetTree(aBBTree);
802 //===========================================
803 BOPAlgo_TNVCnt::Perform(myRunParallel, aVTNV);
804 //===========================================
807 for (i=1; i<=aNbV; ++i) {
808 if (!aMFence.Add(i)) {
812 Standard_Integer aIP, aNbIP1, aIP1;
813 BOPCol_ListOfShape aLVSD;
814 BOPCol_ListOfInteger aLIP, aLIP1, aLIPC;
815 BOPCol_ListIteratorOfListOfInteger aItLIP;
820 aItLIP.Initialize(aLIP);
821 for(; aItLIP.More(); aItLIP.Next()) {
824 BOPAlgo_TNV& aTNV=aVTNV(aIP-1);
825 const BOPCol_ListOfInteger& aLI=aTNV.Indices();
827 for (; aIt.More(); aIt.Next()) {
829 if (!aMFence.Add(aIP1)) {
833 } //for (; aIt.More(); aIt.Next()) {
834 }//for(; aIt1.More(); aIt1.Next()) {
836 aNbIP1=aLIP1.Extent();
838 break; // from for(;;)
842 aLIPC.Append(aLIP1); // items of aLIP1 are moved to aLIPC
845 aItLIP.Initialize(aLIPC);
846 for(; aItLIP.More(); aItLIP.Next()) {
848 const TopoDS_Vertex& aVP=aVTNV(aIP-1).Vertex();
851 aVecOfLVSD.Append(aLVSD);
852 }// for (i=1; i<=aNbV; ++i) {
855 aNbV = aVecOfLVSD.Size();
856 for (i = 0; i < aNbV; ++i) {
857 const BOPCol_ListOfShape& aLVSD = aVecOfLVSD(i);
858 BOPTools_AlgoTools::MakeVertex(aLVSD, aVnew);
859 myImages.Add(aVnew, aLVSD);
862 //=======================================================================
863 //function : FillShrunkData
865 //=======================================================================
866 void BOPAlgo_PaveFiller::FillShrunkData(Handle(BOPDS_PaveBlock)& thePB)
868 Standard_Integer nE, nV1, nV2;
869 Standard_Real aT1, aT2, aTS1, aTS2;
870 IntTools_ShrunkRange aSR;
875 const BOPDS_Pave& aPave1=thePB->Pave1();
877 aT1=aPave1.Parameter();
878 const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
880 const BOPDS_Pave& aPave2=thePB->Pave2();
882 aT2=aPave2.Parameter();
883 const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
885 nE=thePB->OriginalEdge();
886 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
888 aSR.SetContext(myContext);
889 aSR.SetData(aE, aT1, aT2, aV1, aV2);
897 aSR.ShrunkRange(aTS1, aTS2);
898 const Bnd_Box& aBox=aSR.BndBox();
899 Standard_Boolean bIsSplittable = aSR.IsSplittable();
901 thePB->SetShrunkData(aTS1, aTS2, aBox, bIsSplittable);
903 //=======================================================================
904 //function : ForceInterfVE
906 //=======================================================================
907 void BOPAlgo_PaveFiller::ForceInterfVE(const Standard_Integer nV,
908 Handle(BOPDS_PaveBlock)& aPB,
909 BOPDS_MapOfPaveBlock& aMPBToUpdate)
911 Standard_Integer nE, nVx, nVSD, iFlag;
912 Standard_Real aT, aTolVNew;
914 nE = aPB->OriginalEdge();
916 const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
917 if (aSIE.HasSubShape(nV)) {
921 if (myDS->HasInterf(nV, nE)) {
925 if (myDS->HasInterfShapeSubShapes(nV, nE)) {
929 if (aPB->Pave1().Index() == nV ||
930 aPB->Pave2().Index() == nV) {
935 if (myDS->HasShapeSD(nV, nVSD)) {
939 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nVx);
940 const TopoDS_Edge& aE = *(TopoDS_Edge*) &myDS->Shape(nE);
942 iFlag = myContext->ComputeVE(aV, aE, aT, aTolVNew);
943 if (iFlag == 0 || iFlag == -4) {
947 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
948 aVEs.SetIncrement(10);
950 BOPDS_InterfVE& aVE=aVEs.Append1();
951 aVE.SetIndices(nV, nE);
952 aVE.SetParameter(aT);
954 myDS->AddInterf(nV, nE);
956 // 3 update vertex V/E if necessary
957 nVx=UpdateVertex(nV, aTolVNew);
959 if (myDS->IsNewShape(nVx)) {
960 aVE.SetIndexNew(nVx);
962 // 5 append ext pave to pave block
964 aPave.SetParameter(aT);
965 aPB->AppendExtPave(aPave);
967 aMPBToUpdate.Add(aPB);
971 //=======================================================================
972 //function : GetPBBox
974 //=======================================================================
975 Standard_Boolean BOPAlgo_PaveFiller::GetPBBox(const TopoDS_Edge& theE,
976 const Handle(BOPDS_PaveBlock)& thePB,
977 BOPAlgo_DataMapOfPaveBlockBndBox& thePBBox,
978 Standard_Real& theFirst,
979 Standard_Real& theLast,
980 Standard_Real& theSFirst,
981 Standard_Real& theSLast,
984 thePB->Range(theFirst, theLast);
985 // check the validity of PB's range
986 Standard_Boolean bValid = theLast - theFirst > Precision::PConfusion();
992 if (thePB->HasShrunkData()) {
993 Standard_Boolean bIsSplittable;
994 thePB->ShrunkData(theSFirst, theSLast, theBox, bIsSplittable);
998 theSFirst = theFirst;
1001 if (thePBBox.IsBound(thePB)) {
1002 theBox = thePBBox.Find(thePB);
1005 // build bounding box
1006 BRepAdaptor_Curve aBAC(theE);
1007 Standard_Real aTol = BRep_Tool::Tolerance(theE) + Precision::Confusion();
1008 BndLib_Add3dCurve::Add(aBAC, theSFirst, theSLast, aTol, theBox);
1009 thePBBox.Bind(thePB, theBox);