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>
49 #include <IntTools_CommonPrt.hxx>
50 #include <IntTools_Context.hxx>
51 #include <IntTools_EdgeEdge.hxx>
52 #include <IntTools_Range.hxx>
53 #include <IntTools_SequenceOfCommonPrts.hxx>
54 #include <IntTools_SequenceOfRanges.hxx>
55 #include <IntTools_ShrunkRange.hxx>
56 #include <IntTools_Tools.hxx>
57 #include <NCollection_UBTreeFiller.hxx>
58 #include <Precision.hxx>
59 #include <TopoDS_Compound.hxx>
60 #include <TopoDS_Edge.hxx>
61 #include <TopoDS_Face.hxx>
62 #include <TopoDS_Vertex.hxx>
64 /////////////////////////////////////////////////////////////////////////
65 //=======================================================================
66 //class : BOPAlgo_EdgeEdge
68 //=======================================================================
69 class BOPAlgo_EdgeEdge :
70 public IntTools_EdgeEdge,
82 virtual ~BOPAlgo_EdgeEdge(){
85 void SetPaveBlock1(const Handle(BOPDS_PaveBlock)& aPB) {
89 Handle(BOPDS_PaveBlock)& PaveBlock1() {
93 void SetPaveBlock2(const Handle(BOPDS_PaveBlock)& aPB) {
97 Handle(BOPDS_PaveBlock)& PaveBlock2() {
101 void SetFuzzyValue(const Standard_Real theFuzz) {
102 IntTools_EdgeEdge::SetFuzzyValue(theFuzz);
105 virtual void Perform() {
106 BOPAlgo_Algo::UserBreak();
107 IntTools_EdgeEdge::Perform();
111 Handle(BOPDS_PaveBlock) myPB1;
112 Handle(BOPDS_PaveBlock) myPB2;
115 //=======================================================================
116 typedef BOPCol_NCVector
117 <BOPAlgo_EdgeEdge> BOPAlgo_VectorOfEdgeEdge;
119 typedef BOPCol_Functor
121 BOPAlgo_VectorOfEdgeEdge> BOPAlgo_EdgeEdgeFunctor;
124 <BOPAlgo_EdgeEdgeFunctor,
125 BOPAlgo_VectorOfEdgeEdge> BOPAlgo_EdgeEdgeCnt;
127 /////////////////////////////////////////////////////////////////////////
128 //=======================================================================
129 //class : BOPAlgo_TNV
131 //=======================================================================
133 typedef BOPCol_NCVector
134 <BOPAlgo_TNV> BOPAlgo_VectorOfTNV;
136 typedef BOPCol_Functor
138 BOPAlgo_VectorOfTNV> BOPAlgo_TNVFunctor;
142 BOPAlgo_VectorOfTNV> BOPAlgo_TNVCnt;
143 //=======================================================================
144 class BOPAlgo_TNV : public BOPCol_BoxBndTreeSelector{
147 : BOPCol_BoxBndTreeSelector(),
148 myTol (0.), myFuzzyValue(0.), myTree(NULL), myVecTNV(NULL) {
154 void SetVertex(const TopoDS_Vertex& aV) {
156 myPnt = BRep_Tool::Pnt(myV);
159 const TopoDS_Vertex& Vertex()const {
163 void SetTree(BOPCol_BoxBndTree& aTree) {
167 void SetTolerance(const Standard_Real theTol) {
171 Standard_Real Tolerance() const {
175 const gp_Pnt& Pnt() const {
179 void SetFuzzyValue(const Standard_Real theFuzzyValue) {
180 myFuzzyValue = theFuzzyValue;
183 void SetVectorOfTNV(const BOPAlgo_VectorOfTNV& theVec) {
187 virtual Standard_Boolean Accept(const Standard_Integer& theIndex)
189 const BOPAlgo_TNV& aTNV = myVecTNV->Value(theIndex - 1);
190 Standard_Real aTolSum2 = myTol + aTNV.Tolerance() + myFuzzyValue;
191 aTolSum2 *= aTolSum2;
192 Standard_Real aD2 = myPnt.SquareDistance(aTNV.Pnt());
194 return BOPCol_BoxBndTreeSelector::Accept(theIndex);
195 return Standard_False;
199 myTree->Select(*this);
204 Standard_Real myFuzzyValue;
207 BOPCol_BoxBndTree *myTree;
208 const BOPAlgo_VectorOfTNV *myVecTNV;
211 /////////////////////////////////////////////////////////////////////////
212 //=======================================================================
213 //class : BOPAlgo_PVE
215 //=======================================================================
219 : myIV(-1), myIE(-1), myFlag(-1), myT(-1.) {
225 void SetIndices(const Standard_Integer nV,
226 const Standard_Integer nE){
231 void Indices(Standard_Integer& nV,
232 Standard_Integer& nE) const {
237 void SetVertex(const TopoDS_Vertex& aV) {
241 const TopoDS_Vertex& Vertex()const {
245 void SetEdge(const TopoDS_Edge& aE) {
249 const TopoDS_Edge& Edge()const {
253 void SetPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) {
257 Handle(BOPDS_PaveBlock)& PaveBlock() {
261 Standard_Integer Flag()const {
265 Standard_Real Parameter()const {
269 void SetContext(const Handle(IntTools_Context)& aContext) {
273 const Handle(IntTools_Context)& Context()const {
277 void SetFuzzyValue(const Standard_Real theValue) {
278 myFuzzyValue = theValue;
283 myFlag = myContext->ComputeVE(myV, myE, myT, dummy, myFuzzyValue);
287 Standard_Integer myIV;
288 Standard_Integer myIE;
289 Standard_Integer myFlag;
291 Standard_Real myFuzzyValue;
294 Handle(BOPDS_PaveBlock) myPB;
295 Handle(IntTools_Context) myContext;
297 //=======================================================================
298 typedef BOPCol_NCVector
299 <BOPAlgo_PVE> BOPAlgo_VectorOfPVE;
301 typedef BOPCol_ContextFunctor
304 Handle(IntTools_Context),
305 IntTools_Context> BOPAlgo_PVEFunctor;
307 typedef BOPCol_ContextCnt
310 Handle(IntTools_Context)> BOPAlgo_PVECnt;
311 /////////////////////////////////////////////////////////////////////////
312 //=======================================================================
313 // function: PerformEE
315 //=======================================================================
316 void BOPAlgo_PaveFiller::PerformEE()
318 Standard_Integer iSize;
322 FillShrunkData(TopAbs_EDGE, TopAbs_EDGE);
324 myIterator->Initialize(TopAbs_EDGE, TopAbs_EDGE);
325 iSize=myIterator->ExpectedLength();
330 Standard_Boolean bJustAdd, bExpressCompute, bIsPBSplittable1, bIsPBSplittable2;
331 Standard_Integer i, iX, nE1, nE2, aNbCPrts, k, aNbEdgeEdge;
332 Standard_Integer nV11, nV12, nV21, nV22;
333 Standard_Real aTS11, aTS12, aTS21, aTS22, aT11, aT12, aT21, aT22;
334 TopAbs_ShapeEnum aType;
335 BOPDS_ListIteratorOfListOfPaveBlock aIt1, aIt2;
336 Handle(NCollection_BaseAllocator) aAllocator;
337 BOPDS_MapOfPaveBlock aMPBToUpdate;
338 BOPAlgo_VectorOfEdgeEdge aVEdgeEdge;
339 BOPDS_MapIteratorOfMapOfPaveBlock aItPB;
341 aAllocator=NCollection_BaseAllocator::CommonBaseAllocator();
342 //-----------------------------------------------------scope f
343 BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock aMPBLPB(100, aAllocator);
344 BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator);
345 BOPAlgo_DataMapOfPaveBlockBndBox aDMPBBox(100, aAllocator);
347 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
348 aEEs.SetIncrement(iSize);
350 for (; myIterator->More(); myIterator->Next()) {
351 myIterator->Value(nE1, nE2, bJustAdd);
356 const BOPDS_ShapeInfo& aSIE1=myDS->ShapeInfo(nE1);
357 if (aSIE1.HasFlag()){
360 const BOPDS_ShapeInfo& aSIE2=myDS->ShapeInfo(nE2);
361 if (aSIE2.HasFlag()){
365 const TopoDS_Edge& aE1=(*(TopoDS_Edge *)(&aSIE1.Shape()));
366 const TopoDS_Edge& aE2=(*(TopoDS_Edge *)(&aSIE2.Shape()));
368 BOPDS_ListOfPaveBlock& aLPB1=myDS->ChangePaveBlocks(nE1);
369 BOPDS_ListOfPaveBlock& aLPB2=myDS->ChangePaveBlocks(nE2);
371 aIt1.Initialize(aLPB1);
372 for (; aIt1.More(); aIt1.Next()) {
375 Handle(BOPDS_PaveBlock)& aPB1=aIt1.ChangeValue();
377 if (!GetPBBox(aE1, aPB1, aDMPBBox, aT11, aT12, aTS11, aTS12, aBB1)) {
381 aPB1->Indices(nV11, nV12);
383 aIt2.Initialize(aLPB2);
384 for (; aIt2.More(); aIt2.Next()) {
387 Handle(BOPDS_PaveBlock)& aPB2=aIt2.ChangeValue();
389 if (!GetPBBox(aE2, aPB2, aDMPBBox, aT21, aT22, aTS21, aTS22, aBB2)) {
393 if (aBB1.IsOut(aBB2)) {
397 aPB2->Indices(nV21, nV22);
399 bExpressCompute=((nV11==nV21 && nV12==nV22) ||
400 (nV12==nV21 && nV11==nV22));
402 BOPAlgo_EdgeEdge& anEdgeEdge=aVEdgeEdge.Append1();
404 anEdgeEdge.UseQuickCoincidenceCheck(bExpressCompute);
406 anEdgeEdge.SetPaveBlock1(aPB1);
407 anEdgeEdge.SetPaveBlock2(aPB2);
409 anEdgeEdge.SetEdge1(aE1, aT11, aT12);
410 anEdgeEdge.SetEdge2(aE2, aT21, aT22);
411 anEdgeEdge.SetFuzzyValue(myFuzzyValue);
412 anEdgeEdge.SetProgressIndicator(myProgressIndicator);
413 }//for (; aIt2.More(); aIt2.Next()) {
414 }//for (; aIt1.More(); aIt1.Next()) {
415 }//for (; myIterator->More(); myIterator->Next()) {
417 aNbEdgeEdge=aVEdgeEdge.Extent();
418 //======================================================
419 BOPAlgo_EdgeEdgeCnt::Perform(myRunParallel, aVEdgeEdge);
420 //======================================================
422 for (k = 0; k < aNbEdgeEdge; ++k) {
425 BOPAlgo_EdgeEdge& anEdgeEdge=aVEdgeEdge(k);
426 if (!anEdgeEdge.IsDone()) {
430 //--------------------------------------------
431 Handle(BOPDS_PaveBlock)& aPB1=anEdgeEdge.PaveBlock1();
432 nE1=aPB1->OriginalEdge();
433 aPB1->Range(aT11, aT12);
434 if (!aPB1->HasShrunkData()) {
437 bIsPBSplittable1 = Standard_False;
440 aPB1->ShrunkData(aTS11, aTS12, aBB1, bIsPBSplittable1);
443 Handle(BOPDS_PaveBlock)& aPB2=anEdgeEdge.PaveBlock2();
444 nE2=aPB2->OriginalEdge();
445 aPB2->Range(aT21, aT22);
446 if (!aPB2->HasShrunkData()) {
449 bIsPBSplittable2 = Standard_False;
452 aPB2->ShrunkData(aTS21, aTS22, aBB2, bIsPBSplittable2);
455 //--------------------------------------------
456 IntTools_Range aR11(aT11, aTS11), aR12(aTS12, aT12),
457 aR21(aT21, aTS21), aR22(aTS22, aT22);
459 const IntTools_SequenceOfCommonPrts& aCPrts = anEdgeEdge.CommonParts();
460 aNbCPrts = aCPrts.Length();
462 Standard_Boolean bAnalytical = Standard_False;
464 const TopoDS_Edge& aOE1 = *(TopoDS_Edge*)&myDS->Shape(nE1);
465 const TopoDS_Edge& aOE2 = *(TopoDS_Edge*)&myDS->Shape(nE2);
467 BRepAdaptor_Curve aBAC1(aOE1), aBAC2(aOE2);
469 GeomAbs_CurveType aType1 = aBAC1.GetType();
470 GeomAbs_CurveType aType2 = aBAC2.GetType();
472 bAnalytical = (((aType1 == GeomAbs_Line) &&
473 (aType2 == GeomAbs_Line ||
474 aType2 == GeomAbs_Circle)) ||
475 ((aType2 == GeomAbs_Line) &&
476 (aType1 == GeomAbs_Line ||
477 aType1 == GeomAbs_Circle)));
480 for (i=1; i<=aNbCPrts; ++i) {
481 const IntTools_CommonPrt& aCPart=aCPrts(i);
483 const TopoDS_Edge& aE1=aCPart.Edge1();
484 const TopoDS_Edge& aE2=aCPart.Edge2();
488 case TopAbs_VERTEX: {
489 if (!bIsPBSplittable1 || !bIsPBSplittable2) {
493 Standard_Boolean bIsOnPave[4], bFlag;
494 Standard_Integer nV[4], j;
495 Standard_Real aT1, aT2, aTol;
497 IntTools_Range aCR1, aCR2;
499 IntTools_Tools::VertexParameters(aCPart, aT1, aT2);
500 aTol = Precision::Confusion();
501 aCR1 = aCPart.Range1();
502 aCR2 = aCPart.Ranges2()(1);
504 //decide to keep the pave or not
505 bIsOnPave[0] = IntTools_Tools::IsOnPave1(aT1, aR11, aTol) ||
506 IntTools_Tools::IsOnPave1(aR11.First(), aCR1, aTol);
507 bIsOnPave[1] = IntTools_Tools::IsOnPave1(aT1, aR12, aTol) ||
508 IntTools_Tools::IsOnPave1(aR12.Last(), aCR1, aTol);
509 bIsOnPave[2] = IntTools_Tools::IsOnPave1(aT2, aR21, aTol) ||
510 IntTools_Tools::IsOnPave1(aR21.First(), aCR2, aTol);
511 bIsOnPave[3] = IntTools_Tools::IsOnPave1(aT2, aR22, aTol) ||
512 IntTools_Tools::IsOnPave1(aR22.Last(), aCR2, aTol);
514 aPB1->Indices(nV[0], nV[1]);
515 aPB2->Indices(nV[2], nV[3]);
517 if((bIsOnPave[0] && bIsOnPave[2]) ||
518 (bIsOnPave[0] && bIsOnPave[3]) ||
519 (bIsOnPave[1] && bIsOnPave[2]) ||
520 (bIsOnPave[1] && bIsOnPave[3])) {
524 bFlag = Standard_False;
525 for (j = 0; j < 4; ++j) {
527 //add interf VE(nV[j], nE)
528 Handle(BOPDS_PaveBlock)& aPB = (j < 2) ? aPB2 : aPB1;
529 ForceInterfVE(nV[j], aPB, aMPBToUpdate);
530 bFlag = Standard_True;
538 BOPTools_AlgoTools::MakeNewVertex(aE1, aT1, aE2, aT2, aVnew);
539 Standard_Real aTolVnew = BRep_Tool::Tolerance(aVnew);
541 // increase tolerance for Line/Line intersection, but do not update
542 // the vertex till its intersection with some other shape
543 Standard_Real aTolMin = (BRepAdaptor_Curve(aE1).GetType() == GeomAbs_Line) ?
544 (aCR1.Last() - aCR1.First()) / 2. : (aCR2.Last() - aCR2.First()) / 2.;
545 if (aTolMin > aTolVnew) {
551 Standard_Integer nVS[2], iFound;
552 Standard_Real aTolVx, aD2, aDT2;
553 BOPCol_MapOfInteger aMV;
561 if (aMV.Contains(nV[2])) {
565 if (aMV.Contains(nV[3])) {
570 aPnew=BRep_Tool::Pnt(aVnew);
572 for (Standard_Integer k1=0; k1<=j; ++k1) {
573 const TopoDS_Vertex& aVx= *(TopoDS_Vertex*)&(myDS->Shape(nVS[k1]));
574 aTolVx=BRep_Tool::Tolerance(aVx);
575 aPx=BRep_Tool::Pnt(aVx);
576 aD2=aPnew.SquareDistance(aPx);
578 aDT2=100.*(aTolVnew+aTolVx)*(aTolVnew+aTolVx);
592 BOPDS_InterfEE& aEE=aEEs.Append1();
594 aEE.SetIndices(nE1, nE2);
595 aEE.SetCommonPart(aCPart);
597 myDS->AddInterf(nE1, nE2);
599 BOPDS_CoupleOfPaveBlocks aCPB;
601 aCPB.SetPaveBlocks(aPB1, aPB2);
602 aCPB.SetIndexInterf(iX);
603 aCPB.SetTolerance(aTolVnew);
604 aMVCPB.Add(aVnew, aCPB);
605 }//case TopAbs_VERTEX:
613 Standard_Boolean bHasSameBounds;
614 bHasSameBounds=aPB1->HasSameBounds(aPB2);
615 if (!bHasSameBounds) {
619 BOPDS_InterfEE& aEE=aEEs.Append1();
621 aEE.SetIndices(nE1, nE2);
622 aEE.SetCommonPart(aCPart);
624 myDS->AddInterf(nE1, nE2);
626 BOPAlgo_Tools::FillMap(aPB1, aPB2, aMPBLPB, aAllocator);
632 }//for (i=1; i<=aNbCPrts; i++) {
633 }//for (k=0; k < aNbFdgeEdge; ++k) {
635 //=========================================
637 //=========================================
639 Standard_Integer aNbV;
640 Handle(BOPDS_PaveBlock) aPB1, aPB2;
642 aNbV=aMVCPB.Extent();
643 for (i=1; i<=aNbV; ++i) {
644 const BOPDS_CoupleOfPaveBlocks& aCPB=aMVCPB.FindFromIndex(i);
645 aCPB.PaveBlocks(aPB1, aPB2);
647 aMPBToUpdate.Remove(aPB1);
648 aMPBToUpdate.Remove(aPB2);
652 aItPB.Initialize(aMPBToUpdate);
653 for (; aItPB.More(); aItPB.Next()) {
654 Handle(BOPDS_PaveBlock) aPB=aItPB.Value();
655 if (!myDS->IsCommonBlock(aPB)) {
656 myDS->UpdatePaveBlock(aPB);
659 const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
660 myDS->UpdateCommonBlock(aCB, myFuzzyValue);
664 BOPAlgo_Tools::PerformCommonBlocks(aMPBLPB, aAllocator, myDS);
665 PerformVerticesEE(aMVCPB, aAllocator);
666 //-----------------------------------------------------scope t
669 aMPBToUpdate.Clear();
671 //=======================================================================
672 //function : PerformVerticesEE
674 //=======================================================================
675 Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE
676 (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
677 const Handle(NCollection_BaseAllocator)& theAllocator)
679 Standard_Integer aNbV, iRet;
682 aNbV=theMVCPB.Extent();
687 Standard_Integer nVx, iV, j, nE, iFlag, iX, i, aNb;
689 BOPCol_ListIteratorOfListOfShape aItLS;
690 BOPCol_ListIteratorOfListOfInteger aItLI;
691 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
695 BOPDS_IndexedDataMapOfPaveBlockListOfInteger aMPBLI(100, theAllocator);
696 BOPCol_ListOfShape aLS(theAllocator);
697 BOPCol_IndexedDataMapOfShapeInteger aMVI(100, theAllocator);
698 BOPCol_IndexedDataMapOfShapeListOfShape aImages;
700 aSI.SetShapeType(TopAbs_VERTEX);
701 BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
703 // 1 prepare arguments
705 TreatNewVertices(theMVCPB, aImages);
707 // 3 Add new vertices to myDS;
708 // connect indices to CPB structure
709 aNb = aImages.Extent();
710 for (i=1; i<=aNb; ++i) {
711 const TopoDS_Vertex& aV=(*(TopoDS_Vertex*)(&aImages.FindKey(i)));
712 const BOPCol_ListOfShape& aLVSD=aImages.FindFromIndex(i);
715 iV=myDS->Append(aSI);
717 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(iV);
718 Bnd_Box& aBox=aSIDS.ChangeBox();
719 BRepBndLib::Add(aV, aBox);
720 aBox.SetGap(aBox.GetGap() + Precision::Confusion());
722 aItLS.Initialize(aLVSD);
723 for (; aItLS.More(); aItLS.Next()) {
724 const TopoDS_Shape& aVx = aItLS.Value();
725 BOPDS_CoupleOfPaveBlocks &aCPB=theMVCPB.ChangeFromKey(aVx);
727 // update EE interference
728 iX=aCPB.IndexInterf();
729 BOPDS_InterfEE& aEE=aEEs(iX);
734 // 4 Map PaveBlock/ListOfVertices to add to this PaveBlock ->aMPBLI
736 Handle(BOPDS_PaveBlock) aPB[2];
738 for (i=1; i<=aNbV; ++i) {
739 const BOPDS_CoupleOfPaveBlocks& aCPB=theMVCPB.FindFromIndex(i);
741 aCPB.PaveBlocks(aPB[0], aPB[1]);
742 for (j=0; j<2; ++j) {
743 if (aMPBLI.Contains(aPB[j])) {
744 BOPCol_ListOfInteger& aLI=aMPBLI.ChangeFromKey(aPB[j]);
748 BOPCol_ListOfInteger aLI(theAllocator);
750 aMPBLI.Add(aPB[j], aLI);
756 // 5.1 Compute Extra Paves and
757 // 5.2. Add Extra Paves to the PaveBlocks
758 //-------------------------------------------------------------
759 Standard_Integer k, aNbVPVE;
760 BOPAlgo_VectorOfPVE aVPVE;
763 for(i=1; i<=aNb; ++i) {
764 Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
765 nE=aPB->OriginalEdge();
766 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
768 const BOPCol_ListOfInteger& aLI=aMPBLI.FindFromIndex(i);
769 aItLI.Initialize(aLI);
770 for (; aItLI.More(); aItLI.Next()) {
772 const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
774 BOPAlgo_PVE& aPVE=aVPVE.Append1();
775 aPVE.SetIndices(nVx, nE);
778 aPVE.SetFuzzyValue(myFuzzyValue);
779 aPVE.SetPaveBlock(aPB);
783 aNbVPVE=aVPVE.Extent();
784 //=============================================================
785 BOPAlgo_PVECnt::Perform(myRunParallel, aVPVE, myContext);
786 //=============================================================
788 for (k=0; k < aNbVPVE; ++k) {
789 BOPAlgo_PVE& aPVE=aVPVE(k);
792 aPVE.Indices(nVx, nE);
794 Handle(BOPDS_PaveBlock)& aPB=aPVE.PaveBlock();
797 aPave.SetParameter(aT);
798 aPB->AppendExtPave(aPave);
801 // 6 Split PaveBlocksa
803 for(i=1; i<=aNb; ++i) {
804 Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
805 nE=aPB->OriginalEdge();
807 if (!myDS->IsCommonBlock(aPB)) {
808 myDS->UpdatePaveBlock(aPB);
811 const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
812 myDS->UpdateCommonBlock(aCB, myFuzzyValue);
814 }//for (; aItMPBLI.More(); aItMPBLI.Next()) {
818 //=======================================================================
819 //function : TreatNewVertices
821 //=======================================================================
822 void BOPAlgo_PaveFiller::TreatNewVertices
823 (const BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
824 BOPCol_IndexedDataMapOfShapeListOfShape& myImages)
826 Standard_Integer i, aNbV;//, aNbVSD;
829 BOPCol_IndexedMapOfShape aMVProcessed;
830 BOPCol_MapOfInteger aMFence;
831 BOPCol_ListIteratorOfListOfInteger aIt;
832 NCollection_Vector<BOPCol_ListOfShape> aVecOfLVSD;
834 BOPCol_BoxBndTree aBBTree;
835 NCollection_UBTreeFiller <Standard_Integer,
836 Bnd_Box> aTreeFiller(aBBTree);
837 BOPAlgo_VectorOfTNV aVTNV;
839 Standard_Real aTolAdd = myFuzzyValue / 2.;
840 aNbV = theMVCPB.Extent();
841 for (i=1; i<=aNbV; ++i) {
842 const TopoDS_Vertex& aV = *((TopoDS_Vertex*)&theMVCPB.FindKey(i));
845 aTol = theMVCPB.FindFromIndex(i).Tolerance();
846 aBox.Add(BRep_Tool::Pnt(aV));
847 aBox.SetGap(aTol + aTolAdd);
849 aTreeFiller.Add(i, aBox);
851 BOPAlgo_TNV& aTNV=aVTNV.Append1();
852 aTNV.SetTree(aBBTree);
855 aTNV.SetTolerance(aTol);
856 aTNV.SetFuzzyValue(myFuzzyValue);
857 aTNV.SetVectorOfTNV(aVTNV);
862 //===========================================
863 BOPAlgo_TNVCnt::Perform(myRunParallel, aVTNV);
864 //===========================================
867 for (i=1; i<=aNbV; ++i) {
868 if (!aMFence.Add(i)) {
872 Standard_Integer aIP, aNbIP1, aIP1;
873 BOPCol_ListOfShape aLVSD;
874 BOPCol_ListOfInteger aLIP, aLIP1, aLIPC;
875 BOPCol_ListIteratorOfListOfInteger aItLIP;
880 aItLIP.Initialize(aLIP);
881 for(; aItLIP.More(); aItLIP.Next()) {
884 BOPAlgo_TNV& aTNV=aVTNV(aIP-1);
885 const BOPCol_ListOfInteger& aLI=aTNV.Indices();
887 for (; aIt.More(); aIt.Next()) {
889 if (!aMFence.Add(aIP1)) {
893 } //for (; aIt.More(); aIt.Next()) {
894 }//for(; aIt1.More(); aIt1.Next()) {
896 aNbIP1=aLIP1.Extent();
898 break; // from for(;;)
902 aLIPC.Append(aLIP1); // items of aLIP1 are moved to aLIPC
905 aItLIP.Initialize(aLIPC);
906 for(; aItLIP.More(); aItLIP.Next()) {
908 const TopoDS_Vertex& aVP=aVTNV(aIP-1).Vertex();
911 aVecOfLVSD.Append(aLVSD);
912 }// for (i=1; i<=aNbV; ++i) {
915 aNbV = aVecOfLVSD.Size();
916 for (i = 0; i < aNbV; ++i) {
917 const BOPCol_ListOfShape& aLVSD = aVecOfLVSD(i);
918 BOPTools_AlgoTools::MakeVertex(aLVSD, aVnew);
919 myImages.Add(aVnew, aLVSD);
922 //=======================================================================
923 //function : FillShrunkData
925 //=======================================================================
926 void BOPAlgo_PaveFiller::FillShrunkData(Handle(BOPDS_PaveBlock)& thePB)
928 Standard_Integer nE, nV1, nV2;
929 Standard_Real aT1, aT2, aTS1, aTS2;
930 IntTools_ShrunkRange aSR;
935 const BOPDS_Pave& aPave1=thePB->Pave1();
937 aT1=aPave1.Parameter();
938 const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
940 const BOPDS_Pave& aPave2=thePB->Pave2();
942 aT2=aPave2.Parameter();
943 const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
945 nE=thePB->OriginalEdge();
946 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
948 aSR.SetContext(myContext);
949 aSR.SetData(aE, aT1, aT2, aV1, aV2);
957 aSR.ShrunkRange(aTS1, aTS2);
958 const Bnd_Box& aBox=aSR.BndBox();
959 Standard_Boolean bIsSplittable = aSR.IsSplittable();
961 thePB->SetShrunkData(aTS1, aTS2, aBox, bIsSplittable);
963 //=======================================================================
964 //function : ForceInterfVE
966 //=======================================================================
967 void BOPAlgo_PaveFiller::ForceInterfVE(const Standard_Integer nV,
968 Handle(BOPDS_PaveBlock)& aPB,
969 BOPDS_MapOfPaveBlock& aMPBToUpdate)
971 Standard_Integer nE, nVx, nVSD, iFlag;
972 Standard_Real aT, aTolVNew;
974 nE = aPB->OriginalEdge();
976 const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
977 if (aSIE.HasSubShape(nV)) {
981 if (myDS->HasInterf(nV, nE)) {
985 if (myDS->HasInterfShapeSubShapes(nV, nE)) {
989 if (aPB->Pave1().Index() == nV ||
990 aPB->Pave2().Index() == nV) {
995 if (myDS->HasShapeSD(nV, nVSD)) {
999 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nVx);
1000 const TopoDS_Edge& aE = *(TopoDS_Edge*) &myDS->Shape(nE);
1002 iFlag = myContext->ComputeVE(aV, aE, aT, aTolVNew, myFuzzyValue);
1003 if (iFlag == 0 || iFlag == -4) {
1007 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
1008 aVEs.SetIncrement(10);
1010 BOPDS_InterfVE& aVE=aVEs.Append1();
1011 aVE.SetIndices(nV, nE);
1012 aVE.SetParameter(aT);
1014 myDS->AddInterf(nV, nE);
1016 // 3 update vertex V/E if necessary
1017 nVx=UpdateVertex(nV, aTolVNew);
1019 if (myDS->IsNewShape(nVx)) {
1020 aVE.SetIndexNew(nVx);
1022 // 5 append ext pave to pave block
1023 aPave.SetIndex(nVx);
1024 aPave.SetParameter(aT);
1025 aPB->AppendExtPave(aPave);
1027 aMPBToUpdate.Add(aPB);
1031 //=======================================================================
1032 //function : GetPBBox
1034 //=======================================================================
1035 Standard_Boolean BOPAlgo_PaveFiller::GetPBBox(const TopoDS_Edge& theE,
1036 const Handle(BOPDS_PaveBlock)& thePB,
1037 BOPAlgo_DataMapOfPaveBlockBndBox& thePBBox,
1038 Standard_Real& theFirst,
1039 Standard_Real& theLast,
1040 Standard_Real& theSFirst,
1041 Standard_Real& theSLast,
1044 thePB->Range(theFirst, theLast);
1045 // check the validity of PB's range
1046 Standard_Boolean bValid = theLast - theFirst > Precision::PConfusion();
1051 // check shrunk data
1052 if (thePB->HasShrunkData()) {
1053 Standard_Boolean bIsSplittable;
1054 thePB->ShrunkData(theSFirst, theSLast, theBox, bIsSplittable);
1058 theSFirst = theFirst;
1061 if (thePBBox.IsBound(thePB)) {
1062 theBox = thePBBox.Find(thePB);
1065 // build bounding box
1066 BRepAdaptor_Curve aBAC(theE);
1067 Standard_Real aTol = BRep_Tool::Tolerance(theE) + Precision::Confusion();
1068 BndLib_Add3dCurve::Add(aBAC, theSFirst, theSLast, aTol, theBox);
1069 thePBBox.Bind(thePB, theBox);