1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: NMTTools_PaveFiller_4.cxx
23 // Created: Mon Dec 8 17:08:58 2003
24 // Author: Peter KURNEV
26 #include <NMTTools_PaveFiller.ixx>
28 #include <Basics_OCCTVersion.hxx>
31 #include <Precision.hxx>
35 #include <Bnd_Box.hxx>
37 #include <GeomAPI_ProjectPointOnCurve.hxx>
39 #include <TColStd_MapOfInteger.hxx>
40 #include <TColStd_IndexedMapOfInteger.hxx>
41 #include <TColStd_ListIteratorOfListOfInteger.hxx>
42 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
45 #include <TopoDS_Edge.hxx>
46 #include <TopoDS_Vertex.hxx>
47 #include <TopoDS_Compound.hxx>
49 #include <TopTools_IndexedMapOfShape.hxx>
50 #include <TopTools_ListIteratorOfListOfShape.hxx>
51 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
52 #include <TopTools_DataMapOfShapeListOfShape.hxx>
53 #include <TopTools_ListOfShape.hxx>
54 #include <TopTools_DataMapOfShapeShape.hxx>
56 #include <BRep_Tool.hxx>
57 #include <BRep_Builder.hxx>
58 #include <BRepBndLib.hxx>
60 #include <BOPTColStd_Dump.hxx>
61 #include <BOPTColStd_Failure.hxx>
63 #include <IntTools_ShrunkRange.hxx>
64 #include <IntTools_Range.hxx>
65 #include <IntTools_CommonPrt.hxx>
66 #include <IntTools_SequenceOfRanges.hxx>
67 #include <IntTools_EdgeEdge.hxx>
68 #include <IntTools_SequenceOfCommonPrts.hxx>
69 #include <IntTools_Tools.hxx>
71 #include <BOPTools_Pave.hxx>
72 #include <BOPTools_PaveSet.hxx>
73 #include <BOPTools_PaveBlockIterator.hxx>
74 #include <BOPTools_PaveBlock.hxx>
75 #include <BOPTools_CArray1OfEEInterference.hxx>
76 #include <BOPTools_EEInterference.hxx>
77 #include <BOPTools_ListOfPaveBlock.hxx>
78 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
79 #include <BOPTools_CArray1OfVVInterference.hxx>
80 #include <BOPTools_VVInterference.hxx>
81 #include <BOPTools_CArray1OfEEInterference.hxx>
82 #include <BOPTools_Tools.hxx>
83 #include <BOPTools_IDMapOfPaveBlockIMapOfPaveBlock.hxx>
84 #include <BOPTools_IMapOfPaveBlock.hxx>
85 #include <BOPTools_ListIteratorOfListOfPave.hxx>
86 #include <BOPTools_SequenceOfPaveBlock.hxx>
88 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
89 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
90 #include <BooleanOperations_KindOfInterference.hxx>
92 #include <NMTDS_Iterator.hxx>
93 #include <NMTDS_ShapesDataStructure.hxx>
94 #include <NMTDS_IndexedDataMapOfIntegerShape.hxx>
95 #include <NMTDS_IndexedDataMapOfShapeBox.hxx>
96 #include <NMTDS_BoxBndTree.hxx>
97 #include <NCollection_UBTreeFiller.hxx>
98 #include <NMTDS_InterfPool.hxx>
100 #include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
101 #include <NMTTools_ListOfCommonBlock.hxx>
102 #include <NMTTools_CommonBlock.hxx>
103 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
105 #include <TColStd_ListOfInteger.hxx>
106 #include <TColStd_ListIteratorOfListOfInteger.hxx>
107 #include <BRepBndLib.hxx>
108 #include <BOPTools_CArray1OfVSInterference.hxx>
109 #include <BOPTools_VSInterference.hxx>
110 #include <TColStd_MapOfInteger.hxx>
111 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
114 void TreatNewVertices(const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI,
115 TopTools_DataMapOfShapeListOfShape& myImages,
116 TopTools_DataMapOfShapeShape& myOrigins);
119 void MakeNewVertex(const TopTools_ListOfShape& aLV,
120 TopoDS_Vertex& aNewVertex);
123 void VertexParameters(const IntTools_CommonPrt& aCPart,
128 Standard_Boolean IsOnPave(const Standard_Real& aT1,
129 const IntTools_Range& aRange,
130 const Standard_Real& aTolerance);
133 // void EECommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB);
136 void ProcessBlock(const BOPTools_PaveBlock& aPB,
137 const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB,
138 BOPTools_IMapOfPaveBlock& aProcessedBlocks,
139 BOPTools_IMapOfPaveBlock& aChain);
142 void FindChains(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB,
143 NMTTools_ListOfCommonBlock& aLCB);
145 //=======================================================================
146 // function: PerformEE
148 //=======================================================================
149 void NMTTools_PaveFiller::PerformEE()
151 myIsDone=Standard_False;
153 Standard_Boolean bJustAdd;
154 Standard_Integer n1, n2, anIndexIn, nE1, nE2, aNbVEs, aBlockLength;
155 Standard_Integer aTmp, aWhat, aWith, i, aNbCPrts, aDiscretize=30;
156 Standard_Integer aNbLPB1, aNbLPB2;
157 Standard_Real aTolE1, aTolE2, aDeflection=0.01;
158 BOPTools_ListIteratorOfListOfPaveBlock anIt1, anIt2;
159 TopoDS_Edge aEWhat, aEWith;
160 TopoDS_Vertex aNewVertex;
161 BooleanOperations_IndexedDataMapOfShapeInteger aMapVI;
162 BOPTools_IDMapOfPaveBlockIMapOfPaveBlock aMapCB;
164 BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences();
166 myDSIt->Initialize(TopAbs_EDGE, TopAbs_EDGE);
168 // BlockLength correction
169 aNbVEs=myDSIt->BlockLength();
170 aBlockLength=aEEs.BlockLength();
171 if (aNbVEs > aBlockLength) {
172 aEEs.SetBlockLength(aNbVEs);
175 for (; myDSIt->More(); myDSIt->Next()) {
176 myDSIt->Current(n1, n2, bJustAdd);
185 const TopoDS_Edge aE1=TopoDS::Edge(myDS->Shape(nE1));//mpv
186 const TopoDS_Edge aE2=TopoDS::Edge(myDS->Shape(nE2));//mpv
188 if (BRep_Tool::Degenerated(aE1) || BRep_Tool::Degenerated(aE2)){
192 aTolE1=BRep_Tool::Tolerance(aE1);
193 aTolE2=BRep_Tool::Tolerance(aE2);
195 BOPTools_ListOfPaveBlock& aLPB1=mySplitShapesPool(myDS->RefEdge(nE1));
196 BOPTools_ListOfPaveBlock& aLPB2=mySplitShapesPool(myDS->RefEdge(nE2));
198 // Modified Thu Sep 14 14:35:18 2006
199 // Contribution of Samtech www.samcef.com BEGIN
200 aNbLPB1=aLPB1.Extent();
201 aNbLPB2=aLPB2.Extent();
203 //if (aE1.IsSame(aE2) && aNbLPB1==1 && aNbLPB2==1) {
206 // Contribution of Samtech www.samcef.com END
208 for (anIt1.Initialize(aLPB1); anIt1.More(); anIt1.Next()) {
209 BOPTools_PaveBlock& aPB1=anIt1.Value();
210 const IntTools_ShrunkRange& aShrunkRange1=aPB1.ShrunkRange();
212 const IntTools_Range& aSR1=aShrunkRange1.ShrunkRange();
213 const Bnd_Box& aBB1=aShrunkRange1.BndBox();
215 for (anIt2.Initialize(aLPB2); anIt2.More(); anIt2.Next()) {
216 BOPTools_PaveBlock& aPB2=anIt2.Value();
217 const IntTools_ShrunkRange& aShrunkRange2=aPB2.ShrunkRange();
219 const IntTools_Range& aSR2=aShrunkRange2.ShrunkRange();
220 const Bnd_Box& aBB2=aShrunkRange2.BndBox();
222 if (aBB1.IsOut (aBB2)) {
227 IntTools_EdgeEdge aEE;
230 aEE.SetTolerance1 (aTolE1);
231 aEE.SetTolerance2 (aTolE2);
232 aEE.SetDiscretize (aDiscretize);
233 aEE.SetDeflection (aDeflection);
235 IntTools_Range anewSR1 = aSR1;
236 IntTools_Range anewSR2 = aSR2;
238 BOPTools_Tools::CorrectRange (aE1, aE2, aSR1, anewSR1);
239 BOPTools_Tools::CorrectRange (aE2, aE1, aSR2, anewSR2);
241 aEE.SetRange1(anewSR1);
242 aEE.SetRange2(anewSR2);
249 // reverse order if it is necessary
262 const IntTools_SequenceOfCommonPrts& aCPrts=aEE.CommonParts();
263 aNbCPrts=aCPrts.Length();
264 for (i=1; i<=aNbCPrts; i++) {
265 const IntTools_CommonPrt& aCPart=aCPrts(i);
266 const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2();
270 TopAbs_ShapeEnum aType=aCPart.Type();
272 case TopAbs_VERTEX: {
273 Standard_Real aT1, aT2, aTol=Precision::PConfusion();
274 Standard_Boolean bIsOnPave1, bIsOnPave2;
275 IntTools_Range aR1, aR2;
277 VertexParameters(aCPart, aT1, aT2);
279 //decide to keep the pave or not
280 aR1 = (aEE.Order()) ? anewSR2 : anewSR1;
281 aR2 = (aEE.Order()) ? anewSR1 : anewSR2;
284 bIsOnPave1=IsOnPave(aT1, aR1, aTol);
285 bIsOnPave2=IsOnPave(aT2, aR2, aTol);
287 if(bIsOnPave1 || bIsOnPave2) {
291 BOPTools_Tools::MakeNewVertex(aEWhat, aT1, aEWith, aT2, aNewVertex);
294 Standard_Integer nV11, nV12, nV21, nV22, nVS[2], k, j, iFound;
295 Standard_Real aTolVx, aTolVnew, aD2, aDT2;
296 TColStd_MapOfInteger aMV;
301 nV11=aPB1.Pave1().Index();
302 nV12=aPB1.Pave2().Index();
303 nV21=aPB2.Pave1().Index();
304 nV22=aPB2.Pave2().Index();
308 if (aMV.Contains(nV21)) {
312 if (aMV.Contains(nV22)) {
317 aTolVnew=BRep_Tool::Tolerance(aNewVertex);
318 aPnew=BRep_Tool::Pnt(aNewVertex);
320 for (k=0; k<=j; ++k) {
321 const TopoDS_Vertex& aVx=TopoDS::Vertex(myDS->Shape(nVS[k]));
322 aTolVx=BRep_Tool::Tolerance(aVx);
323 aPx=BRep_Tool::Pnt(aVx);
324 aD2=aPnew.SquareDistance(aPx);
326 aDT2=100.*(aTolVnew+aTolVx)*(aTolVnew+aTolVx);
339 // Add Interference to the Pool
340 BOPTools_EEInterference anInterf (aWhat, aWith, aCPart);
342 anIndexIn=aEEs.Append(anInterf);
345 myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_EE);
350 aMapVI.Add(aNewVertex, anIndexIn);
355 Standard_Integer aNbComPrt2;
356 Standard_Boolean aCoinsideFlag;
358 aNbComPrt2=aRanges2.Length();
359 aCoinsideFlag=IsBlocksCoinside(aPB1, aPB2);
361 if (aNbComPrt2>1 || !aCoinsideFlag) {
366 if (aMapCB.Contains(aPB1)) {
367 BOPTools_IMapOfPaveBlock& aMapPB=aMapCB.ChangeFromKey(aPB1);
372 BOPTools_IMapOfPaveBlock aMapPB;
375 aMapCB.Add(aPB1, aMapPB);
378 if (aMapCB.Contains(aPB2)) {
379 BOPTools_IMapOfPaveBlock& aMapPB=aMapCB.ChangeFromKey(aPB2);
384 BOPTools_IMapOfPaveBlock aMapPB;
387 aMapCB.Add(aPB2, aMapPB);
391 myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_EE);
399 } // for (i=1; i<=aNbCPrts; i++)
400 }// if (aEE.IsDone())
401 } // for (; anIt2.More(); anIt2.Next())
402 } // for (; anIt1.More(); anIt1.Next())
403 }// for (; myDSIt.More(); myDSIt.Next())
406 NMTTools_ListOfCommonBlock aLCB;
408 FindChains(aMapCB, aLCB);
409 EENewVertices (aMapVI);
410 //TreatPaveBlocks(*this, aLCB);
411 TreatPaveBlocks(aLCB);
412 ReplaceCommonBlocks(aLCB);
417 myIsDone=Standard_True;
420 //=======================================================================
421 // function:TreatPaveBlocks
423 //=======================================================================
424 void NMTTools_PaveFiller::TreatPaveBlocks (NMTTools_ListOfCommonBlock& theLCB)
426 Standard_Boolean bFound;
427 Standard_Integer nE, nV, nVp, iFlag;
429 TColStd_MapOfInteger aMI;
430 TColStd_MapIteratorOfMapOfInteger aItMI;
431 NMTTools_ListIteratorOfListOfCommonBlock aItLCB;
432 BOPTools_ListIteratorOfListOfPaveBlock aItLPB;
433 BOPTools_ListIteratorOfListOfPave aItLP;
435 aItLCB.Initialize(theLCB);
436 for (; aItLCB.More(); aItLCB.Next()) {
437 const NMTTools_CommonBlock& aCB=aItLCB.Value();
440 const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
443 aItLPB.Initialize(aLPB);
444 for (; aItLPB.More(); aItLPB.Next()) {
445 const BOPTools_PaveBlock& aPB=aItLPB.Value();
446 nE=aPB.OriginalEdge();
447 BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
448 BOPTools_ListOfPave& aLP=aPaveSet.ChangeSet();
450 aItLP.Initialize(aLP);
451 for (; aItLP.More(); aItLP.Next()) {
452 const BOPTools_Pave& aPave=aItLP.Value();
456 }//for (; anItLPB.More(); anItLPB.Next()) {
459 aItLPB.Initialize(aLPB);
460 for (; aItLPB.More(); aItLPB.Next()) {
461 const BOPTools_PaveBlock& aPB=aItLPB.Value();
462 nE=aPB.OriginalEdge();
463 BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
464 BOPTools_ListOfPave& aLP=aPaveSet.ChangeSet();
466 aItMI.Initialize(aMI);
467 for (; aItMI.More(); aItMI.Next()) {
469 bFound=Standard_False;
470 aItLP.Initialize(aLP);
471 for (; aItLP.More(); aItLP.Next()) {
472 const BOPTools_Pave& aPave=aItLP.Value();
481 // Append Pave of nV to rhe edge nE
482 const TopoDS_Edge& aE=*(TopoDS_Edge*)(&myDS->Shape(nE));
483 const TopoDS_Vertex& aV= *(TopoDS_Vertex*)(&myDS->Shape(nV));
484 #if OCC_VERSION_LARGE > 0x06050200
485 iFlag=myContext->ComputeVE (aV, aE, aT);
487 iFlag=myContext.ComputeVE (aV, aE, aT);
492 aPave.SetInterference(-1);
493 aPave.SetType (BooleanOperations_EdgeEdge);
496 aPaveSet.Append(aPave);
499 }//for (; aItMI.More(); aItMI.Next()) {
500 }//for (; anItLPB.More(); anItLPB.Next()) {
504 //=======================================================================
505 // function:EECommonBlocks
507 //=======================================================================
508 void NMTTools_PaveFiller::EECommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB)
510 NMTTools_ListOfCommonBlock aLCB;
512 FindChains(aMapCB, aLCB);
513 ReplaceCommonBlocks(aLCB);
516 //=======================================================================
517 // function:EENewVertices
519 //=======================================================================
520 void NMTTools_PaveFiller::EENewVertices (const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI)
522 Standard_Integer aNb, aNbVSD, nVnew, nIEE, nE[2], j, iFlag;
525 TopTools_DataMapOfShapeListOfShape myImages;
526 TopTools_DataMapOfShapeShape myOrigins;
527 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
528 TopTools_ListIteratorOfListOfShape aIt;
529 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
530 TColStd_MapOfInteger aMFence;
533 BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences();
536 if (!aNb) { // no new vertices, no new problems
542 TopoDS_Vertex aV1=TopoDS::Vertex(aMapVI.FindKey(1));
543 EENewVertices(aV1, aMapVI);
548 TreatNewVertices(aMapVI, myImages, myOrigins);
550 aItIm.Initialize(myImages);
551 for (; aItIm.More(); aItIm.Next()) {
552 const TopoDS_Vertex& aVnew=TopoDS::Vertex(aItIm.Key());
553 const TopTools_ListOfShape& aLVSD=aItIm.Value();
555 aNbVSD=aLVSD.Extent();
556 if (aNbVSD==1) {// simple case aVnew=aVold
557 EENewVertices(aVnew, aMapVI);
562 myDS->InsertShapeAndAncestorsSuccessors(aVnew, anASSeq);
563 nVnew=myDS->NumberOfInsertedShapes();
564 myDS->SetState(nVnew, BooleanOperations_ON);
567 aIt.Initialize(aLVSD);
568 for (; aIt.More(); aIt.Next()) {
569 const TopoDS_Vertex& aVold=TopoDS::Vertex(aIt.Value());
570 nIEE=aMapVI.FindFromKey(aVold);
571 BOPTools_EEInterference& aEE=aEEs(nIEE);
572 aEE.Indices(nE[0], nE[1]);
573 aEE.SetNewShape(nVnew);
575 for (j=0; j<2; ++j) {
576 if (aMFence.Add(nE[j])) {
577 aE=TopoDS::Edge(myDS->Shape(nE[j]));
578 #if OCC_VERSION_LARGE > 0x06050200
579 iFlag=myContext->ComputeVE (aVnew, aE, aT);
581 iFlag=myContext.ComputeVE (aVnew, aE, aT);
584 aPave.SetInterference(-1);
585 aPave.SetType (BooleanOperations_EdgeEdge);
586 aPave.SetIndex(nVnew);
589 BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE[j]));
590 aPaveSet.Append(aPave);
592 }// if (aMFence.Add(nE[j])) {
593 }// for (j=0; j<2; ++j) {
594 }//for (; aIt.More(); aIt.Next()) {
595 }// for (; aItIm.More(); aItIm.Next())
599 // completely rewritten
600 //=======================================================================
601 //function : TreatNewVertices
603 //=======================================================================
604 void TreatNewVertices(const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI,
605 TopTools_DataMapOfShapeListOfShape& myImages,
606 TopTools_DataMapOfShapeShape& myOrigins)
608 Standard_Integer j, i, aNbV, aNbVSD;
610 TColStd_ListIteratorOfListOfInteger aIt;
611 TopoDS_Shape aSTmp, aVF;
613 TopTools_IndexedMapOfShape aMV, aMVProcessed;
614 TopTools_ListIteratorOfListOfShape aItS;
615 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
616 TopTools_DataMapOfShapeListOfShape aMVV;
617 NMTDS_IndexedDataMapOfIntegerShape aMIS;
618 NMTDS_IndexedDataMapOfShapeBox aMSB;
620 NMTDS_BoxBndTreeSelector aSelector;
621 NMTDS_BoxBndTree aBBTree;
622 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
627 aNbV=aMapVI.Extent();
628 for (i=1; i<=aNbV; ++i) {
629 const TopoDS_Shape& aV=aMapVI.FindKey(i);
633 for (i=1; i<=aNbV; ++i) {
634 const TopoDS_Shape& aV=aMV(i);
637 aTol=BRep_Tool::Tolerance(TopoDS::Vertex(aV));
639 BRepBndLib::Add(aV, aBox);
641 aTreeFiller.Add(i, aBox);
650 for (i=1; i<=aNbV; ++i) {
651 const TopoDS_Shape& aV=aMV(i);
653 if (aMVProcessed.Contains(aV)) {
657 Standard_Integer aNbIP, aIP, aNbIP1, aIP1;
658 TopTools_ListOfShape aLVSD;
659 TColStd_MapOfInteger aMIP, aMIP1, aMIPC;
660 TColStd_MapIteratorOfMapOfInteger aIt1;
665 aIt1.Initialize(aMIP);
666 for(; aIt1.More(); aIt1.Next()) {
668 if (aMIPC.Contains(aIP)) {
672 const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
673 const Bnd_Box& aBoxVP=aMSB.FindFromKey(aVP);
676 aSelector.SetBox(aBoxVP);
678 aNbVSD=aBBTree.Select(aSelector);
680 continue; // it must not be
683 const TColStd_ListOfInteger& aLI=aSelector.Indices();
685 for (; aIt.More(); aIt.Next()) {
687 if (aMIP.Contains(aIP1)) {
691 } //for (; aIt.More(); aIt.Next()) {
692 }//for(; aIt1.More(); aIt1.Next()) {
694 aNbIP1=aMIP1.Extent();
696 break; // from while(1)
699 aIt1.Initialize(aMIP);
700 for(; aIt1.More(); aIt1.Next()) {
706 aIt1.Initialize(aMIP1);
707 for(; aIt1.More(); aIt1.Next()) {
714 aNbIP=aMIPC.Extent();
719 aIt1.Initialize(aMIPC);
720 for(j=0; aIt1.More(); aIt1.Next(), ++j) {
722 const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
727 aMVProcessed.Add(aVP);
729 myImages.Bind(aVF, aLVSD);
730 }// for (i=1; i<=aNbV; ++i) {
731 //------------------------------
735 aItIm.Initialize(myImages);
736 for (; aItIm.More(); aItIm.Next()) {
737 const TopoDS_Shape& aV=aItIm.Key();
738 const TopTools_ListOfShape& aLVSD=aItIm.Value();
739 aNbVSD=aLVSD.Extent();
742 MakeNewVertex(aLVSD, aVnew);
743 aMVV.Bind(aVnew, aLVSD);
747 // UnBind old vertices
749 for (i=1; i<=aNbV; ++i) {
750 const TopoDS_Shape& aV=aMV(i);
755 aItIm.Initialize(aMVV);
756 for (; aItIm.More(); aItIm.Next()) {
757 const TopoDS_Shape& aV=aItIm.Key();
758 const TopTools_ListOfShape& aLVSD=aItIm.Value();
759 myImages.Bind(aV, aLVSD);
763 aItIm.Initialize(myImages);
764 for (; aItIm.More(); aItIm.Next()) {
765 const TopoDS_Shape& aV=aItIm.Key();
766 const TopTools_ListOfShape& aLVSD=aItIm.Value();
768 aItS.Initialize(aLVSD);
769 for (; aItS.More(); aItS.Next()) {
770 const TopoDS_Shape& aVSD=aItS.Value();
771 if (!myOrigins.IsBound(aVSD)) {
772 myOrigins.Bind(aVSD, aV);
778 //=======================================================================
779 //function : MakeNewVertex
781 //=======================================================================
782 void MakeNewVertex(const TopTools_ListOfShape& aLV,
783 TopoDS_Vertex& aNewVertex)
785 Standard_Integer aNbV;
786 Standard_Real aTolV, aD, aDmax;
791 TopTools_ListIteratorOfListOfShape aIt;
799 aGC.SetCoord(0.,0.,0.);
801 for (; aIt.More(); aIt.Next()) {
802 aVx=TopoDS::Vertex(aIt.Value());
803 aP3D=BRep_Tool::Pnt(aVx);
806 aGC/=(Standard_Real)aNbV;
812 for (; aIt.More(); aIt.Next()) {
813 aVx=TopoDS::Vertex(aIt.Value());
814 aP3D=BRep_Tool::Pnt(aVx);
815 aTolV=BRep_Tool::Tolerance(aVx);
816 aD=aPGC.Distance(aP3D)+aTolV;
822 aBB.MakeVertex (aNewVertex, aPGC, aDmax);
825 //=======================================================================
826 // function:EENewVertices
828 //=======================================================================
829 void NMTTools_PaveFiller::EENewVertices (const TopoDS_Vertex& aNewVertex,
830 const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI)
832 Standard_Integer i, aNewShape, nE1, nE2;
833 Standard_Real aT1, aT2;
834 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
837 BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences();
839 // one new vertex case is treated in usual way
841 // Insert New Vertex in DS;
842 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
843 aNewShape=myDS->NumberOfInsertedShapes();
844 myDS->SetState (aNewShape, BooleanOperations_ON);
845 // Insert New Vertex in EE Interference
846 i=aMapVI.FindFromKey(aNewVertex);
847 BOPTools_EEInterference& aEEInterf= aEEs(i);
848 aEEInterf.SetNewShape(aNewShape);
849 // Extact interference info
850 aEEInterf.Indices(nE1, nE2);
851 const IntTools_CommonPrt& aCPart=aEEInterf.CommonPrt();
852 VertexParameters(aCPart, aT1, aT2);
854 // Add Paves to the myPavePoolNew
855 aPave.SetInterference(i);
856 aPave.SetType (BooleanOperations_EdgeEdge);
857 aPave.SetIndex(aNewShape);
860 BOPTools_PaveSet& aPaveSet1=myPavePoolNew(myDS->RefEdge(nE1));
861 aPaveSet1.Append(aPave);
864 BOPTools_PaveSet& aPaveSet2=myPavePoolNew(myDS->RefEdge(nE2));
865 aPaveSet2.Append(aPave);
868 //=======================================================================
869 // function: RefinePavePool
871 //=======================================================================
872 void NMTTools_PaveFiller::RefinePavePool()
874 Standard_Integer i, aNbNew;
876 for (i=1; i<=myNbSources; i++) {
878 if ((myDS->GetShape(i)).ShapeType()==TopAbs_EDGE) {
879 BOPTools_PaveSet& aPS= myPavePool(myDS->RefEdge(i));
881 BOPTools_PaveSet& aNewPS= myPavePoolNew(myDS->RefEdge(i));
882 BOPTools_ListOfPave& aNewLP=aNewPS.ChangeSet();
884 aNbNew=aNewLP.Extent();
886 BOPTools_ListIteratorOfListOfPave anIt(aNewLP);
887 for (; anIt.More(); anIt.Next()) {
888 const BOPTools_Pave& aPave=anIt.Value();
891 // Clear the ListOfPaveBlock
892 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(i));
894 // Prepare the paveBlocks for that egde again
895 PreparePaveBlocks(i);
902 //=======================================================================
903 // function: PreparePaveBlocks
905 //=======================================================================
906 void NMTTools_PaveFiller::PreparePaveBlocks(const TopAbs_ShapeEnum aType1,
907 const TopAbs_ShapeEnum aType2)
909 myIsDone=Standard_False;
911 Standard_Boolean bOk1, bOk2, bOk3, bFlag;
912 Standard_Integer i, aNb, nE[2], n1, n2, aNbSplits;
913 TColStd_MapOfInteger aMap;
915 bOk1= (aType1==TopAbs_VERTEX) && (aType2==TopAbs_EDGE) ;
916 bOk2= (aType1==TopAbs_EDGE) && (aType2==TopAbs_EDGE) ;
917 bOk3= (aType1==TopAbs_EDGE) && (aType2==TopAbs_FACE) ;
918 if (!bOk1 && !bOk2 && !bOk3) {// error: Type mismatch
924 myDSIt->Initialize(aType1, aType2);
925 for (; myDSIt->More(); myDSIt->Next()) {
926 myDSIt->Current(n1, n2, bFlag);
930 if (myDS->GetShapeType(n1)!=TopAbs_EDGE) {
935 for (i=0; i<aNb; ++i) {
936 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE[i]));
937 aNbSplits=aLPB.Extent();
939 if (aMap.Add(nE[i])) {
940 PreparePaveBlocks(nE[i]);
947 }// for (; myDSIt.More(); myDSIt.Next())
948 myIsDone=Standard_True;
951 //=======================================================================
952 // function: PreparePaveBlocks
954 //=======================================================================
955 void NMTTools_PaveFiller::PreparePaveBlocks(const Standard_Integer nE)
957 myIsDone=Standard_False;
960 Standard_Integer nV1, nV2, iErr;
962 TopoDS_Vertex aV1, aV2;
964 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
966 aE=TopoDS::Edge(myDS->Shape(nE));
967 if (BRep_Tool::Degenerated(aE)) {
968 myIsDone=Standard_True;
972 BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE));
974 BOPTools_PaveBlockIterator aPBIt(nE, aPS);
975 for (; aPBIt.More(); aPBIt.Next()) {
976 BOPTools_PaveBlock& aPB=aPBIt.Value();
977 const IntTools_Range& aRange=aPB.Range();
979 const BOPTools_Pave& aPave1=aPB.Pave1();
981 aV1=TopoDS::Vertex(myDS->GetShape(nV1));
983 const BOPTools_Pave& aPave2=aPB.Pave2();
985 aV2=TopoDS::Vertex(myDS->GetShape(nV2));
988 IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext);
989 iErr=aSR.ErrorStatus();
991 sprintf (buf, "Can not obtain ShrunkRange for Edge %d\n", nE);
992 BOPTColStd_Dump::PrintMessage(buf);
993 sprintf (buf, "Can not obtain ShrunkRange for Edge %d", nE);
995 BOPTColStd_Failure(buf) ;
1000 "Warning: [PreparePaveBlocks()] Max.Dummy Shrunk Range for Edge %d\n", nE);
1001 BOPTColStd_Dump::PrintMessage(buf);
1004 // Check left paves and correct ShrunkRange if it is necessary
1005 CorrectShrunkRanges (0, aPave1, aSR);
1006 CorrectShrunkRanges (1, aPave2, aSR);
1009 aPB.SetShrunkRange(aSR);
1011 } //for (; aPBIt.More(); aPBIt.Next())
1012 myIsDone=Standard_True;
1015 //=======================================================================
1016 // function: CorrectShrunkRanges
1018 //=======================================================================
1019 void NMTTools_PaveFiller::CorrectShrunkRanges(const Standard_Integer aSide,
1020 const BOPTools_Pave& aPave,
1021 IntTools_ShrunkRange& aShrunkRange)
1023 BooleanOperations_KindOfInterference aType;
1024 Standard_Integer anIndexInterf ;
1027 if (aType!=BooleanOperations_EdgeEdge) {
1031 anIndexInterf=aPave.Interference();
1032 if (anIndexInterf<0) {
1033 // it can be EE interf between E and (e1,e2,..en) -> vertex
1034 // so we can't decide which aEE.CommonPrt() we should take.
1038 BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences();
1039 const BOPTools_EEInterference& aEE=aEEs(anIndexInterf);
1040 const IntTools_CommonPrt& aCP=aEE.CommonPrt();
1041 const TopoDS_Edge& aE1=aCP.Edge1();
1042 const TopoDS_Edge& aE2=aCP.Edge2();
1044 const IntTools_Range& aSR=aShrunkRange.ShrunkRange();
1045 const TopoDS_Edge& aE=aShrunkRange.Edge();
1047 IntTools_Range aNewRange;
1048 IntTools_Range aCPRange;
1050 if (aE1.IsSame(aE)) {
1051 const IntTools_Range& aR1=aCP.Range1();
1054 if (aE2.IsSame(aE)) {
1055 const IntTools_SequenceOfRanges& aSeqR=aCP.Ranges2();
1056 const IntTools_Range& aR2=aSeqR(1);
1060 Standard_Real aCoeff=1.05, tV, tNV;
1062 if (aSide==0) { // Left
1063 if (aCPRange.Last() > aSR.First()) {
1064 tNV=aCPRange.Last();
1065 tNV=tV+aCoeff*(tNV-tV);
1066 aNewRange.SetFirst(tNV);
1067 aNewRange.SetLast (aSR.Last());
1068 if(aNewRange.First() < aNewRange.Last()) {
1069 aShrunkRange.SetShrunkRange(aNewRange);
1074 if (aCPRange.First() < aSR.Last()) {
1075 tNV=aCPRange.First();
1076 tNV=tV-aCoeff*(tV-tNV);
1077 aNewRange.SetFirst(aSR.First());
1078 aNewRange.SetLast (tNV);
1080 if(aNewRange.First() < aNewRange.Last()) {
1081 aShrunkRange.SetShrunkRange(aNewRange);
1087 //=======================================================================
1088 // function: IsBlocksCoinside
1090 //=======================================================================
1091 Standard_Boolean NMTTools_PaveFiller::IsBlocksCoinside(const BOPTools_PaveBlock& aPB1,
1092 const BOPTools_PaveBlock& aPB2) const
1094 Standard_Boolean bRetFlag=Standard_True;
1095 Standard_Real aTolV11, aTolV12, aTolV21, aTolV22;
1096 Standard_Real d1121, d1122, d1222, d1221, aTolSum, aCoeff=1.05;
1097 gp_Pnt aP11, aP12, aP21, aP22;
1099 const TopoDS_Vertex aV11=TopoDS::Vertex(myDS->Shape(aPB1.Pave1().Index()));//mpv
1100 const TopoDS_Vertex aV12=TopoDS::Vertex(myDS->Shape(aPB1.Pave2().Index()));//mpv
1101 const TopoDS_Vertex aV21=TopoDS::Vertex(myDS->Shape(aPB2.Pave1().Index()));//mpv
1102 const TopoDS_Vertex aV22=TopoDS::Vertex(myDS->Shape(aPB2.Pave2().Index()));//mpv
1104 aTolV11=BRep_Tool::Tolerance(aV11);
1105 aTolV12=BRep_Tool::Tolerance(aV12);
1106 aTolV21=BRep_Tool::Tolerance(aV21);
1107 aTolV22=BRep_Tool::Tolerance(aV22);
1109 aP11=BRep_Tool::Pnt(aV11);
1110 aP12=BRep_Tool::Pnt(aV12);
1111 aP21=BRep_Tool::Pnt(aV21);
1112 aP22=BRep_Tool::Pnt(aV22);
1114 d1121=aP11.Distance(aP21);
1115 aTolSum=aCoeff*(aTolV11+aTolV21);
1116 if (d1121<aTolSum) {
1117 d1222=aP12.Distance(aP22);
1118 aTolSum=aCoeff*(aTolV12+aTolV22);
1119 if (d1222<aTolSum) {
1124 d1122=aP11.Distance(aP22);
1125 aTolSum=aCoeff*(aTolV11+aTolV22);
1126 if (d1122<aTolSum) {
1127 d1221=aP12.Distance(aP21);
1128 aTolSum=aCoeff*(aTolV12+aTolV21);
1129 if (d1221<aTolSum) {
1136 //=======================================================================
1137 // function: ReplaceCommonBlocks
1139 //=======================================================================
1140 void NMTTools_PaveFiller::ReplaceCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB)
1142 RemoveCommonBlocks(aLCB);
1143 SplitCommonBlocks(aLCB);
1146 //=======================================================================
1147 // function: SplitCommonBlocks
1149 //=======================================================================
1150 void NMTTools_PaveFiller::SplitCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB)
1152 Standard_Integer nE;
1153 NMTTools_ListOfCommonBlock aLCBx;
1154 NMTTools_ListIteratorOfListOfCommonBlock anIt, anItCBx;
1155 BOPTools_ListIteratorOfListOfPaveBlock anItLPE;
1157 anIt.Initialize(aLCB);
1158 for (; anIt.More(); anIt.Next()) {
1159 const NMTTools_CommonBlock& aCB=anIt.Value();
1164 SplitCommonBlock(aCB, aLCBx);
1166 anItCBx.Initialize(aLCBx);
1167 for (; anItCBx.More(); anItCBx.Next()) {
1168 const NMTTools_CommonBlock& aCBx=anItCBx.Value();
1169 const BOPTools_ListOfPaveBlock& aLPBx=aCBx.PaveBlocks();
1171 anItLPE.Initialize(aLPBx);
1172 for (; anItLPE.More(); anItLPE.Next()) {
1173 const BOPTools_PaveBlock& aPBx=anItLPE.Value();
1174 nE=aPBx.OriginalEdge();
1175 NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
1180 // Modified to provide the order of edges
1181 // in common block where the edge with max
1182 // tolerance value will be the first
1183 // Thu Sep 14 14:35:18 2006
1184 // Contribution of Samtech www.samcef.com BEGIN
1185 Standard_Integer i, iMax, aNb, aNbCB, nSp;
1186 Standard_Real aTolSp, aTolMax;
1187 BOPTools_ListOfPaveBlock *pLPBE;
1189 aNb=myDS->NumberOfShapesOfTheObject();
1190 for (nE=1; nE<=aNb; ++nE) {
1191 const TopoDS_Shape& aE=myDS->Shape(nE);
1192 if (aE.ShapeType()!=TopAbs_EDGE) {
1196 NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
1197 aNbCB=aLCBE.Extent();
1202 anIt.Initialize(aLCBE);
1203 for (; anIt.More(); anIt.Next()) {
1204 NMTTools_CommonBlock& aCBE=anIt.Value();
1205 const BOPTools_ListOfPaveBlock& aLPBE=aCBE.PaveBlocks();
1208 anItLPE.Initialize(aLPBE);
1209 for (i=0; anItLPE.More(); anItLPE.Next(), ++i) {
1210 const BOPTools_PaveBlock& aPB=anItLPE.Value();
1211 nSp=aPB.OriginalEdge();
1212 const TopoDS_Edge& aSp=TopoDS::Edge(myDS->Shape(nSp));
1213 aTolSp=BRep_Tool::Tolerance(aSp);
1214 if (aTolSp>aTolMax) {
1220 BOPTools_ListOfPaveBlock aLPBx;
1222 anItLPE.Initialize(aLPBE);
1223 for (i=0; anItLPE.More(); anItLPE.Next(), ++i) {
1224 const BOPTools_PaveBlock& aPB=anItLPE.Value();
1233 pLPBE=(BOPTools_ListOfPaveBlock *)&aLPBE;
1235 pLPBE->Append(aLPBx);
1236 }//for (; anIt.More(); anIt.Next()) {
1237 }//for (nE=1; nE<=aNb; ++nE) {
1238 // Contribution of Samtech www.samcef.com END
1241 //=======================================================================
1242 // function: RemoveCommonBlocks
1244 //=======================================================================
1245 void NMTTools_PaveFiller::RemoveCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB)
1247 Standard_Integer nE;
1248 NMTTools_ListOfCommonBlock aLCBx;
1249 NMTTools_ListIteratorOfListOfCommonBlock anItCB, anItCBE;
1250 BOPTools_ListIteratorOfListOfPaveBlock anItLPB;
1252 anItCB.Initialize(aLCB);
1253 for (; anItCB.More(); anItCB.Next()) {
1254 const NMTTools_CommonBlock& aCB=anItCB.Value();
1255 const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
1257 // Remove aCB from each edge
1258 anItLPB.Initialize(aLPB);
1259 for (; anItLPB.More(); anItLPB.Next()) {
1260 const BOPTools_PaveBlock& aPB=anItLPB.Value();
1261 nE=aPB.OriginalEdge();
1263 NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
1264 anItCBE.Initialize(aLCBE);
1265 for (; anItCBE.More(); anItCBE.Next()) {
1266 const NMTTools_CommonBlock& aCBE=anItCBE.Value();
1267 if (aCBE.IsEqual(aCB)) {
1268 aLCBE.Remove(anItCBE);
1276 //=======================================================================
1277 // function: SplitCommonBlock
1279 //=======================================================================
1280 void NMTTools_PaveFiller::SplitCommonBlock(const NMTTools_CommonBlock& aCB,
1281 NMTTools_ListOfCommonBlock& aLCBx)
1283 Standard_Boolean bIsCoincided;
1284 Standard_Integer i, j,nE, aNbE, aNbSPBx, aNbPB, k;
1285 BOPTools_SequenceOfPaveBlock aSPBx;
1286 BOPTools_ListIteratorOfListOfPaveBlock anItLPB;
1287 BOPTools_ListIteratorOfListOfPave anIt;
1288 BOPTools_PaveBlockIterator anPBIt;
1290 const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
1293 // 1. Checking: Whether we realy need to split the common block ?
1294 anItLPB.Initialize(aLPB);
1295 for (; anItLPB.More(); anItLPB.Next()) {
1296 const BOPTools_PaveBlock& aPB=anItLPB.Value();
1297 nE=aPB.OriginalEdge();
1298 BOPTools_PaveSet& aPSE=myPavePoolNew(myDS->RefEdge(nE));
1301 BOPTools_PaveSet aPSx;
1303 const BOPTools_ListOfPave& aLPE=aPSE.Set();
1304 anIt.Initialize(aLPE);
1305 for (; anIt.More(); anIt.Next()) {
1306 const BOPTools_Pave& aPx=anIt.Value();
1307 if (aPB.IsInBlock(aPx)) {
1311 aNbPB=aPSx.Set().Extent();
1316 // we need not split it
1321 // 2. Get sequence of pave Blocks containing all new pave blocks
1322 // for each edges's source pave Block
1323 anItLPB.Initialize(aLPB);
1324 for (; anItLPB.More(); anItLPB.Next()) {
1325 const BOPTools_PaveBlock& aPB=anItLPB.Value();
1326 const BOPTools_Pave& aPave1=aPB.Pave1();
1327 const BOPTools_Pave& aPave2=aPB.Pave2();
1328 nE=aPB.OriginalEdge();
1330 BOPTools_PaveSet aPSx;
1332 // the set aPsx will contain bounadry paves aPave1, aPave2 and
1333 // all paves of the edge nE that are inside block aPB
1334 aPSx.Append(aPave1);
1335 aPSx.Append(aPave2);
1337 BOPTools_PaveSet& aPSE=myPavePoolNew(myDS->RefEdge(nE));
1340 const BOPTools_ListOfPave& aLPE=aPSE.Set();
1341 anIt.Initialize(aLPE);
1342 for (; anIt.More(); anIt.Next()) {
1343 const BOPTools_Pave& aPx=anIt.Value();
1344 if (aPB.IsInBlock(aPx)) {
1349 // Form pave blocks from aPSx and collect them in aSPBx
1350 anPBIt.Initialize(nE, aPSx);
1351 for (; anPBIt.More(); anPBIt.Next()) {
1352 const BOPTools_PaveBlock& aPBx=anPBIt.Value();
1357 // 3. Do new common blocks
1359 const TColStd_ListOfInteger& aLF=aCB.Faces();
1360 aNbSPBx=aSPBx.Length();
1363 Standard_Integer k1, k2, n11, n12, n21, n22;
1365 for (i=1; i<=aNbPB; ++i) {
1366 NMTTools_CommonBlock aCBx;
1370 const BOPTools_PaveBlock& aPB1=aSPBx(i);
1371 n11=aPB1.Pave1().Index();
1372 n12=aPB1.Pave2().Index();
1374 aCBx.AddPaveBlock(aPB1);
1376 for (j=2; j<=aNbE; ++j) {
1379 for(k=k1; k<=k2; ++k) {
1380 const BOPTools_PaveBlock& aPB2=aSPBx(k);
1381 n21=aPB2.Pave1().Index();
1382 n22=aPB2.Pave2().Index();
1383 if ((n21==n11 && n22==n12) || (n21==n12 && n22==n11)) {
1384 //modified by NIZNHY-PKV Thu Nov 11 08:13:24 2010f
1385 bIsCoincided=CheckCoincidence(aPB2, aPB1);
1387 aCBx.AddPaveBlock(aPB2);
1390 //aCBx.AddPaveBlock(aPB2);
1392 //modified by NIZNHY-PKV Thu Nov 11 08:13:31 2010t
1400 //=======================================================================
1401 // function: VertexParameters
1403 //=======================================================================
1404 void VertexParameters(const IntTools_CommonPrt& aCPart,
1408 const IntTools_Range& aR1=aCPart.Range1();
1409 aT1=0.5*(aR1.First()+aR1.Last());
1411 if((aCPart.VertexParameter1() >= aR1.First()) &&
1412 (aCPart.VertexParameter1() <= aR1.Last())) {
1413 aT1 = aCPart.VertexParameter1();
1416 const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2();
1417 const IntTools_Range& aR2=aRanges2(1);
1418 aT2=0.5*(aR2.First()+aR2.Last());
1420 if((aCPart.VertexParameter2() >= aR2.First()) &&
1421 (aCPart.VertexParameter2() <= aR2.Last())) {
1422 aT2 = aCPart.VertexParameter2();
1426 //=======================================================================
1427 // function: KeepPave
1429 //=======================================================================
1430 Standard_Boolean IsOnPave(const Standard_Real& aT1,
1431 const IntTools_Range& aRange,
1432 const Standard_Real& aTolerance)
1434 Standard_Boolean firstisonpave1, firstisonpave2, bIsOnPave;
1436 firstisonpave1 = (Abs(aRange.First() - aT1) < aTolerance);
1437 firstisonpave2 = (Abs(aRange.Last() - aT1) < aTolerance);
1438 bIsOnPave=(firstisonpave1 || firstisonpave2);
1442 //=======================================================================
1443 // function:FindChains
1445 //=======================================================================
1446 void FindChains(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB,
1447 NMTTools_ListOfCommonBlock& aLCB)
1449 Standard_Integer i, j, aNbCB, aNbPB;
1450 BOPTools_IMapOfPaveBlock aProcessedBlocks, aChain;
1452 aNbCB=aMapCB.Extent();
1453 for (i=1; i<=aNbCB; ++i) {
1454 const BOPTools_PaveBlock& aPB=aMapCB.FindKey(i);
1455 if (aProcessedBlocks.Contains(aPB)) {
1459 aProcessedBlocks.Add(aPB);
1462 const BOPTools_IMapOfPaveBlock& aMapPB=aMapCB(i);
1463 aNbPB=aMapPB.Extent();
1464 for (j=1; j<=aNbPB; ++j) {
1465 const BOPTools_PaveBlock& aPBx=aMapPB(j);
1466 ProcessBlock(aPBx, aMapCB, aProcessedBlocks, aChain);
1469 NMTTools_CommonBlock aCB;
1471 aNbPB=aChain.Extent();
1472 for (j=1; j<=aNbPB; ++j) {
1473 const BOPTools_PaveBlock& aPBx=aChain(j);
1474 aCB.AddPaveBlock(aPBx);
1481 //=======================================================================
1482 // function:ProcessBlock
1484 //=======================================================================
1485 void ProcessBlock(const BOPTools_PaveBlock& aPB,
1486 const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB,
1487 BOPTools_IMapOfPaveBlock& aProcessedBlocks,
1488 BOPTools_IMapOfPaveBlock& aChain)
1490 Standard_Integer j, aNbPB;
1492 if (aProcessedBlocks.Contains(aPB)) {
1495 aProcessedBlocks.Add(aPB);
1498 const BOPTools_IMapOfPaveBlock& aMapPB=aMapCB.FindFromKey(aPB);
1499 aNbPB=aMapPB.Extent();
1500 for (j=1; j<=aNbPB; ++j) {
1501 const BOPTools_PaveBlock& aPBx=aMapPB(j);
1502 ProcessBlock(aPBx, aMapCB, aProcessedBlocks, aChain);
1505 // Modified to provide VS interference between
1506 // vertex as result of EE and a Face of argument
1507 // Thu Sep 14 14:35:18 2006
1508 // Contribution of Samtech www.samcef.com BEGIN
1509 //=======================================================================
1510 // function: PerformVF1
1512 //=======================================================================
1513 void NMTTools_PaveFiller::PerformVF1()
1515 Standard_Integer i, aNbEE, n1, n2, nNewShape, aNbS, nF;
1516 Standard_Integer anIndexIn, aFlag;
1517 Standard_Real aU, aV;
1518 TColStd_ListOfInteger aLFI;
1519 TColStd_ListIteratorOfListOfInteger aItLFI;
1521 BOPTools_CArray1OfVSInterference& aVSs=myIP->VSInterferences();
1522 BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences();
1524 aNbS=myDS->NumberOfShapesOfTheObject();
1525 for (i=1; i<=aNbS; ++i) {
1526 const TopoDS_Shape& aF=myDS->Shape(i);
1527 if (aF.ShapeType()==TopAbs_FACE) {
1531 if (!aLFI.Extent()) {
1535 aNbEE=aEEs.Extent();
1536 for (i=1; i<=aNbEE; ++i) {
1537 BOPTools_EEInterference& aEE=aEEs(i);
1538 aEE.Indices(n1, n2);
1539 nNewShape=aEE.NewShape();
1544 const TopoDS_Shape& aSnew=myDS->Shape(nNewShape);
1545 if (aSnew.ShapeType()!=TopAbs_VERTEX) {
1549 const TopoDS_Vertex& aVnew=TopoDS::Vertex(aSnew);
1553 BRepBndLib::Add(aVnew, aBV);
1555 aItLFI.Initialize(aLFI);
1556 for (; aItLFI.More(); aItLFI.Next()) {
1559 const TopoDS_Face& aF=TopoDS::Face(myDS->Shape(nF));
1560 const Bnd_Box& aBF=myDS->GetBoundingBox(nF);
1561 if (aBF.IsOut(aBV)) {
1566 #if OCC_VERSION_LARGE > 0x06050200
1567 aFlag=myContext->ComputeVS (aVnew, aF, aU, aV);
1569 aFlag=myContext.ComputeVS (aVnew, aF, aU, aV);
1572 BOPTools_VSInterference anInterf (nNewShape, nF, aU, aV);
1574 anIndexIn=aVSs.Append(anInterf);
1575 BOPTools_VSInterference& aVS=aVSs(anIndexIn);
1576 aVS.SetNewShape(nNewShape);//->
1581 // Contribution of Samtech www.samcef.com END
1582 //modified by NIZNHY-PKV Thu Nov 11 08:13:48 2010f
1583 //=======================================================================
1584 // function: CheckCoincidence
1586 //=======================================================================
1587 Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock& aPB1,
1588 const BOPTools_PaveBlock& aPB2)
1590 Standard_Boolean bRet;
1591 Standard_Integer nE1, nE2, aNbPoints;
1592 Standard_Real aT11, aT12, aT21, aT22, aT1m, aD, aTol, aT2x;
1595 bRet=Standard_False;
1597 aT11=aPB1.Pave1().Param();
1598 aT12=aPB1.Pave2().Param();
1599 aT1m=IntTools_Tools::IntermediatePoint (aT11, aT12);
1600 nE1=aPB1.OriginalEdge();
1601 const TopoDS_Edge& aE1=(*(TopoDS_Edge*)(&myDS->Shape(nE1)));
1602 BOPTools_Tools::PointOnEdge(aE1, aT1m, aP1m);
1604 aT21=aPB2.Pave1().Param();
1605 aT22=aPB2.Pave2().Param();
1606 nE2=aPB2.OriginalEdge();
1607 const TopoDS_Edge& aE2=(*(TopoDS_Edge*)(&myDS->Shape(nE2)));
1609 #if OCC_VERSION_LARGE > 0x06050200
1610 GeomAPI_ProjectPointOnCurve& aPPC=myContext->ProjPC(aE2);
1612 GeomAPI_ProjectPointOnCurve& aPPC=myContext.ProjPC(aE2);
1615 aNbPoints=aPPC.NbPoints();
1617 aD=aPPC.LowerDistance();
1619 aTol=BRep_Tool::Tolerance(aE1);
1620 aTol=aTol+BRep_Tool::Tolerance(aE2);
1622 aT2x=aPPC.LowerDistanceParameter();
1623 if (aT2x>aT21 && aT2x<aT22) {
1630 //modified by NIZNHY-PKV Thu Nov 11 08:13:55 2010t