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_6.cxx
23 // Created: Fri Dec 19 10:27:31 2003
24 // Author: Peter KURNEV
26 #include <NMTTools_PaveFiller.hxx>
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>
95 #include <BOPTools_Curve.hxx>
97 #include <NMTDS_Iterator.hxx>
98 #include <NMTDS_ShapesDataStructure.hxx>
99 #include <NMTDS_InterfPool.hxx>
101 #include <NMTTools_Tools.hxx>
102 #include <NMTTools_IndexedDataMapOfShapePaveBlock.hxx>
103 #include <NMTTools_CommonBlock.hxx>
104 #include <NMTTools_CommonBlockAPI.hxx>
105 #include <NMTTools_ListOfCommonBlock.hxx>
106 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
107 #include <NMTTools_DataMapOfIntegerListOfPaveBlock.hxx>
108 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
109 #include <NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx>
110 #include <NMTTools_MapOfPaveBlock.hxx>
111 #include <NMTTools_MapIteratorOfMapOfPaveBlock.hxx>
112 #include <NMTTools_FaceInfo.hxx>
113 #include <NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo.hxx>
116 Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE,
117 const Handle(IntTools_Context)& aCtx);
119 //=======================================================================
120 // function: PerformFF
122 //=======================================================================
123 void NMTTools_PaveFiller::PerformFF()
125 myIsDone=Standard_False;
127 Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone;
128 Standard_Boolean bJustAdd, bToSplit;
129 Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs;
130 Standard_Integer aNbCurves, aNbPoints;
131 Standard_Real anApproxTol, aTolR3D, aTolR2D;
132 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith;
133 IntTools_SequenceOfPntOn2Faces aPnts;
134 IntTools_SequenceOfCurves aCvs;
136 BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
138 // F/F Interferences [BooleanOperations_SurfaceSurface]
139 myDSIt->Initialize(TopAbs_FACE, TopAbs_FACE);
141 // BlockLength correction
142 aNbFFs=myDSIt->BlockLength();
143 aBlockLength=aFFs.BlockLength();
144 if (aNbFFs > aBlockLength) {
145 aFFs.SetBlockLength(aNbFFs);
148 //modified by NIZNHY-PKV Thu Sep 15 08:02:52 2011f
149 bToSplit=Standard_False;
150 //modified by NIZNHY-PKV Thu Sep 15 08:02:55 2011t
152 for (; myDSIt->More(); myDSIt->Next()) {
153 myDSIt->Current(n1, n2, bJustAdd);
165 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv
166 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv
169 bToApproxC3d = mySectionAttribute.Approximation();
170 bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1();
171 bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2();
175 IntTools_FaceFace aFF;
177 aFF.SetParameters (bToApproxC3d, bToApproxC2dOnS1,
178 bToApproxC2dOnS2, anApproxTol);
180 aFF.Perform(aF1, aF2);
182 bIsDone=aFF.IsDone();
185 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
186 anIndexIn=aFFs.Append(anInterf);
190 aTolR3D=aFF.TolReached3d();
191 aTolR2D=aFF.TolReached2d();
192 if (aTolR3D < 1.e-7){
196 //modified by NIZNHY-PKV Thu Sep 15 08:03:02 2011f
197 #if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
198 aFF.PrepareLines3D(bToSplit);
200 aFF.PrepareLines3D();
201 #endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
202 //modified by NIZNHY-PKV Thu Sep 15 08:03:04 2011t
204 const IntTools_SequenceOfCurves& aCvsX=aFF.Lines();
205 const IntTools_SequenceOfPntOn2Faces& aPntsX=aFF.Points();
207 aNbCurves=aCvsX.Length();
208 aNbPoints=aPntsX.Length();
210 if (!aNbCurves && !aNbPoints) {
211 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
212 anIndexIn=aFFs.Append(anInterf);
217 BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvsX, aPntsX);
218 anIndexIn=aFFs.Append(anInterf);
221 }// for (; myDSIt.More(); myDSIt.Next())
223 myIsDone=Standard_True;
226 //=======================================================================
227 // function: MakeBlocks
229 //=======================================================================
230 void NMTTools_PaveFiller::MakeBlocks()
232 myIsDone=Standard_False;
234 Standard_Boolean bIsExistingPaveBlock, bIsValidIn2D, bIsCoincided;
235 Standard_Boolean bIsMicroEdge, bHasES;
236 Standard_Integer i, aNbFFs, nF1, nF2;
237 Standard_Integer nV1, nV2, j, aNbCurves;
238 Standard_Real aTolR3D, aTol2D, aT1, aT2, aTolPPC=Precision::PConfusion();
239 TopoDS_Face aF1, aF2;
240 NMTTools_IndexedDataMapOfShapePaveBlock aMEPB;
241 BooleanOperations_IndexedDataMapOfShapeInteger aMapEI;
242 BOPTools_ListIteratorOfListOfPaveBlock anIt;
244 BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
248 // 1. Make Section Edges from intersection curves
249 // between each pair of faces
250 aNbFFs=aFFs.Extent();
257 for (i=1; i<=aNbFFs; ++i) {
258 BOPTools_ListOfPaveBlock aLPB;
259 TColStd_MapOfInteger aMVStick;
260 TopTools_ListOfShape aLSE;
261 TColStd_ListOfInteger aLNE;
262 BOPTools_PaveSet aPSF;
263 NMTTools_MapOfPaveBlock aMPBX;
264 TColStd_MapIteratorOfMapOfInteger aItMI;
265 NMTTools_MapIteratorOfMapOfPaveBlock aItMPB;
267 BOPTools_SSInterference& aFFi=aFFs(i);
270 aFFi.Indices(nF1, nF2);
271 aF1=*((TopoDS_Face*)(&myDS->Shape(nF1)));
272 aF2=*((TopoDS_Face*)(&myDS->Shape(nF2)));
274 SharedEdges(nF1, nF2, aLNE, aLSE);
275 aFFi.SetSharedEdges(aLNE);
278 const NMTTools_FaceInfo& aFI1=myFaceInfo.Find(nF1);
279 const NMTTools_FaceInfo& aFI2=myFaceInfo.Find(nF2);
281 const TColStd_MapOfInteger& aMVOn1=aFI1.VerticesOn();
282 const TColStd_MapOfInteger& aMVIn1=aFI1.VerticesIn();
283 const TColStd_MapOfInteger& aMVOn2=aFI2.VerticesOn();
284 const TColStd_MapOfInteger& aMVIn2=aFI2.VerticesIn();
286 for (j=0; j<2; ++j) {
287 const TColStd_MapOfInteger& aMV1=(!j) ? aMVOn1 :aMVIn1;
288 aItMI.Initialize(aMV1);
289 for (; aItMI.More(); aItMI.Next()) {
291 if (aMVOn2.Contains(nV1) || aMVIn2.Contains(nV1)) {
298 const NMTTools_MapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn();
299 const NMTTools_MapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn();
300 const NMTTools_MapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn();
301 const NMTTools_MapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn();
304 for (j=0; j<4; ++j) {
305 NMTTools_MapOfPaveBlock *pMPB;
308 pMPB=((NMTTools_MapOfPaveBlock*)&aMPBIn1);
311 pMPB=((NMTTools_MapOfPaveBlock*)&aMPBOn1);
314 pMPB=((NMTTools_MapOfPaveBlock*)&aMPBIn2);
317 pMPB=((NMTTools_MapOfPaveBlock*)&aMPBOn2);
320 const NMTTools_MapOfPaveBlock& aMPB=*pMPB;
321 aItMPB.Initialize(aMPB);
322 for (; aItMPB.More(); aItMPB.Next()) {
323 const BOPTools_PaveBlock& aPB=aItMPB.Key();
324 if (aMPBX.Add(aPB)) {
330 aFFi.AppendBlock(aPB);
337 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
338 aNbCurves=aSCvs.Length();
343 aTolR3D=aFFi.TolR3D();
344 aTol2D=(aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D;
346 CorrectTolR3D(aFFi, aMVStick, aTolR3D);
348 PrepareSetForFace (nF1, nF2, aLPB, aPSF);
350 // Put Paves On Curves
351 for (j=1; j<=aNbCurves; ++j) {
352 BOPTools_Curve& aBC=aSCvs(j);
353 const IntTools_Curve& aC=aBC.Curve();
355 Handle(Geom_Curve) aC3D = aC.Curve();
357 PutPaveOnCurve (aPSF, aTolR3D, aBC);
360 // Put bounding paves on curves
361 for (j=1; j<=aNbCurves; ++j) {
362 BOPTools_Curve& aBC=aSCvs(j);
363 PutBoundPaveOnCurve (aBC, aFFi);
365 //modified by NIZNHY-PKV Wed Sep 14 13:12:14 2011f
366 #if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
368 // Put closing pave if needded
369 for (j=1; j<=aNbCurves; ++j) {
370 BOPTools_Curve& aBC=aSCvs(j);
371 PutClosingPaveOnCurve (aBC, aFFi);
373 #endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
374 //modified by NIZNHY-PKV Wed Sep 14 13:12:17 2011t
376 // Pave Blocks on Curves
377 bHasES=Standard_False;
378 for (j=1; j<=aNbCurves; ++j) {
379 BOPTools_Curve& aBC=aSCvs(j);
380 const IntTools_Curve& aIC= aBC.Curve();
381 BOPTools_PaveSet& aPaveSet=aBC.Set();
383 BOPTools_PaveBlockIterator aPBIter(0, aPaveSet);
384 for (; aPBIter.More(); aPBIter.Next()) {
385 BOPTools_PaveBlock& aPBNew=aPBIter.Value();
386 aPBNew.SetCurve(aIC);
387 aPBNew.SetFace1(nF1);
388 aPBNew.SetFace2(nF2);
390 nV1=aPBNew.Pave1().Index();
391 nV2=aPBNew.Pave2().Index();
392 aT1=aPBNew.Pave1().Param();
393 aT2=aPBNew.Pave2().Param();
395 if((nV1==nV2) && (Abs(aT2 - aT1) < aTolPPC)) {
396 continue;// mkk ft ???
400 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPB, aTolR3D);
401 if (bIsExistingPaveBlock) {
405 bIsCoincided=CheckCoincidence(aPBNew, aLPB);
411 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLSE, aTolR3D);
412 if (bIsExistingPaveBlock) {
416 // Checking of validity in 2D
418 bIsValidIn2D=myContext->IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D);
427 const TopoDS_Vertex aV1=TopoDS::Vertex(myDS->Shape(nV1));
428 const TopoDS_Vertex aV2=TopoDS::Vertex(myDS->Shape(nV2));
433 myContext->IsVertexOnLine(aV1, aIC, aTolR3D, aT);
434 BOPTools_Tools::UpdateVertex (aIC, aT, aV1);
436 myContext->IsVertexOnLine(aV2, aIC, aTolR3D, aT);
437 BOPTools_Tools::UpdateVertex (aIC, aT, aV2);
440 BOPTools_Tools::MakeSectEdge (aIC, aV1, aT1, aV2, aT2, aES);
442 NMTTools_Tools::UpdateEdge (aES, aTolR3D);
443 bIsMicroEdge=IsMicroEdge(aES, myContext);
449 Handle(Geom2d_Curve) aC2D1, aC2D2;
451 aC2D1=aIC.FirstCurve2d();
452 aC2D2=aIC.SecondCurve2d();
454 NMTTools_Tools::MakePCurve(aES, aF1, aC2D1);
455 NMTTools_Tools::MakePCurve(aES, aF2, aC2D2);
458 aMEPB.Add(aES, aPBNew);
461 bHasES=Standard_True;
462 }// for (; aPBIter.More(); aPBIter.Next())
463 } // end of for (j=1; j<=aNbCurves; ++j)
466 myIP->Add(nF1, nF2, Standard_True, NMTDS_TI_FF);
469 }// for (i=1; i<=aNbFFs; ++i)
470 //=============================================================
472 // II. Post treatment
474 // Input data: aMEPB, aMapEI
475 // Result : section edges in myDS
477 Standard_Integer aNbSE;
479 aNbSE=aMEPB.Extent();
481 // there is nothing to do here
486 TopoDS_Compound aCompound;
488 // 1. Make compound from SE
489 aBB.MakeCompound(aCompound);
490 for (i=1; i<=aNbSE; ++i) {
491 const TopoDS_Shape& aSE=aMEPB.FindKey(i);
492 aBB.Add(aCompound, aSE);
496 // 2. Intersect SE using auxiliary Filler
497 NMTTools_PaveFiller tPF;
499 tPF.SetCompositeShape(aCompound);
506 tPF.myPavePool.Resize (tPF.myNbEdges);
514 tPF.myCommonBlockPool.Resize (tPF.myNbEdges);
515 tPF.mySplitShapesPool.Resize (tPF.myNbEdges);
516 tPF.myPavePoolNew .Resize (tPF.myNbEdges);
518 tPF.PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE);
519 tPF.PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE);
523 tPF.RefinePavePool ();
525 tPF.myPavePoolNew.Destroy();
527 tPF.MakeSplitEdges();
528 tPF.UpdateCommonBlocks();
530 // 3. Treatment of the result of intersection
532 Standard_Integer aNbOld, aNbLines, aNbPB, mV1, mV2, nE, mE, iFF;
533 TopAbs_ShapeEnum aType;
534 BOPTools_ListIteratorOfListOfPaveBlock aIt;
535 BOPTColStd_IndexedDataMapOfIntegerInteger aMNewOld;
537 const NMTDS_ShapesDataStructure& tDS=*(tPF.DS());
538 const BOPTools_SplitShapesPool& aSSP=tPF.mySplitShapesPool;
539 const NMTTools_CommonBlockPool& aCBP=tPF.myCommonBlockPool;
541 aNbLines=tDS.NumberOfInsertedShapes();
542 aNbOld=tDS.NumberOfShapesOfTheObject();
544 // 3.1 Links between indices in tDS and DS (kept in aMNewOld)
546 // 3.1.1.Old vertices [ links ]
547 for (i=1; i<=aNbOld; ++i) {
548 const TopoDS_Shape& aV=tDS.Shape(i);
549 aType=aV.ShapeType();
550 if (aType!=TopAbs_VERTEX) {
554 for (j=1; j<=aNbSE; ++j) {
555 const BOPTools_PaveBlock& aPBSE=aMEPB(j);
556 nV1=aPBSE.Pave1().Index();
557 const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
558 if (aV1.IsSame(aV)) {
559 aMNewOld.Add(i, nV1);
562 nV2=aPBSE.Pave2().Index();
563 const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
564 if (aV2.IsSame(aV)) {
565 aMNewOld.Add(i, nV2);
571 // 3.1.2. New vertices [ links ]
572 i=tDS.NumberOfSourceShapes()+1;
573 for (; i<=aNbLines; ++i) {
574 const TopoDS_Shape& aV=tDS.Shape(i);
575 aType=aV.ShapeType();
576 if (aType!=TopAbs_VERTEX) {
580 // Insert new vertex in myDS
581 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
582 myDS->InsertShapeAndAncestorsSuccessors(aV, anASSeq);
583 nV1=myDS->NumberOfInsertedShapes();
585 aMNewOld.Add(i, nV1);
588 // 3.2. Treatment of section edges (SE)
589 for (i=1; i<=aNbOld; ++i) {
590 const TopoDS_Shape& aE=tDS.Shape(i);
591 aType=aE.ShapeType();
592 if (aType!=TopAbs_EDGE) {
596 // block of section edge that we already have for this SE
597 BOPTools_PaveBlock& aPBSE=aMEPB.ChangeFromKey(aE);
599 // Corresponding FF-interference
600 iFF=aMapEI.FindFromKey(aE);
601 BOPTools_SSInterference& aFFi=aFFs(iFF);
602 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
604 BOPTools_Curve& aBC=aSCvs(1);
606 const BOPTools_ListOfPaveBlock& aLPB=aSSP(tDS.RefEdge(i));
610 // no pave blocks -> use aPBSE and whole edge aE
611 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
613 nV1=aPBSE.Pave1().Index();
614 const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
615 nV2=aPBSE.Pave2().Index();
616 const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
618 anASSeq.SetNewSuccessor(nV1);
619 anASSeq.SetNewOrientation(aV1.Orientation());
620 anASSeq.SetNewSuccessor(nV2);
621 anASSeq.SetNewOrientation(aV2.Orientation());
623 myDS->InsertShapeAndAncestorsSuccessors(aE, anASSeq);
624 nE=myDS->NumberOfInsertedShapes();
627 aBC.AppendNewBlock(aPBSE);
635 const NMTTools_ListOfCommonBlock& aLCB=aCBP(tDS.RefEdge(i));
636 NMTTools_CommonBlockAPI aCBAPI(aLCB);
638 aIt.Initialize(aLPB);
639 for (; aIt.More(); aIt.Next()) {
640 BOPTools_PaveBlock aPB=aIt.Value();
642 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));
643 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));
645 if (aCBAPI.IsCommonBlock(aPB)) {
646 // it can be Common Block
647 Standard_Real aTolEx;
648 Handle(Geom2d_Curve) aC2D1, aC2D2;
649 TopoDS_Face aF1FWD, aF2FWD;
651 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
652 //const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
654 aPB=aCB.PaveBlock1();
655 mE=aPB.Edge(); // index of edge in tDS
656 const TopoDS_Edge& aEx=TopoDS::Edge(tDS.Shape(mE));
657 aTolEx=BRep_Tool::Tolerance(aEx);
660 aF1FWD.Orientation(TopAbs_FORWARD);
662 aF2FWD.Orientation(TopAbs_FORWARD);
664 NMTTools_Tools::MakePCurve(aEx, aF1FWD, aC2D1);
665 NMTTools_Tools::MakePCurve(aEx, aF2FWD, aC2D2);
666 NMTTools_Tools::UpdateEdge (aEx, aTolEx);
667 } //if (aCBAPI.IsCommonBlock(aPB))
670 mE=aPB.Edge(); // index of edge in tDS
671 const TopoDS_Shape& aSp=tDS.Shape(mE);
673 const BOPTools_Pave& aPave1=aPB.Pave1();
675 mV1=aPave1.Index(); // index in tDS
676 nV1=aMNewOld.FindFromKey(mV1); // index in myDS
677 const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
679 const BOPTools_Pave& aPave2=aPB.Pave2();
682 nV2=aMNewOld.FindFromKey(mV2);
683 const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
685 if (!aMNewOld.Contains(mE)) {
686 // add new SE to the myDS
687 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
689 anASSeq.SetNewSuccessor(nV1);
690 anASSeq.SetNewOrientation(aV1.Orientation());
692 anASSeq.SetNewSuccessor(nV2);
693 anASSeq.SetNewOrientation(aV2.Orientation());
695 myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq);
696 nE=myDS->NumberOfInsertedShapes();
698 aMNewOld.Add(mE, nE);
701 nE=aMNewOld.FindFromKey(mE);
704 BOPTools_PaveBlock aPBx;
705 BOPTools_Pave aP1, aP2;
721 aBC.AppendNewBlock(aPBx);
722 }// for (; aIt.More(); aIt.Next())
723 }// for (i=1; i<=aNbOld; ++i)
725 myIsDone=Standard_True;
728 //=======================================================================
729 // function: MakePCurves
731 //=======================================================================
732 void NMTTools_PaveFiller::MakePCurves()
734 Standard_Integer i, aNb, nF1, nF2, nE;
735 Standard_Integer aNbCB, aNbF, nSp, nF;
736 TopAbs_ShapeEnum aType;
737 TopoDS_Face aF1FWD, aF2FWD;
738 TColStd_ListIteratorOfListOfInteger aItF;
739 BOPTools_ListIteratorOfListOfPaveBlock anIt;
740 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
742 BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
745 for (i=1; i<=aNb; i++) {
746 BOPTools_SSInterference& aFF=aFFs(i);
747 aFF.Indices(nF1, nF2);
749 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv
750 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv
753 aF1FWD.Orientation(TopAbs_FORWARD);
755 aF2FWD.Orientation(TopAbs_FORWARD);
757 // In, On parts processing
758 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
760 anIt.Initialize(aLPBInOn);
761 for (; anIt.More(); anIt.Next()) {
762 const BOPTools_PaveBlock& aPB=anIt.Value();
764 const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));//mpv
766 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
767 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
770 // Check common blocks between edges and faces
771 // Build P-Curves if they were not built in previos block.
772 // The main case is :arguments for e.g aEdge, aFace -> no FFs,
773 // but p-curves are needed.
775 aNb=myDS->NumberOfShapesOfTheObject();
776 for (i=1; i<=aNb; ++i) {
777 const TopoDS_Shape& aS=myDS->Shape(i);
778 aType=aS.ShapeType();
780 if (aType!=TopAbs_EDGE) {
783 const TopoDS_Edge& aE=TopoDS::Edge(aS);
785 if (BRep_Tool::Degenerated(aE)) {
789 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(i));
795 aItCB.Initialize(aLCB);
796 for (; aItCB.More(); aItCB.Next()) {
797 const NMTTools_CommonBlock& aCB=aItCB.Value();
798 const BOPTools_PaveBlock &aPB1=aCB.PaveBlock1();
800 const TColStd_ListOfInteger& aLF=aCB.Faces();
807 const TopoDS_Edge aSp=TopoDS::Edge(myDS->Shape(nSp));//mpv
809 aItF.Initialize(aLF);
810 for (; aItF.More(); aItF.Next()) {
812 aF1FWD=TopoDS::Face(myDS->Shape(nF));
813 aF1FWD.Orientation(TopAbs_FORWARD);
815 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aSp, aF1FWD);
816 } // for (; aItCB.More(); aItCB.Next()) {
817 }//if (aS.ShapeType()==TopAbs_EDGE) {
821 //=======================================================================
822 // function: IsExistingPaveBlock
824 //=======================================================================
825 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
826 const BOPTools_ListOfPaveBlock& aLPBR,
827 const Standard_Real aTolR3D)
829 Standard_Boolean bFlag;
830 Standard_Integer nVNew1, nVNew2, nV1, nV2, iC;
831 BOPTools_ListIteratorOfListOfPaveBlock anIt;
833 bFlag=Standard_False;
834 nVNew1=aPBNew.Pave1().Index();
835 nVNew2=aPBNew.Pave2().Index();
837 anIt.Initialize(aLPBR);
838 for (; anIt.More(); anIt.Next()) {
839 const BOPTools_PaveBlock& aPBR=anIt.Value();
840 nV1=aPBR.Pave1().Index();
841 nV2=aPBR.Pave2().Index();
842 if (nVNew1==nV1 || nVNew1==nV2 || nVNew2==nV1 || nVNew2==nV2) {
844 iC=CheckIntermediatePoint(aPBNew, aPBR, aTolR3D);
853 //=======================================================================
854 // function: IsExistingPaveBlock
856 //=======================================================================
857 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
858 const TopTools_ListOfShape& aLSE,
859 const Standard_Real aTolR3D)
861 Standard_Boolean bFlag;
862 Standard_Integer aNbSE, iC;
863 Standard_Real aTolE, aTol;
864 TopTools_ListIteratorOfListOfShape anIt;
866 bFlag=Standard_False;
873 anIt.Initialize(aLSE);
874 for (; anIt.More(); anIt.Next()) {
875 const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value());
876 aTolE=BRep_Tool::Tolerance(aE);
881 iC=CheckIntermediatePoint(aPBNew, aE, aTol);
889 //=======================================================================
890 // function: CheckIntermediatePoint
892 //=======================================================================
893 Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
894 const BOPTools_PaveBlock& aPBR,
895 const Standard_Real aTolC)
897 Standard_Integer iVM, nE2;
900 const TopoDS_Edge aE2=TopoDS::Edge(myDS->Shape(nE2));//mpv
901 iVM=CheckIntermediatePoint(aPB, aE2, aTolC);
906 //=======================================================================
907 // function: CheckIntermediatePoint
909 //=======================================================================
910 Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
911 const TopoDS_Edge& aE2,
912 const Standard_Real aTolC)
914 Standard_Real aT11, aT12, aTM, aTmp;
915 Standard_Integer iVM;
921 const BOPTools_Pave& aPave11=aPB.Pave1();
922 aT11=aPave11.Param();
924 const BOPTools_Pave& aPave12=aPB.Pave2();
925 aT12=aPave12.Param();
927 aTM=IntTools_Tools::IntermediatePoint (aT11, aT12);
929 const IntTools_Curve& aIC=aPB.Curve();
932 aBB.MakeVertex (aVM, aPM, aTolC);
934 iVM=myContext->ComputeVE(aVM, aE2, aTmp);
939 //=======================================================================
940 // function: PutBoundPaveOnCurve
942 //=======================================================================
943 void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC,
944 BOPTools_SSInterference& aFFi)
946 Standard_Boolean bHasBounds, bVF;
947 Standard_Integer nF1, nF2;
948 Standard_Real aT1, aT2, aTolR3D;
951 const IntTools_Curve& aIC=aBC.Curve();
952 bHasBounds=aIC.HasBounds ();
958 aIC.Bounds (aT1, aT2, aP1, aP2);
961 aFFi.Indices(nF1, nF2);
962 aTolR3D=aFFi.TolR3D();
964 const TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1));//mpv
965 const TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2));//mpv
967 bVF=myContext->IsValidPointForFaces (aP1, aF1, aF2, aTolR3D);
969 PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi);
972 bVF=myContext->IsValidPointForFaces (aP2, aF1, aF2, aTolR3D);
974 PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi);
978 //=======================================================================
979 // function: PutBoundPaveOnCurve
981 //=======================================================================
982 void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP,
983 const Standard_Real aT,
985 BOPTools_SSInterference& aFFi)
987 Standard_Boolean bFound1, bFound2;
989 Standard_Real aTolV=aFFi.TolR3D();
991 BOPTools_Pave aPave1, aPave2, aPave;
992 BOPTools_PaveSet& aCPS=aBC.Set();
993 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
994 const IntTools_Curve& aIC=aBC.Curve();
996 bFound1=FindPave(aP, aTolV, aCPS , aPave1);
997 bFound2=FindPave(aP, aTolV, aFFiPS, aPave2);
999 if (!bFound1 && !bFound2) {
1000 TopoDS_Vertex aNewVertex;
1001 BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex);
1003 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
1004 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
1005 nV=myDS->NumberOfInsertedShapes();
1010 aFFiPS.Append(aPave);
1012 // Append Techno Vertex to the Curve
1013 TColStd_ListOfInteger& aTVs=aBC.TechnoVertices();
1016 if (bFound1 && !bFound2) {
1020 aFFiPS.Append(aPave);
1022 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1023 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
1026 if (!bFound1 && bFound2) {
1032 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1033 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
1037 //=======================================================================
1038 // function: FindPave
1040 //=======================================================================
1041 Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP,
1042 const Standard_Real aTolPV,
1043 const BOPTools_PaveSet& aPS,
1044 BOPTools_Pave& aPave)
1046 Standard_Integer nV;
1047 Standard_Boolean bIsVertex=Standard_False;
1049 const BOPTools_ListOfPave& aLP=aPS.Set();
1050 BOPTools_ListIteratorOfListOfPave anIt(aLP);
1051 for (; anIt.More(); anIt.Next()) {
1052 const BOPTools_Pave& aPC=anIt.Value();
1054 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1055 bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV);
1064 //=======================================================================
1065 // function: PrepareSetForFace
1067 //=======================================================================
1068 void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer ,//nF1,
1069 const Standard_Integer ,//nF2,
1070 const BOPTools_ListOfPaveBlock& aLPBC,
1071 BOPTools_PaveSet& aPSF)
1073 Standard_Integer nV1, nV2;
1074 TColStd_MapOfInteger aMap;
1075 BOPTools_ListIteratorOfListOfPaveBlock anIt;
1077 anIt.Initialize(aLPBC);
1078 for (; anIt.More(); anIt.Next()) {
1079 const BOPTools_PaveBlock& aPB=anIt.Value();
1080 const BOPTools_Pave& aPave1=aPB.Pave1();
1082 if (!aMap.Contains(nV1)) {
1084 aPSF.Append(aPave1);
1086 const BOPTools_Pave& aPave2=aPB.Pave2();
1088 if (!aMap.Contains(nV2)) {
1090 aPSF.Append(aPave2);
1095 //=======================================================================
1096 // function: CheckCoincidence
1098 //=======================================================================
1099 Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock& aPBNew,
1100 const BOPTools_ListOfPaveBlock& aLPBFF)
1102 Standard_Boolean bRet;
1104 Standard_Integer nV11, nV12, nV21, nV22, iVV, iVE, nE2;
1105 Standard_Integer iV, iCount, iCountExt;
1106 BOPTools_ListIteratorOfListOfPaveBlock anIt;
1108 const BOPTools_Pave& aPave11=aPBNew.Pave1();
1109 nV11=aPave11.Index();
1110 const TopoDS_Vertex& aV11=TopoDS::Vertex(myDS->Shape(nV11));
1113 const BOPTools_Pave& aPave12=aPBNew.Pave2();
1114 nV12=aPave12.Index();
1115 const TopoDS_Vertex& aV12=TopoDS::Vertex(myDS->Shape(nV12));
1119 anIt.Initialize(aLPBFF);
1120 for (; anIt.More(); anIt.Next()) {
1123 const BOPTools_PaveBlock& aPBR=anIt.Value();
1125 const BOPTools_Pave& aPave21=aPBR.Pave1();
1126 nV21=aPave21.Index();
1129 const BOPTools_Pave& aPave22=aPBR.Pave2();
1130 nV22=aPave22.Index();
1132 if (nV11==nV21 || nV11==nV22 || nV12==nV21 || nV12==nV22) {
1139 const TopoDS_Vertex& aV21=TopoDS::Vertex(myDS->Shape(nV21));
1140 const TopoDS_Vertex& aV22=TopoDS::Vertex(myDS->Shape(nV22));
1141 const TopoDS_Edge& aE2=TopoDS::Edge(myDS->Shape(nE2));
1145 iVV=IntTools_Tools::ComputeVV (aV11, aV21);
1149 if (iCount>iCountExt) {
1154 iVV=IntTools_Tools::ComputeVV (aV11, aV22);
1158 if (iCount>iCountExt) {
1164 iVE=myContext->ComputeVE (aV11, aE2, aTE);
1167 if (iCount>iCountExt) {
1174 iVV=IntTools_Tools::ComputeVV (aV12, aV21);
1178 if (iCount>iCountExt) {
1183 iVV=IntTools_Tools::ComputeVV (aV12, aV22);
1187 if (iCount>iCountExt) {
1193 iVE=myContext->ComputeVE (aV12, aE2, aTE);
1196 if (iCount>iCountExt) {
1202 bRet=(Standard_Boolean)(iCount>iCountExt);
1206 //=======================================================================
1207 //function : IsMicroEdge
1209 //=======================================================================
1210 Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE,
1211 const Handle(IntTools_Context)& aCtx)
1213 Standard_Boolean bRet;
1214 Standard_Integer iErr;
1215 Standard_Real aT1, aT2, aTmp;
1216 Handle(Geom_Curve) aC3D;
1217 TopoDS_Vertex aV1, aV2;
1220 bRet=(BRep_Tool::Degenerated(aE) ||
1221 !BRep_Tool::IsGeometric(aE));
1226 aC3D=BRep_Tool::Curve(aE, aT1, aT2);
1227 TopExp::Vertices(aE, aV1, aV2);
1228 aT1=BRep_Tool::Parameter(aV1, aE);
1229 aT2=BRep_Tool::Parameter(aV2, aE);
1238 IntTools_ShrunkRange aSR (aE, aV1, aV2, aR, aCtx);
1239 iErr=aSR.ErrorStatus();
1244 //=======================================================================
1245 // function: PutPaveOnCurve
1247 //=======================================================================
1248 void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
1249 const Standard_Real aTolR3D,
1250 BOPTools_Curve& aBC)
1252 Standard_Integer nV;
1253 Standard_Boolean bIsVertexOnLine;
1255 BOPTools_ListIteratorOfListOfPave anIt;
1257 GeomAdaptor_Curve aGAC;
1259 const IntTools_Curve& aC=aBC.Curve();
1260 Handle (Geom_Curve) aC3D= aC.Curve();
1262 BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBBC);
1264 const BOPTools_ListOfPave& aLP=aPaveSet.Set();
1265 anIt.Initialize(aLP);
1266 for (; anIt.More(); anIt.Next()) {
1267 const BOPTools_Pave& aPave=anIt.Value();
1270 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));
1273 BRepBndLib::Add(aV, aBBV);
1274 if (aBBC.IsOut(aBBV)){
1278 bIsVertexOnLine=myContext->IsVertexOnLine(aV, aC, aTolR3D, aT);
1281 if (bIsVertexOnLine) {
1282 BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface);
1283 BOPTools_PaveSet& aPS=aBC.Set();
1284 aPS.Append(aPaveNew);
1290 //=======================================================================
1291 //function : FillFaceInfo
1293 //=======================================================================
1294 void NMTTools_PaveFiller::FillFaceInfo()
1296 Standard_Integer i, aNbS, aNbFFs, nF, aNbVFs, aNbEFs, j, n1, n2, nX, aNbF;
1297 TopAbs_ShapeEnum aType;
1299 TColStd_ListIteratorOfListOfInteger aItF;
1300 BOPTools_ListIteratorOfListOfPaveBlock anItPB;
1301 NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo aItMFI;
1302 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
1306 BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
1307 BOPTools_CArray1OfVSInterference& aVFs=myIP->VSInterferences();
1308 BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
1310 aNbFFs=aFFs.Extent();
1316 for (i=1; i<=aNbFFs; ++i) {
1317 NMTTools_FaceInfo aFI;
1319 BOPTools_SSInterference& aFFi=aFFs(i);
1320 aFFi.Indices(n1, n2);
1321 myFaceInfo.Bind(n1, aFI);
1322 myFaceInfo.Bind(n2, aFI);
1326 aNbS=myDS->NumberOfShapesOfTheObject();
1327 for (i=1; i<=aNbS; ++i) {
1329 aType=aS.ShapeType();
1330 if (aType==TopAbs_EDGE) {
1331 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(i));
1332 aItCB.Initialize(aLCB);
1333 for (; aItCB.More(); aItCB.Next()) {
1334 const NMTTools_CommonBlock& aCB=aItCB.Value();
1335 const BOPTools_PaveBlock &aPB1=aCB.PaveBlock1();
1336 const TColStd_ListOfInteger& aLF=aCB.Faces();
1342 aItF.Initialize(aLF);
1343 for (; aItF.More(); aItF.Next()) {
1345 if (!myFaceInfo.IsBound(nF)) {
1349 NMTTools_FaceInfo& aFI=myFaceInfo.ChangeFind(nF);
1350 aFI.ChangePaveBlocksIn().Add(aPB1);
1352 n1=aPB1.Pave1().Index();
1353 n2=aPB1.Pave2().Index();
1354 aFI.ChangeVerticesIn().Add(n1);
1355 aFI.ChangeVerticesIn().Add(n2);
1358 }// if (aType==TopAbs_EDGE) {
1359 else if (aType==TopAbs_FACE) {
1360 if (!myFaceInfo.IsBound(i)) {
1364 BOPTools_ListOfPaveBlock aLPBOn;
1367 NMTTools_FaceInfo& aFI=myFaceInfo.ChangeFind(nF);
1369 RealSplitsFace(nF, aLPBOn);
1371 anItPB.Initialize(aLPBOn);
1372 for (; anItPB.More(); anItPB.Next()) {
1373 const BOPTools_PaveBlock &aPB=anItPB.Value();
1374 aFI.ChangePaveBlocksOn().Add(aPB);
1376 n1=aPB.Pave1().Index();
1377 n2=aPB.Pave2().Index();
1378 aFI.ChangeVerticesOn().Add(n1);
1379 aFI.ChangeVerticesOn().Add(n2);
1382 }// else if (aType==TopAbs_FACE) {
1383 }// for (i=1; i<=aNbS; ++i) {
1386 aItMFI.Initialize(myFaceInfo);
1387 for (; aItMFI.More(); aItMFI.Next()) {
1389 NMTTools_FaceInfo& aFI=*((NMTTools_FaceInfo*)&aItMFI.Value());
1395 aNbVFs=aVFs.Extent();
1396 for (j=1; j<=aNbVFs; ++j) {
1397 BOPTools_VSInterference& aVFj=aVFs(j);
1398 aVFj.Indices(n1, n2);
1400 aFI.ChangeVerticesIn().Add(n2);
1403 aFI.ChangeVerticesIn().Add(n1);
1405 }// for (j=1; j<=aNbVFs; ++j) {
1408 aNbEFs=aEFs.Extent();
1409 for (j=1; j<=aNbEFs; ++j) {
1410 BOPTools_ESInterference& aEFj=aEFs(j);
1411 aEFj.Indices(n1, n2);
1412 if (!(nF==n1 || nF==n2)) {
1422 aType=aS.ShapeType();
1423 if (aType!=TopAbs_VERTEX) {
1427 aFI.ChangeVerticesIn().Add(nX);
1428 }// for (j=1; j<=aNbEFs; ++j) {
1429 }// for (; aItMFI.More(); aItMFI.Next()) {
1433 #include <gp_Pnt.hxx>
1434 #include <gp_Dir.hxx>
1435 #include <gp_Vec.hxx>
1436 #include <GeomAPI_ProjectPointOnSurf.hxx>
1437 //=======================================================================
1438 //function : CorrectTolR3D
1439 //purpose : Attempt to correct the value of tolerance aTolR3D for
1440 // the intersection curve in order to
1441 // compel it to pass through the sticks.
1443 // 2. The are based on B-Spline surfaces;
1444 // 1. There is at least the one intersection curve;
1445 // 2. The faces have stick vertices to catch the curve;
1446 // 3. The intersection angle is rather small (0.7-7 deg)
1448 //=======================================================================
1449 void NMTTools_PaveFiller::CorrectTolR3D(const BOPTools_SSInterference& aFF,
1450 const TColStd_MapOfInteger& aMVStick,
1451 Standard_Real& aTolR3D)
1454 Standard_Boolean bHasBounds;
1455 Standard_Integer i, nF[2], nV, aNbCurves;
1456 Standard_Real aT1, aT2, aU, aV, aT, aA, aTolV, aTolVmax;
1457 Standard_Real aTolR, aTolTresh, aAmin, aAmax;
1458 TColStd_MapIteratorOfMapOfInteger aIt;
1459 gp_Pnt aP, aP1, aP2;
1462 Handle(Geom_Surface) aS[2];
1463 Handle(Geom_Curve) aC3D;
1464 GeomAdaptor_Surface aGAS;
1465 GeomAbs_SurfaceType aType;
1469 aAmin=0.012;// 0.7-7 deg
1472 if (!aMVStick.Extent()) {
1476 BOPTools_SSInterference& aFFi=*((BOPTools_SSInterference*)&aFF);
1477 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
1478 aNbCurves=aSCvs.Length();
1483 aFFi.Indices(nF[0], nF[1]);
1484 for (i=0; i<2; ++i) {
1485 aF[i]=*((TopoDS_Face*)(&myDS->Shape(nF[i])));
1486 aS[i]=BRep_Tool::Surface(aF[i]);
1488 aType=aGAS.GetType();
1489 if (aType!=GeomAbs_BSplineSurface) {
1494 BOPTools_Curve& aBC=aSCvs(1);
1495 const IntTools_Curve& aIC=aBC.Curve();
1496 bHasBounds=aIC.HasBounds();
1501 aIC.Bounds (aT1, aT2, aP1, aP2);
1502 aT=IntTools_Tools::IntermediatePoint(aT1, aT2);
1506 for (i=0; i<2; ++i) {
1507 GeomAPI_ProjectPointOnSurf& aPPS=myContext->ProjPS(aF[i]);
1509 aPPS.LowerDistanceParameters(aU, aV);
1510 BOPTools_Tools3D::GetNormalToSurface(aS[i], aU, aV, aDN[i]);
1513 aA=aDN[0].Angle(aDN[1]);
1515 if (aA > 0.5*M_PI) {
1519 if (aA<aAmin || aA>aAmax) {
1524 aIt.Initialize(aMVStick);
1525 for (; aIt.More(); aIt.Next()) {
1527 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)(&myDS->Shape(nV)));
1528 aTolV=BRep_Tool::Tolerance(aV);
1529 if (aTolV>aTolVmax) {
1536 if (aTolR<aTolTresh) {
1541 //modified by NIZNHY-PKV Wed Sep 14 13:21:13 2011f
1542 #if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
1543 //=======================================================================
1544 // function: PutClosingPaveOnCurve
1546 //=======================================================================
1547 void NMTTools_PaveFiller::PutClosingPaveOnCurve(BOPTools_Curve& aBC,
1548 BOPTools_SSInterference& aFFi)
1550 Standard_Boolean bIsClosed, bHasBounds, bAdded;
1551 Standard_Integer nVC, j;
1552 Standard_Real aT[2], aTolR3D, aTC, dT, aTx;
1555 BOPTools_ListIteratorOfListOfPave aItLP;
1557 const IntTools_Curve& aIC=aBC.Curve();
1558 const Handle (Geom_Curve)& aC3D=aIC.Curve();
1563 bIsClosed=IntTools_Tools::IsClosed(aC3D);
1568 bHasBounds=aIC.HasBounds ();
1573 bAdded=Standard_False;
1574 dT=Precision::PConfusion();
1575 aTolR3D=aFFi.TolR3D();
1576 aIC.Bounds (aT[0], aT[1], aP[0], aP[1]);
1578 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
1579 BOPTools_PaveSet& aCPS=aBC.Set();
1581 const BOPTools_ListOfPave& aLP=aCPS.Set();
1582 aItLP.Initialize(aLP);
1583 for (; aItLP.More() && !bAdded; aItLP.Next()) {
1584 const BOPTools_Pave& aPC=aItLP.Value();
1586 const TopoDS_Vertex aVC=TopoDS::Vertex(myDS->Shape(nVC));
1589 for (j=0; j<2; ++j) {
1590 if (fabs(aTC-aT[j]) < dT) {
1591 aTx=(!j) ? aT[1] : aT[0];
1596 aFFiPS.Append(aPVx);
1598 bAdded=Standard_True;
1604 #endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
1605 //modified by NIZNHY-PKV Wed Sep 14 13:21:17 2011t