1 // Copyright (C) 2007-2012 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.hxx>
29 #include <Precision.hxx>
33 #include <Bnd_Box.hxx>
35 #include <GeomAPI_ProjectPointOnCurve.hxx>
37 #include <TColStd_MapOfInteger.hxx>
38 #include <TColStd_IndexedMapOfInteger.hxx>
39 #include <TColStd_ListIteratorOfListOfInteger.hxx>
40 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
43 #include <TopoDS_Edge.hxx>
44 #include <TopoDS_Vertex.hxx>
45 #include <TopoDS_Compound.hxx>
47 #include <TopTools_IndexedMapOfShape.hxx>
48 #include <TopTools_ListIteratorOfListOfShape.hxx>
49 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
50 #include <TopTools_DataMapOfShapeListOfShape.hxx>
51 #include <TopTools_ListOfShape.hxx>
52 #include <TopTools_DataMapOfShapeShape.hxx>
54 #include <BRep_Tool.hxx>
55 #include <BRep_Builder.hxx>
56 #include <BRepBndLib.hxx>
58 #include <BOPTColStd_Dump.hxx>
59 #include <BOPTColStd_Failure.hxx>
61 #include <IntTools_ShrunkRange.hxx>
62 #include <IntTools_Range.hxx>
63 #include <IntTools_CommonPrt.hxx>
64 #include <IntTools_SequenceOfRanges.hxx>
65 #include <IntTools_EdgeEdge.hxx>
66 #include <IntTools_SequenceOfCommonPrts.hxx>
67 #include <IntTools_Tools.hxx>
68 #include <IntTools_Context.hxx>
70 #include <BOPTools_Pave.hxx>
71 #include <BOPTools_PaveSet.hxx>
72 #include <BOPTools_PaveBlockIterator.hxx>
73 #include <BOPTools_PaveBlock.hxx>
74 #include <BOPTools_CArray1OfEEInterference.hxx>
75 #include <BOPTools_EEInterference.hxx>
76 #include <BOPTools_ListOfPaveBlock.hxx>
77 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
78 #include <BOPTools_CArray1OfVVInterference.hxx>
79 #include <BOPTools_VVInterference.hxx>
80 #include <BOPTools_CArray1OfEEInterference.hxx>
81 #include <BOPTools_Tools.hxx>
82 #include <BOPTools_IDMapOfPaveBlockIMapOfPaveBlock.hxx>
83 #include <BOPTools_IMapOfPaveBlock.hxx>
84 #include <BOPTools_ListIteratorOfListOfPave.hxx>
85 #include <BOPTools_SequenceOfPaveBlock.hxx>
87 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
88 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
89 #include <BooleanOperations_KindOfInterference.hxx>
91 #include <NMTDS_Iterator.hxx>
92 #include <NMTDS_ShapesDataStructure.hxx>
93 #include <NMTDS_IndexedDataMapOfIntegerShape.hxx>
94 #include <NMTDS_IndexedDataMapOfShapeBox.hxx>
95 #include <NMTDS_BoxBndTree.hxx>
96 #include <NCollection_UBTreeFiller.hxx>
97 #include <NMTDS_InterfPool.hxx>
99 #include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
100 #include <NMTTools_ListOfCommonBlock.hxx>
101 #include <NMTTools_CommonBlock.hxx>
102 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
104 #include <TColStd_ListOfInteger.hxx>
105 #include <TColStd_ListIteratorOfListOfInteger.hxx>
106 #include <BRepBndLib.hxx>
107 #include <BOPTools_CArray1OfVSInterference.hxx>
108 #include <BOPTools_VSInterference.hxx>
109 #include <TColStd_MapOfInteger.hxx>
110 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
113 void TreatNewVertices(const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI,
114 TopTools_DataMapOfShapeListOfShape& myImages,
115 TopTools_DataMapOfShapeShape& myOrigins);
118 void MakeNewVertex(const TopTools_ListOfShape& aLV,
119 TopoDS_Vertex& aNewVertex);
122 void VertexParameters(const IntTools_CommonPrt& aCPart,
127 Standard_Boolean IsOnPave(const Standard_Real& aT1,
128 const IntTools_Range& aRange,
129 const Standard_Real& aTolerance);
132 // void EECommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB);
135 void ProcessBlock(const BOPTools_PaveBlock& aPB,
136 const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB,
137 BOPTools_IMapOfPaveBlock& aProcessedBlocks,
138 BOPTools_IMapOfPaveBlock& aChain);
141 void FindChains(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB,
142 NMTTools_ListOfCommonBlock& aLCB);
144 //=======================================================================
145 // function: PerformEE
147 //=======================================================================
148 void NMTTools_PaveFiller::PerformEE()
150 myIsDone=Standard_False;
152 Standard_Boolean bJustAdd;
153 Standard_Integer n1, n2, anIndexIn, nE1, nE2, aNbVEs, aBlockLength;
154 Standard_Integer aTmp, aWhat, aWith, i, aNbCPrts, aDiscretize=30;
155 Standard_Integer aNbLPB1, aNbLPB2;
156 Standard_Real aTolE1, aTolE2, aDeflection=0.01;
157 BOPTools_ListIteratorOfListOfPaveBlock anIt1, anIt2;
158 TopoDS_Edge aEWhat, aEWith;
159 TopoDS_Vertex aNewVertex;
160 BooleanOperations_IndexedDataMapOfShapeInteger aMapVI;
161 BOPTools_IDMapOfPaveBlockIMapOfPaveBlock aMapCB;
163 BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences();
165 myDSIt->Initialize(TopAbs_EDGE, TopAbs_EDGE);
167 // BlockLength correction
168 aNbVEs=myDSIt->BlockLength();
169 aBlockLength=aEEs.BlockLength();
170 if (aNbVEs > aBlockLength) {
171 aEEs.SetBlockLength(aNbVEs);
174 for (; myDSIt->More(); myDSIt->Next()) {
175 myDSIt->Current(n1, n2, bJustAdd);
184 const TopoDS_Edge aE1=TopoDS::Edge(myDS->Shape(nE1));//mpv
185 const TopoDS_Edge aE2=TopoDS::Edge(myDS->Shape(nE2));//mpv
187 if (BRep_Tool::Degenerated(aE1) || BRep_Tool::Degenerated(aE2)){
191 aTolE1=BRep_Tool::Tolerance(aE1);
192 aTolE2=BRep_Tool::Tolerance(aE2);
194 BOPTools_ListOfPaveBlock& aLPB1=mySplitShapesPool(myDS->RefEdge(nE1));
195 BOPTools_ListOfPaveBlock& aLPB2=mySplitShapesPool(myDS->RefEdge(nE2));
197 // Modified Thu Sep 14 14:35:18 2006
198 // Contribution of Samtech www.samcef.com BEGIN
199 aNbLPB1=aLPB1.Extent();
200 aNbLPB2=aLPB2.Extent();
202 //if (aE1.IsSame(aE2) && aNbLPB1==1 && aNbLPB2==1) {
205 // Contribution of Samtech www.samcef.com END
207 for (anIt1.Initialize(aLPB1); anIt1.More(); anIt1.Next()) {
208 BOPTools_PaveBlock& aPB1=anIt1.Value();
209 const IntTools_ShrunkRange& aShrunkRange1=aPB1.ShrunkRange();
211 const IntTools_Range& aSR1=aShrunkRange1.ShrunkRange();
212 const Bnd_Box& aBB1=aShrunkRange1.BndBox();
214 for (anIt2.Initialize(aLPB2); anIt2.More(); anIt2.Next()) {
215 BOPTools_PaveBlock& aPB2=anIt2.Value();
216 const IntTools_ShrunkRange& aShrunkRange2=aPB2.ShrunkRange();
218 const IntTools_Range& aSR2=aShrunkRange2.ShrunkRange();
219 const Bnd_Box& aBB2=aShrunkRange2.BndBox();
221 if (aBB1.IsOut (aBB2)) {
226 IntTools_EdgeEdge aEE;
229 aEE.SetTolerance1 (aTolE1);
230 aEE.SetTolerance2 (aTolE2);
231 aEE.SetDiscretize (aDiscretize);
232 aEE.SetDeflection (aDeflection);
234 IntTools_Range anewSR1 = aSR1;
235 IntTools_Range anewSR2 = aSR2;
237 BOPTools_Tools::CorrectRange (aE1, aE2, aSR1, anewSR1);
238 BOPTools_Tools::CorrectRange (aE2, aE1, aSR2, anewSR2);
240 aEE.SetRange1(anewSR1);
241 aEE.SetRange2(anewSR2);
248 // reverse order if it is necessary
261 const IntTools_SequenceOfCommonPrts& aCPrts=aEE.CommonParts();
262 aNbCPrts=aCPrts.Length();
263 for (i=1; i<=aNbCPrts; i++) {
264 const IntTools_CommonPrt& aCPart=aCPrts(i);
265 const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2();
269 TopAbs_ShapeEnum aType=aCPart.Type();
271 case TopAbs_VERTEX: {
272 Standard_Real aT1, aT2, aTol=Precision::PConfusion();
273 Standard_Boolean bIsOnPave1, bIsOnPave2;
274 IntTools_Range aR1, aR2;
276 VertexParameters(aCPart, aT1, aT2);
278 //decide to keep the pave or not
279 aR1 = (aEE.Order()) ? anewSR2 : anewSR1;
280 aR2 = (aEE.Order()) ? anewSR1 : anewSR2;
283 bIsOnPave1=IsOnPave(aT1, aR1, aTol);
284 bIsOnPave2=IsOnPave(aT2, aR2, aTol);
286 if(bIsOnPave1 || bIsOnPave2) {
290 BOPTools_Tools::MakeNewVertex(aEWhat, aT1, aEWith, aT2, aNewVertex);
293 Standard_Integer nV11, nV12, nV21, nV22, nVS[2], k, j, iFound;
294 Standard_Real aTolVx, aTolVnew, aD2, aDT2;
295 TColStd_MapOfInteger aMV;
300 nV11=aPB1.Pave1().Index();
301 nV12=aPB1.Pave2().Index();
302 nV21=aPB2.Pave1().Index();
303 nV22=aPB2.Pave2().Index();
307 if (aMV.Contains(nV21)) {
311 if (aMV.Contains(nV22)) {
316 aTolVnew=BRep_Tool::Tolerance(aNewVertex);
317 aPnew=BRep_Tool::Pnt(aNewVertex);
319 for (k=0; k<=j; ++k) {
320 const TopoDS_Vertex& aVx=TopoDS::Vertex(myDS->Shape(nVS[k]));
321 aTolVx=BRep_Tool::Tolerance(aVx);
322 aPx=BRep_Tool::Pnt(aVx);
323 aD2=aPnew.SquareDistance(aPx);
325 aDT2=100.*(aTolVnew+aTolVx)*(aTolVnew+aTolVx);
338 // Add Interference to the Pool
339 BOPTools_EEInterference anInterf (aWhat, aWith, aCPart);
341 anIndexIn=aEEs.Append(anInterf);
344 myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_EE);
349 aMapVI.Add(aNewVertex, anIndexIn);
354 Standard_Integer aNbComPrt2;
355 Standard_Boolean aCoinsideFlag;
357 aNbComPrt2=aRanges2.Length();
358 aCoinsideFlag=IsBlocksCoinside(aPB1, aPB2);
360 if (aNbComPrt2>1 || !aCoinsideFlag) {
365 if (aMapCB.Contains(aPB1)) {
366 BOPTools_IMapOfPaveBlock& aMapPB=aMapCB.ChangeFromKey(aPB1);
371 BOPTools_IMapOfPaveBlock aMapPB;
374 aMapCB.Add(aPB1, aMapPB);
377 if (aMapCB.Contains(aPB2)) {
378 BOPTools_IMapOfPaveBlock& aMapPB=aMapCB.ChangeFromKey(aPB2);
383 BOPTools_IMapOfPaveBlock aMapPB;
386 aMapCB.Add(aPB2, aMapPB);
390 myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_EE);
398 } // for (i=1; i<=aNbCPrts; i++)
399 }// if (aEE.IsDone())
400 } // for (; anIt2.More(); anIt2.Next())
401 } // for (; anIt1.More(); anIt1.Next())
402 }// for (; myDSIt.More(); myDSIt.Next())
405 NMTTools_ListOfCommonBlock aLCB;
407 FindChains(aMapCB, aLCB);
408 EENewVertices (aMapVI);
409 //TreatPaveBlocks(*this, aLCB);
410 TreatPaveBlocks(aLCB);
411 ReplaceCommonBlocks(aLCB);
416 myIsDone=Standard_True;
419 //=======================================================================
420 // function:TreatPaveBlocks
422 //=======================================================================
423 void NMTTools_PaveFiller::TreatPaveBlocks (NMTTools_ListOfCommonBlock& theLCB)
425 Standard_Boolean bFound;
426 Standard_Integer nE, nV, nVp, iFlag;
428 TColStd_MapOfInteger aMI;
429 TColStd_MapIteratorOfMapOfInteger aItMI;
430 NMTTools_ListIteratorOfListOfCommonBlock aItLCB;
431 BOPTools_ListIteratorOfListOfPaveBlock aItLPB;
432 BOPTools_ListIteratorOfListOfPave aItLP;
434 aItLCB.Initialize(theLCB);
435 for (; aItLCB.More(); aItLCB.Next()) {
436 const NMTTools_CommonBlock& aCB=aItLCB.Value();
439 const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
442 aItLPB.Initialize(aLPB);
443 for (; aItLPB.More(); aItLPB.Next()) {
444 const BOPTools_PaveBlock& aPB=aItLPB.Value();
445 nE=aPB.OriginalEdge();
446 BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
447 BOPTools_ListOfPave& aLP=aPaveSet.ChangeSet();
449 aItLP.Initialize(aLP);
450 for (; aItLP.More(); aItLP.Next()) {
451 const BOPTools_Pave& aPave=aItLP.Value();
455 }//for (; anItLPB.More(); anItLPB.Next()) {
458 aItLPB.Initialize(aLPB);
459 for (; aItLPB.More(); aItLPB.Next()) {
460 const BOPTools_PaveBlock& aPB=aItLPB.Value();
461 nE=aPB.OriginalEdge();
462 BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
463 BOPTools_ListOfPave& aLP=aPaveSet.ChangeSet();
465 aItMI.Initialize(aMI);
466 for (; aItMI.More(); aItMI.Next()) {
468 bFound=Standard_False;
469 aItLP.Initialize(aLP);
470 for (; aItLP.More(); aItLP.Next()) {
471 const BOPTools_Pave& aPave=aItLP.Value();
480 // Append Pave of nV to rhe edge nE
481 const TopoDS_Edge& aE=*(TopoDS_Edge*)(&myDS->Shape(nE));
482 const TopoDS_Vertex& aV= *(TopoDS_Vertex*)(&myDS->Shape(nV));
483 iFlag=myContext->ComputeVE (aV, aE, aT);
487 aPave.SetInterference(-1);
488 aPave.SetType (BooleanOperations_EdgeEdge);
491 aPaveSet.Append(aPave);
494 }//for (; aItMI.More(); aItMI.Next()) {
495 }//for (; anItLPB.More(); anItLPB.Next()) {
499 //=======================================================================
500 // function:EECommonBlocks
502 //=======================================================================
503 void NMTTools_PaveFiller::EECommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB)
505 NMTTools_ListOfCommonBlock aLCB;
507 FindChains(aMapCB, aLCB);
508 ReplaceCommonBlocks(aLCB);
511 //=======================================================================
512 // function:EENewVertices
514 //=======================================================================
515 void NMTTools_PaveFiller::EENewVertices (const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI)
517 Standard_Integer aNb, aNbVSD, nVnew, nIEE, nE[2], j, iFlag;
520 TopTools_DataMapOfShapeListOfShape myImages;
521 TopTools_DataMapOfShapeShape myOrigins;
522 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
523 TopTools_ListIteratorOfListOfShape aIt;
524 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
525 TColStd_MapOfInteger aMFence;
528 BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences();
531 if (!aNb) { // no new vertices, no new problems
537 TopoDS_Vertex aV1=TopoDS::Vertex(aMapVI.FindKey(1));
538 EENewVertices(aV1, aMapVI);
543 TreatNewVertices(aMapVI, myImages, myOrigins);
545 aItIm.Initialize(myImages);
546 for (; aItIm.More(); aItIm.Next()) {
547 const TopoDS_Vertex& aVnew=TopoDS::Vertex(aItIm.Key());
548 const TopTools_ListOfShape& aLVSD=aItIm.Value();
550 aNbVSD=aLVSD.Extent();
551 if (aNbVSD==1) {// simple case aVnew=aVold
552 EENewVertices(aVnew, aMapVI);
557 myDS->InsertShapeAndAncestorsSuccessors(aVnew, anASSeq);
558 nVnew=myDS->NumberOfInsertedShapes();
559 myDS->SetState(nVnew, BooleanOperations_ON);
562 aIt.Initialize(aLVSD);
563 for (; aIt.More(); aIt.Next()) {
564 const TopoDS_Vertex& aVold=TopoDS::Vertex(aIt.Value());
565 nIEE=aMapVI.FindFromKey(aVold);
566 BOPTools_EEInterference& aEE=aEEs(nIEE);
567 aEE.Indices(nE[0], nE[1]);
568 aEE.SetNewShape(nVnew);
570 for (j=0; j<2; ++j) {
571 if (aMFence.Add(nE[j])) {
572 aE=TopoDS::Edge(myDS->Shape(nE[j]));
573 iFlag=myContext->ComputeVE (aVnew, aE, aT);
575 aPave.SetInterference(-1);
576 aPave.SetType (BooleanOperations_EdgeEdge);
577 aPave.SetIndex(nVnew);
580 BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE[j]));
581 aPaveSet.Append(aPave);
583 }// if (aMFence.Add(nE[j])) {
584 }// for (j=0; j<2; ++j) {
585 }//for (; aIt.More(); aIt.Next()) {
586 }// for (; aItIm.More(); aItIm.Next())
590 // completely rewritten
591 //=======================================================================
592 //function : TreatNewVertices
594 //=======================================================================
595 void TreatNewVertices(const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI,
596 TopTools_DataMapOfShapeListOfShape& myImages,
597 TopTools_DataMapOfShapeShape& myOrigins)
599 Standard_Integer j, i, aNbV, aNbVSD;
601 TColStd_ListIteratorOfListOfInteger aIt;
602 TopoDS_Shape aSTmp, aVF;
604 TopTools_IndexedMapOfShape aMV, aMVProcessed;
605 TopTools_ListIteratorOfListOfShape aItS;
606 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
607 TopTools_DataMapOfShapeListOfShape aMVV;
608 NMTDS_IndexedDataMapOfIntegerShape aMIS;
609 NMTDS_IndexedDataMapOfShapeBox aMSB;
611 NMTDS_BoxBndTreeSelector aSelector;
612 NMTDS_BoxBndTree aBBTree;
613 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
618 aNbV=aMapVI.Extent();
619 for (i=1; i<=aNbV; ++i) {
620 const TopoDS_Shape& aV=aMapVI.FindKey(i);
624 for (i=1; i<=aNbV; ++i) {
625 const TopoDS_Shape& aV=aMV(i);
628 aTol=BRep_Tool::Tolerance(TopoDS::Vertex(aV));
630 BRepBndLib::Add(aV, aBox);
632 aTreeFiller.Add(i, aBox);
641 for (i=1; i<=aNbV; ++i) {
642 const TopoDS_Shape& aV=aMV(i);
644 if (aMVProcessed.Contains(aV)) {
648 Standard_Integer aNbIP, aIP, aNbIP1, aIP1;
649 TopTools_ListOfShape aLVSD;
650 TColStd_MapOfInteger aMIP, aMIP1, aMIPC;
651 TColStd_MapIteratorOfMapOfInteger aIt1;
656 aIt1.Initialize(aMIP);
657 for(; aIt1.More(); aIt1.Next()) {
659 if (aMIPC.Contains(aIP)) {
663 const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
664 const Bnd_Box& aBoxVP=aMSB.FindFromKey(aVP);
667 aSelector.SetBox(aBoxVP);
669 aNbVSD=aBBTree.Select(aSelector);
671 continue; // it must not be
674 const TColStd_ListOfInteger& aLI=aSelector.Indices();
676 for (; aIt.More(); aIt.Next()) {
678 if (aMIP.Contains(aIP1)) {
682 } //for (; aIt.More(); aIt.Next()) {
683 }//for(; aIt1.More(); aIt1.Next()) {
685 aNbIP1=aMIP1.Extent();
687 break; // from while(1)
690 aIt1.Initialize(aMIP);
691 for(; aIt1.More(); aIt1.Next()) {
697 aIt1.Initialize(aMIP1);
698 for(; aIt1.More(); aIt1.Next()) {
705 aNbIP=aMIPC.Extent();
710 aIt1.Initialize(aMIPC);
711 for(j=0; aIt1.More(); aIt1.Next(), ++j) {
713 const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
718 aMVProcessed.Add(aVP);
720 myImages.Bind(aVF, aLVSD);
721 }// for (i=1; i<=aNbV; ++i) {
722 //------------------------------
726 aItIm.Initialize(myImages);
727 for (; aItIm.More(); aItIm.Next()) {
728 const TopoDS_Shape& aV=aItIm.Key();
729 const TopTools_ListOfShape& aLVSD=aItIm.Value();
730 aNbVSD=aLVSD.Extent();
733 MakeNewVertex(aLVSD, aVnew);
734 aMVV.Bind(aVnew, aLVSD);
738 // UnBind old vertices
740 for (i=1; i<=aNbV; ++i) {
741 const TopoDS_Shape& aV=aMV(i);
746 aItIm.Initialize(aMVV);
747 for (; aItIm.More(); aItIm.Next()) {
748 const TopoDS_Shape& aV=aItIm.Key();
749 const TopTools_ListOfShape& aLVSD=aItIm.Value();
750 myImages.Bind(aV, aLVSD);
754 aItIm.Initialize(myImages);
755 for (; aItIm.More(); aItIm.Next()) {
756 const TopoDS_Shape& aV=aItIm.Key();
757 const TopTools_ListOfShape& aLVSD=aItIm.Value();
759 aItS.Initialize(aLVSD);
760 for (; aItS.More(); aItS.Next()) {
761 const TopoDS_Shape& aVSD=aItS.Value();
762 if (!myOrigins.IsBound(aVSD)) {
763 myOrigins.Bind(aVSD, aV);
769 //=======================================================================
770 //function : MakeNewVertex
772 //=======================================================================
773 void MakeNewVertex(const TopTools_ListOfShape& aLV,
774 TopoDS_Vertex& aNewVertex)
776 Standard_Integer aNbV;
777 Standard_Real aTolV, aD, aDmax;
782 TopTools_ListIteratorOfListOfShape aIt;
790 aGC.SetCoord(0.,0.,0.);
792 for (; aIt.More(); aIt.Next()) {
793 aVx=TopoDS::Vertex(aIt.Value());
794 aP3D=BRep_Tool::Pnt(aVx);
797 aGC/=(Standard_Real)aNbV;
803 for (; aIt.More(); aIt.Next()) {
804 aVx=TopoDS::Vertex(aIt.Value());
805 aP3D=BRep_Tool::Pnt(aVx);
806 aTolV=BRep_Tool::Tolerance(aVx);
807 aD=aPGC.Distance(aP3D)+aTolV;
813 aBB.MakeVertex (aNewVertex, aPGC, aDmax);
816 //=======================================================================
817 // function:EENewVertices
819 //=======================================================================
820 void NMTTools_PaveFiller::EENewVertices (const TopoDS_Vertex& aNewVertex,
821 const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI)
823 Standard_Integer i, aNewShape, nE1, nE2;
824 Standard_Real aT1, aT2;
825 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
828 BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences();
830 // one new vertex case is treated in usual way
832 // Insert New Vertex in DS;
833 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
834 aNewShape=myDS->NumberOfInsertedShapes();
835 myDS->SetState (aNewShape, BooleanOperations_ON);
836 // Insert New Vertex in EE Interference
837 i=aMapVI.FindFromKey(aNewVertex);
838 BOPTools_EEInterference& aEEInterf= aEEs(i);
839 aEEInterf.SetNewShape(aNewShape);
840 // Extact interference info
841 aEEInterf.Indices(nE1, nE2);
842 const IntTools_CommonPrt& aCPart=aEEInterf.CommonPrt();
843 VertexParameters(aCPart, aT1, aT2);
845 // Add Paves to the myPavePoolNew
846 aPave.SetInterference(i);
847 aPave.SetType (BooleanOperations_EdgeEdge);
848 aPave.SetIndex(aNewShape);
851 BOPTools_PaveSet& aPaveSet1=myPavePoolNew(myDS->RefEdge(nE1));
852 aPaveSet1.Append(aPave);
855 BOPTools_PaveSet& aPaveSet2=myPavePoolNew(myDS->RefEdge(nE2));
856 aPaveSet2.Append(aPave);
859 //=======================================================================
860 // function: RefinePavePool
862 //=======================================================================
863 void NMTTools_PaveFiller::RefinePavePool()
865 Standard_Integer i, aNbNew;
867 for (i=1; i<=myNbSources; i++) {
869 if ((myDS->GetShape(i)).ShapeType()==TopAbs_EDGE) {
870 BOPTools_PaveSet& aPS= myPavePool(myDS->RefEdge(i));
872 BOPTools_PaveSet& aNewPS= myPavePoolNew(myDS->RefEdge(i));
873 BOPTools_ListOfPave& aNewLP=aNewPS.ChangeSet();
875 aNbNew=aNewLP.Extent();
877 BOPTools_ListIteratorOfListOfPave anIt(aNewLP);
878 for (; anIt.More(); anIt.Next()) {
879 const BOPTools_Pave& aPave=anIt.Value();
882 // Clear the ListOfPaveBlock
883 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(i));
885 // Prepare the paveBlocks for that egde again
886 PreparePaveBlocks(i);
893 //=======================================================================
894 // function: PreparePaveBlocks
896 //=======================================================================
897 void NMTTools_PaveFiller::PreparePaveBlocks(const TopAbs_ShapeEnum aType1,
898 const TopAbs_ShapeEnum aType2)
900 myIsDone=Standard_False;
902 Standard_Boolean bOk1, bOk2, bOk3, bFlag;
903 Standard_Integer i, aNb, nE[2], n1, n2, aNbSplits;
904 TColStd_MapOfInteger aMap;
906 bOk1= (aType1==TopAbs_VERTEX) && (aType2==TopAbs_EDGE) ;
907 bOk2= (aType1==TopAbs_EDGE) && (aType2==TopAbs_EDGE) ;
908 bOk3= (aType1==TopAbs_EDGE) && (aType2==TopAbs_FACE) ;
909 if (!bOk1 && !bOk2 && !bOk3) {// error: Type mismatch
915 myDSIt->Initialize(aType1, aType2);
916 for (; myDSIt->More(); myDSIt->Next()) {
917 myDSIt->Current(n1, n2, bFlag);
921 if (myDS->GetShapeType(n1)!=TopAbs_EDGE) {
926 for (i=0; i<aNb; ++i) {
927 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE[i]));
928 aNbSplits=aLPB.Extent();
930 if (aMap.Add(nE[i])) {
931 PreparePaveBlocks(nE[i]);
938 }// for (; myDSIt.More(); myDSIt.Next())
939 myIsDone=Standard_True;
942 //=======================================================================
943 // function: PreparePaveBlocks
945 //=======================================================================
946 void NMTTools_PaveFiller::PreparePaveBlocks(const Standard_Integer nE)
948 myIsDone=Standard_False;
951 Standard_Integer nV1, nV2, iErr;
953 TopoDS_Vertex aV1, aV2;
955 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
957 aE=TopoDS::Edge(myDS->Shape(nE));
958 if (BRep_Tool::Degenerated(aE)) {
959 myIsDone=Standard_True;
963 BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE));
965 BOPTools_PaveBlockIterator aPBIt(nE, aPS);
966 for (; aPBIt.More(); aPBIt.Next()) {
967 BOPTools_PaveBlock& aPB=aPBIt.Value();
968 const IntTools_Range& aRange=aPB.Range();
970 const BOPTools_Pave& aPave1=aPB.Pave1();
972 aV1=TopoDS::Vertex(myDS->GetShape(nV1));
974 const BOPTools_Pave& aPave2=aPB.Pave2();
976 aV2=TopoDS::Vertex(myDS->GetShape(nV2));
979 IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext);
980 iErr=aSR.ErrorStatus();
982 sprintf (buf, "Can not obtain ShrunkRange for Edge %d\n", nE);
983 BOPTColStd_Dump::PrintMessage(buf);
984 sprintf (buf, "Can not obtain ShrunkRange for Edge %d", nE);
986 BOPTColStd_Failure(buf) ;
991 "Warning: [PreparePaveBlocks()] Max.Dummy Shrunk Range for Edge %d\n", nE);
992 BOPTColStd_Dump::PrintMessage(buf);
995 // Check left paves and correct ShrunkRange if it is necessary
996 CorrectShrunkRanges (0, aPave1, aSR);
997 CorrectShrunkRanges (1, aPave2, aSR);
1000 aPB.SetShrunkRange(aSR);
1002 } //for (; aPBIt.More(); aPBIt.Next())
1003 myIsDone=Standard_True;
1006 //=======================================================================
1007 // function: CorrectShrunkRanges
1009 //=======================================================================
1010 void NMTTools_PaveFiller::CorrectShrunkRanges(const Standard_Integer aSide,
1011 const BOPTools_Pave& aPave,
1012 IntTools_ShrunkRange& aShrunkRange)
1014 BooleanOperations_KindOfInterference aType;
1015 Standard_Integer anIndexInterf ;
1018 if (aType!=BooleanOperations_EdgeEdge) {
1022 anIndexInterf=aPave.Interference();
1023 if (anIndexInterf<0) {
1024 // it can be EE interf between E and (e1,e2,..en) -> vertex
1025 // so we can't decide which aEE.CommonPrt() we should take.
1029 BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences();
1030 const BOPTools_EEInterference& aEE=aEEs(anIndexInterf);
1031 const IntTools_CommonPrt& aCP=aEE.CommonPrt();
1032 const TopoDS_Edge& aE1=aCP.Edge1();
1033 const TopoDS_Edge& aE2=aCP.Edge2();
1035 const IntTools_Range& aSR=aShrunkRange.ShrunkRange();
1036 const TopoDS_Edge& aE=aShrunkRange.Edge();
1038 IntTools_Range aNewRange;
1039 IntTools_Range aCPRange;
1041 if (aE1.IsSame(aE)) {
1042 const IntTools_Range& aR1=aCP.Range1();
1045 if (aE2.IsSame(aE)) {
1046 const IntTools_SequenceOfRanges& aSeqR=aCP.Ranges2();
1047 const IntTools_Range& aR2=aSeqR(1);
1051 Standard_Real aCoeff=1.05, tV, tNV;
1053 if (aSide==0) { // Left
1054 if (aCPRange.Last() > aSR.First()) {
1055 tNV=aCPRange.Last();
1056 tNV=tV+aCoeff*(tNV-tV);
1057 aNewRange.SetFirst(tNV);
1058 aNewRange.SetLast (aSR.Last());
1059 if(aNewRange.First() < aNewRange.Last()) {
1060 aShrunkRange.SetShrunkRange(aNewRange);
1065 if (aCPRange.First() < aSR.Last()) {
1066 tNV=aCPRange.First();
1067 tNV=tV-aCoeff*(tV-tNV);
1068 aNewRange.SetFirst(aSR.First());
1069 aNewRange.SetLast (tNV);
1071 if(aNewRange.First() < aNewRange.Last()) {
1072 aShrunkRange.SetShrunkRange(aNewRange);
1078 //=======================================================================
1079 // function: IsBlocksCoinside
1081 //=======================================================================
1082 Standard_Boolean NMTTools_PaveFiller::IsBlocksCoinside(const BOPTools_PaveBlock& aPB1,
1083 const BOPTools_PaveBlock& aPB2) const
1085 Standard_Boolean bRetFlag=Standard_True;
1086 Standard_Real aTolV11, aTolV12, aTolV21, aTolV22;
1087 Standard_Real d1121, d1122, d1222, d1221, aTolSum, aCoeff=1.05;
1088 gp_Pnt aP11, aP12, aP21, aP22;
1090 const TopoDS_Vertex aV11=TopoDS::Vertex(myDS->Shape(aPB1.Pave1().Index()));//mpv
1091 const TopoDS_Vertex aV12=TopoDS::Vertex(myDS->Shape(aPB1.Pave2().Index()));//mpv
1092 const TopoDS_Vertex aV21=TopoDS::Vertex(myDS->Shape(aPB2.Pave1().Index()));//mpv
1093 const TopoDS_Vertex aV22=TopoDS::Vertex(myDS->Shape(aPB2.Pave2().Index()));//mpv
1095 aTolV11=BRep_Tool::Tolerance(aV11);
1096 aTolV12=BRep_Tool::Tolerance(aV12);
1097 aTolV21=BRep_Tool::Tolerance(aV21);
1098 aTolV22=BRep_Tool::Tolerance(aV22);
1100 aP11=BRep_Tool::Pnt(aV11);
1101 aP12=BRep_Tool::Pnt(aV12);
1102 aP21=BRep_Tool::Pnt(aV21);
1103 aP22=BRep_Tool::Pnt(aV22);
1105 d1121=aP11.Distance(aP21);
1106 aTolSum=aCoeff*(aTolV11+aTolV21);
1107 if (d1121<aTolSum) {
1108 d1222=aP12.Distance(aP22);
1109 aTolSum=aCoeff*(aTolV12+aTolV22);
1110 if (d1222<aTolSum) {
1115 d1122=aP11.Distance(aP22);
1116 aTolSum=aCoeff*(aTolV11+aTolV22);
1117 if (d1122<aTolSum) {
1118 d1221=aP12.Distance(aP21);
1119 aTolSum=aCoeff*(aTolV12+aTolV21);
1120 if (d1221<aTolSum) {
1127 //=======================================================================
1128 // function: ReplaceCommonBlocks
1130 //=======================================================================
1131 void NMTTools_PaveFiller::ReplaceCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB)
1133 RemoveCommonBlocks(aLCB);
1134 SplitCommonBlocks(aLCB);
1137 //=======================================================================
1138 // function: SplitCommonBlocks
1140 //=======================================================================
1141 void NMTTools_PaveFiller::SplitCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB)
1143 Standard_Integer nE;
1144 NMTTools_ListOfCommonBlock aLCBx;
1145 NMTTools_ListIteratorOfListOfCommonBlock anIt, anItCBx;
1146 BOPTools_ListIteratorOfListOfPaveBlock anItLPE;
1148 anIt.Initialize(aLCB);
1149 for (; anIt.More(); anIt.Next()) {
1150 const NMTTools_CommonBlock& aCB=anIt.Value();
1155 SplitCommonBlock(aCB, aLCBx);
1157 anItCBx.Initialize(aLCBx);
1158 for (; anItCBx.More(); anItCBx.Next()) {
1159 const NMTTools_CommonBlock& aCBx=anItCBx.Value();
1160 const BOPTools_ListOfPaveBlock& aLPBx=aCBx.PaveBlocks();
1162 anItLPE.Initialize(aLPBx);
1163 for (; anItLPE.More(); anItLPE.Next()) {
1164 const BOPTools_PaveBlock& aPBx=anItLPE.Value();
1165 nE=aPBx.OriginalEdge();
1166 NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
1171 // Modified to provide the order of edges
1172 // in common block where the edge with max
1173 // tolerance value will be the first
1174 // Thu Sep 14 14:35:18 2006
1175 // Contribution of Samtech www.samcef.com BEGIN
1176 Standard_Integer i, iMax, aNb, aNbCB, nSp;
1177 Standard_Real aTolSp, aTolMax;
1178 BOPTools_ListOfPaveBlock *pLPBE;
1180 aNb=myDS->NumberOfShapesOfTheObject();
1181 for (nE=1; nE<=aNb; ++nE) {
1182 const TopoDS_Shape& aE=myDS->Shape(nE);
1183 if (aE.ShapeType()!=TopAbs_EDGE) {
1187 NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
1188 aNbCB=aLCBE.Extent();
1193 anIt.Initialize(aLCBE);
1194 for (; anIt.More(); anIt.Next()) {
1195 NMTTools_CommonBlock& aCBE=anIt.ChangeValue();
1196 const BOPTools_ListOfPaveBlock& aLPBE=aCBE.PaveBlocks();
1199 anItLPE.Initialize(aLPBE);
1200 for (i=0; anItLPE.More(); anItLPE.Next(), ++i) {
1201 const BOPTools_PaveBlock& aPB=anItLPE.Value();
1202 nSp=aPB.OriginalEdge();
1203 const TopoDS_Edge& aSp=TopoDS::Edge(myDS->Shape(nSp));
1204 aTolSp=BRep_Tool::Tolerance(aSp);
1205 if (aTolSp>aTolMax) {
1211 BOPTools_ListOfPaveBlock aLPBx;
1213 anItLPE.Initialize(aLPBE);
1214 for (i=0; anItLPE.More(); anItLPE.Next(), ++i) {
1215 const BOPTools_PaveBlock& aPB=anItLPE.Value();
1224 pLPBE=(BOPTools_ListOfPaveBlock *)&aLPBE;
1226 pLPBE->Append(aLPBx);
1227 }//for (; anIt.More(); anIt.Next()) {
1228 }//for (nE=1; nE<=aNb; ++nE) {
1229 // Contribution of Samtech www.samcef.com END
1232 //=======================================================================
1233 // function: RemoveCommonBlocks
1235 //=======================================================================
1236 void NMTTools_PaveFiller::RemoveCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB)
1238 Standard_Integer nE;
1239 NMTTools_ListOfCommonBlock aLCBx;
1240 NMTTools_ListIteratorOfListOfCommonBlock anItCB, anItCBE;
1241 BOPTools_ListIteratorOfListOfPaveBlock anItLPB;
1243 anItCB.Initialize(aLCB);
1244 for (; anItCB.More(); anItCB.Next()) {
1245 const NMTTools_CommonBlock& aCB=anItCB.Value();
1246 const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
1248 // Remove aCB from each edge
1249 anItLPB.Initialize(aLPB);
1250 for (; anItLPB.More(); anItLPB.Next()) {
1251 const BOPTools_PaveBlock& aPB=anItLPB.Value();
1252 nE=aPB.OriginalEdge();
1254 NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
1255 anItCBE.Initialize(aLCBE);
1256 for (; anItCBE.More(); anItCBE.Next()) {
1257 const NMTTools_CommonBlock& aCBE=anItCBE.Value();
1258 if (aCBE.IsEqual(aCB)) {
1259 aLCBE.Remove(anItCBE);
1267 //=======================================================================
1268 // function: SplitCommonBlock
1270 //=======================================================================
1271 void NMTTools_PaveFiller::SplitCommonBlock(const NMTTools_CommonBlock& aCB,
1272 NMTTools_ListOfCommonBlock& aLCBx)
1274 Standard_Boolean bIsCoincided;
1275 Standard_Integer i, j,nE, aNbE, aNbSPBx, aNbPB, k;
1276 BOPTools_SequenceOfPaveBlock aSPBx;
1277 BOPTools_ListIteratorOfListOfPaveBlock anItLPB;
1278 BOPTools_ListIteratorOfListOfPave anIt;
1279 BOPTools_PaveBlockIterator anPBIt;
1281 const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
1284 // 1. Checking: Whether we realy need to split the common block ?
1285 anItLPB.Initialize(aLPB);
1286 for (; anItLPB.More(); anItLPB.Next()) {
1287 const BOPTools_PaveBlock& aPB=anItLPB.Value();
1288 nE=aPB.OriginalEdge();
1289 BOPTools_PaveSet& aPSE=myPavePoolNew(myDS->RefEdge(nE));
1292 BOPTools_PaveSet aPSx;
1294 const BOPTools_ListOfPave& aLPE=aPSE.Set();
1295 anIt.Initialize(aLPE);
1296 for (; anIt.More(); anIt.Next()) {
1297 const BOPTools_Pave& aPx=anIt.Value();
1298 if (aPB.IsInBlock(aPx)) {
1302 aNbPB=aPSx.Set().Extent();
1307 // we need not split it
1312 // 2. Get sequence of pave Blocks containing all new pave blocks
1313 // for each edges's source pave Block
1314 anItLPB.Initialize(aLPB);
1315 for (; anItLPB.More(); anItLPB.Next()) {
1316 const BOPTools_PaveBlock& aPB=anItLPB.Value();
1317 const BOPTools_Pave& aPave1=aPB.Pave1();
1318 const BOPTools_Pave& aPave2=aPB.Pave2();
1319 nE=aPB.OriginalEdge();
1321 BOPTools_PaveSet aPSx;
1323 // the set aPsx will contain bounadry paves aPave1, aPave2 and
1324 // all paves of the edge nE that are inside block aPB
1325 aPSx.Append(aPave1);
1326 aPSx.Append(aPave2);
1328 BOPTools_PaveSet& aPSE=myPavePoolNew(myDS->RefEdge(nE));
1331 const BOPTools_ListOfPave& aLPE=aPSE.Set();
1332 anIt.Initialize(aLPE);
1333 for (; anIt.More(); anIt.Next()) {
1334 const BOPTools_Pave& aPx=anIt.Value();
1335 if (aPB.IsInBlock(aPx)) {
1340 // Form pave blocks from aPSx and collect them in aSPBx
1341 anPBIt.Initialize(nE, aPSx);
1342 for (; anPBIt.More(); anPBIt.Next()) {
1343 const BOPTools_PaveBlock& aPBx=anPBIt.Value();
1348 // 3. Do new common blocks
1350 const TColStd_ListOfInteger& aLF=aCB.Faces();
1351 aNbSPBx=aSPBx.Length();
1354 Standard_Integer k1, k2, n11, n12, n21, n22;
1356 for (i=1; i<=aNbPB; ++i) {
1357 NMTTools_CommonBlock aCBx;
1361 const BOPTools_PaveBlock& aPB1=aSPBx(i);
1362 n11=aPB1.Pave1().Index();
1363 n12=aPB1.Pave2().Index();
1365 aCBx.AddPaveBlock(aPB1);
1367 for (j=2; j<=aNbE; ++j) {
1370 for(k=k1; k<=k2; ++k) {
1371 const BOPTools_PaveBlock& aPB2=aSPBx(k);
1372 n21=aPB2.Pave1().Index();
1373 n22=aPB2.Pave2().Index();
1374 if ((n21==n11 && n22==n12) || (n21==n12 && n22==n11)) {
1375 //modified by NIZNHY-PKV Thu Nov 11 08:13:24 2010f
1376 bIsCoincided=CheckCoincidence(aPB2, aPB1);
1378 aCBx.AddPaveBlock(aPB2);
1381 //aCBx.AddPaveBlock(aPB2);
1383 //modified by NIZNHY-PKV Thu Nov 11 08:13:31 2010t
1391 //=======================================================================
1392 // function: VertexParameters
1394 //=======================================================================
1395 void VertexParameters(const IntTools_CommonPrt& aCPart,
1399 const IntTools_Range& aR1=aCPart.Range1();
1400 aT1=0.5*(aR1.First()+aR1.Last());
1402 if((aCPart.VertexParameter1() >= aR1.First()) &&
1403 (aCPart.VertexParameter1() <= aR1.Last())) {
1404 aT1 = aCPart.VertexParameter1();
1407 const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2();
1408 const IntTools_Range& aR2=aRanges2(1);
1409 aT2=0.5*(aR2.First()+aR2.Last());
1411 if((aCPart.VertexParameter2() >= aR2.First()) &&
1412 (aCPart.VertexParameter2() <= aR2.Last())) {
1413 aT2 = aCPart.VertexParameter2();
1417 //=======================================================================
1418 // function: KeepPave
1420 //=======================================================================
1421 Standard_Boolean IsOnPave(const Standard_Real& aT1,
1422 const IntTools_Range& aRange,
1423 const Standard_Real& aTolerance)
1425 Standard_Boolean firstisonpave1, firstisonpave2, bIsOnPave;
1427 firstisonpave1 = (Abs(aRange.First() - aT1) < aTolerance);
1428 firstisonpave2 = (Abs(aRange.Last() - aT1) < aTolerance);
1429 bIsOnPave=(firstisonpave1 || firstisonpave2);
1433 //=======================================================================
1434 // function:FindChains
1436 //=======================================================================
1437 void FindChains(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB,
1438 NMTTools_ListOfCommonBlock& aLCB)
1440 Standard_Integer i, j, aNbCB, aNbPB;
1441 BOPTools_IMapOfPaveBlock aProcessedBlocks, aChain;
1443 aNbCB=aMapCB.Extent();
1444 for (i=1; i<=aNbCB; ++i) {
1445 const BOPTools_PaveBlock& aPB=aMapCB.FindKey(i);
1446 if (aProcessedBlocks.Contains(aPB)) {
1450 aProcessedBlocks.Add(aPB);
1453 const BOPTools_IMapOfPaveBlock& aMapPB=aMapCB(i);
1454 aNbPB=aMapPB.Extent();
1455 for (j=1; j<=aNbPB; ++j) {
1456 const BOPTools_PaveBlock& aPBx=aMapPB(j);
1457 ProcessBlock(aPBx, aMapCB, aProcessedBlocks, aChain);
1460 NMTTools_CommonBlock aCB;
1462 aNbPB=aChain.Extent();
1463 for (j=1; j<=aNbPB; ++j) {
1464 const BOPTools_PaveBlock& aPBx=aChain(j);
1465 aCB.AddPaveBlock(aPBx);
1472 //=======================================================================
1473 // function:ProcessBlock
1475 //=======================================================================
1476 void ProcessBlock(const BOPTools_PaveBlock& aPB,
1477 const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB,
1478 BOPTools_IMapOfPaveBlock& aProcessedBlocks,
1479 BOPTools_IMapOfPaveBlock& aChain)
1481 Standard_Integer j, aNbPB;
1483 if (aProcessedBlocks.Contains(aPB)) {
1486 aProcessedBlocks.Add(aPB);
1489 const BOPTools_IMapOfPaveBlock& aMapPB=aMapCB.FindFromKey(aPB);
1490 aNbPB=aMapPB.Extent();
1491 for (j=1; j<=aNbPB; ++j) {
1492 const BOPTools_PaveBlock& aPBx=aMapPB(j);
1493 ProcessBlock(aPBx, aMapCB, aProcessedBlocks, aChain);
1496 // Modified to provide VS interference between
1497 // vertex as result of EE and a Face of argument
1498 // Thu Sep 14 14:35:18 2006
1499 // Contribution of Samtech www.samcef.com BEGIN
1500 //=======================================================================
1501 // function: PerformVF1
1503 //=======================================================================
1504 void NMTTools_PaveFiller::PerformVF1()
1506 Standard_Integer i, aNbEE, n1, n2, nNewShape, aNbS, nF;
1507 Standard_Integer anIndexIn, aFlag;
1508 Standard_Real aU, aV;
1509 TColStd_ListOfInteger aLFI;
1510 TColStd_ListIteratorOfListOfInteger aItLFI;
1512 BOPTools_CArray1OfVSInterference& aVSs=myIP->VSInterferences();
1513 BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences();
1515 aNbS=myDS->NumberOfShapesOfTheObject();
1516 for (i=1; i<=aNbS; ++i) {
1517 const TopoDS_Shape& aF=myDS->Shape(i);
1518 if (aF.ShapeType()==TopAbs_FACE) {
1522 if (!aLFI.Extent()) {
1526 aNbEE=aEEs.Extent();
1527 for (i=1; i<=aNbEE; ++i) {
1528 BOPTools_EEInterference& aEE=aEEs(i);
1529 aEE.Indices(n1, n2);
1530 nNewShape=aEE.NewShape();
1535 const TopoDS_Shape& aSnew=myDS->Shape(nNewShape);
1536 if (aSnew.ShapeType()!=TopAbs_VERTEX) {
1540 const TopoDS_Vertex& aVnew=TopoDS::Vertex(aSnew);
1544 BRepBndLib::Add(aVnew, aBV);
1546 aItLFI.Initialize(aLFI);
1547 for (; aItLFI.More(); aItLFI.Next()) {
1550 const TopoDS_Face& aF=TopoDS::Face(myDS->Shape(nF));
1551 const Bnd_Box& aBF=myDS->GetBoundingBox(nF);
1552 if (aBF.IsOut(aBV)) {
1557 aFlag=myContext->ComputeVS (aVnew, aF, aU, aV);
1559 BOPTools_VSInterference anInterf (nNewShape, nF, aU, aV);
1561 anIndexIn=aVSs.Append(anInterf);
1562 BOPTools_VSInterference& aVS=aVSs(anIndexIn);
1563 aVS.SetNewShape(nNewShape);//->
1568 // Contribution of Samtech www.samcef.com END
1569 //modified by NIZNHY-PKV Thu Nov 11 08:13:48 2010f
1570 //=======================================================================
1571 // function: CheckCoincidence
1573 //=======================================================================
1574 Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock& aPB1,
1575 const BOPTools_PaveBlock& aPB2)
1577 Standard_Boolean bRet;
1578 Standard_Integer nE1, nE2, aNbPoints;
1579 Standard_Real aT11, aT12, aT21, aT22, aT1m, aD, aTol, aT2x;
1582 bRet=Standard_False;
1584 aT11=aPB1.Pave1().Param();
1585 aT12=aPB1.Pave2().Param();
1586 aT1m=IntTools_Tools::IntermediatePoint (aT11, aT12);
1587 nE1=aPB1.OriginalEdge();
1588 const TopoDS_Edge& aE1=(*(TopoDS_Edge*)(&myDS->Shape(nE1)));
1589 BOPTools_Tools::PointOnEdge(aE1, aT1m, aP1m);
1591 aT21=aPB2.Pave1().Param();
1592 aT22=aPB2.Pave2().Param();
1593 nE2=aPB2.OriginalEdge();
1594 const TopoDS_Edge& aE2=(*(TopoDS_Edge*)(&myDS->Shape(nE2)));
1596 GeomAPI_ProjectPointOnCurve& aPPC=myContext->ProjPC(aE2);
1598 aNbPoints=aPPC.NbPoints();
1600 aD=aPPC.LowerDistance();
1602 aTol=BRep_Tool::Tolerance(aE1);
1603 aTol=aTol+BRep_Tool::Tolerance(aE2);
1605 aT2x=aPPC.LowerDistanceParameter();
1606 if (aT2x>aT21 && aT2x<aT22) {
1613 //modified by NIZNHY-PKV Thu Nov 11 08:13:55 2010t