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_6.cxx
23 // Created: Fri Dec 19 10:27:31 2003
24 // Author: Peter KURNEV
26 #include <NMTTools_PaveFiller.ixx>
28 #include <Basics_OCCTVersion.hxx>
30 #include <Precision.hxx>
32 #include <TColStd_IndexedMapOfInteger.hxx>
33 #include <TColStd_MapOfInteger.hxx>
34 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
35 #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
36 #include <TColStd_ListOfInteger.hxx>
37 #include <TColStd_ListIteratorOfListOfInteger.hxx>
38 #include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
41 #include <Geom_TrimmedCurve.hxx>
42 #include <Geom2d_TrimmedCurve.hxx>
43 #include <Geom2d_Curve.hxx>
44 #include <GeomAdaptor_Curve.hxx>
45 #include <GeomAdaptor_Surface.hxx>
46 #include <Geom_Surface.hxx>
48 #include <BndLib_Add3dCurve.hxx>
50 #include <TopoDS_Face.hxx>
52 #include <TopoDS_Compound.hxx>
53 #include <TopoDS_Vertex.hxx>
54 #include <TopoDS_Edge.hxx>
58 #include <BRepLib.hxx>
59 #include <BRep_Builder.hxx>
60 #include <BRep_Tool.hxx>
61 #include <BRepBndLib.hxx>
63 #include <TopTools_IndexedMapOfShape.hxx>
64 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
65 #include <TopTools_ListOfShape.hxx>
66 #include <TopTools_ListIteratorOfListOfShape.hxx>
68 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
69 #include <BOPTColStd_IndexedDataMapOfIntegerInteger.hxx>
71 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
72 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
73 #include <BooleanOperations_OnceExplorer.hxx>
74 #include <BooleanOperations_ShapesDataStructure.hxx>
76 #include <IntTools_SequenceOfPntOn2Faces.hxx>
77 #include <IntTools_SequenceOfCurves.hxx>
78 #include <IntTools_FaceFace.hxx>
79 #include <IntTools_Tools.hxx>
80 #include <IntTools_ShrunkRange.hxx>
81 #include <IntTools_Context.hxx>
83 #include <BOPTools_CArray1OfSSInterference.hxx>
84 #include <BOPTools_VSInterference.hxx>
85 #include <BOPTools_ESInterference.hxx>
86 #include <BOPTools_SSInterference.hxx>
87 #include <BOPTools_ListOfPaveBlock.hxx>
88 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
89 #include <BOPTools_PaveBlock.hxx>
90 #include <BOPTools_ListIteratorOfListOfPave.hxx>
91 #include <BOPTools_Tools.hxx>
92 #include <BOPTools_PaveBlockIterator.hxx>
93 #include <BOPTools_Tools2D.hxx>
94 #include <BOPTools_Tools3D.hxx>
96 #include <NMTDS_Iterator.hxx>
97 #include <NMTDS_ShapesDataStructure.hxx>
98 #include <NMTDS_InterfPool.hxx>
100 #include <NMTTools_Tools.hxx>
101 #include <NMTTools_IndexedDataMapOfShapePaveBlock.hxx>
102 #include <NMTTools_CommonBlock.hxx>
103 #include <NMTTools_CommonBlockAPI.hxx>
104 #include <NMTTools_ListOfCommonBlock.hxx>
105 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
106 #include <NMTTools_DataMapOfIntegerListOfPaveBlock.hxx>
107 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
108 #include <NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx>
109 #include <NMTTools_MapOfPaveBlock.hxx>
110 #include <NMTTools_MapIteratorOfMapOfPaveBlock.hxx>
111 #include <NMTTools_FaceInfo.hxx>
112 #include <NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo.hxx>
115 Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE,
116 IntTools_Context& aCtx);
118 //=======================================================================
119 // function: PerformFF
121 //=======================================================================
122 void NMTTools_PaveFiller::PerformFF()
124 myIsDone=Standard_False;
126 Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone;
127 Standard_Boolean bJustAdd, bToSplit;
128 Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs;
129 Standard_Integer aNbCurves, aNbPoints;
130 Standard_Real anApproxTol, aTolR3D, aTolR2D;
131 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith;
132 IntTools_SequenceOfPntOn2Faces aPnts;
133 IntTools_SequenceOfCurves aCvs;
135 BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
137 // F/F Interferences [BooleanOperations_SurfaceSurface]
138 myDSIt->Initialize(TopAbs_FACE, TopAbs_FACE);
140 // BlockLength correction
141 aNbFFs=myDSIt->BlockLength();
142 aBlockLength=aFFs.BlockLength();
143 if (aNbFFs > aBlockLength) {
144 aFFs.SetBlockLength(aNbFFs);
147 //modified by NIZNHY-PKV Thu Sep 15 08:02:52 2011f
148 bToSplit=Standard_False;
149 //modified by NIZNHY-PKV Thu Sep 15 08:02:55 2011t
151 for (; myDSIt->More(); myDSIt->Next()) {
152 myDSIt->Current(n1, n2, bJustAdd);
164 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv
165 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv
168 bToApproxC3d = mySectionAttribute.Approximation();
169 bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1();
170 bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2();
174 IntTools_FaceFace aFF;
176 aFF.SetParameters (bToApproxC3d, bToApproxC2dOnS1,
177 bToApproxC2dOnS2, anApproxTol);
179 aFF.Perform(aF1, aF2);
181 bIsDone=aFF.IsDone();
184 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
185 anIndexIn=aFFs.Append(anInterf);
189 aTolR3D=aFF.TolReached3d();
190 aTolR2D=aFF.TolReached2d();
191 if (aTolR3D < 1.e-7){
195 //modified by NIZNHY-PKV Thu Sep 15 08:03:02 2011f
196 #if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
197 aFF.PrepareLines3D(bToSplit);
199 aFF.PrepareLines3D();
200 #endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
201 //modified by NIZNHY-PKV Thu Sep 15 08:03:04 2011t
203 const IntTools_SequenceOfCurves& aCvsX=aFF.Lines();
204 const IntTools_SequenceOfPntOn2Faces& aPntsX=aFF.Points();
206 aNbCurves=aCvsX.Length();
207 aNbPoints=aPntsX.Length();
209 if (!aNbCurves && !aNbPoints) {
210 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
211 anIndexIn=aFFs.Append(anInterf);
216 BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvsX, aPntsX);
217 anIndexIn=aFFs.Append(anInterf);
220 }// for (; myDSIt.More(); myDSIt.Next())
222 myIsDone=Standard_True;
225 //=======================================================================
226 // function: MakeBlocks
228 //=======================================================================
229 void NMTTools_PaveFiller::MakeBlocks()
231 myIsDone=Standard_False;
233 Standard_Boolean bIsExistingPaveBlock, bIsValidIn2D, bIsCoincided;
234 Standard_Boolean bIsMicroEdge, bHasES;
235 Standard_Integer i, aNbFFs, nF1, nF2;
236 Standard_Integer nV1, nV2, j, aNbCurves;
237 Standard_Real aTolR3D, aTol2D, aT1, aT2, aTolPPC=Precision::PConfusion();
238 TopoDS_Face aF1, aF2;
239 NMTTools_IndexedDataMapOfShapePaveBlock aMEPB;
240 BooleanOperations_IndexedDataMapOfShapeInteger aMapEI;
241 BOPTools_ListIteratorOfListOfPaveBlock anIt;
243 BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
247 // 1. Make Section Edges from intersection curves
248 // between each pair of faces
249 aNbFFs=aFFs.Extent();
256 for (i=1; i<=aNbFFs; ++i) {
257 BOPTools_ListOfPaveBlock aLPB;
258 TColStd_MapOfInteger aMVStick;
259 TopTools_ListOfShape aLSE;
260 TColStd_ListOfInteger aLNE;
261 BOPTools_PaveSet aPSF;
262 NMTTools_MapOfPaveBlock aMPBX;
263 TColStd_MapIteratorOfMapOfInteger aItMI;
264 NMTTools_MapIteratorOfMapOfPaveBlock aItMPB;
266 BOPTools_SSInterference& aFFi=aFFs(i);
269 aFFi.Indices(nF1, nF2);
270 aF1=*((TopoDS_Face*)(&myDS->Shape(nF1)));
271 aF2=*((TopoDS_Face*)(&myDS->Shape(nF2)));
273 SharedEdges(nF1, nF2, aLNE, aLSE);
274 aFFi.SetSharedEdges(aLNE);
277 const NMTTools_FaceInfo& aFI1=myFaceInfo.Find(nF1);
278 const NMTTools_FaceInfo& aFI2=myFaceInfo.Find(nF2);
280 const TColStd_MapOfInteger& aMVOn1=aFI1.VerticesOn();
281 const TColStd_MapOfInteger& aMVIn1=aFI1.VerticesIn();
282 const TColStd_MapOfInteger& aMVOn2=aFI2.VerticesOn();
283 const TColStd_MapOfInteger& aMVIn2=aFI2.VerticesIn();
285 for (j=0; j<2; ++j) {
286 const TColStd_MapOfInteger& aMV1=(!j) ? aMVOn1 :aMVIn1;
287 aItMI.Initialize(aMV1);
288 for (; aItMI.More(); aItMI.Next()) {
290 if (aMVOn2.Contains(nV1) || aMVIn2.Contains(nV1)) {
297 const NMTTools_MapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn();
298 const NMTTools_MapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn();
299 const NMTTools_MapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn();
300 const NMTTools_MapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn();
303 for (j=0; j<4; ++j) {
304 NMTTools_MapOfPaveBlock *pMPB;
307 pMPB=((NMTTools_MapOfPaveBlock*)&aMPBIn1);
310 pMPB=((NMTTools_MapOfPaveBlock*)&aMPBOn1);
313 pMPB=((NMTTools_MapOfPaveBlock*)&aMPBIn2);
316 pMPB=((NMTTools_MapOfPaveBlock*)&aMPBOn2);
319 const NMTTools_MapOfPaveBlock& aMPB=*pMPB;
320 aItMPB.Initialize(aMPB);
321 for (; aItMPB.More(); aItMPB.Next()) {
322 const BOPTools_PaveBlock& aPB=aItMPB.Key();
323 if (aMPBX.Add(aPB)) {
329 aFFi.AppendBlock(aPB);
336 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
337 aNbCurves=aSCvs.Length();
342 aTolR3D=aFFi.TolR3D();
343 aTol2D=(aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D;
345 CorrectTolR3D(aFFi, aMVStick, aTolR3D);
347 PrepareSetForFace (nF1, nF2, aLPB, aPSF);
349 // Put Paves On Curves
350 for (j=1; j<=aNbCurves; ++j) {
351 BOPTools_Curve& aBC=aSCvs(j);
352 const IntTools_Curve& aC=aBC.Curve();
354 Handle(Geom_Curve) aC3D = aC.Curve();
356 PutPaveOnCurve (aPSF, aTolR3D, aBC);
359 // Put bounding paves on curves
360 for (j=1; j<=aNbCurves; ++j) {
361 BOPTools_Curve& aBC=aSCvs(j);
362 PutBoundPaveOnCurve (aBC, aFFi);
364 //modified by NIZNHY-PKV Wed Sep 14 13:12:14 2011f
365 #if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
367 // Put closing pave if needded
368 for (j=1; j<=aNbCurves; ++j) {
369 BOPTools_Curve& aBC=aSCvs(j);
370 PutClosingPaveOnCurve (aBC, aFFi);
372 #endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
373 //modified by NIZNHY-PKV Wed Sep 14 13:12:17 2011t
375 // Pave Blocks on Curves
376 bHasES=Standard_False;
377 for (j=1; j<=aNbCurves; ++j) {
378 BOPTools_Curve& aBC=aSCvs(j);
379 const IntTools_Curve& aIC= aBC.Curve();
380 BOPTools_PaveSet& aPaveSet=aBC.Set();
382 BOPTools_PaveBlockIterator aPBIter(0, aPaveSet);
383 for (; aPBIter.More(); aPBIter.Next()) {
384 BOPTools_PaveBlock& aPBNew=aPBIter.Value();
385 aPBNew.SetCurve(aIC);
386 aPBNew.SetFace1(nF1);
387 aPBNew.SetFace2(nF2);
389 nV1=aPBNew.Pave1().Index();
390 nV2=aPBNew.Pave2().Index();
391 aT1=aPBNew.Pave1().Param();
392 aT2=aPBNew.Pave2().Param();
394 if((nV1==nV2) && (Abs(aT2 - aT1) < aTolPPC)) {
395 continue;// mkk ft ???
399 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPB, aTolR3D);
400 if (bIsExistingPaveBlock) {
404 bIsCoincided=CheckCoincidence(aPBNew, aLPB);
410 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLSE, aTolR3D);
411 if (bIsExistingPaveBlock) {
415 // Checking of validity in 2D
417 bIsValidIn2D=myContext.IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D);
426 const TopoDS_Vertex aV1=TopoDS::Vertex(myDS->Shape(nV1));
427 const TopoDS_Vertex aV2=TopoDS::Vertex(myDS->Shape(nV2));
432 myContext.IsVertexOnLine(aV1, aIC, aTolR3D, aT);
433 BOPTools_Tools::UpdateVertex (aIC, aT, aV1);
435 myContext.IsVertexOnLine(aV2, aIC, aTolR3D, aT);
436 BOPTools_Tools::UpdateVertex (aIC, aT, aV2);
439 BOPTools_Tools::MakeSectEdge (aIC, aV1, aT1, aV2, aT2, aES);
441 NMTTools_Tools::UpdateEdge (aES, aTolR3D);
442 bIsMicroEdge=IsMicroEdge(aES, myContext);
448 Handle(Geom2d_Curve) aC2D1, aC2D2;
450 aC2D1=aIC.FirstCurve2d();
451 aC2D2=aIC.SecondCurve2d();
453 NMTTools_Tools::MakePCurve(aES, aF1, aC2D1);
454 NMTTools_Tools::MakePCurve(aES, aF2, aC2D2);
457 aMEPB.Add(aES, aPBNew);
460 bHasES=Standard_True;
461 }// for (; aPBIter.More(); aPBIter.Next())
462 } // end of for (j=1; j<=aNbCurves; ++j)
465 myIP->Add(nF1, nF2, Standard_True, NMTDS_TI_FF);
468 }// for (i=1; i<=aNbFFs; ++i)
469 //=============================================================
471 // II. Post treatment
473 // Input data: aMEPB, aMapEI
474 // Result : section edges in myDS
476 Standard_Integer aNbSE;
478 aNbSE=aMEPB.Extent();
480 // there is nothing to do here
485 TopoDS_Compound aCompound;
487 // 1. Make compound from SE
488 aBB.MakeCompound(aCompound);
489 for (i=1; i<=aNbSE; ++i) {
490 const TopoDS_Shape& aSE=aMEPB.FindKey(i);
491 aBB.Add(aCompound, aSE);
495 // 2. Intersect SE using auxiliary Filler
496 NMTTools_PaveFiller tPF;
498 tPF.SetCompositeShape(aCompound);
505 tPF.myPavePool.Resize (tPF.myNbEdges);
513 tPF.myCommonBlockPool.Resize (tPF.myNbEdges);
514 tPF.mySplitShapesPool.Resize (tPF.myNbEdges);
515 tPF.myPavePoolNew .Resize (tPF.myNbEdges);
517 tPF.PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE);
518 tPF.PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE);
522 tPF.RefinePavePool ();
524 tPF.myPavePoolNew.Destroy();
526 tPF.MakeSplitEdges();
527 tPF.UpdateCommonBlocks();
529 // 3. Treatment of the result of intersection
531 Standard_Integer aNbOld, aNbLines, aNbPB, mV1, mV2, nE, mE, iFF;
532 TopAbs_ShapeEnum aType;
533 BOPTools_ListIteratorOfListOfPaveBlock aIt;
534 BOPTColStd_IndexedDataMapOfIntegerInteger aMNewOld;
536 const NMTDS_ShapesDataStructure& tDS=*(tPF.DS());
537 const BOPTools_SplitShapesPool& aSSP=tPF.mySplitShapesPool;
538 const NMTTools_CommonBlockPool& aCBP=tPF.myCommonBlockPool;
540 aNbLines=tDS.NumberOfInsertedShapes();
541 aNbOld=tDS.NumberOfShapesOfTheObject();
543 // 3.1 Links between indices in tDS and DS (kept in aMNewOld)
545 // 3.1.1.Old vertices [ links ]
546 for (i=1; i<=aNbOld; ++i) {
547 const TopoDS_Shape& aV=tDS.Shape(i);
548 aType=aV.ShapeType();
549 if (aType!=TopAbs_VERTEX) {
553 for (j=1; j<=aNbSE; ++j) {
554 const BOPTools_PaveBlock& aPBSE=aMEPB(j);
555 nV1=aPBSE.Pave1().Index();
556 const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
557 if (aV1.IsSame(aV)) {
558 aMNewOld.Add(i, nV1);
561 nV2=aPBSE.Pave2().Index();
562 const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
563 if (aV2.IsSame(aV)) {
564 aMNewOld.Add(i, nV2);
570 // 3.1.2. New vertices [ links ]
571 i=tDS.NumberOfSourceShapes()+1;
572 for (; i<=aNbLines; ++i) {
573 const TopoDS_Shape& aV=tDS.Shape(i);
574 aType=aV.ShapeType();
575 if (aType!=TopAbs_VERTEX) {
579 // Insert new vertex in myDS
580 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
581 myDS->InsertShapeAndAncestorsSuccessors(aV, anASSeq);
582 nV1=myDS->NumberOfInsertedShapes();
584 aMNewOld.Add(i, nV1);
587 // 3.2. Treatment of section edges (SE)
588 for (i=1; i<=aNbOld; ++i) {
589 const TopoDS_Shape& aE=tDS.Shape(i);
590 aType=aE.ShapeType();
591 if (aType!=TopAbs_EDGE) {
595 // block of section edge that we already have for this SE
596 BOPTools_PaveBlock& aPBSE=aMEPB.ChangeFromKey(aE);
598 // Corresponding FF-interference
599 iFF=aMapEI.FindFromKey(aE);
600 BOPTools_SSInterference& aFFi=aFFs(iFF);
601 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
603 BOPTools_Curve& aBC=aSCvs(1);
605 const BOPTools_ListOfPaveBlock& aLPB=aSSP(tDS.RefEdge(i));
609 // no pave blocks -> use aPBSE and whole edge aE
610 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
612 nV1=aPBSE.Pave1().Index();
613 const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
614 nV2=aPBSE.Pave2().Index();
615 const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
617 anASSeq.SetNewSuccessor(nV1);
618 anASSeq.SetNewOrientation(aV1.Orientation());
619 anASSeq.SetNewSuccessor(nV2);
620 anASSeq.SetNewOrientation(aV2.Orientation());
622 myDS->InsertShapeAndAncestorsSuccessors(aE, anASSeq);
623 nE=myDS->NumberOfInsertedShapes();
626 aBC.AppendNewBlock(aPBSE);
634 const NMTTools_ListOfCommonBlock& aLCB=aCBP(tDS.RefEdge(i));
635 NMTTools_CommonBlockAPI aCBAPI(aLCB);
637 aIt.Initialize(aLPB);
638 for (; aIt.More(); aIt.Next()) {
639 BOPTools_PaveBlock aPB=aIt.Value();
641 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));
642 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));
644 if (aCBAPI.IsCommonBlock(aPB)) {
645 // it can be Common Block
646 Standard_Real aTolEx;
647 Handle(Geom2d_Curve) aC2D1, aC2D2;
648 TopoDS_Face aF1FWD, aF2FWD;
650 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
651 //const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
653 aPB=aCB.PaveBlock1();
654 mE=aPB.Edge(); // index of edge in tDS
655 const TopoDS_Edge& aEx=TopoDS::Edge(tDS.Shape(mE));
656 aTolEx=BRep_Tool::Tolerance(aEx);
659 aF1FWD.Orientation(TopAbs_FORWARD);
661 aF2FWD.Orientation(TopAbs_FORWARD);
663 NMTTools_Tools::MakePCurve(aEx, aF1FWD, aC2D1);
664 NMTTools_Tools::MakePCurve(aEx, aF2FWD, aC2D2);
665 NMTTools_Tools::UpdateEdge (aEx, aTolEx);
666 } //if (aCBAPI.IsCommonBlock(aPB))
669 mE=aPB.Edge(); // index of edge in tDS
670 const TopoDS_Shape& aSp=tDS.Shape(mE);
672 const BOPTools_Pave& aPave1=aPB.Pave1();
674 mV1=aPave1.Index(); // index in tDS
675 nV1=aMNewOld.FindFromKey(mV1); // index in myDS
676 const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
678 const BOPTools_Pave& aPave2=aPB.Pave2();
681 nV2=aMNewOld.FindFromKey(mV2);
682 const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
684 if (!aMNewOld.Contains(mE)) {
685 // add new SE to the myDS
686 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
688 anASSeq.SetNewSuccessor(nV1);
689 anASSeq.SetNewOrientation(aV1.Orientation());
691 anASSeq.SetNewSuccessor(nV2);
692 anASSeq.SetNewOrientation(aV2.Orientation());
694 myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq);
695 nE=myDS->NumberOfInsertedShapes();
697 aMNewOld.Add(mE, nE);
700 nE=aMNewOld.FindFromKey(mE);
703 BOPTools_PaveBlock aPBx;
704 BOPTools_Pave aP1, aP2;
720 aBC.AppendNewBlock(aPBx);
721 }// for (; aIt.More(); aIt.Next())
722 }// for (i=1; i<=aNbOld; ++i)
724 myIsDone=Standard_True;
727 //=======================================================================
728 // function: MakePCurves
730 //=======================================================================
731 void NMTTools_PaveFiller::MakePCurves()
733 Standard_Integer i, aNb, nF1, nF2, nE;
734 Standard_Integer aNbCB, aNbF, nSp, nF;
735 TopAbs_ShapeEnum aType;
736 TopoDS_Face aF1FWD, aF2FWD;
737 TColStd_ListIteratorOfListOfInteger aItF;
738 BOPTools_ListIteratorOfListOfPaveBlock anIt;
739 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
741 BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
744 for (i=1; i<=aNb; i++) {
745 BOPTools_SSInterference& aFF=aFFs(i);
746 aFF.Indices(nF1, nF2);
748 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv
749 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv
752 aF1FWD.Orientation(TopAbs_FORWARD);
754 aF2FWD.Orientation(TopAbs_FORWARD);
756 // In, On parts processing
757 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
759 anIt.Initialize(aLPBInOn);
760 for (; anIt.More(); anIt.Next()) {
761 const BOPTools_PaveBlock& aPB=anIt.Value();
763 const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));//mpv
765 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
766 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
769 // Check common blocks between edges and faces
770 // Build P-Curves if they were not built in previos block.
771 // The main case is :arguments for e.g aEdge, aFace -> no FFs,
772 // but p-curves are needed.
774 aNb=myDS->NumberOfShapesOfTheObject();
775 for (i=1; i<=aNb; ++i) {
776 const TopoDS_Shape& aS=myDS->Shape(i);
777 aType=aS.ShapeType();
779 if (aType!=TopAbs_EDGE) {
782 const TopoDS_Edge& aE=TopoDS::Edge(aS);
784 if (BRep_Tool::Degenerated(aE)) {
788 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(i));
794 aItCB.Initialize(aLCB);
795 for (; aItCB.More(); aItCB.Next()) {
796 const NMTTools_CommonBlock& aCB=aItCB.Value();
797 const BOPTools_PaveBlock &aPB1=aCB.PaveBlock1();
799 const TColStd_ListOfInteger& aLF=aCB.Faces();
806 const TopoDS_Edge aSp=TopoDS::Edge(myDS->Shape(nSp));//mpv
808 aItF.Initialize(aLF);
809 for (; aItF.More(); aItF.Next()) {
811 aF1FWD=TopoDS::Face(myDS->Shape(nF));
812 aF1FWD.Orientation(TopAbs_FORWARD);
814 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aSp, aF1FWD);
815 } // for (; aItCB.More(); aItCB.Next()) {
816 }//if (aS.ShapeType()==TopAbs_EDGE) {
820 //=======================================================================
821 // function: IsExistingPaveBlock
823 //=======================================================================
824 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
825 const BOPTools_ListOfPaveBlock& aLPBR,
826 const Standard_Real aTolR3D)
828 Standard_Boolean bFlag;
829 Standard_Integer nVNew1, nVNew2, nV1, nV2, iC;
830 BOPTools_ListIteratorOfListOfPaveBlock anIt;
832 bFlag=Standard_False;
833 nVNew1=aPBNew.Pave1().Index();
834 nVNew2=aPBNew.Pave2().Index();
836 anIt.Initialize(aLPBR);
837 for (; anIt.More(); anIt.Next()) {
838 const BOPTools_PaveBlock& aPBR=anIt.Value();
839 nV1=aPBR.Pave1().Index();
840 nV2=aPBR.Pave2().Index();
841 if (nVNew1==nV1 || nVNew1==nV2 || nVNew2==nV1 || nVNew2==nV2) {
843 iC=CheckIntermediatePoint(aPBNew, aPBR, aTolR3D);
852 //=======================================================================
853 // function: IsExistingPaveBlock
855 //=======================================================================
856 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
857 const TopTools_ListOfShape& aLSE,
858 const Standard_Real aTolR3D)
860 Standard_Boolean bFlag;
861 Standard_Integer aNbSE, iC;
862 Standard_Real aTolE, aTol;
863 TopTools_ListIteratorOfListOfShape anIt;
865 bFlag=Standard_False;
872 anIt.Initialize(aLSE);
873 for (; anIt.More(); anIt.Next()) {
874 const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value());
875 aTolE=BRep_Tool::Tolerance(aE);
880 iC=CheckIntermediatePoint(aPBNew, aE, aTol);
888 //=======================================================================
889 // function: CheckIntermediatePoint
891 //=======================================================================
892 Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
893 const BOPTools_PaveBlock& aPBR,
894 const Standard_Real aTolC)
896 Standard_Integer iVM, nE2;
899 const TopoDS_Edge aE2=TopoDS::Edge(myDS->Shape(nE2));//mpv
900 iVM=CheckIntermediatePoint(aPB, aE2, aTolC);
905 //=======================================================================
906 // function: CheckIntermediatePoint
908 //=======================================================================
909 Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
910 const TopoDS_Edge& aE2,
911 const Standard_Real aTolC)
913 Standard_Real aT11, aT12, aTM, aTmp;
914 Standard_Integer iVM;
920 const BOPTools_Pave& aPave11=aPB.Pave1();
921 aT11=aPave11.Param();
923 const BOPTools_Pave& aPave12=aPB.Pave2();
924 aT12=aPave12.Param();
926 aTM=IntTools_Tools::IntermediatePoint (aT11, aT12);
928 const IntTools_Curve& aIC=aPB.Curve();
931 aBB.MakeVertex (aVM, aPM, aTolC);
933 iVM=myContext.ComputeVE(aVM, aE2, aTmp);
938 //=======================================================================
939 // function: PutBoundPaveOnCurve
941 //=======================================================================
942 void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC,
943 BOPTools_SSInterference& aFFi)
945 Standard_Boolean bHasBounds, bVF;
946 Standard_Integer nF1, nF2;
947 Standard_Real aT1, aT2, aTolR3D;
950 const IntTools_Curve& aIC=aBC.Curve();
951 bHasBounds=aIC.HasBounds ();
957 aIC.Bounds (aT1, aT2, aP1, aP2);
960 aFFi.Indices(nF1, nF2);
961 aTolR3D=aFFi.TolR3D();
963 const TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1));//mpv
964 const TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2));//mpv
966 bVF=myContext.IsValidPointForFaces (aP1, aF1, aF2, aTolR3D);
968 PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi);
971 bVF=myContext.IsValidPointForFaces (aP2, aF1, aF2, aTolR3D);
973 PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi);
977 //=======================================================================
978 // function: PutBoundPaveOnCurve
980 //=======================================================================
981 void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP,
982 const Standard_Real aT,
984 BOPTools_SSInterference& aFFi)
986 Standard_Boolean bFound1, bFound2;
988 Standard_Real aTolV=aFFi.TolR3D();
990 BOPTools_Pave aPave1, aPave2, aPave;
991 BOPTools_PaveSet& aCPS=aBC.Set();
992 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
993 const IntTools_Curve& aIC=aBC.Curve();
995 bFound1=FindPave(aP, aTolV, aCPS , aPave1);
996 bFound2=FindPave(aP, aTolV, aFFiPS, aPave2);
998 if (!bFound1 && !bFound2) {
999 TopoDS_Vertex aNewVertex;
1000 BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex);
1002 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
1003 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
1004 nV=myDS->NumberOfInsertedShapes();
1009 aFFiPS.Append(aPave);
1011 // Append Techno Vertex to the Curve
1012 TColStd_ListOfInteger& aTVs=aBC.TechnoVertices();
1015 if (bFound1 && !bFound2) {
1019 aFFiPS.Append(aPave);
1021 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1022 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
1025 if (!bFound1 && bFound2) {
1031 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1032 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
1036 //=======================================================================
1037 // function: FindPave
1039 //=======================================================================
1040 Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP,
1041 const Standard_Real aTolPV,
1042 const BOPTools_PaveSet& aPS,
1043 BOPTools_Pave& aPave)
1045 Standard_Integer nV;
1046 Standard_Boolean bIsVertex=Standard_False;
1048 const BOPTools_ListOfPave& aLP=aPS.Set();
1049 BOPTools_ListIteratorOfListOfPave anIt(aLP);
1050 for (; anIt.More(); anIt.Next()) {
1051 const BOPTools_Pave& aPC=anIt.Value();
1053 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1054 bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV);
1063 //=======================================================================
1064 // function: PrepareSetForFace
1066 //=======================================================================
1067 void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer ,//nF1,
1068 const Standard_Integer ,//nF2,
1069 const BOPTools_ListOfPaveBlock& aLPBC,
1070 BOPTools_PaveSet& aPSF)
1072 Standard_Integer nV1, nV2;
1073 TColStd_MapOfInteger aMap;
1074 BOPTools_ListIteratorOfListOfPaveBlock anIt;
1076 anIt.Initialize(aLPBC);
1077 for (; anIt.More(); anIt.Next()) {
1078 const BOPTools_PaveBlock& aPB=anIt.Value();
1079 const BOPTools_Pave& aPave1=aPB.Pave1();
1081 if (!aMap.Contains(nV1)) {
1083 aPSF.Append(aPave1);
1085 const BOPTools_Pave& aPave2=aPB.Pave2();
1087 if (!aMap.Contains(nV2)) {
1089 aPSF.Append(aPave2);
1094 //=======================================================================
1095 // function: CheckCoincidence
1097 //=======================================================================
1098 Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock& aPBNew,
1099 const BOPTools_ListOfPaveBlock& aLPBFF)
1101 Standard_Boolean bRet;
1103 Standard_Integer nV11, nV12, nV21, nV22, iVV, iVE, nE2;
1104 Standard_Integer iV, iCount, iCountExt;
1105 BOPTools_ListIteratorOfListOfPaveBlock anIt;
1107 const BOPTools_Pave& aPave11=aPBNew.Pave1();
1108 nV11=aPave11.Index();
1109 const TopoDS_Vertex& aV11=TopoDS::Vertex(myDS->Shape(nV11));
1112 const BOPTools_Pave& aPave12=aPBNew.Pave2();
1113 nV12=aPave12.Index();
1114 const TopoDS_Vertex& aV12=TopoDS::Vertex(myDS->Shape(nV12));
1118 anIt.Initialize(aLPBFF);
1119 for (; anIt.More(); anIt.Next()) {
1122 const BOPTools_PaveBlock& aPBR=anIt.Value();
1124 const BOPTools_Pave& aPave21=aPBR.Pave1();
1125 nV21=aPave21.Index();
1128 const BOPTools_Pave& aPave22=aPBR.Pave2();
1129 nV22=aPave22.Index();
1131 if (nV11==nV21 || nV11==nV22 || nV12==nV21 || nV12==nV22) {
1138 const TopoDS_Vertex& aV21=TopoDS::Vertex(myDS->Shape(nV21));
1139 const TopoDS_Vertex& aV22=TopoDS::Vertex(myDS->Shape(nV22));
1140 const TopoDS_Edge& aE2=TopoDS::Edge(myDS->Shape(nE2));
1144 iVV=IntTools_Tools::ComputeVV (aV11, aV21);
1148 if (iCount>iCountExt) {
1153 iVV=IntTools_Tools::ComputeVV (aV11, aV22);
1157 if (iCount>iCountExt) {
1163 iVE=myContext.ComputeVE (aV11, aE2, aTE);
1166 if (iCount>iCountExt) {
1173 iVV=IntTools_Tools::ComputeVV (aV12, aV21);
1177 if (iCount>iCountExt) {
1182 iVV=IntTools_Tools::ComputeVV (aV12, aV22);
1186 if (iCount>iCountExt) {
1192 iVE=myContext.ComputeVE (aV12, aE2, aTE);
1195 if (iCount>iCountExt) {
1201 bRet=(Standard_Boolean)(iCount>iCountExt);
1205 //=======================================================================
1206 //function : IsMicroEdge
1208 //=======================================================================
1209 Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE,
1210 IntTools_Context& aCtx)
1212 Standard_Boolean bRet;
1213 Standard_Integer iErr;
1214 Standard_Real aT1, aT2, aTmp;
1215 Handle(Geom_Curve) aC3D;
1216 TopoDS_Vertex aV1, aV2;
1219 bRet=(BRep_Tool::Degenerated(aE) ||
1220 !BRep_Tool::IsGeometric(aE));
1225 aC3D=BRep_Tool::Curve(aE, aT1, aT2);
1226 TopExp::Vertices(aE, aV1, aV2);
1227 aT1=BRep_Tool::Parameter(aV1, aE);
1228 aT2=BRep_Tool::Parameter(aV2, aE);
1237 IntTools_ShrunkRange aSR (aE, aV1, aV2, aR, aCtx);
1238 iErr=aSR.ErrorStatus();
1243 //=======================================================================
1244 // function: PutPaveOnCurve
1246 //=======================================================================
1247 void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
1248 const Standard_Real aTolR3D,
1249 BOPTools_Curve& aBC)
1251 Standard_Integer nV;
1252 Standard_Boolean bIsVertexOnLine;
1254 BOPTools_ListIteratorOfListOfPave anIt;
1256 GeomAdaptor_Curve aGAC;
1258 const IntTools_Curve& aC=aBC.Curve();
1259 Handle (Geom_Curve) aC3D= aC.Curve();
1261 BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBBC);
1263 const BOPTools_ListOfPave& aLP=aPaveSet.Set();
1264 anIt.Initialize(aLP);
1265 for (; anIt.More(); anIt.Next()) {
1266 const BOPTools_Pave& aPave=anIt.Value();
1269 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));
1272 BRepBndLib::Add(aV, aBBV);
1273 if (aBBC.IsOut(aBBV)){
1277 bIsVertexOnLine=myContext.IsVertexOnLine(aV, aC, aTolR3D, aT);
1280 if (bIsVertexOnLine) {
1281 BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface);
1282 BOPTools_PaveSet& aPS=aBC.Set();
1283 aPS.Append(aPaveNew);
1289 //=======================================================================
1290 //function : FillFaceInfo
1292 //=======================================================================
1293 void NMTTools_PaveFiller::FillFaceInfo()
1295 Standard_Integer i, aNbS, aNbFFs, nF, aNbVFs, aNbEFs, j, n1, n2, nX, aNbF;
1296 TopAbs_ShapeEnum aType;
1298 TColStd_ListIteratorOfListOfInteger aItF;
1299 BOPTools_ListIteratorOfListOfPaveBlock anItPB;
1300 NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo aItMFI;
1301 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
1305 BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
1306 BOPTools_CArray1OfVSInterference& aVFs=myIP->VSInterferences();
1307 BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
1309 aNbFFs=aFFs.Extent();
1315 for (i=1; i<=aNbFFs; ++i) {
1316 NMTTools_FaceInfo aFI;
1318 BOPTools_SSInterference& aFFi=aFFs(i);
1319 aFFi.Indices(n1, n2);
1320 myFaceInfo.Bind(n1, aFI);
1321 myFaceInfo.Bind(n2, aFI);
1325 aNbS=myDS->NumberOfShapesOfTheObject();
1326 for (i=1; i<=aNbS; ++i) {
1328 aType=aS.ShapeType();
1329 if (aType==TopAbs_EDGE) {
1330 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(i));
1331 aItCB.Initialize(aLCB);
1332 for (; aItCB.More(); aItCB.Next()) {
1333 const NMTTools_CommonBlock& aCB=aItCB.Value();
1334 const BOPTools_PaveBlock &aPB1=aCB.PaveBlock1();
1335 const TColStd_ListOfInteger& aLF=aCB.Faces();
1341 aItF.Initialize(aLF);
1342 for (; aItF.More(); aItF.Next()) {
1344 if (!myFaceInfo.IsBound(nF)) {
1348 NMTTools_FaceInfo& aFI=myFaceInfo.ChangeFind(nF);
1349 aFI.ChangePaveBlocksIn().Add(aPB1);
1351 n1=aPB1.Pave1().Index();
1352 n2=aPB1.Pave2().Index();
1353 aFI.ChangeVerticesIn().Add(n1);
1354 aFI.ChangeVerticesIn().Add(n2);
1357 }// if (aType==TopAbs_EDGE) {
1358 else if (aType==TopAbs_FACE) {
1359 if (!myFaceInfo.IsBound(i)) {
1363 BOPTools_ListOfPaveBlock aLPBOn;
1366 NMTTools_FaceInfo& aFI=myFaceInfo.ChangeFind(nF);
1368 RealSplitsFace(nF, aLPBOn);
1370 anItPB.Initialize(aLPBOn);
1371 for (; anItPB.More(); anItPB.Next()) {
1372 const BOPTools_PaveBlock &aPB=anItPB.Value();
1373 aFI.ChangePaveBlocksOn().Add(aPB);
1375 n1=aPB.Pave1().Index();
1376 n2=aPB.Pave2().Index();
1377 aFI.ChangeVerticesOn().Add(n1);
1378 aFI.ChangeVerticesOn().Add(n2);
1381 }// else if (aType==TopAbs_FACE) {
1382 }// for (i=1; i<=aNbS; ++i) {
1385 aItMFI.Initialize(myFaceInfo);
1386 for (; aItMFI.More(); aItMFI.Next()) {
1388 NMTTools_FaceInfo& aFI=*((NMTTools_FaceInfo*)&aItMFI.Value());
1394 aNbVFs=aVFs.Extent();
1395 for (j=1; j<=aNbVFs; ++j) {
1396 BOPTools_VSInterference& aVFj=aVFs(j);
1397 aVFj.Indices(n1, n2);
1399 aFI.ChangeVerticesIn().Add(n2);
1402 aFI.ChangeVerticesIn().Add(n1);
1404 }// for (j=1; j<=aNbVFs; ++j) {
1407 aNbEFs=aEFs.Extent();
1408 for (j=1; j<=aNbEFs; ++j) {
1409 BOPTools_ESInterference& aEFj=aEFs(j);
1410 aEFj.Indices(n1, n2);
1411 if (!(nF==n1 || nF==n2)) {
1421 aType=aS.ShapeType();
1422 if (aType!=TopAbs_VERTEX) {
1426 aFI.ChangeVerticesIn().Add(nX);
1427 }// for (j=1; j<=aNbEFs; ++j) {
1428 }// for (; aItMFI.More(); aItMFI.Next()) {
1432 #include <gp_Pnt.hxx>
1433 #include <gp_Dir.hxx>
1434 #include <gp_Vec.hxx>
1435 #include <GeomAPI_ProjectPointOnSurf.hxx>
1436 //=======================================================================
1437 //function : CorrectTolR3D
1438 //purpose : Attempt to correct the value of tolerance aTolR3D for
1439 // the intersection curve in order to
1440 // compel it to pass through the sticks.
1442 // 2. The are based on B-Spline surfaces;
1443 // 1. There is at least the one intersection curve;
1444 // 2. The faces have stick vertices to catch the curve;
1445 // 3. The intersection angle is rather small (0.7-7 deg)
1447 //=======================================================================
1448 void NMTTools_PaveFiller::CorrectTolR3D(const BOPTools_SSInterference& aFF,
1449 const TColStd_MapOfInteger& aMVStick,
1450 Standard_Real& aTolR3D)
1453 Standard_Boolean bHasBounds;
1454 Standard_Integer i, nF[2], nV, aNbCurves;
1455 Standard_Real aT1, aT2, aU, aV, aT, aA, aTolV, aTolVmax;
1456 Standard_Real aTolR, aTolTresh, aAmin, aAmax;
1457 TColStd_MapIteratorOfMapOfInteger aIt;
1458 gp_Pnt aP, aP1, aP2;
1461 Handle(Geom_Surface) aS[2];
1462 Handle(Geom_Curve) aC3D;
1463 GeomAdaptor_Surface aGAS;
1464 GeomAbs_SurfaceType aType;
1468 aAmin=0.012;// 0.7-7 deg
1471 if (!aMVStick.Extent()) {
1475 BOPTools_SSInterference& aFFi=*((BOPTools_SSInterference*)&aFF);
1476 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
1477 aNbCurves=aSCvs.Length();
1482 aFFi.Indices(nF[0], nF[1]);
1483 for (i=0; i<2; ++i) {
1484 aF[i]=*((TopoDS_Face*)(&myDS->Shape(nF[i])));
1485 aS[i]=BRep_Tool::Surface(aF[i]);
1487 aType=aGAS.GetType();
1488 if (aType!=GeomAbs_BSplineSurface) {
1493 BOPTools_Curve& aBC=aSCvs(1);
1494 const IntTools_Curve& aIC=aBC.Curve();
1495 bHasBounds=aIC.HasBounds();
1500 aIC.Bounds (aT1, aT2, aP1, aP2);
1501 aT=IntTools_Tools::IntermediatePoint(aT1, aT2);
1505 for (i=0; i<2; ++i) {
1506 GeomAPI_ProjectPointOnSurf& aPPS=myContext.ProjPS(aF[i]);
1508 aPPS.LowerDistanceParameters(aU, aV);
1509 BOPTools_Tools3D::GetNormalToSurface(aS[i], aU, aV, aDN[i]);
1512 aA=aDN[0].Angle(aDN[1]);
1518 if (aA<aAmin || aA>aAmax) {
1523 aIt.Initialize(aMVStick);
1524 for (; aIt.More(); aIt.Next()) {
1526 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)(&myDS->Shape(nV)));
1527 aTolV=BRep_Tool::Tolerance(aV);
1528 if (aTolV>aTolVmax) {
1535 if (aTolR<aTolTresh) {
1540 //modified by NIZNHY-PKV Wed Sep 14 13:21:13 2011f
1541 #if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
1542 //=======================================================================
1543 // function: PutClosingPaveOnCurve
1545 //=======================================================================
1546 void NMTTools_PaveFiller::PutClosingPaveOnCurve(BOPTools_Curve& aBC,
1547 BOPTools_SSInterference& aFFi)
1549 Standard_Boolean bIsClosed, bHasBounds, bAdded;
1550 Standard_Integer nVC, j;
1551 Standard_Real aT[2], aTolR3D, aTC, dT, aTx;
1554 BOPTools_ListIteratorOfListOfPave aItLP;
1556 const IntTools_Curve& aIC=aBC.Curve();
1557 const Handle (Geom_Curve)& aC3D=aIC.Curve();
1562 bIsClosed=IntTools_Tools::IsClosed(aC3D);
1567 bHasBounds=aIC.HasBounds ();
1572 bAdded=Standard_False;
1573 dT=Precision::PConfusion();
1574 aTolR3D=aFFi.TolR3D();
1575 aIC.Bounds (aT[0], aT[1], aP[0], aP[1]);
1577 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
1578 BOPTools_PaveSet& aCPS=aBC.Set();
1580 const BOPTools_ListOfPave& aLP=aCPS.Set();
1581 aItLP.Initialize(aLP);
1582 for (; aItLP.More() && !bAdded; aItLP.Next()) {
1583 const BOPTools_Pave& aPC=aItLP.Value();
1585 const TopoDS_Vertex aVC=TopoDS::Vertex(myDS->Shape(nVC));
1588 for (j=0; j<2; ++j) {
1589 if (fabs(aTC-aT[j]) < dT) {
1590 aTx=(!j) ? aT[1] : aT[0];
1595 aFFiPS.Append(aPVx);
1597 bAdded=Standard_True;
1603 #endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
1604 //modified by NIZNHY-PKV Wed Sep 14 13:21:17 2011t