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>
40 #include <Geom_TrimmedCurve.hxx>
41 #include <Geom2d_TrimmedCurve.hxx>
42 #include <Geom2d_Curve.hxx>
43 #include <GeomAdaptor_Curve.hxx>
44 #include <GeomAdaptor_Surface.hxx>
45 #include <Geom_Surface.hxx>
47 #include <BndLib_Add3dCurve.hxx>
49 #include <TopoDS_Face.hxx>
51 #include <TopoDS_Compound.hxx>
52 #include <TopoDS_Vertex.hxx>
53 #include <TopoDS_Edge.hxx>
57 #include <BRepLib.hxx>
58 #include <BRep_Builder.hxx>
59 #include <BRep_Tool.hxx>
60 #include <BRepBndLib.hxx>
62 #include <TopTools_IndexedMapOfShape.hxx>
63 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
64 #include <TopTools_ListOfShape.hxx>
65 #include <TopTools_ListIteratorOfListOfShape.hxx>
67 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
68 #include <BOPTColStd_IndexedDataMapOfIntegerInteger.hxx>
70 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
71 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
72 #include <BooleanOperations_OnceExplorer.hxx>
73 #include <BooleanOperations_ShapesDataStructure.hxx>
75 #include <IntTools_SequenceOfPntOn2Faces.hxx>
76 #include <IntTools_SequenceOfCurves.hxx>
77 #include <IntTools_FaceFace.hxx>
78 #include <IntTools_Tools.hxx>
79 #include <IntTools_ShrunkRange.hxx>
80 #include <IntTools_Context.hxx>
82 #include <BOPTools_CArray1OfSSInterference.hxx>
83 #include <BOPTools_VSInterference.hxx>
84 #include <BOPTools_ESInterference.hxx>
85 #include <BOPTools_SSInterference.hxx>
86 #include <BOPTools_ListOfPaveBlock.hxx>
87 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
88 #include <BOPTools_PaveBlock.hxx>
89 #include <BOPTools_ListIteratorOfListOfPave.hxx>
90 #include <BOPTools_Tools.hxx>
91 #include <BOPTools_PaveBlockIterator.hxx>
92 #include <BOPTools_Tools2D.hxx>
93 #include <BOPTools_Tools3D.hxx>
95 #include <NMTDS_Iterator.hxx>
96 #include <NMTDS_ShapesDataStructure.hxx>
97 #include <NMTDS_InterfPool.hxx>
99 #include <NMTTools_Tools.hxx>
100 #include <NMTTools_IndexedDataMapOfShapePaveBlock.hxx>
101 #include <NMTTools_CommonBlock.hxx>
102 #include <NMTTools_CommonBlockAPI.hxx>
103 #include <NMTTools_ListOfCommonBlock.hxx>
104 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
105 #include <NMTTools_DataMapOfIntegerListOfPaveBlock.hxx>
106 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
107 #include <NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx>
108 #include <NMTTools_MapOfPaveBlock.hxx>
109 #include <NMTTools_MapIteratorOfMapOfPaveBlock.hxx>
110 #include <NMTTools_FaceInfo.hxx>
111 #include <NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo.hxx>
114 Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE,
115 #if OCC_VERSION_LARGE > 0x06050200
116 const Handle(IntTools_Context)& aCtx);
118 IntTools_Context& aCtx);
121 //=======================================================================
122 // function: PerformFF
124 //=======================================================================
125 void NMTTools_PaveFiller::PerformFF()
127 myIsDone=Standard_False;
129 Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone;
130 Standard_Boolean bJustAdd, bToSplit;
131 Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs;
132 Standard_Integer aNbCurves, aNbPoints;
133 Standard_Real anApproxTol, aTolR3D, aTolR2D;
134 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith;
135 IntTools_SequenceOfPntOn2Faces aPnts;
136 IntTools_SequenceOfCurves aCvs;
138 BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
140 // F/F Interferences [BooleanOperations_SurfaceSurface]
141 myDSIt->Initialize(TopAbs_FACE, TopAbs_FACE);
143 // BlockLength correction
144 aNbFFs=myDSIt->BlockLength();
145 aBlockLength=aFFs.BlockLength();
146 if (aNbFFs > aBlockLength) {
147 aFFs.SetBlockLength(aNbFFs);
150 //modified by NIZNHY-PKV Thu Sep 15 08:02:52 2011f
151 bToSplit=Standard_False;
152 //modified by NIZNHY-PKV Thu Sep 15 08:02:55 2011t
154 for (; myDSIt->More(); myDSIt->Next()) {
155 myDSIt->Current(n1, n2, bJustAdd);
167 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv
168 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv
171 bToApproxC3d = mySectionAttribute.Approximation();
172 bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1();
173 bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2();
177 IntTools_FaceFace aFF;
179 aFF.SetParameters (bToApproxC3d, bToApproxC2dOnS1,
180 bToApproxC2dOnS2, anApproxTol);
182 aFF.Perform(aF1, aF2);
184 bIsDone=aFF.IsDone();
187 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
188 anIndexIn=aFFs.Append(anInterf);
192 aTolR3D=aFF.TolReached3d();
193 aTolR2D=aFF.TolReached2d();
194 if (aTolR3D < 1.e-7){
198 //modified by NIZNHY-PKV Thu Sep 15 08:03:02 2011f
199 #if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
200 aFF.PrepareLines3D(bToSplit);
202 aFF.PrepareLines3D();
203 #endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
204 //modified by NIZNHY-PKV Thu Sep 15 08:03:04 2011t
206 const IntTools_SequenceOfCurves& aCvsX=aFF.Lines();
207 const IntTools_SequenceOfPntOn2Faces& aPntsX=aFF.Points();
209 aNbCurves=aCvsX.Length();
210 aNbPoints=aPntsX.Length();
212 if (!aNbCurves && !aNbPoints) {
213 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
214 anIndexIn=aFFs.Append(anInterf);
219 BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvsX, aPntsX);
220 anIndexIn=aFFs.Append(anInterf);
223 }// for (; myDSIt.More(); myDSIt.Next())
225 myIsDone=Standard_True;
228 //=======================================================================
229 // function: MakeBlocks
231 //=======================================================================
232 void NMTTools_PaveFiller::MakeBlocks()
234 myIsDone=Standard_False;
236 Standard_Boolean bIsExistingPaveBlock, bIsValidIn2D, bIsCoincided;
237 Standard_Boolean bIsMicroEdge, bHasES;
238 Standard_Integer i, aNbFFs, nF1, nF2;
239 Standard_Integer nV1, nV2, j, aNbCurves;
240 Standard_Real aTolR3D, aTol2D, aT1, aT2, aTolPPC=Precision::PConfusion();
241 TopoDS_Face aF1, aF2;
242 NMTTools_IndexedDataMapOfShapePaveBlock aMEPB;
243 BooleanOperations_IndexedDataMapOfShapeInteger aMapEI;
244 BOPTools_ListIteratorOfListOfPaveBlock anIt;
246 BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
250 // 1. Make Section Edges from intersection curves
251 // between each pair of faces
252 aNbFFs=aFFs.Extent();
259 for (i=1; i<=aNbFFs; ++i) {
260 BOPTools_ListOfPaveBlock aLPB;
261 TColStd_MapOfInteger aMVStick;
262 TopTools_ListOfShape aLSE;
263 TColStd_ListOfInteger aLNE;
264 BOPTools_PaveSet aPSF;
265 NMTTools_MapOfPaveBlock aMPBX;
266 TColStd_MapIteratorOfMapOfInteger aItMI;
267 NMTTools_MapIteratorOfMapOfPaveBlock aItMPB;
269 BOPTools_SSInterference& aFFi=aFFs(i);
272 aFFi.Indices(nF1, nF2);
273 aF1=*((TopoDS_Face*)(&myDS->Shape(nF1)));
274 aF2=*((TopoDS_Face*)(&myDS->Shape(nF2)));
276 SharedEdges(nF1, nF2, aLNE, aLSE);
277 aFFi.SetSharedEdges(aLNE);
280 const NMTTools_FaceInfo& aFI1=myFaceInfo.Find(nF1);
281 const NMTTools_FaceInfo& aFI2=myFaceInfo.Find(nF2);
283 const TColStd_MapOfInteger& aMVOn1=aFI1.VerticesOn();
284 const TColStd_MapOfInteger& aMVIn1=aFI1.VerticesIn();
285 const TColStd_MapOfInteger& aMVOn2=aFI2.VerticesOn();
286 const TColStd_MapOfInteger& aMVIn2=aFI2.VerticesIn();
288 for (j=0; j<2; ++j) {
289 const TColStd_MapOfInteger& aMV1=(!j) ? aMVOn1 :aMVIn1;
290 aItMI.Initialize(aMV1);
291 for (; aItMI.More(); aItMI.Next()) {
293 if (aMVOn2.Contains(nV1) || aMVIn2.Contains(nV1)) {
300 const NMTTools_MapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn();
301 const NMTTools_MapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn();
302 const NMTTools_MapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn();
303 const NMTTools_MapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn();
306 for (j=0; j<4; ++j) {
307 NMTTools_MapOfPaveBlock *pMPB;
310 pMPB=((NMTTools_MapOfPaveBlock*)&aMPBIn1);
313 pMPB=((NMTTools_MapOfPaveBlock*)&aMPBOn1);
316 pMPB=((NMTTools_MapOfPaveBlock*)&aMPBIn2);
319 pMPB=((NMTTools_MapOfPaveBlock*)&aMPBOn2);
322 const NMTTools_MapOfPaveBlock& aMPB=*pMPB;
323 aItMPB.Initialize(aMPB);
324 for (; aItMPB.More(); aItMPB.Next()) {
325 const BOPTools_PaveBlock& aPB=aItMPB.Key();
326 if (aMPBX.Add(aPB)) {
332 aFFi.AppendBlock(aPB);
339 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
340 aNbCurves=aSCvs.Length();
345 aTolR3D=aFFi.TolR3D();
346 aTol2D=(aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D;
348 CorrectTolR3D(aFFi, aMVStick, aTolR3D);
350 PrepareSetForFace (nF1, nF2, aLPB, aPSF);
352 // Put Paves On Curves
353 for (j=1; j<=aNbCurves; ++j) {
354 BOPTools_Curve& aBC=aSCvs(j);
355 const IntTools_Curve& aC=aBC.Curve();
357 Handle(Geom_Curve) aC3D = aC.Curve();
359 PutPaveOnCurve (aPSF, aTolR3D, aBC);
362 // Put bounding paves on curves
363 for (j=1; j<=aNbCurves; ++j) {
364 BOPTools_Curve& aBC=aSCvs(j);
365 PutBoundPaveOnCurve (aBC, aFFi);
367 //modified by NIZNHY-PKV Wed Sep 14 13:12:14 2011f
368 #if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
370 // Put closing pave if needded
371 for (j=1; j<=aNbCurves; ++j) {
372 BOPTools_Curve& aBC=aSCvs(j);
373 PutClosingPaveOnCurve (aBC, aFFi);
375 #endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
376 //modified by NIZNHY-PKV Wed Sep 14 13:12:17 2011t
378 // Pave Blocks on Curves
379 bHasES=Standard_False;
380 for (j=1; j<=aNbCurves; ++j) {
381 BOPTools_Curve& aBC=aSCvs(j);
382 const IntTools_Curve& aIC= aBC.Curve();
383 BOPTools_PaveSet& aPaveSet=aBC.Set();
385 BOPTools_PaveBlockIterator aPBIter(0, aPaveSet);
386 for (; aPBIter.More(); aPBIter.Next()) {
387 BOPTools_PaveBlock& aPBNew=aPBIter.Value();
388 aPBNew.SetCurve(aIC);
389 aPBNew.SetFace1(nF1);
390 aPBNew.SetFace2(nF2);
392 nV1=aPBNew.Pave1().Index();
393 nV2=aPBNew.Pave2().Index();
394 aT1=aPBNew.Pave1().Param();
395 aT2=aPBNew.Pave2().Param();
397 if((nV1==nV2) && (Abs(aT2 - aT1) < aTolPPC)) {
398 continue;// mkk ft ???
402 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPB, aTolR3D);
403 if (bIsExistingPaveBlock) {
407 bIsCoincided=CheckCoincidence(aPBNew, aLPB);
413 bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLSE, aTolR3D);
414 if (bIsExistingPaveBlock) {
418 // Checking of validity in 2D
420 #if OCC_VERSION_LARGE > 0x06050200
421 bIsValidIn2D=myContext->IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D);
423 bIsValidIn2D=myContext.IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D);
433 const TopoDS_Vertex aV1=TopoDS::Vertex(myDS->Shape(nV1));
434 const TopoDS_Vertex aV2=TopoDS::Vertex(myDS->Shape(nV2));
439 #if OCC_VERSION_LARGE > 0x06050200
440 myContext->IsVertexOnLine(aV1, aIC, aTolR3D, aT);
442 myContext.IsVertexOnLine(aV1, aIC, aTolR3D, aT);
444 BOPTools_Tools::UpdateVertex (aIC, aT, aV1);
446 #if OCC_VERSION_LARGE > 0x06050200
447 myContext->IsVertexOnLine(aV2, aIC, aTolR3D, aT);
449 myContext.IsVertexOnLine(aV2, aIC, aTolR3D, aT);
451 BOPTools_Tools::UpdateVertex (aIC, aT, aV2);
454 BOPTools_Tools::MakeSectEdge (aIC, aV1, aT1, aV2, aT2, aES);
456 NMTTools_Tools::UpdateEdge (aES, aTolR3D);
457 bIsMicroEdge=IsMicroEdge(aES, myContext);
463 Handle(Geom2d_Curve) aC2D1, aC2D2;
465 aC2D1=aIC.FirstCurve2d();
466 aC2D2=aIC.SecondCurve2d();
468 NMTTools_Tools::MakePCurve(aES, aF1, aC2D1);
469 NMTTools_Tools::MakePCurve(aES, aF2, aC2D2);
472 aMEPB.Add(aES, aPBNew);
475 bHasES=Standard_True;
476 }// for (; aPBIter.More(); aPBIter.Next())
477 } // end of for (j=1; j<=aNbCurves; ++j)
480 myIP->Add(nF1, nF2, Standard_True, NMTDS_TI_FF);
483 }// for (i=1; i<=aNbFFs; ++i)
484 //=============================================================
486 // II. Post treatment
488 // Input data: aMEPB, aMapEI
489 // Result : section edges in myDS
491 Standard_Integer aNbSE;
493 aNbSE=aMEPB.Extent();
495 // there is nothing to do here
500 TopoDS_Compound aCompound;
502 // 1. Make compound from SE
503 aBB.MakeCompound(aCompound);
504 for (i=1; i<=aNbSE; ++i) {
505 const TopoDS_Shape& aSE=aMEPB.FindKey(i);
506 aBB.Add(aCompound, aSE);
510 // 2. Intersect SE using auxiliary Filler
511 NMTTools_PaveFiller tPF;
513 tPF.SetCompositeShape(aCompound);
520 tPF.myPavePool.Resize (tPF.myNbEdges);
528 tPF.myCommonBlockPool.Resize (tPF.myNbEdges);
529 tPF.mySplitShapesPool.Resize (tPF.myNbEdges);
530 tPF.myPavePoolNew .Resize (tPF.myNbEdges);
532 tPF.PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE);
533 tPF.PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE);
537 tPF.RefinePavePool ();
539 tPF.myPavePoolNew.Destroy();
541 tPF.MakeSplitEdges();
542 tPF.UpdateCommonBlocks();
544 // 3. Treatment of the result of intersection
546 Standard_Integer aNbOld, aNbLines, aNbPB, mV1, mV2, nE, mE, iFF;
547 TopAbs_ShapeEnum aType;
548 BOPTools_ListIteratorOfListOfPaveBlock aIt;
549 BOPTColStd_IndexedDataMapOfIntegerInteger aMNewOld;
551 const NMTDS_ShapesDataStructure& tDS=*(tPF.DS());
552 const BOPTools_SplitShapesPool& aSSP=tPF.mySplitShapesPool;
553 const NMTTools_CommonBlockPool& aCBP=tPF.myCommonBlockPool;
555 aNbLines=tDS.NumberOfInsertedShapes();
556 aNbOld=tDS.NumberOfShapesOfTheObject();
558 // 3.1 Links between indices in tDS and DS (kept in aMNewOld)
560 // 3.1.1.Old vertices [ links ]
561 for (i=1; i<=aNbOld; ++i) {
562 const TopoDS_Shape& aV=tDS.Shape(i);
563 aType=aV.ShapeType();
564 if (aType!=TopAbs_VERTEX) {
568 for (j=1; j<=aNbSE; ++j) {
569 const BOPTools_PaveBlock& aPBSE=aMEPB(j);
570 nV1=aPBSE.Pave1().Index();
571 const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
572 if (aV1.IsSame(aV)) {
573 aMNewOld.Add(i, nV1);
576 nV2=aPBSE.Pave2().Index();
577 const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
578 if (aV2.IsSame(aV)) {
579 aMNewOld.Add(i, nV2);
585 // 3.1.2. New vertices [ links ]
586 i=tDS.NumberOfSourceShapes()+1;
587 for (; i<=aNbLines; ++i) {
588 const TopoDS_Shape& aV=tDS.Shape(i);
589 aType=aV.ShapeType();
590 if (aType!=TopAbs_VERTEX) {
594 // Insert new vertex in myDS
595 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
596 myDS->InsertShapeAndAncestorsSuccessors(aV, anASSeq);
597 nV1=myDS->NumberOfInsertedShapes();
599 aMNewOld.Add(i, nV1);
602 // 3.2. Treatment of section edges (SE)
603 for (i=1; i<=aNbOld; ++i) {
604 const TopoDS_Shape& aE=tDS.Shape(i);
605 aType=aE.ShapeType();
606 if (aType!=TopAbs_EDGE) {
610 // block of section edge that we already have for this SE
611 BOPTools_PaveBlock& aPBSE=aMEPB.ChangeFromKey(aE);
613 // Corresponding FF-interference
614 iFF=aMapEI.FindFromKey(aE);
615 BOPTools_SSInterference& aFFi=aFFs(iFF);
616 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
618 BOPTools_Curve& aBC=aSCvs(1);
620 const BOPTools_ListOfPaveBlock& aLPB=aSSP(tDS.RefEdge(i));
624 // no pave blocks -> use aPBSE and whole edge aE
625 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
627 nV1=aPBSE.Pave1().Index();
628 const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
629 nV2=aPBSE.Pave2().Index();
630 const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
632 anASSeq.SetNewSuccessor(nV1);
633 anASSeq.SetNewOrientation(aV1.Orientation());
634 anASSeq.SetNewSuccessor(nV2);
635 anASSeq.SetNewOrientation(aV2.Orientation());
637 myDS->InsertShapeAndAncestorsSuccessors(aE, anASSeq);
638 nE=myDS->NumberOfInsertedShapes();
641 aBC.AppendNewBlock(aPBSE);
649 const NMTTools_ListOfCommonBlock& aLCB=aCBP(tDS.RefEdge(i));
650 NMTTools_CommonBlockAPI aCBAPI(aLCB);
652 aIt.Initialize(aLPB);
653 for (; aIt.More(); aIt.Next()) {
654 BOPTools_PaveBlock aPB=aIt.Value();
656 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));
657 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));
659 if (aCBAPI.IsCommonBlock(aPB)) {
660 // it can be Common Block
661 Standard_Real aTolEx;
662 Handle(Geom2d_Curve) aC2D1, aC2D2;
663 TopoDS_Face aF1FWD, aF2FWD;
665 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
666 //const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
668 aPB=aCB.PaveBlock1();
669 mE=aPB.Edge(); // index of edge in tDS
670 const TopoDS_Edge& aEx=TopoDS::Edge(tDS.Shape(mE));
671 aTolEx=BRep_Tool::Tolerance(aEx);
674 aF1FWD.Orientation(TopAbs_FORWARD);
676 aF2FWD.Orientation(TopAbs_FORWARD);
678 NMTTools_Tools::MakePCurve(aEx, aF1FWD, aC2D1);
679 NMTTools_Tools::MakePCurve(aEx, aF2FWD, aC2D2);
680 NMTTools_Tools::UpdateEdge (aEx, aTolEx);
681 } //if (aCBAPI.IsCommonBlock(aPB))
684 mE=aPB.Edge(); // index of edge in tDS
685 const TopoDS_Shape& aSp=tDS.Shape(mE);
687 const BOPTools_Pave& aPave1=aPB.Pave1();
689 mV1=aPave1.Index(); // index in tDS
690 nV1=aMNewOld.FindFromKey(mV1); // index in myDS
691 const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
693 const BOPTools_Pave& aPave2=aPB.Pave2();
696 nV2=aMNewOld.FindFromKey(mV2);
697 const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
699 if (!aMNewOld.Contains(mE)) {
700 // add new SE to the myDS
701 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
703 anASSeq.SetNewSuccessor(nV1);
704 anASSeq.SetNewOrientation(aV1.Orientation());
706 anASSeq.SetNewSuccessor(nV2);
707 anASSeq.SetNewOrientation(aV2.Orientation());
709 myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq);
710 nE=myDS->NumberOfInsertedShapes();
712 aMNewOld.Add(mE, nE);
715 nE=aMNewOld.FindFromKey(mE);
718 BOPTools_PaveBlock aPBx;
719 BOPTools_Pave aP1, aP2;
735 aBC.AppendNewBlock(aPBx);
736 }// for (; aIt.More(); aIt.Next())
737 }// for (i=1; i<=aNbOld; ++i)
739 myIsDone=Standard_True;
742 //=======================================================================
743 // function: MakePCurves
745 //=======================================================================
746 void NMTTools_PaveFiller::MakePCurves()
748 Standard_Integer i, aNb, nF1, nF2, nE;
749 Standard_Integer aNbCB, aNbF, nSp, nF;
750 TopAbs_ShapeEnum aType;
751 TopoDS_Face aF1FWD, aF2FWD;
752 TColStd_ListIteratorOfListOfInteger aItF;
753 BOPTools_ListIteratorOfListOfPaveBlock anIt;
754 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
756 BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
759 for (i=1; i<=aNb; i++) {
760 BOPTools_SSInterference& aFF=aFFs(i);
761 aFF.Indices(nF1, nF2);
763 const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv
764 const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv
767 aF1FWD.Orientation(TopAbs_FORWARD);
769 aF2FWD.Orientation(TopAbs_FORWARD);
771 // In, On parts processing
772 const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
774 anIt.Initialize(aLPBInOn);
775 for (; anIt.More(); anIt.Next()) {
776 const BOPTools_PaveBlock& aPB=anIt.Value();
778 const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));//mpv
780 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
781 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
784 // Check common blocks between edges and faces
785 // Build P-Curves if they were not built in previos block.
786 // The main case is :arguments for e.g aEdge, aFace -> no FFs,
787 // but p-curves are needed.
789 aNb=myDS->NumberOfShapesOfTheObject();
790 for (i=1; i<=aNb; ++i) {
791 const TopoDS_Shape& aS=myDS->Shape(i);
792 aType=aS.ShapeType();
794 if (aType!=TopAbs_EDGE) {
797 const TopoDS_Edge& aE=TopoDS::Edge(aS);
799 if (BRep_Tool::Degenerated(aE)) {
803 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(i));
809 aItCB.Initialize(aLCB);
810 for (; aItCB.More(); aItCB.Next()) {
811 const NMTTools_CommonBlock& aCB=aItCB.Value();
812 const BOPTools_PaveBlock &aPB1=aCB.PaveBlock1();
814 const TColStd_ListOfInteger& aLF=aCB.Faces();
821 const TopoDS_Edge aSp=TopoDS::Edge(myDS->Shape(nSp));//mpv
823 aItF.Initialize(aLF);
824 for (; aItF.More(); aItF.Next()) {
826 aF1FWD=TopoDS::Face(myDS->Shape(nF));
827 aF1FWD.Orientation(TopAbs_FORWARD);
829 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aSp, aF1FWD);
830 } // for (; aItCB.More(); aItCB.Next()) {
831 }//if (aS.ShapeType()==TopAbs_EDGE) {
835 //=======================================================================
836 // function: IsExistingPaveBlock
838 //=======================================================================
839 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
840 const BOPTools_ListOfPaveBlock& aLPBR,
841 const Standard_Real aTolR3D)
843 Standard_Boolean bFlag;
844 Standard_Integer nVNew1, nVNew2, nV1, nV2, iC;
845 BOPTools_ListIteratorOfListOfPaveBlock anIt;
847 bFlag=Standard_False;
848 nVNew1=aPBNew.Pave1().Index();
849 nVNew2=aPBNew.Pave2().Index();
851 anIt.Initialize(aLPBR);
852 for (; anIt.More(); anIt.Next()) {
853 const BOPTools_PaveBlock& aPBR=anIt.Value();
854 nV1=aPBR.Pave1().Index();
855 nV2=aPBR.Pave2().Index();
856 if (nVNew1==nV1 || nVNew1==nV2 || nVNew2==nV1 || nVNew2==nV2) {
858 iC=CheckIntermediatePoint(aPBNew, aPBR, aTolR3D);
867 //=======================================================================
868 // function: IsExistingPaveBlock
870 //=======================================================================
871 Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
872 const TopTools_ListOfShape& aLSE,
873 const Standard_Real aTolR3D)
875 Standard_Boolean bFlag;
876 Standard_Integer aNbSE, iC;
877 Standard_Real aTolE, aTol;
878 TopTools_ListIteratorOfListOfShape anIt;
880 bFlag=Standard_False;
887 anIt.Initialize(aLSE);
888 for (; anIt.More(); anIt.Next()) {
889 const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value());
890 aTolE=BRep_Tool::Tolerance(aE);
895 iC=CheckIntermediatePoint(aPBNew, aE, aTol);
903 //=======================================================================
904 // function: CheckIntermediatePoint
906 //=======================================================================
907 Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
908 const BOPTools_PaveBlock& aPBR,
909 const Standard_Real aTolC)
911 Standard_Integer iVM, nE2;
914 const TopoDS_Edge aE2=TopoDS::Edge(myDS->Shape(nE2));//mpv
915 iVM=CheckIntermediatePoint(aPB, aE2, aTolC);
920 //=======================================================================
921 // function: CheckIntermediatePoint
923 //=======================================================================
924 Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
925 const TopoDS_Edge& aE2,
926 const Standard_Real aTolC)
928 Standard_Real aT11, aT12, aTM, aTmp;
929 Standard_Integer iVM;
935 const BOPTools_Pave& aPave11=aPB.Pave1();
936 aT11=aPave11.Param();
938 const BOPTools_Pave& aPave12=aPB.Pave2();
939 aT12=aPave12.Param();
941 aTM=IntTools_Tools::IntermediatePoint (aT11, aT12);
943 const IntTools_Curve& aIC=aPB.Curve();
946 aBB.MakeVertex (aVM, aPM, aTolC);
948 #if OCC_VERSION_LARGE > 0x06050200
949 iVM=myContext->ComputeVE(aVM, aE2, aTmp);
951 iVM=myContext.ComputeVE(aVM, aE2, aTmp);
957 //=======================================================================
958 // function: PutBoundPaveOnCurve
960 //=======================================================================
961 void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC,
962 BOPTools_SSInterference& aFFi)
964 Standard_Boolean bHasBounds, bVF;
965 Standard_Integer nF1, nF2;
966 Standard_Real aT1, aT2, aTolR3D;
969 const IntTools_Curve& aIC=aBC.Curve();
970 bHasBounds=aIC.HasBounds ();
976 aIC.Bounds (aT1, aT2, aP1, aP2);
979 aFFi.Indices(nF1, nF2);
980 aTolR3D=aFFi.TolR3D();
982 const TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1));//mpv
983 const TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2));//mpv
985 #if OCC_VERSION_LARGE > 0x06050200
986 bVF=myContext->IsValidPointForFaces (aP1, aF1, aF2, aTolR3D);
988 bVF=myContext.IsValidPointForFaces (aP1, aF1, aF2, aTolR3D);
991 PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi);
994 #if OCC_VERSION_LARGE > 0x06050200
995 bVF=myContext->IsValidPointForFaces (aP2, aF1, aF2, aTolR3D);
997 bVF=myContext.IsValidPointForFaces (aP2, aF1, aF2, aTolR3D);
1000 PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi);
1004 //=======================================================================
1005 // function: PutBoundPaveOnCurve
1007 //=======================================================================
1008 void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP,
1009 const Standard_Real aT,
1010 BOPTools_Curve& aBC,
1011 BOPTools_SSInterference& aFFi)
1013 Standard_Boolean bFound1, bFound2;
1014 Standard_Integer nV;
1015 Standard_Real aTolV=aFFi.TolR3D();
1017 BOPTools_Pave aPave1, aPave2, aPave;
1018 BOPTools_PaveSet& aCPS=aBC.Set();
1019 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
1020 const IntTools_Curve& aIC=aBC.Curve();
1022 bFound1=FindPave(aP, aTolV, aCPS , aPave1);
1023 bFound2=FindPave(aP, aTolV, aFFiPS, aPave2);
1025 if (!bFound1 && !bFound2) {
1026 TopoDS_Vertex aNewVertex;
1027 BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex);
1029 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
1030 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
1031 nV=myDS->NumberOfInsertedShapes();
1036 aFFiPS.Append(aPave);
1038 // Append Techno Vertex to the Curve
1039 TColStd_ListOfInteger& aTVs=aBC.TechnoVertices();
1042 if (bFound1 && !bFound2) {
1046 aFFiPS.Append(aPave);
1048 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1049 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
1052 if (!bFound1 && bFound2) {
1058 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1059 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
1063 //=======================================================================
1064 // function: FindPave
1066 //=======================================================================
1067 Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP,
1068 const Standard_Real aTolPV,
1069 const BOPTools_PaveSet& aPS,
1070 BOPTools_Pave& aPave)
1072 Standard_Integer nV;
1073 Standard_Boolean bIsVertex=Standard_False;
1075 const BOPTools_ListOfPave& aLP=aPS.Set();
1076 BOPTools_ListIteratorOfListOfPave anIt(aLP);
1077 for (; anIt.More(); anIt.Next()) {
1078 const BOPTools_Pave& aPC=anIt.Value();
1080 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv
1081 bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV);
1090 //=======================================================================
1091 // function: PrepareSetForFace
1093 //=======================================================================
1094 void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer ,//nF1,
1095 const Standard_Integer ,//nF2,
1096 const BOPTools_ListOfPaveBlock& aLPBC,
1097 BOPTools_PaveSet& aPSF)
1099 Standard_Integer nV1, nV2;
1100 TColStd_MapOfInteger aMap;
1101 BOPTools_ListIteratorOfListOfPaveBlock anIt;
1103 anIt.Initialize(aLPBC);
1104 for (; anIt.More(); anIt.Next()) {
1105 const BOPTools_PaveBlock& aPB=anIt.Value();
1106 const BOPTools_Pave& aPave1=aPB.Pave1();
1108 if (!aMap.Contains(nV1)) {
1110 aPSF.Append(aPave1);
1112 const BOPTools_Pave& aPave2=aPB.Pave2();
1114 if (!aMap.Contains(nV2)) {
1116 aPSF.Append(aPave2);
1121 //=======================================================================
1122 // function: CheckCoincidence
1124 //=======================================================================
1125 Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock& aPBNew,
1126 const BOPTools_ListOfPaveBlock& aLPBFF)
1128 Standard_Boolean bRet;
1130 Standard_Integer nV11, nV12, nV21, nV22, iVV, iVE, nE2;
1131 Standard_Integer iV, iCount, iCountExt;
1132 BOPTools_ListIteratorOfListOfPaveBlock anIt;
1134 const BOPTools_Pave& aPave11=aPBNew.Pave1();
1135 nV11=aPave11.Index();
1136 const TopoDS_Vertex& aV11=TopoDS::Vertex(myDS->Shape(nV11));
1139 const BOPTools_Pave& aPave12=aPBNew.Pave2();
1140 nV12=aPave12.Index();
1141 const TopoDS_Vertex& aV12=TopoDS::Vertex(myDS->Shape(nV12));
1145 anIt.Initialize(aLPBFF);
1146 for (; anIt.More(); anIt.Next()) {
1149 const BOPTools_PaveBlock& aPBR=anIt.Value();
1151 const BOPTools_Pave& aPave21=aPBR.Pave1();
1152 nV21=aPave21.Index();
1155 const BOPTools_Pave& aPave22=aPBR.Pave2();
1156 nV22=aPave22.Index();
1158 if (nV11==nV21 || nV11==nV22 || nV12==nV21 || nV12==nV22) {
1165 const TopoDS_Vertex& aV21=TopoDS::Vertex(myDS->Shape(nV21));
1166 const TopoDS_Vertex& aV22=TopoDS::Vertex(myDS->Shape(nV22));
1167 const TopoDS_Edge& aE2=TopoDS::Edge(myDS->Shape(nE2));
1171 iVV=IntTools_Tools::ComputeVV (aV11, aV21);
1175 if (iCount>iCountExt) {
1180 iVV=IntTools_Tools::ComputeVV (aV11, aV22);
1184 if (iCount>iCountExt) {
1190 #if OCC_VERSION_LARGE > 0x06050200
1191 iVE=myContext->ComputeVE (aV11, aE2, aTE);
1193 iVE=myContext.ComputeVE (aV11, aE2, aTE);
1197 if (iCount>iCountExt) {
1204 iVV=IntTools_Tools::ComputeVV (aV12, aV21);
1208 if (iCount>iCountExt) {
1213 iVV=IntTools_Tools::ComputeVV (aV12, aV22);
1217 if (iCount>iCountExt) {
1223 #if OCC_VERSION_LARGE > 0x06050200
1224 iVE=myContext->ComputeVE (aV12, aE2, aTE);
1226 iVE=myContext.ComputeVE (aV12, aE2, aTE);
1230 if (iCount>iCountExt) {
1236 bRet=(Standard_Boolean)(iCount>iCountExt);
1240 //=======================================================================
1241 //function : IsMicroEdge
1243 //=======================================================================
1244 Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE,
1245 #if OCC_VERSION_LARGE > 0x06050200
1246 const Handle(IntTools_Context)& aCtx)
1248 IntTools_Context& aCtx)
1251 Standard_Boolean bRet;
1252 Standard_Integer iErr;
1253 Standard_Real aT1, aT2, aTmp;
1254 Handle(Geom_Curve) aC3D;
1255 TopoDS_Vertex aV1, aV2;
1258 bRet=(BRep_Tool::Degenerated(aE) ||
1259 !BRep_Tool::IsGeometric(aE));
1264 aC3D=BRep_Tool::Curve(aE, aT1, aT2);
1265 TopExp::Vertices(aE, aV1, aV2);
1266 aT1=BRep_Tool::Parameter(aV1, aE);
1267 aT2=BRep_Tool::Parameter(aV2, aE);
1276 IntTools_ShrunkRange aSR (aE, aV1, aV2, aR, aCtx);
1277 iErr=aSR.ErrorStatus();
1282 //=======================================================================
1283 // function: PutPaveOnCurve
1285 //=======================================================================
1286 void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
1287 const Standard_Real aTolR3D,
1288 BOPTools_Curve& aBC)
1290 Standard_Integer nV;
1291 Standard_Boolean bIsVertexOnLine;
1293 BOPTools_ListIteratorOfListOfPave anIt;
1295 GeomAdaptor_Curve aGAC;
1297 const IntTools_Curve& aC=aBC.Curve();
1298 Handle (Geom_Curve) aC3D= aC.Curve();
1300 BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBBC);
1302 const BOPTools_ListOfPave& aLP=aPaveSet.Set();
1303 anIt.Initialize(aLP);
1304 for (; anIt.More(); anIt.Next()) {
1305 const BOPTools_Pave& aPave=anIt.Value();
1308 const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));
1311 BRepBndLib::Add(aV, aBBV);
1312 if (aBBC.IsOut(aBBV)){
1316 #if OCC_VERSION_LARGE > 0x06050200
1317 bIsVertexOnLine=myContext->IsVertexOnLine(aV, aC, aTolR3D, aT);
1319 bIsVertexOnLine=myContext.IsVertexOnLine(aV, aC, aTolR3D, aT);
1323 if (bIsVertexOnLine) {
1324 BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface);
1325 BOPTools_PaveSet& aPS=aBC.Set();
1326 aPS.Append(aPaveNew);
1332 //=======================================================================
1333 //function : FillFaceInfo
1335 //=======================================================================
1336 void NMTTools_PaveFiller::FillFaceInfo()
1338 Standard_Integer i, aNbS, aNbFFs, nF, aNbVFs, aNbEFs, j, n1, n2, nX, aNbF;
1339 TopAbs_ShapeEnum aType;
1341 TColStd_ListIteratorOfListOfInteger aItF;
1342 BOPTools_ListIteratorOfListOfPaveBlock anItPB;
1343 NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo aItMFI;
1344 NMTTools_ListIteratorOfListOfCommonBlock aItCB;
1348 BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
1349 BOPTools_CArray1OfVSInterference& aVFs=myIP->VSInterferences();
1350 BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
1352 aNbFFs=aFFs.Extent();
1358 for (i=1; i<=aNbFFs; ++i) {
1359 NMTTools_FaceInfo aFI;
1361 BOPTools_SSInterference& aFFi=aFFs(i);
1362 aFFi.Indices(n1, n2);
1363 myFaceInfo.Bind(n1, aFI);
1364 myFaceInfo.Bind(n2, aFI);
1368 aNbS=myDS->NumberOfShapesOfTheObject();
1369 for (i=1; i<=aNbS; ++i) {
1371 aType=aS.ShapeType();
1372 if (aType==TopAbs_EDGE) {
1373 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(i));
1374 aItCB.Initialize(aLCB);
1375 for (; aItCB.More(); aItCB.Next()) {
1376 const NMTTools_CommonBlock& aCB=aItCB.Value();
1377 const BOPTools_PaveBlock &aPB1=aCB.PaveBlock1();
1378 const TColStd_ListOfInteger& aLF=aCB.Faces();
1384 aItF.Initialize(aLF);
1385 for (; aItF.More(); aItF.Next()) {
1387 if (!myFaceInfo.IsBound(nF)) {
1391 NMTTools_FaceInfo& aFI=myFaceInfo.ChangeFind(nF);
1392 aFI.ChangePaveBlocksIn().Add(aPB1);
1394 n1=aPB1.Pave1().Index();
1395 n2=aPB1.Pave2().Index();
1396 aFI.ChangeVerticesIn().Add(n1);
1397 aFI.ChangeVerticesIn().Add(n2);
1400 }// if (aType==TopAbs_EDGE) {
1401 else if (aType==TopAbs_FACE) {
1402 if (!myFaceInfo.IsBound(i)) {
1406 BOPTools_ListOfPaveBlock aLPBOn;
1409 NMTTools_FaceInfo& aFI=myFaceInfo.ChangeFind(nF);
1411 RealSplitsFace(nF, aLPBOn);
1413 anItPB.Initialize(aLPBOn);
1414 for (; anItPB.More(); anItPB.Next()) {
1415 const BOPTools_PaveBlock &aPB=anItPB.Value();
1416 aFI.ChangePaveBlocksOn().Add(aPB);
1418 n1=aPB.Pave1().Index();
1419 n2=aPB.Pave2().Index();
1420 aFI.ChangeVerticesOn().Add(n1);
1421 aFI.ChangeVerticesOn().Add(n2);
1424 }// else if (aType==TopAbs_FACE) {
1425 }// for (i=1; i<=aNbS; ++i) {
1428 aItMFI.Initialize(myFaceInfo);
1429 for (; aItMFI.More(); aItMFI.Next()) {
1431 NMTTools_FaceInfo& aFI=*((NMTTools_FaceInfo*)&aItMFI.Value());
1437 aNbVFs=aVFs.Extent();
1438 for (j=1; j<=aNbVFs; ++j) {
1439 BOPTools_VSInterference& aVFj=aVFs(j);
1440 aVFj.Indices(n1, n2);
1442 aFI.ChangeVerticesIn().Add(n2);
1445 aFI.ChangeVerticesIn().Add(n1);
1447 }// for (j=1; j<=aNbVFs; ++j) {
1450 aNbEFs=aEFs.Extent();
1451 for (j=1; j<=aNbEFs; ++j) {
1452 BOPTools_ESInterference& aEFj=aEFs(j);
1453 aEFj.Indices(n1, n2);
1454 if (!(nF==n1 || nF==n2)) {
1464 aType=aS.ShapeType();
1465 if (aType!=TopAbs_VERTEX) {
1469 aFI.ChangeVerticesIn().Add(nX);
1470 }// for (j=1; j<=aNbEFs; ++j) {
1471 }// for (; aItMFI.More(); aItMFI.Next()) {
1475 #include <gp_Pnt.hxx>
1476 #include <gp_Dir.hxx>
1477 #include <gp_Vec.hxx>
1478 #include <GeomAPI_ProjectPointOnSurf.hxx>
1479 //=======================================================================
1480 //function : CorrectTolR3D
1481 //purpose : Attempt to correct the value of tolerance aTolR3D for
1482 // the intersection curve in order to
1483 // compel it to pass through the sticks.
1485 // 2. The are based on B-Spline surfaces;
1486 // 1. There is at least the one intersection curve;
1487 // 2. The faces have stick vertices to catch the curve;
1488 // 3. The intersection angle is rather small (0.7-7 deg)
1490 //=======================================================================
1491 void NMTTools_PaveFiller::CorrectTolR3D(const BOPTools_SSInterference& aFF,
1492 const TColStd_MapOfInteger& aMVStick,
1493 Standard_Real& aTolR3D)
1496 Standard_Boolean bHasBounds;
1497 Standard_Integer i, nF[2], nV, aNbCurves;
1498 Standard_Real aT1, aT2, aU, aV, aT, aA, aTolV, aTolVmax;
1499 Standard_Real aTolR, aTolTresh, aAmin, aAmax;
1500 TColStd_MapIteratorOfMapOfInteger aIt;
1501 gp_Pnt aP, aP1, aP2;
1504 Handle(Geom_Surface) aS[2];
1505 Handle(Geom_Curve) aC3D;
1506 GeomAdaptor_Surface aGAS;
1507 GeomAbs_SurfaceType aType;
1511 aAmin=0.012;// 0.7-7 deg
1514 if (!aMVStick.Extent()) {
1518 BOPTools_SSInterference& aFFi=*((BOPTools_SSInterference*)&aFF);
1519 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
1520 aNbCurves=aSCvs.Length();
1525 aFFi.Indices(nF[0], nF[1]);
1526 for (i=0; i<2; ++i) {
1527 aF[i]=*((TopoDS_Face*)(&myDS->Shape(nF[i])));
1528 aS[i]=BRep_Tool::Surface(aF[i]);
1530 aType=aGAS.GetType();
1531 if (aType!=GeomAbs_BSplineSurface) {
1536 BOPTools_Curve& aBC=aSCvs(1);
1537 const IntTools_Curve& aIC=aBC.Curve();
1538 bHasBounds=aIC.HasBounds();
1543 aIC.Bounds (aT1, aT2, aP1, aP2);
1544 aT=IntTools_Tools::IntermediatePoint(aT1, aT2);
1548 for (i=0; i<2; ++i) {
1549 #if OCC_VERSION_LARGE > 0x06050200
1550 GeomAPI_ProjectPointOnSurf& aPPS=myContext->ProjPS(aF[i]);
1552 GeomAPI_ProjectPointOnSurf& aPPS=myContext.ProjPS(aF[i]);
1555 aPPS.LowerDistanceParameters(aU, aV);
1556 BOPTools_Tools3D::GetNormalToSurface(aS[i], aU, aV, aDN[i]);
1559 aA=aDN[0].Angle(aDN[1]);
1561 if (aA > 0.5*M_PI) {
1565 if (aA<aAmin || aA>aAmax) {
1570 aIt.Initialize(aMVStick);
1571 for (; aIt.More(); aIt.Next()) {
1573 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)(&myDS->Shape(nV)));
1574 aTolV=BRep_Tool::Tolerance(aV);
1575 if (aTolV>aTolVmax) {
1582 if (aTolR<aTolTresh) {
1587 //modified by NIZNHY-PKV Wed Sep 14 13:21:13 2011f
1588 #if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
1589 //=======================================================================
1590 // function: PutClosingPaveOnCurve
1592 //=======================================================================
1593 void NMTTools_PaveFiller::PutClosingPaveOnCurve(BOPTools_Curve& aBC,
1594 BOPTools_SSInterference& aFFi)
1596 Standard_Boolean bIsClosed, bHasBounds, bAdded;
1597 Standard_Integer nVC, j;
1598 Standard_Real aT[2], aTolR3D, aTC, dT, aTx;
1601 BOPTools_ListIteratorOfListOfPave aItLP;
1603 const IntTools_Curve& aIC=aBC.Curve();
1604 const Handle (Geom_Curve)& aC3D=aIC.Curve();
1609 bIsClosed=IntTools_Tools::IsClosed(aC3D);
1614 bHasBounds=aIC.HasBounds ();
1619 bAdded=Standard_False;
1620 dT=Precision::PConfusion();
1621 aTolR3D=aFFi.TolR3D();
1622 aIC.Bounds (aT[0], aT[1], aP[0], aP[1]);
1624 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
1625 BOPTools_PaveSet& aCPS=aBC.Set();
1627 const BOPTools_ListOfPave& aLP=aCPS.Set();
1628 aItLP.Initialize(aLP);
1629 for (; aItLP.More() && !bAdded; aItLP.Next()) {
1630 const BOPTools_Pave& aPC=aItLP.Value();
1632 const TopoDS_Vertex aVC=TopoDS::Vertex(myDS->Shape(nVC));
1635 for (j=0; j<2; ++j) {
1636 if (fabs(aTC-aT[j]) < dT) {
1637 aTx=(!j) ? aT[1] : aT[0];
1642 aFFiPS.Append(aPVx);
1644 bAdded=Standard_True;
1650 #endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
1651 //modified by NIZNHY-PKV Wed Sep 14 13:21:17 2011t