1 // Created on: 2001-03-13
2 // Created by: Peter KURNEV
3 // Copyright (c) 2001-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
22 #include <BOPTools_PaveFiller.ixx>
24 #include <Geom_Curve.hxx>
27 #include <TColStd_SequenceOfInteger.hxx>
28 #include <TColStd_SequenceOfReal.hxx>
30 #include <TColStd_MapOfInteger.hxx>
31 #include <TColStd_ListOfInteger.hxx>
32 #include <TColStd_IndexedMapOfInteger.hxx>
33 #include <TColStd_ListIteratorOfListOfInteger.hxx>
34 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
37 #include <TopoDS_Face.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <TopoDS_Vertex.hxx>
41 #include <BRep_Tool.hxx>
42 #include <BRep_Builder.hxx>
44 #include <BooleanOperations_ShapesDataStructure.hxx>
45 #include <BooleanOperations_OnceExplorer.hxx>
46 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
48 #include <IntTools_FaceFace.hxx>
49 #include <IntTools_SequenceOfCurves.hxx>
50 #include <IntTools_Curve.hxx>
51 #include <IntTools_Tools.hxx>
52 #include <IntTools_SequenceOfPntOn2Faces.hxx>
53 #include <IntTools_PntOn2Faces.hxx>
54 #include <IntTools_PntOnFace.hxx>
56 #include <BOPTools_IteratorOfCoupleOfShape.hxx>
57 #include <BOPTools_CArray1OfSSInterference.hxx>
58 #include <BOPTools_SSInterference.hxx>
59 #include <BOPTools_ListOfPaveBlock.hxx>
60 #include <BOPTools_PaveBlock.hxx>
61 #include <BOPTools_Pave.hxx>
62 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
63 #include <BOPTools_ListIteratorOfListOfPave.hxx>
64 #include <BOPTools_PaveBlockIterator.hxx>
65 #include <BOPTools_Tools.hxx>
66 #include <BOPTools_SequenceOfCurves.hxx>
67 #include <BOPTools_Curve.hxx>
68 #include <BOPTools_ListOfPave.hxx>
69 #include <BOPTools_PaveSet.hxx>
70 #include <BOPTools_CommonBlock.hxx>
71 #include <BOPTools_ListIteratorOfListOfCommonBlock.hxx>
72 #include <BOPTools_ListOfCommonBlock.hxx>
74 #include <BOPTools_InterferencePool.hxx>
75 #include <BOPTools_ListIteratorOfListOfInterference.hxx>
76 #include <BOPTools_InterferenceLine.hxx>
77 #include <BOPTools_ListOfInterference.hxx>
78 #include <BOPTools_Interference.hxx>
79 #include <BOPTools_CArray1OfInterferenceLine.hxx>
81 #include <Precision.hxx>
82 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
84 #include <TopExp_Explorer.hxx>
85 #include <Geom2d_Curve.hxx>
86 #include <Geom2dAPI_InterCurveCurve.hxx>
87 #include <IntRes2d_IntersectionPoint.hxx>
88 #include <BOPTools_ESInterference.hxx>
89 #include <BOPTools_VSInterference.hxx>
90 #include <BOPTools_VEInterference.hxx>
91 #include <BOPTools_VVInterference.hxx>
92 #include <BRepAdaptor_Surface.hxx>
93 #include <TopTools_ListOfShape.hxx>
94 #include <TopTools_ListIteratorOfListOfShape.hxx>
96 #include <BOPTools_EEInterference.hxx>
97 #include <IntTools_CommonPrt.hxx>
98 #include <BOPTools_ESInterference.hxx>
99 #include <BOPTools_ShapeShapeInterference.hxx>
101 #include <IntSurf_ListOfPntOn2S.hxx>
103 #include <GeomAPI_ProjectPointOnSurf.hxx>
104 #include <IntSurf_PntOn2S.hxx>
105 #include <TopTools_MapOfShape.hxx>
109 Standard_Boolean IsPaveBlock(const Standard_Integer nV1,
110 const Standard_Integer nV2,
111 const BOPTools_ListOfPaveBlock& aLPBExisting);
113 Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
114 const TColStd_IndexedMapOfInteger& aMapWith);
116 void FMapWith(const Standard_Integer nF,
117 BOPTools_InterferencePool* myIntrPool,
118 TColStd_IndexedMapOfInteger& aMapWith);
120 void FMapWhat(const Standard_Integer nF,
121 BOPTools_InterferencePool* myIntrPool,
122 TColStd_IndexedMapOfInteger& aMapWhat);
126 void UnUsedMap(BOPTools_SequenceOfCurves& aSCvs,
127 const BOPTools_PaveSet& aPSF,
128 TColStd_IndexedMapOfInteger& aMapUnUsed);
130 Standard_Boolean VertexRangeTolerance(const Standard_Integer nV,
131 const Standard_Integer nF1,
132 const Standard_Integer nF2,
133 const BOPTools_InterferencePool& anIntrPool,
134 Standard_Real& aTolV);
136 void FaceAndEdgeMap(const Standard_Integer nF,
137 const BOPTools_InterferencePool& anIntrPool,
138 TColStd_IndexedMapOfInteger& aMEF);
140 void ProcessAloneStickVertices(const Standard_Integer nF1,
141 const Standard_Integer nF2,
142 const BOPTools_PaveSet& aPSF,
143 BOPTools_SequenceOfCurves& aSCvs,
144 const BOPTools_InterferencePool& anIntrPool,
145 BOPTools_PaveFiller& aPF,
146 TColStd_SequenceOfInteger& aSeqVx,
147 TColStd_SequenceOfReal& aSeqTolVx);
149 void ProcessAloneStickVertices(const Standard_Integer nF1,
150 const Standard_Integer nF2,
151 const BOPTools_PaveSet& aPSF,
152 BOPTools_SequenceOfCurves& aSCvs,
153 BOPTools_PaveFiller& aPF,
154 TColStd_SequenceOfInteger& aSeqVx,
155 TColStd_SequenceOfReal& aSeqTolVx);
159 Standard_Boolean IsPairFound(const Standard_Integer nF1,
160 const Standard_Integer nF2,
161 BOPTools_InterferencePool* myIntrPool,
162 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
163 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith);
165 static Standard_Boolean CheckNewVertexAndUpdateData(const TopoDS_Vertex& theVertex,
166 const Standard_Real theParamOnE,
167 const TopoDS_Edge& theEdge,
168 const Standard_Real theParamOnCurve,
169 const Standard_Integer theIndexF1,
170 const Standard_Integer theIndexF2,
171 const Standard_Real theTolerance,
172 const BOPTools_PInterferencePool& theIntrPool,
173 const BooleanOperations_PShapesDataStructure& theDS,
174 const Handle(IntTools_Context)& theContext,
175 const BOPTools_PaveSet& theEdgePaveSet,
176 const Standard_Boolean bAddNewVertex,
177 const Standard_Boolean bAddOldVertex,
178 BOPTools_Curve& theBC,
179 BOPTools_Pave& thePaveToPut,
180 Standard_Boolean& bAddNewVertexOut,
181 Standard_Boolean& bAddOldVertexOut);
183 static void AddInterfForAdjacentFace(const Standard_Integer theEdgeIndex,
184 const Standard_Integer theIndexF1,
185 const Standard_Integer theIndexF2,
186 BOPTools_PInterferencePool theIntrPool,
187 const BooleanOperations_PShapesDataStructure& theDS);
189 static Standard_Boolean RejectPaveBlock(const IntTools_Curve& theC,
190 const Standard_Real theT1,
191 const Standard_Real theT2,
192 const TopoDS_Vertex& theV,
193 Standard_Real& theRT);
195 static Standard_Boolean ModifFFTol(const TopoDS_Face& theF1,
196 const TopoDS_Face& theF2,
197 Standard_Real& theTF);
199 static Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC,
200 const TopoDS_Vertex& theV1,
201 const TopoDS_Vertex& theV2,
202 const Standard_Real theT1,
203 const Standard_Real theT2,
204 const TopTools_ListOfShape& theL,
205 Standard_Real& theTF);
208 void CorrectTolR3D(BOPTools_PaveFiller& aPF,
209 const BOPTools_SSInterference& aFF,
210 const TColStd_MapOfInteger& aMVStick,
211 Standard_Real& aTolR3D);
213 //=======================================================================
214 // function: PerformFF
216 //=======================================================================
217 void BOPTools_PaveFiller::PerformFF()
219 myIsDone=Standard_False;
220 Standard_Boolean bIsFound, bToSplit;
221 Standard_Integer n1, n2, anIndexIn=0, nF1, nF2, aNbFFs, aBlockLength;
222 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith;
224 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
226 // F/F Interferences [BooleanOperations_SurfaceSurface]
227 myDSIt.Initialize(TopAbs_FACE, TopAbs_FACE);
229 // BlockLength correction
230 aNbFFs=ExpectedPoolLength();
231 aBlockLength=aFFs.BlockLength();
232 if (aNbFFs > aBlockLength) {
233 aFFs.SetBlockLength(aNbFFs);
236 bToSplit=Standard_False;
238 for (; myDSIt.More(); myDSIt.Next()) {
239 Standard_Boolean justaddinterference = Standard_True;
240 myDSIt.Current(n1, n2, justaddinterference);
242 if(justaddinterference) {
243 if (!myIntrPool->IsComputed(n1, n2)) {
254 bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith);
257 myIntrPool->AddInterference (nF1, nF2, BooleanOperations_SurfaceSurface, anIndexIn);
260 IntTools_SequenceOfPntOn2Faces aPnts;
261 IntTools_SequenceOfCurves aCvs;
263 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
264 anIndexIn=aFFs.Append(anInterf);
265 myIntrPool->AddInterference (nF1, nF2, BooleanOperations_SurfaceSurface, anIndexIn);
271 if (myIntrPool->IsComputed(n1, n2)) {
278 Standard_Integer iTmp;
284 TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1));
285 TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2));
287 IntSurf_ListOfPntOn2S aListOfPnts;
288 GeomAPI_ProjectPointOnSurf& aProj1 = myContext->ProjPS(aF1);
289 GeomAPI_ProjectPointOnSurf& aProj2 = myContext->ProjPS(aF2);
291 BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences();
292 TColStd_MapOfInteger aMapEdgeIndex1, aMapEdgeIndex2;
293 for(Standard_Integer fIt = 0; fIt < 2; fIt++) {
294 Standard_Integer nF = (fIt == 0) ? nF1 : nF2;
295 for(Standard_Integer sIt1 = 1; sIt1 <= myDS->NumberOfSuccessors(nF); sIt1++) {
296 Standard_Integer nIndexS1 = myDS->GetSuccessor(nF, sIt1);
297 if(myDS->GetShapeType(nIndexS1) == TopAbs_EDGE) {
299 aMapEdgeIndex1.Add(nIndexS1);
301 aMapEdgeIndex2.Add(nIndexS1);
304 for(Standard_Integer sIt2 = 1; sIt2 <= myDS->NumberOfSuccessors(nIndexS1); sIt2++) {
305 Standard_Integer nIndexS2 = myDS->GetSuccessor(nIndexS1, sIt2);
307 if(myDS->GetShapeType(nIndexS2) == TopAbs_EDGE) {
309 aMapEdgeIndex1.Add(nIndexS2);
311 aMapEdgeIndex2.Add(nIndexS2);
317 TColStd_MapIteratorOfMapOfInteger anIt;
319 anIt.Initialize(aMapEdgeIndex1);
321 anIt.Initialize(aMapEdgeIndex2);
323 Standard_Integer nFOpposite = (fIt == 0) ? nF2 : nF1;
325 for(; anIt.More(); anIt.Next()) {
326 Standard_Integer nIndexE = anIt.Key();
328 for(Standard_Integer interIt = 1; interIt <= aEFs.Length(); interIt++) {
329 const BOPTools_ESInterference& aEF = aEFs(interIt);
331 if((aEF.Index1() == nIndexE) && (nFOpposite == aEF.Index2())) {
332 IntTools_CommonPrt aCP = aEF.CommonPrt();
334 if(aCP.Type() == TopAbs_VERTEX) {
335 Standard_Real aPar = aCP.VertexParameter1();
336 // compute points and add to the list
338 Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(myDS->GetShape(nIndexE)), f,l);
339 Handle(Geom2d_Curve) aPCurve;
341 aPCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myDS->GetShape(nIndexE)),
345 aPCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myDS->GetShape(nIndexE)),
350 aCurve->D0(aPar, aPoint);
351 Standard_Real U1,V1,U2,V2;
352 IntSurf_PntOn2S aPnt;
353 if(!aPCurve.IsNull()) {
354 gp_Pnt2d aP2d = aPCurve->Value(aPar);
356 aProj2.Perform(aPoint);
357 if(aProj2.IsDone()) {
358 aProj2.LowerDistanceParameters(U2,V2);
359 aPnt.SetValue(aP2d.X(),aP2d.Y(),U2,V2);
360 aListOfPnts.Append(aPnt);
364 aProj1.Perform(aPoint);
365 if(aProj1.IsDone()) {
366 aProj1.LowerDistanceParameters(U1,V1);
367 aPnt.SetValue(U1,V1,aP2d.X(),aP2d.Y());
368 aListOfPnts.Append(aPnt);
373 aProj1.Perform(aPoint);
374 aProj2.Perform(aPoint);
375 if(aProj1.IsDone() && aProj2.IsDone()){
376 aProj1.LowerDistanceParameters(U1,V1);
377 aProj2.LowerDistanceParameters(U2,V2);
378 aPnt.SetValue(U1,V1,U2,V2);
379 aListOfPnts.Append(aPnt);
389 Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone;
390 Standard_Real anApproxTol, aTolR3D, aTolR2D;
392 bToApproxC3d = mySectionAttribute.Approximation();
393 bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1();
394 bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2();
398 IntTools_FaceFace aFF;
400 aFF.SetContext(myContext);
402 aFF.SetParameters (bToApproxC3d,
407 if (!aListOfPnts.IsEmpty()) {
408 aFF.SetList(aListOfPnts);
411 aFF.Perform(aF1, aF2);
413 bIsDone=aFF.IsDone();
415 // Add Interference to the Pool
416 aTolR3D=aFF.TolReached3d();
417 aTolR2D=aFF.TolReached2d();
418 if (aTolR3D < 1.e-7){
421 aFF.PrepareLines3D(bToSplit);
424 Standard_Integer aNbCurves, aNbPoints;
426 const IntTools_SequenceOfCurves& aCvs=aFF.Lines();
427 aNbCurves=aCvs.Length();
429 const IntTools_SequenceOfPntOn2Faces& aPnts=aFF.Points();
430 aNbPoints=aPnts.Length();
432 if (!aNbCurves && !aNbPoints) {
434 bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith);
437 myIntrPool->AddInterference (nF1, nF2, BooleanOperations_SurfaceSurface, anIndexIn);
442 BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvs, aPnts);
443 anIndexIn=aFFs.Append(anInterf);
445 myIntrPool->AddInterference (nF1, nF2, BooleanOperations_SurfaceSurface, anIndexIn);
451 bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith);
454 myIntrPool->AddInterference (nF1, nF2, BooleanOperations_SurfaceSurface, anIndexIn);
457 IntTools_SequenceOfPntOn2Faces aPnts;
458 IntTools_SequenceOfCurves aCvs;
460 BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
461 anIndexIn=aFFs.Append(anInterf);
462 myIntrPool->AddInterference (nF1, nF2, BooleanOperations_SurfaceSurface, anIndexIn);
465 }// for (; myDSIt.More(); myDSIt.Next())
466 myIsDone=Standard_True;
468 //=======================================================================
469 // function: MakeBlocks
471 //=======================================================================
472 void BOPTools_PaveFiller::MakeBlocks()
474 Standard_Integer i, j, aNbCurves, aNbFFs, nF1, nF2, aBid=0, nV1, nV2;
475 Standard_Real aTolR3D, aT1, aT2;
476 Standard_Boolean bValid, bCoincide;
478 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
480 aNbFFs=aFFs.Extent();
482 for (i=1; i<=aNbFFs; i++) {
483 BOPTools_SSInterference& aFFi=aFFs(i);
489 aTolR3D=aFFi.TolR3D();
492 const TopoDS_Face& aF1=TopoDS::Face(myDS->GetShape(nF1));
493 const TopoDS_Face& aF2=TopoDS::Face(myDS->GetShape(nF2));
495 TColStd_MapOfInteger aMap;
496 BOPTools_ListOfPaveBlock aLPB;
497 SplitsInFace (aBid, nF1, nF2, aLPB);
498 SplitsInFace (aBid, nF2, nF1, aLPB);
499 SplitsOnFace (aBid, nF1, nF2, aLPB);
501 BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
502 for (; anIt.More(); anIt.Next()) {
503 const BOPTools_PaveBlock& aPB=anIt.Value();
504 aFFi.AppendBlock(aPB);
505 nV1=aPB.Pave1().Index();
506 nV2=aPB.Pave2().Index();
510 // Put existing paves on curves
511 // BOPTools_PaveSet aPSF;
512 // PrepareSetForFace (nF1, nF2, aPSF);
514 BOPTools_SequenceOfCurves& aSCvs = aFFi.Curves();
515 aNbCurves=aSCvs.Length();
518 // Pave Blocks On Curves
520 Standard_Boolean bIsPaveBlock;
521 Standard_Integer iCheckIntermediatePoint;
523 for (j=1; j<=aNbCurves; j++) {
524 BOPTools_Curve& aBC=aSCvs(j);
525 const IntTools_Curve& aC= aBC.Curve();
527 BOPTools_PaveSet& aPaveSet=aBC.Set();
528 BOPTools_PaveBlockIterator aPBIter(0, aPaveSet);
529 for (; aPBIter.More(); aPBIter.Next()) {
530 BOPTools_PaveBlock& aPBNew=aPBIter.Value();
532 aPBNew.SetFace1(nF1);
533 aPBNew.SetFace2(nF2);
535 nV1=aPBNew.Pave1().Index();
536 nV2=aPBNew.Pave2().Index();
538 if (aMap.Contains(nV1) && aMap.Contains(nV2)) {
540 const BOPTools_ListOfPaveBlock& aLPBExisting=aFFi.PaveBlocks();
541 bIsPaveBlock=IsPaveBlock(nV1, nV2, aLPBExisting);
543 iCheckIntermediatePoint=1;
545 BOPTools_ListIteratorOfListOfPaveBlock anItLPB(aLPBExisting);
547 for (; anItLPB.More(); anItLPB.Next()) {
548 const BOPTools_PaveBlock& aPBR=anItLPB.Value();
549 iCheckIntermediatePoint=
550 CheckIntermediatePoint(aPBNew, aPBR, aTolR3D);
551 if (!iCheckIntermediatePoint) {
555 bIsPaveBlock=bIsPaveBlock && !iCheckIntermediatePoint;
564 iCheckIntermediatePoint=0;
567 aT1=aPBNew.Pave1().Param();
568 aT2=aPBNew.Pave2().Param();
570 if((nV1 == nV2) && (Abs(aT2 - aT1) < Precision::PConfusion())) {
574 // Checking of validity in 2D
576 Standard_Real aTolerance = (aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D;
577 bValid=myContext->IsValidBlockForFaces(aT1, aT2, aC, aF1, aF2, aTolerance);
583 // Checking the paveblocks for coinsidence with aLPB
584 bCoincide=CheckCoincidence (aPBNew, aFFi);
586 bCoincide=bCoincide && !iCheckIntermediatePoint;
592 // reject pave block (FF) v1==v2 for too small sect. edge
593 TopoDS_Vertex aV1=TopoDS::Vertex(myDS->GetShape(nV1));
594 TopoDS_Vertex aV2=TopoDS::Vertex(myDS->GetShape(nV2));
595 Standard_Boolean rejectPaveBlock = Standard_False;
596 if(aV1.IsSame(aV2)) {
597 Standard_Real aRT = 1.e-7;
598 rejectPaveBlock = RejectPaveBlock(aC,aT1,aT2,aV1,aRT);
599 if(rejectPaveBlock) {
602 BB.UpdateVertex( aV1, 2*aRT );
608 aBC.AppendNewBlock(aPBNew);
610 } // end of for (j=1; j<=aNbCurves; j++)
611 }// end of for (i=1; i<=aNbFFs; i++)
613 //=======================================================================
614 // function: MakeAloneVertices
616 //=======================================================================
617 void BOPTools_PaveFiller::MakeAloneVertices()
619 Standard_Integer i, j, k, aNbFFs, aNbCurves, nF1, nF2, nV, aNbAlone, aNbV;
620 Standard_Boolean bFlag=Standard_False;
622 BOPTools_ListIteratorOfListOfPave anIt;
623 TColStd_IndexedMapOfInteger aMap;
624 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
626 aNbFFs=aFFs.Extent();
627 for (i=1; i<=aNbFFs; i++) {
628 BOPTools_SSInterference& aFFi=aFFs(i);
630 const IntTools_SequenceOfPntOn2Faces& aSeqAlonePnts=aFFi.AlonePnts();
631 aNbAlone=aSeqAlonePnts.Length();
640 TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));
641 TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));
643 // 1. fill aMap where all indices for (F/F) vertices are
646 BOPTools_PaveSet aPSF;
648 PrepareSetForFace (nF1, nF2, aPSF);
649 const BOPTools_ListOfPave& aLPaves=aPSF.Set();
650 anIt.Initialize(aLPaves);
651 for (; anIt.More(); anIt.Next()) {
652 const BOPTools_Pave& aPave=anIt.Value();
657 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
658 aNbCurves=aSCvs.Length();
659 for (j=1; j<=aNbCurves; j++) {
660 BOPTools_Curve& aBC=aSCvs(j);
661 const BOPTools_PaveSet& aCPSF=aBC.Set();
662 const BOPTools_ListOfPave& aLPs=aCPSF.Set();
663 anIt.Initialize(aLPs);
664 for (; anIt.More(); anIt.Next()) {
665 const BOPTools_Pave& aPv=anIt.Value();
671 // 2. check alone points on closure with aMap's vertices
672 Standard_Integer iVV;
673 Standard_Real aTolVAlone, aTolF1, aTolF2;
674 TopoDS_Vertex aVAlone;
677 aTolF1=BRep_Tool::Tolerance(aF1);
678 aTolF2=BRep_Tool::Tolerance(aF2);
679 aTolVAlone=aTolF1+aTolF2;
682 for (j=1; j<=aNbAlone; ++j) {
683 const IntTools_PntOn2Faces& aP2F=aSeqAlonePnts(j);
684 const IntTools_PntOnFace& aPF1=aP2F.P1();
685 const gp_Pnt& aPAlone=aPF1.Pnt();
686 aBB.MakeVertex(aVAlone, aPAlone, aTolVAlone);
690 for (k=1; k<=aNbV; ++k) {
692 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
694 iVV= IntTools_Tools::ComputeVV (aVAlone, aV);
696 // It means that aVAlone and aV coinsided so
697 // we do not need to insert aVAlone into the DS
698 bFlag=Standard_False;
704 Standard_Boolean bVF;
705 Standard_Integer aNewShape;
707 bVF=myContext->IsValidPointForFaces (aPAlone, aF1, aF2, 1.e-3);
710 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
711 myDS->InsertShapeAndAncestorsSuccessors(aVAlone, anASSeq);
712 aNewShape=myDS->NumberOfInsertedShapes();
713 myDS->SetState (aNewShape, BooleanOperations_ON);
715 TColStd_ListOfInteger& anAloneVertices=aFFi.AloneVertices();
716 anAloneVertices.Append(aNewShape);
723 //=======================================================================
724 // function: CheckCoincidence
726 //=======================================================================
727 Standard_Boolean BOPTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock& aPB,
728 const BOPTools_SSInterference& aFFi)
731 Standard_Real aTolC, aTE, aT11, aT12;
732 Standard_Integer nV11, nV12, nV21, nV22, iVV, iVE, nE2, iCount=0, iCountExt=1;
737 const BOPTools_Pave& aPave11=aPB.Pave1();
738 nV11=aPave11.Index();
739 const TopoDS_Vertex& aV11=TopoDS::Vertex(myDS->GetShape(nV11));
740 aT11=aPave11.Param();
742 const BOPTools_Pave& aPave12=aPB.Pave2();
743 nV12=aPave12.Index();
744 const TopoDS_Vertex& aV12=TopoDS::Vertex(myDS->GetShape(nV12));
745 aT12=aPave12.Param();
747 const BOPTools_ListOfPaveBlock& aLPB=aFFi.PaveBlocks();
748 BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
749 for (; anIt.More(); anIt.Next()) {
753 const BOPTools_PaveBlock& aPBR=anIt.Value();
755 const BOPTools_Pave& aPave21=aPBR.Pave1();
756 nV21=aPave21.Index();
757 const TopoDS_Vertex& aV21=TopoDS::Vertex(myDS->GetShape(nV21));
759 const BOPTools_Pave& aPave22=aPBR.Pave2();
760 nV22=aPave22.Index();
761 const TopoDS_Vertex& aV22=TopoDS::Vertex(myDS->GetShape(nV22));
764 const TopoDS_Edge& aE2=TopoDS::Edge(myDS->GetShape(nE2));
768 iVV=IntTools_Tools::ComputeVV (aV11, aV21);
772 if (iCount>iCountExt) {
777 iVV=IntTools_Tools::ComputeVV (aV11, aV22);
781 if (iCount>iCountExt) {
788 iVE=myContext->ComputeVE (aV11, aE2, aTE);
791 if (iCount>iCountExt) {
799 iVV=IntTools_Tools::ComputeVV (aV12, aV21);
803 if (iCount>iCountExt) {
808 iVV=IntTools_Tools::ComputeVV (aV12, aV22);
812 if (iCount>iCountExt) {
819 iVE=myContext->ComputeVE (aV12, aE2, aTE);
823 if (iCount>iCountExt) {
830 return (iCount>iCountExt);
832 //=======================================================================
833 // function: CheckIntermediatePoint
835 //=======================================================================
836 Standard_Integer BOPTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
837 const BOPTools_PaveBlock& aPBR,
838 const Standard_Real aTolC)
841 Standard_Real aT11, aT12, aTM, aTmp;
842 Standard_Integer iVM, nE2;
849 const BOPTools_Pave& aPave11=aPB.Pave1();
850 aT11=aPave11.Param();
852 const BOPTools_Pave& aPave12=aPB.Pave2();
853 aT12=aPave12.Param();
855 aTM=IntTools_Tools::IntermediatePoint (aT11, aT12);
857 const IntTools_Curve& aIC=aPB.Curve();
860 aBB.MakeVertex (aVM, aPM, aTolC);
864 const TopoDS_Edge& aE2=TopoDS::Edge(myDS->GetShape(nE2));
866 iVM=myContext->ComputeVE(aVM, aE2, aTmp);
870 //=======================================================================
871 // function: PutBoundPaveOnCurve
873 //=======================================================================
874 void BOPTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC,
875 BOPTools_SSInterference& aFFi)
877 Standard_Boolean bHasBounds, bVF;
880 const IntTools_Curve& aIC=aBC.Curve();
881 bHasBounds=aIC.HasBounds ();
887 Standard_Integer nF1, nF2;
888 Standard_Real aT1, aT2, aTolR3D;
892 aIC.Bounds (aT1, aT2, aP1, aP2);
898 aTolR3D=aFFi.TolR3D();
900 TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1));
901 TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2));
903 bVF=myContext->IsValidPointForFaces (aP1, aF1, aF2, aTolR3D);
906 PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi);
909 bVF=myContext->IsValidPointForFaces (aP2, aF1, aF2, aTolR3D);
912 PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi);
915 //=======================================================================
916 // function: PutBoundPaveOnCurve
918 //=======================================================================
919 void BOPTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP,
920 const Standard_Real aT,
922 BOPTools_SSInterference& aFFi)
924 Standard_Boolean bFound1, bFound2;
926 Standard_Real aTolV=aFFi.TolR3D();
928 BOPTools_Pave aPave1, aPave2, aPave;
929 BOPTools_PaveSet& aCPS=aBC.Set();
930 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
931 const IntTools_Curve& aIC=aBC.Curve();
933 bFound1=FindPave(aP, aTolV, aCPS , aPave1);
934 bFound2=FindPave(aP, aTolV, aFFiPS, aPave2);
936 if (!bFound1 && !bFound2) {
937 TopoDS_Vertex aNewVertex;
938 BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex);
940 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
941 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
942 nV=myDS->NumberOfInsertedShapes();
947 aFFiPS.Append(aPave);
949 // Append Techno Vertex to the Curve
950 TColStd_ListOfInteger& aTVs=aBC.TechnoVertices();
954 if (bFound1 && !bFound2) {
958 aFFiPS.Append(aPave);
960 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
961 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
964 if (!bFound1 && bFound2) {
970 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
971 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
975 //=======================================================================
976 // function: PutBoundPaveOnCurveSpec
978 //=======================================================================
979 void BOPTools_PaveFiller::PutBoundPaveOnCurveSpec(BOPTools_Curve& aBC,
980 BOPTools_SSInterference& aFFi)
982 Standard_Boolean bHasBounds, bVF;
985 const IntTools_Curve& aIC=aBC.Curve();
986 bHasBounds=aIC.HasBounds ();
992 Standard_Integer nF1, nF2;
993 Standard_Real aT1, aT2, aTolR3D;
997 aIC.Bounds (aT1, aT2, aP1, aP2);
1003 aTolR3D=aFFi.TolR3D();
1005 TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1));
1006 TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2));
1008 bVF=myContext->IsValidPointForFaces (aP1, aF1, aF2, aTolR3D);
1011 PutBoundPaveOnCurveSpec (aP1, aT1, aBC, aFFi);
1014 bVF=myContext->IsValidPointForFaces (aP2, aF1, aF2, aTolR3D);
1017 PutBoundPaveOnCurveSpec (aP2, aT2, aBC, aFFi);
1020 //=======================================================================
1021 // function: PutBoundPaveOnCurveSpec
1023 //=======================================================================
1024 void BOPTools_PaveFiller::PutBoundPaveOnCurveSpec(const gp_Pnt& aP,
1025 const Standard_Real aT,
1026 BOPTools_Curve& aBC,
1027 BOPTools_SSInterference& aFFi)
1029 Standard_Boolean bFound1, bFound2;
1030 Standard_Integer nV;
1031 Standard_Real aTolV=aFFi.TolR3D();
1033 BOPTools_Pave aPave1, aPave2, aPave;
1034 BOPTools_PaveSet& aCPS=aBC.Set();
1035 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
1036 const IntTools_Curve& aIC=aBC.Curve();
1038 bFound1=FindPave(aP, aTolV, aCPS , aPave1);
1039 bFound2=FindPave(aP, aTolV, aFFiPS, aPave2);
1041 if (!bFound1 && !bFound2) {
1042 TopoDS_Vertex aNewVertex;
1043 BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex);
1045 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
1046 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
1047 nV=myDS->NumberOfInsertedShapes();
1052 aFFiPS.Append(aPave);
1054 // Append Techno Vertex to the Curve
1055 TColStd_ListOfInteger& aTVs=aBC.TechnoVertices();
1058 //To check, if face boundary must be split by new vertex
1059 TopTools_MapOfShape aMap;
1061 Standard_Integer anErrStat;
1062 Standard_Integer aWhat, aWith, anIndexIn;
1063 BOPTools_CArray1OfVEInterference& aVEs=myIntrPool->VEInterferences();
1065 Standard_Integer nF1=aFFi.Index1();
1066 const TopoDS_Shape aF1 = myDS->GetShape(nF1);
1068 Standard_Integer nF2=aFFi.Index2();
1069 const TopoDS_Shape aF2 = myDS->GetShape(nF2);
1072 Standard_Integer aRank = myDS->Rank(nF1);
1073 TopExp_Explorer anExp(aF1, TopAbs_EDGE);
1074 for(; anExp.More(); anExp.Next()) {
1076 const TopoDS_Shape& anE = anExp.Current();
1077 if (BRep_Tool::Degenerated(TopoDS::Edge(anE))){
1081 if(!aMap.Add(anE)) continue;
1084 myContext->ComputeVE(aNewVertex, TopoDS::Edge(anE), aPar);
1085 if(anErrStat) continue;
1087 Standard_Real aT1, aT2;
1089 aIC.Bounds(aT1, aT2, aP1, aP2);
1090 //Check if any other point on curve belongs edge
1091 aT1 = 0.5*(aT1+aT2);
1093 TopoDS_Vertex aNewVertex1;
1094 BOPTools_Tools::MakeNewVertex(aP1, aTolV, aNewVertex1);
1096 myContext->ComputeVE(aNewVertex1, TopoDS::Edge(anE), aT1);
1097 if(!anErrStat) continue; //curve and edge seem to be coincide
1100 aWith = myDS->ShapeIndex(anE, aRank);
1101 BOPTools_VEInterference anInterf (aWhat, aWith, aPar);
1102 anIndexIn=aVEs.Append(anInterf);
1104 // Add Pave to the Edge's myPavePool
1105 BOPTools_Pave aPave3(aWhat, aPar, BooleanOperations_VertexEdge);
1106 aPave3.SetInterference(anIndexIn);
1107 BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith));
1108 aPaveSet.Append(aPave3);
1111 // State for the Vertex in DS;
1112 myDS->SetState (aWhat, BooleanOperations_ON);
1113 // Insert Vertex in Interference Object
1114 BOPTools_VEInterference& aVE=aVEs(anIndexIn);
1115 aVE.SetNewShape(aWhat);
1117 PreparePaveBlocks(aWith);
1118 RecomputeCommonBlocks(aWith);
1121 aRank = myDS->Rank(nF2);
1122 anExp.Init(aF2, TopAbs_EDGE);
1123 for(; anExp.More(); anExp.Next()) {
1124 const TopoDS_Shape& anE = anExp.Current();
1125 if (BRep_Tool::Degenerated(TopoDS::Edge(anE))){
1129 if(!aMap.Add(anE)) continue;
1132 myContext->ComputeVE(aNewVertex, TopoDS::Edge(anE), aPar);
1133 if(anErrStat) continue;
1135 Standard_Real aT1, aT2;
1137 aIC.Bounds(aT1, aT2, aP1, aP2);
1138 //Check if any other point on curve belongs edge
1139 aT1 = 0.5*(aT1+aT2);
1141 TopoDS_Vertex aNewVertex1;
1142 BOPTools_Tools::MakeNewVertex(aP1, aTolV, aNewVertex1);
1144 myContext->ComputeVE(aNewVertex1, TopoDS::Edge(anE), aT1);
1145 if(!anErrStat) continue; //curve and edge seem to be coincide
1148 aWith = myDS->ShapeIndex(anE, aRank);
1149 BOPTools_VEInterference anInterf (aWhat, aWith, aPar);
1150 anIndexIn=aVEs.Append(anInterf);
1152 // Add Pave to the Edge's myPavePool
1153 BOPTools_Pave aPave3(aWhat, aPar, BooleanOperations_VertexEdge);
1154 aPave3.SetInterference(anIndexIn);
1155 BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith));
1156 aPaveSet.Append(aPave3);
1159 // State for the Vertex in DS;
1160 myDS->SetState (aWhat, BooleanOperations_ON);
1161 // Insert Vertex in Interference Object
1162 BOPTools_VEInterference& aVE=aVEs(anIndexIn);
1163 aVE.SetNewShape(aWhat);
1165 PreparePaveBlocks(aWith);
1166 RecomputeCommonBlocks(aWith);
1171 if (bFound1 && !bFound2) {
1175 aFFiPS.Append(aPave);
1177 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
1178 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
1181 if (!bFound1 && bFound2) {
1187 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
1188 BOPTools_Tools::UpdateVertex (aIC, aT, aV);
1191 //=======================================================================
1192 // function: FindPave
1194 //=======================================================================
1195 Standard_Boolean BOPTools_PaveFiller::FindPave(const gp_Pnt& aP,
1196 const Standard_Real aTolPV,
1197 const BOPTools_PaveSet& aPS,
1198 BOPTools_Pave& aPave)
1200 Standard_Integer nV;
1201 Standard_Boolean bIsVertex=Standard_False;
1203 const BOPTools_ListOfPave& aLP=aPS.Set();
1204 BOPTools_ListIteratorOfListOfPave anIt(aLP);
1205 for (; anIt.More(); anIt.Next()) {
1206 const BOPTools_Pave& aPC=anIt.Value();
1208 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->GetShape(nV));
1209 bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV);
1217 //=======================================================================
1218 // function: MakeSectionEdges
1220 //=======================================================================
1221 void BOPTools_PaveFiller::MakeSectionEdges()
1223 Standard_Integer i, j, aNbCurves, aNbFFs, nF1, nF2, nV1, nV2, aNbPaveBlocks,
1225 Standard_Real t1, t2;
1227 TopoDS_Vertex aV1, aV2;
1230 Standard_Integer pbi = 0;
1233 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
1235 aNbFFs=aFFs.Extent();
1236 for (i=1; i<=aNbFFs; i++) {
1237 BOPTools_SSInterference& aFFi=aFFs(i);
1241 Standard_Real aTF = 1.e-7;
1242 TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1));
1243 TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2));
1244 Standard_Boolean isModT = ModifFFTol(aF1,aF2,aTF);
1245 Standard_Real aTolFF = (isModT) ? Max(aTF,aFFi.TolR3D()) : aFFi.TolR3D();
1246 BOPTools_ListOfPaveBlock aFFPBL;
1247 TopTools_ListOfShape aFFSEL;
1249 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
1250 aNbCurves=aSCvs.Length();
1251 for (j=1; j<=aNbCurves; j++) {
1252 BOPTools_Curve& aBC=aSCvs(j);
1253 const IntTools_Curve& aIC=aBC.Curve();
1255 const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks();
1256 aNbPaveBlocks=aSectEdges.Extent();
1257 BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges);
1259 for (; aPBIt.More(); aPBIt.Next()) {
1261 BOPTools_PaveBlock& aPB=aPBIt.Value();
1264 const BOPTools_Pave& aPave1=aPB.Pave1();
1267 aV1=TopoDS::Vertex(myDS->GetShape(nV1));
1268 aV1.Orientation(TopAbs_FORWARD);
1271 const BOPTools_Pave& aPave2=aPB.Pave2();
1274 aV2=TopoDS::Vertex(myDS->GetShape(nV2));
1275 aV2.Orientation(TopAbs_REVERSED);
1279 // reject building parallel sect. edge on the same pave block,
1280 // if distance between created and this edges is too small
1281 if(IsPaveBlock(nV1,nV2,aFFPBL)) {
1282 Standard_Real diffTol = 1.e-7;
1283 Standard_Integer eI = RejectBuildingEdge(aIC,aV1,aV2,t1,t2,aFFSEL,diffTol);
1285 Standard_Integer eIndex = 0;
1286 TopTools_ListIteratorOfListOfShape aSEIt(aFFSEL);
1287 for(; aSEIt.More(); aSEIt.Next()) {
1290 const TopoDS_Edge & aE = TopoDS::Edge(aSEIt.Value());
1291 TopoDS_Edge& anEdge = (TopoDS_Edge &) aE;
1292 BOPTools_ListOfPaveBlock& aListPB = (BOPTools_ListOfPaveBlock&) aSectEdges;
1293 aListPB.Remove(aPBIt);
1294 BB.UpdateEdge( anEdge, 2*(aTolFF+diffTol) );
1295 BB.UpdateVertex( aV1, 2*(aTolFF+diffTol) );
1296 BB.UpdateVertex( aV2, 2*(aTolFF+diffTol) );
1307 if(fabs(t1-t2) <= 1.e-10) continue;
1308 BOPTools_Tools::MakeSectEdge (aIC, aV1, t1, aV2, t2, aESect);
1310 BB.UpdateEdge( aESect, aTolFF );
1311 BB.UpdateVertex( aV1, aTolFF );
1312 BB.UpdateVertex( aV2, aTolFF );
1313 ///////////////////////////////////
1314 // Add Sect Part to the DS
1315 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
1317 anASSeq.SetNewSuccessor(nV1);
1318 anASSeq.SetNewOrientation(aV1.Orientation());
1320 anASSeq.SetNewSuccessor(nV2);
1321 anASSeq.SetNewOrientation(aV2.Orientation());
1323 myDS->InsertShapeAndAncestorsSuccessors(aESect, anASSeq);
1324 aNewShapeIndex=myDS->NumberOfInsertedShapes();
1326 aPB.SetEdge(aNewShapeIndex);
1328 aFFSEL.Append(aESect);
1335 //=======================================================================
1336 // function: PutPaveOnCurve
1338 //=======================================================================
1339 void BOPTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
1340 const Standard_Real aTolR3D,
1341 BOPTools_Curve& aBC)
1343 const BOPTools_ListOfPave& aLP=aPaveSet.Set();
1344 BOPTools_ListIteratorOfListOfPave anIt(aLP);
1345 for (; anIt.More(); anIt.Next()) {
1346 const BOPTools_Pave& aPave=anIt.Value();
1347 PutPaveOnCurve (aPave, aTolR3D, aBC);
1350 //=======================================================================
1351 // function: PutPaveOnCurve
1353 //=======================================================================
1354 void BOPTools_PaveFiller::PutPaveOnCurve (const BOPTools_Pave& aPave,
1355 const Standard_Real aTolR3D,
1356 BOPTools_Curve& aBC)
1358 Standard_Integer nV;
1359 Standard_Boolean bIsVertexOnLine;
1360 Standard_Real aT, aTolVExt, aTolTresh;
1365 const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
1366 const IntTools_Curve& aC=aBC.Curve();
1367 Handle (Geom_Curve) aC3D= aC.Curve();
1369 aTolVExt=BRep_Tool::Tolerance(aV);
1370 ExtendedTolerance(nV, aTolVExt);
1371 bIsVertexOnLine=myContext->IsVertexOnLine(aV, aTolVExt, aC, aTolR3D, aT);
1373 if (bIsVertexOnLine) {
1374 BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface);
1375 BOPTools_PaveSet& aPaveSet=aBC.Set();
1376 aPaveSet.Append(aPaveNew);
1378 BOPTools_Tools::UpdateVertex (aC, aT, aV);
1379 if(aTolR3D<aTolTresh) {
1380 aBB.UpdateVertex(aV, aTolR3D);
1385 //=======================================================================
1386 // function: ExtendedTolerance
1388 //=======================================================================
1389 Standard_Boolean BOPTools_PaveFiller::ExtendedTolerance(const Standard_Integer nV,
1390 Standard_Real& aTolVExt)
1392 Standard_Boolean bFound, bIsNewShape;
1393 Standard_Integer k, i, aNbLines, aNewShape;
1394 Standard_Real aT11, aT12, aD1, aD2, aD;
1396 gp_Pnt aPV, aP11, aP12;
1398 bFound=Standard_False;
1400 bIsNewShape=myDS->IsNewShape(nV);
1405 aV=TopoDS::Vertex(myDS->Shape(nV));
1406 aPV=BRep_Tool::Pnt(aV);
1408 const BOPTools_InterferencePool& anInterferencePool=*myIntrPool;
1409 const BOPTools_CArray1OfEEInterference& aEEInterfs=anInterferencePool.EEInterfs();
1410 const BOPTools_CArray1OfESInterference& aESInterfs=anInterferencePool.ESInterfs();
1412 for (k=0; k<2; ++k) {
1413 aNbLines=(!k) ? aEEInterfs.Extent() : aESInterfs.Extent();
1414 for (i=1; i<=aNbLines; ++i) {
1415 BOPTools_ShapeShapeInterference *pI=(!k) ?
1416 (BOPTools_ShapeShapeInterference *)&aEEInterfs(i):
1417 (BOPTools_ShapeShapeInterference *)&aESInterfs(i);
1419 aNewShape=pI->NewShape();
1420 if (aNewShape==nV) {
1421 const IntTools_CommonPrt& aCPart=(!k) ?
1422 aEEInterfs(i).CommonPrt() :
1423 aESInterfs(i).CommonPrt();
1425 const TopoDS_Edge& aE1=aCPart.Edge1();
1426 aCPart.Range1(aT11, aT12);
1427 BOPTools_Tools::PointOnEdge(aE1, aT11, aP11);
1428 BOPTools_Tools::PointOnEdge(aE1, aT12, aP12);
1429 aD1=aPV.Distance(aP11);
1430 aD2=aPV.Distance(aP12);
1431 aD=(aD1>aD2)? aD1 : aD2;
1444 //=======================================================================
1445 // function: PutPavesOnCurves
1447 //=======================================================================
1448 void BOPTools_PaveFiller::PutPavesOnCurves ()
1450 Standard_Integer i, j, aNbCurves, aNbFFs, nF1, nF2, nV;
1451 Standard_Real aTolR3D = 0.;
1453 BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
1455 aNbFFs=aFFs.Extent();
1457 for (i=1; i<=aNbFFs; i++) {
1458 BOPTools_SSInterference& aFFi=aFFs(i);
1460 // Curves' tolerance
1461 aTolR3D=aFFi.TolR3D();
1468 // Put existing paves on curves
1469 BOPTools_PaveSet aPSF;
1470 PrepareSetForFace (nF1, nF2, aPSF);
1474 Standard_Integer nVX;
1475 BOPTools_ListIteratorOfListOfPave aItLP;
1476 TColStd_MapOfInteger aMVStick;
1478 const BOPTools_ListOfPave& aLPX=aPSF.Set();
1479 aItLP.Initialize(aLPX);
1480 for (; aItLP.More(); aItLP.Next()) {
1481 const BOPTools_Pave& aPX=aItLP.Value();
1486 CorrectTolR3D(*this, aFFi, aMVStick, aTolR3D);
1490 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
1491 aNbCurves=aSCvs.Length();
1492 for (j=1; j<=aNbCurves; j++) {
1493 BOPTools_Curve& aBC=aSCvs(j);
1495 const IntTools_Curve& aC=aBC.Curve();
1496 Handle (Geom_Curve) aC3D= aC.Curve();
1498 PutPaveOnCurve (aPSF, aTolR3D, aBC);
1502 Standard_Integer aNbVtx, jx;
1503 Standard_Real aTolVRange;
1504 TColStd_SequenceOfInteger aSeqVx;
1505 TColStd_SequenceOfReal aSeqTolVx;
1507 ProcessAloneStickVertices(nF1,
1515 aNbVtx=aSeqVx.Length();
1516 for (jx=1; jx<=aNbVtx; ++jx) {
1517 BOPTools_PaveSet aPSFx;
1521 aTolVRange=aSeqTolVx(jx);
1526 for (j=1; j<=aNbCurves; j++) {
1527 BOPTools_Curve& aBC=aSCvs(j);
1529 const IntTools_Curve& aC=aBC.Curve();
1530 Handle (Geom_Curve) aC3D= aC.Curve();
1532 PutPaveOnCurve (aPSFx, aTolVRange, aBC);
1538 // Put bounding paves on curves
1539 //Check very specific case of cone-cone intersection (OCC13211)
1541 Standard_Boolean bIsSpecific = Standard_False;
1542 if(aNbCurves >= 4) {
1543 const TopoDS_Shape aF1 = myDS->GetShape(nF1);
1544 BRepAdaptor_Surface aS1(TopoDS::Face(aF1), Standard_False);
1545 GeomAbs_SurfaceType aSType = aS1.GetType();
1546 if(aSType == GeomAbs_Cone) {
1547 const TopoDS_Shape aF2 = myDS->GetShape(nF2);
1548 BRepAdaptor_Surface aS2(TopoDS::Face(aF2), Standard_False);
1549 aSType = aS2.GetType();
1550 if(aSType == GeomAbs_Cone) {
1551 bIsSpecific = Standard_True;
1557 for (j=1; j<=aNbCurves; j++) {
1558 BOPTools_Curve& aBC=aSCvs(j);
1559 PutBoundPaveOnCurveSpec (aBC, aFFi);
1563 for (j=1; j<=aNbCurves; j++) {
1564 BOPTools_Curve& aBC=aSCvs(j);
1565 PutBoundPaveOnCurve (aBC, aFFi);
1569 // Put closing pave if needded
1570 for (j=1; j<=aNbCurves; ++j) {
1571 BOPTools_Curve& aBC=aSCvs(j);
1572 PutClosingPaveOnCurve (aBC, aFFi);
1576 for (j=1; j<=aNbCurves; j++) {
1577 BOPTools_Curve& aBC=aSCvs(j);
1578 BOPTools_ListOfPave anOldList;
1579 anOldList = aBC.Set().Set();
1581 if (aBC.NewPaveBlocks().IsEmpty()) {
1586 BOPTools_CArray1OfESInterference& aESs = myIntrPool->ESInterferences();
1587 Standard_Integer k, fit;
1589 // Among all aESs find those that are between nE1 from nF1(nE2 from nF2) and nF2(nF1)
1590 for(k = 1; k <= aESs.Length(); k++) {
1591 BOPTools_ESInterference& aES = aESs(k);
1593 if(aES.Index1() == nF1 || aES.Index2() == nF2) {
1594 Standard_Integer nE = (aES.Index1() == nF1) ? aES.Index2() : aES.Index1();
1596 // check if it belongs to F1 or F2.begin
1597 Standard_Boolean edgefound = Standard_False;
1599 for(fit = 0; !edgefound && (fit < 2); fit++) {
1600 Standard_Integer nF = (fit == 0) ? nF1 : nF2;
1601 Standard_Integer sit1 = 0, sit2 = 0;
1603 for(sit1 = 1; !edgefound && (sit1 <= myDS->NumberOfSuccessors(nF)); sit1++) {
1604 Standard_Integer asuccessor = myDS->GetSuccessor(nF, sit1);
1606 for(sit2 = 1; sit2 <= myDS->NumberOfSuccessors(asuccessor); sit2++) {
1607 if(nE == myDS->GetSuccessor(asuccessor, sit2)) {
1608 edgefound = Standard_True;
1614 // check if it belongs to F1 or F2.end
1617 RestrictCurveIn2d (nE, nF1, nF2, aTolR3D, aBC);// ->
1620 }// for(k = 1; k <= aESs.Length(); k++)
1622 for(fit = 1; fit <= 2; fit++) {
1623 Standard_Integer nF = (fit == 1) ? nF1 : nF2;
1624 Standard_Integer nFOpposite = (fit == 1) ? nF2 : nF1;
1625 TopExp_Explorer anExp(myDS->Shape(nF), TopAbs_EDGE);
1627 for(; anExp.More(); anExp.Next()) {
1628 Standard_Integer nE = myDS->ShapeIndex(anExp.Current(), fit);
1631 const BOPTools_ListOfInterference& aList =
1632 myIntrPool->InterferenceTable().Value(nE).GetOnType(BooleanOperations_EdgeSurface);
1633 BOPTools_ListIteratorOfListOfInterference anIt2(aList);
1634 Standard_Boolean bProcessed = Standard_False;
1636 for(; anIt2.More(); anIt2.Next()) {
1637 if(anIt2.Value().With() == nFOpposite) {
1639 RestrictCurveIn2d (nE, nF1, nF2, aTolR3D, aBC);
1640 bProcessed = Standard_True;
1646 if(!myCommonBlockPool(myDS->RefEdge(nE)).IsEmpty() &&
1648 RestrictCurveIn2d (nE, nF1, nF2, aTolR3D, aBC);
1653 // end for(fit = 1...
1655 // put new paves on other curves.begin
1656 BOPTools_ListOfPave aListOfNewPave;
1657 BOPTools_ListIteratorOfListOfPave anIt1, anIt2;
1659 for(anIt1.Initialize(aBC.Set().Set()); anIt1.More(); anIt1.Next()) {
1660 Standard_Boolean bfound = Standard_False;
1661 for(anIt2.Initialize(anOldList); anIt2.More(); anIt2.Next()) {
1662 if(anIt1.Value().IsEqual(anIt2.Value())) {
1663 bfound = Standard_True;
1669 aListOfNewPave.Append(anIt1.Value());
1673 Standard_Integer m = 0, n = 0;
1674 for (m=1; m<=aNbFFs; m++) {
1675 BOPTools_SSInterference& aFFm = aFFs(m);
1677 // Curves' tolerance
1678 Standard_Real aTolR3D2 = aFFm.TolR3D();
1680 BOPTools_SequenceOfCurves& aSCvs2 = aFFm.Curves();
1681 Standard_Integer aNbCurves2 = aSCvs2.Length();
1683 for(n = 1; n <= aNbCurves2; n++) {
1684 if((n == j) && (m == i))
1686 BOPTools_Curve& aBC2 = aSCvs2(n);
1688 for(anIt1.Initialize(aListOfNewPave); anIt1.More(); anIt1.Next()) {
1689 Standard_Boolean bfound = Standard_False;
1690 for(anIt2.Initialize(aBC2.Set().Set()); anIt2.More(); anIt2.Next()) {
1691 if(anIt1.Value().Index() == anIt2.Value().Index()) {
1692 bfound = Standard_True;
1698 PutPaveOnCurve (anIt1.Value(), aTolR3D2, aBC2);
1703 // put new paves on other curves.end
1704 } // xxx for (j=1; j<=aNbCurves; j++)
1708 Standard_Integer aNbVtx, jx;
1709 Standard_Real aTolVRange;
1710 TColStd_SequenceOfInteger aSeqVx;
1711 TColStd_SequenceOfReal aSeqTolVx;
1713 ProcessAloneStickVertices(nF1,
1722 aNbVtx=aSeqVx.Length();
1723 for (jx=1; jx<=aNbVtx; ++jx) {
1724 BOPTools_PaveSet aPSFx;
1728 aTolVRange=aSeqTolVx(jx);
1733 for (j=1; j<=aNbCurves; j++) {
1734 BOPTools_Curve& aBC=aSCvs(j);
1736 const IntTools_Curve& aC=aBC.Curve();
1737 Handle (Geom_Curve) aC3D= aC.Curve();
1739 PutPaveOnCurve (aPSFx, aTolVRange, aBC);
1746 //=======================================================================
1747 // function: PrepareSetForFace
1749 //=======================================================================
1750 void BOPTools_PaveFiller::PrepareSetForFace(const Standard_Integer nF1,
1751 const Standard_Integer nF2,
1752 BOPTools_PaveSet& aPaveSet)
1754 Standard_Integer i, aNbV, nV;
1755 TColStd_IndexedMapOfInteger aMV;
1757 StickVertices(nF1, nF2, aMV);
1760 for (i=1; i<=aNbV; ++i) {
1764 aPaveSet.Append(aPV);
1767 //=======================================================================
1768 // function: IsPaveBlock
1770 //=======================================================================
1771 Standard_Boolean IsPaveBlock(const Standard_Integer nV1,
1772 const Standard_Integer nV2,
1773 const BOPTools_ListOfPaveBlock& aLPBExisting)
1775 Standard_Boolean bFlag=Standard_True;
1776 Standard_Integer nVE1, nVE2;
1778 BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPBExisting);
1779 for (; anIt.More(); anIt.Next()) {
1780 const BOPTools_PaveBlock& aPBR=anIt.Value();
1782 nVE1=aPBR.Pave1().Index();
1784 nVE2=aPBR.Pave2().Index();
1786 if ((nVE1==nV1 && nVE2==nV2) || (nVE2==nV1 && nVE1==nV2)) {
1793 //=======================================================================
1794 // function: FMapWhat
1796 //=======================================================================
1797 void FMapWhat(const Standard_Integer nF,
1798 BOPTools_InterferencePool* myIntrPool,
1799 TColStd_IndexedMapOfInteger& aMapWhat)
1802 Standard_Integer nE, nV;
1806 BooleanOperations_ShapesDataStructure* myDS=myIntrPool->DS();
1807 BooleanOperations_OnceExplorer aExp(*myDS);
1811 aExp.Init(nF, TopAbs_VERTEX);
1812 for (; aExp.More(); aExp.Next()) {
1817 aExp.Init(nF, TopAbs_EDGE);
1818 for (; aExp.More(); aExp.Next()) {
1824 //=======================================================================
1825 // function: FMapWith
1827 //=======================================================================
1828 void FMapWith(const Standard_Integer nF,
1829 BOPTools_InterferencePool* myIntrPool,
1830 TColStd_IndexedMapOfInteger& aMapWith)
1832 TColStd_IndexedMapOfInteger aMapWhat;
1834 FMapWhat(nF, myIntrPool, aMapWhat);
1837 Standard_Integer i, aNb, anIndex, aWhat, aWith;
1838 BOPTools_ListIteratorOfListOfInterference anIt;
1840 const BOPTools_CArray1OfInterferenceLine& anArrIL= myIntrPool->InterferenceTable();
1842 aNb=aMapWhat.Extent();
1843 for (i=1; i<=aNb; i++) {
1846 const BOPTools_InterferenceLine& aWithLine=anArrIL(aWhat);
1848 const BOPTools_ListOfInterference& aLI=aWithLine.List();
1849 anIt.Initialize(aLI);
1850 for (; anIt.More(); anIt.Next()) {
1851 const BOPTools_Interference& anIntf=anIt.Value();
1852 anIndex=anIntf.Index();
1854 aWith=anIntf.With();
1855 aMapWith.Add(aWith);
1861 //=======================================================================
1862 // function: IsFound
1864 //=======================================================================
1865 Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
1866 const TColStd_IndexedMapOfInteger& aMapWith)
1868 Standard_Boolean bFlag=Standard_False;
1869 Standard_Integer i, aNb, aWhat;
1871 aNb=aMapWhat.Extent();
1872 for (i=1; i<=aNb; i++) {
1874 if (aMapWith.Contains(aWhat)) {
1883 #include <BOPTools_CArray1OfESInterference.hxx>
1884 #include <BOPTools_CArray1OfEEInterference.hxx>
1885 #include <BOPTools_ESInterference.hxx>
1886 #include <BOPTools_EEInterference.hxx>
1887 #include <IntTools_CommonPrt.hxx>
1888 #include <gp_Pnt.hxx>
1889 #include <Geom_Curve.hxx>
1890 #include <GeomAbs_SurfaceType.hxx>
1891 #include <Geom_Surface.hxx>
1892 #include <GeomAdaptor_Surface.hxx>
1893 #include <GeomAPI_ProjectPointOnCurve.hxx>
1894 #include <BOPTools_Tools3D.hxx>
1896 //=======================================================================
1897 // function: ProcessAloneStickVertices
1899 //=======================================================================
1900 void ProcessAloneStickVertices(const Standard_Integer nF1,
1901 const Standard_Integer nF2,
1902 const BOPTools_PaveSet& aPSF,
1903 BOPTools_SequenceOfCurves& aSCvs,
1904 const BOPTools_InterferencePool& anIntrPool,
1905 BOPTools_PaveFiller& aPF,
1906 TColStd_SequenceOfInteger& aSeqVx,
1907 TColStd_SequenceOfReal& aSeqTolVx)
1909 Standard_Boolean bFound, bIsClosed;
1910 Standard_Integer aNbVtx, jx, nV;
1911 Standard_Real aTolVRange;
1912 TColStd_IndexedMapOfInteger aMapUnUsed;
1913 GeomAbs_SurfaceType aType1, aType2;
1915 BooleanOperations_PShapesDataStructure pDS=anIntrPool.DS();
1917 const TopoDS_Face& aF1= TopoDS::Face(pDS->Shape(nF1));
1918 const TopoDS_Face& aF2= TopoDS::Face(pDS->Shape(nF2));
1919 Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1);
1920 Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2);
1921 GeomAdaptor_Surface aGAS1(aS1);
1922 GeomAdaptor_Surface aGAS2(aS2);
1924 aType1=aGAS1.GetType();
1925 aType2=aGAS2.GetType();
1927 if((aType1==GeomAbs_Cylinder && aType2==GeomAbs_Cylinder)
1929 (aType1==GeomAbs_Plane && aType2==GeomAbs_Plane)) {
1931 UnUsedMap(aSCvs, aPSF, aMapUnUsed);
1933 aNbVtx=aMapUnUsed.Extent();
1934 for (jx=1; jx<=aNbVtx; ++jx) {
1936 if (pDS->IsNewShape(nV)) {
1937 bFound=VertexRangeTolerance(nV, nF1, nF2, anIntrPool, aTolVRange);
1940 aSeqTolVx.Append(aTolVRange);
1947 if((aType1==GeomAbs_Torus && aType2==GeomAbs_Plane) ||
1948 (aType1==GeomAbs_Plane && aType2==GeomAbs_Torus)) {
1949 Standard_Integer aNbSCvs, aNbPoints;
1950 Standard_Real aDist, aTolV;
1953 UnUsedMap(aSCvs, aPSF, aMapUnUsed);
1954 aNbVtx=aMapUnUsed.Extent();
1956 const Handle(IntTools_Context)& aCtx=aPF.Context();
1958 aNbSCvs=aSCvs.Length();
1960 BOPTools_Curve& aBC=aSCvs(1);
1961 const IntTools_Curve& aIC=aBC.Curve();
1962 Handle (Geom_Curve) aC3D= aIC.Curve();
1964 bIsClosed=IntTools_Tools::IsClosed(aC3D);
1968 GeomAPI_ProjectPointOnCurve& aProjPT=aCtx->ProjPT(aC3D);
1970 for (jx=1; jx<=aNbVtx; ++jx) {
1972 if (pDS->IsNewShape(nV)) {
1973 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&pDS->Shape(nV));
1974 aTolV=BRep_Tool::Tolerance(aV);
1975 aPV=BRep_Tool::Pnt(aV);
1977 aProjPT.Perform(aPV);
1978 aNbPoints=aProjPT.NbPoints();
1980 aDist=aProjPT.LowerDistance();
1981 aDist=(aDist>aTolV)? aDist : aTolV;
1983 aSeqTolVx.Append(aDist);
1991 //=======================================================================
1992 // function: ProcessAloneStickVertices
1994 //=======================================================================
1995 void ProcessAloneStickVertices(const Standard_Integer nF1,
1996 const Standard_Integer nF2,
1997 const BOPTools_PaveSet& aPSF,
1998 BOPTools_SequenceOfCurves& aSCvs,
1999 BOPTools_PaveFiller& aPF,
2000 TColStd_SequenceOfInteger& aSeqVx,
2001 TColStd_SequenceOfReal& aSeqTolVx)
2003 GeomAbs_SurfaceType aType1, aType2;
2005 BooleanOperations_PShapesDataStructure pDS=aPF.DS();
2007 const TopoDS_Face& aF1= TopoDS::Face(pDS->Shape(nF1));
2008 const TopoDS_Face& aF2= TopoDS::Face(pDS->Shape(nF2));
2009 Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1);
2010 Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2);
2011 GeomAdaptor_Surface aGAS1(aS1);
2012 GeomAdaptor_Surface aGAS2(aS2);
2014 aType1=aGAS1.GetType();
2015 aType2=aGAS2.GetType();
2017 if(aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) {
2018 Standard_Integer aNbSCvs, jVU, aNbVU, nVU, k, m, n;
2019 Standard_Real aTC[2], aD, aD2, aDT2, aU, aV, aScPr, aDScPr;
2020 TColStd_IndexedMapOfInteger aMVU;
2021 GeomAbs_CurveType aTypeC;
2022 gp_Pnt aPC[2], aPVU;
2026 Handle(Geom2d_Curve) aC2D[2];
2028 aDT2=2e-7; // the rich criteria
2029 aDScPr=5.e-9; // the creasing criteria
2031 UnUsedMap(aSCvs, aPSF, aMVU);
2033 aNbVU=aMVU.Extent();
2034 for (jVU=1; jVU<=aNbVU; ++jVU) {
2036 const TopoDS_Vertex& aVU=*((TopoDS_Vertex*)&pDS->Shape(nVU));
2037 aPVU=BRep_Tool::Pnt(aVU);
2039 aNbSCvs=aSCvs.Length();
2040 for (k=1; k<=aNbSCvs; ++k) {
2041 BOPTools_Curve& aBC=aSCvs(k);
2042 const IntTools_Curve& aIC=aBC.Curve();
2043 //Handle(Geom_Curve) aC3D=aIC.Curve(); //DEB
2045 if (!(aTypeC==GeomAbs_BezierCurve || GeomAbs_BSplineCurve)) {
2049 aIC.Bounds(aTC[0], aTC[1], aPC[0], aPC[1]);
2050 aC2D[0]=aIC.FirstCurve2d();
2051 aC2D[1]=aIC.SecondCurve2d();
2052 if (aC2D[0].IsNull() || aC2D[1].IsNull()) {
2056 for (m=0; m<2; ++m) {
2057 aD2=aPC[m].SquareDistance(aPVU);
2058 if (aD2>aDT2) {// no rich
2062 for (n=0; n<2; ++n) {
2063 Handle(Geom_Surface)& aS=(!n)? aS1 : aS2;
2064 aC2D[n]->D0(aTC[m], aP2D);
2066 BOPTools_Tools3D::GetNormalToSurface(aS, aU, aV, aDN[n]);
2069 aScPr=aDN[0]*aDN[1];
2079 // The intersection curve aIC is vanishing curve (the crease)
2083 aSeqTolVx.Append(aD);
2085 }//for (k=1; k<=aNbSCvs; ++k) {
2086 }//for (jVU=1; jVU=aNbVU; ++jVU) {
2087 }//if(aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) {
2089 //=======================================================================
2090 // function: UnUsedMap
2092 //=======================================================================
2093 void UnUsedMap(BOPTools_SequenceOfCurves& aSCvs,
2094 const BOPTools_PaveSet& aPSF,
2095 TColStd_IndexedMapOfInteger& aMapUnUsed)
2098 // What stick/non-stick vertices we used
2099 TColStd_IndexedMapOfInteger aMapUsed, aMapMustBeUsed;
2100 Standard_Integer j, aNbCurves, aNbVtx, nV1;//, nV2;
2101 BOPTools_ListIteratorOfListOfPave anLPIt;
2103 aNbCurves=aSCvs.Length();
2104 for (j=1; j<=aNbCurves; ++j) {
2105 BOPTools_Curve& aBC=aSCvs(j);
2106 //const IntTools_Curve& aC= aBC.Curve();// Wng in Gcc 3.0
2108 const BOPTools_PaveSet& aPaveSet=aBC.Set();
2109 const BOPTools_ListOfPave& aLPAlreadyUsed=aPaveSet.Set();
2110 anLPIt.Initialize(aLPAlreadyUsed);
2111 for (; anLPIt.More(); anLPIt.Next()) {
2112 const BOPTools_Pave& aPave=anLPIt.Value();
2118 // 2. Stick vertices that must be used
2119 const BOPTools_ListOfPave& aLPMustUsed=aPSF.Set();
2120 anLPIt.Initialize(aLPMustUsed);
2121 for (; anLPIt.More(); anLPIt.Next()) {
2122 const BOPTools_Pave& aPave=anLPIt.Value();
2124 aMapMustBeUsed.Add(nV1);
2127 // 3.Unused Stick vertices .
2128 aNbVtx=aMapMustBeUsed.Extent();
2129 for (j=1; j<=aNbVtx; ++j) {
2130 nV1=aMapMustBeUsed(j);
2131 if (!aMapUsed.Contains(nV1)) {
2132 aMapUnUsed.Add(nV1);
2137 //=======================================================================
2138 // function: VertexRangeTolerance
2140 //=======================================================================
2141 Standard_Boolean VertexRangeTolerance(const Standard_Integer nV,
2142 const Standard_Integer nF1,
2143 const Standard_Integer nF2,
2144 const BOPTools_InterferencePool& anIntrPool,
2145 Standard_Real& aTolV)
2147 Standard_Boolean bFound=Standard_False;
2148 Standard_Integer i, aNbEFs, iWhat, iWith, iNewShape ;
2149 TColStd_IndexedMapOfInteger aMEF;
2151 BooleanOperations_PShapesDataStructure pDS=anIntrPool.DS();
2153 const TopoDS_Vertex& aV=TopoDS::Vertex(pDS->Shape(nV));
2155 FaceAndEdgeMap(nF1, anIntrPool, aMEF);
2156 FaceAndEdgeMap(nF2, anIntrPool, aMEF);
2159 const BOPTools_CArray1OfESInterference& aEFs=anIntrPool.ESInterfs();
2161 aNbEFs=aEFs.Extent();
2162 for (i=1; i<=aNbEFs; ++i) {
2163 const BOPTools_ESInterference& aEF=aEFs(i);
2164 iNewShape=aEF.NewShape();
2165 if (iNewShape==nV) {
2166 aEF.Indices(iWhat, iWith);
2167 if (aMEF.Contains(iWhat) && aMEF.Contains(iWith)) {
2169 Standard_Real aTolVWas, aD1, aD2, aDMax;
2170 gp_Pnt aP3DV, aP3DV1, aP3DV2;
2172 const IntTools_CommonPrt& aCommonPrt=aEF.CommonPrt();
2173 //const TopoDS_Edge& aE1= aCommonPrt.Edge1();// Wng in Gcc 3.0
2175 aP3DV=BRep_Tool::Pnt(aV);
2176 aTolVWas=BRep_Tool::Tolerance(aV);
2178 aCommonPrt.BoundingPoints(aP3DV1, aP3DV2);
2179 aD1=aP3DV.Distance(aP3DV1);
2180 aD2=aP3DV.Distance(aP3DV2);
2182 aDMax=Max(aD1, aD2);
2185 if (aDMax>aTolVWas) {
2195 const BOPTools_CArray1OfEEInterference& aEEs=anIntrPool.EEInterfs();
2196 aNbEEs=aEEs.Extent();
2197 for (i=1; i<=aNbEEs; ++i) {
2198 const BOPTools_EEInterference& aEE=aEEs(i);
2199 iNewShape=aEE.NewShape();
2200 if (iNewShape==nV) {
2201 aEE.Indices(iWhat, iWith);
2202 if (aMEF.Contains(iWhat) && aMEF.Contains(iWith)) {
2214 //=======================================================================
2215 // function: FaceAndEdgeMap
2217 //=======================================================================
2218 void FaceAndEdgeMap(const Standard_Integer nF,
2219 const BOPTools_InterferencePool& anIntrPool,
2220 TColStd_IndexedMapOfInteger& aMEF)
2222 Standard_Integer nEF;
2224 BooleanOperations_PShapesDataStructure myDS=anIntrPool.DS();
2225 BooleanOperations_OnceExplorer aExp(*myDS);
2226 aExp.Init(nF, TopAbs_EDGE);
2227 for (; aExp.More(); aExp.Next()) {
2234 //=======================================================================
2235 // function: IsPairFound
2237 //=======================================================================
2238 Standard_Boolean IsPairFound(const Standard_Integer nF1,
2239 const Standard_Integer nF2,
2240 BOPTools_InterferencePool* myIntrPool,
2241 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
2242 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith)
2244 Standard_Boolean bIsFound;
2246 if (!aMapWhat.Contains(nF1)) {
2247 TColStd_IndexedMapOfInteger aMWhat;
2248 FMapWhat(nF1, myIntrPool, aMWhat);
2249 aMapWhat.Add(nF1, aMWhat);
2252 if (!aMapWith.Contains(nF2)) {
2253 TColStd_IndexedMapOfInteger aMWith;
2254 FMapWith(nF2, myIntrPool, aMWith);
2255 aMapWith.Add(nF2, aMWith);
2258 const TColStd_IndexedMapOfInteger& aMWht=aMapWhat.FindFromKey(nF1);
2259 const TColStd_IndexedMapOfInteger& aMWit=aMapWith.FindFromKey(nF2);
2261 bIsFound=IsFound(aMWht, aMWit);
2266 //=======================================================================
2267 // function: RestrictCurveIn2d
2268 // purpose: Intersects 2d curve of edge nE and 2d curve of theBC.
2269 // Splits theBC by new vertex, also splits nE by new vertex.
2270 // If nE has same domain with another edge, the same domain
2271 // edge is splitted too.
2272 //=======================================================================
2273 void BOPTools_PaveFiller::RestrictCurveIn2d(const Standard_Integer nE,
2274 const Standard_Integer nF1,
2275 const Standard_Integer nF2,
2276 const Standard_Real theTolerance,
2277 BOPTools_Curve& theBC)
2279 myPavePoolNew.Resize (myNbEdges);
2280 TopoDS_Shape atmpShape;
2282 BOPTools_CArray1OfESInterference& aESs = myIntrPool->ESInterferences();
2284 BOPTools_PaveSet& aPS = myPavePool(myDS->RefEdge(nE));
2285 Standard_Boolean bSearchInter = Standard_True;
2288 Standard_Integer pvVrtIndex = 0;
2291 BOPTools_ListIteratorOfListOfPave anIt1(aPS.Set());
2292 BOPTools_ListIteratorOfListOfPave anIt2;
2294 for(; bSearchInter && anIt1.More(); anIt1.Next()) {
2296 for(anIt2.Initialize(theBC.Set().Set()); anIt2.More(); anIt2.Next()) {
2298 if(anIt1.Value().Index() == anIt2.Value().Index()) { // too hard condition for the algorithm
2300 pvVrtIndex = anIt1.Value().Index();
2302 bSearchInter = Standard_False;
2307 // -- 6841: test 2d intersection any way, but update vertex only
2308 if((!bSearchInter && pvVrtIndex != 0)) {
2309 Standard_Boolean OnFirst = (myDS->Rank(nE) == 1);
2310 TopoDS_Edge aE = TopoDS::Edge(myDS->Shape(nE));
2311 TopoDS_Face aF = (OnFirst) ? TopoDS::Face(myDS->Shape(nF1)) : TopoDS::Face(myDS->Shape(nF2));
2312 Standard_Real pf2 = 0., pl2 = 0.;
2313 Handle(Geom_Curve) aC2D3 = BRep_Tool::Curve(aE, pf2, pl2);
2314 Handle(Geom2d_Curve) aC2D2 = BRep_Tool::CurveOnSurface(aE, aF, pf2, pl2);
2315 Handle(Geom2d_Curve) aC1D2 = (OnFirst) ? theBC.Curve().FirstCurve2d() : theBC.Curve().SecondCurve2d();
2316 Handle(Geom_Curve) aC1D3 = theBC.Curve().Curve();
2317 if((!aC2D3.IsNull() && !aC2D2.IsNull()) && (!aC1D2.IsNull() && !aC1D3.IsNull())) {
2318 Standard_Real pf1 = aC1D2->FirstParameter();
2319 Standard_Real pl1 = aC1D2->LastParameter();
2320 Geom2dAPI_InterCurveCurve aInt(aC1D2, aC2D2, Precision::PConfusion());
2321 if(aInt.NbPoints() > 0) {
2322 Standard_Integer jj = 1;
2323 for(; jj <= aInt.NbPoints(); jj++) {
2324 Standard_Real t1 = aInt.Intersector().Point(jj).ParamOnFirst();
2325 Standard_Real t2 = aInt.Intersector().Point(jj).ParamOnSecond();
2326 if((t1 >= pf1) && (t1 <= pl1) && (t2 >= pf2) && (t2 <= pl2)) {
2327 // gp_Pnt2d aP2d = aInt.Point(jj);
2328 gp_Pnt aP3d = aC2D3->Value(t2);
2329 gp_Pnt aP3d2 = aC1D3->Value(t1);
2330 TopoDS_Vertex & aVrt = (TopoDS_Vertex &) myDS->Shape(pvVrtIndex);
2331 gp_Pnt aVP = BRep_Tool::Pnt(aVrt);
2332 Standard_Real aVTol = BRep_Tool::Tolerance(aVrt);
2333 Standard_Real aD1 = aP3d.Distance(aVP);
2334 Standard_Real aD2 = aP3d2.Distance(aVP);
2335 Standard_Real aFD1 = fabs(aVTol-aD1);
2336 Standard_Real aFD2 = fabs(aVTol-aD2);
2337 if(aD1 > aVTol || aD2 > aVTol) {
2338 if(Max(aFD1,aFD2) <= 1.e-2) {
2339 Standard_Real nTol = aVTol + 2. * Max(aFD1,aFD2) + 1.e-7;
2341 bb.UpdateVertex(aVrt, nTol);
2352 // search intersection in 2d. begin
2353 BOPTools_ListOfPave aPavesOnCurve, aPavesOnEdge;
2354 Standard_Boolean bIsOnFirst = (myDS->Rank(nE) == 1);
2356 Handle(Geom2d_Curve) aC1 = (bIsOnFirst) ? theBC.Curve().FirstCurve2d() : theBC.Curve().SecondCurve2d();
2360 Standard_Real f1 = aC1->FirstParameter();
2361 Standard_Real l1 = aC1->LastParameter();
2363 // f1 and l1 may not correspond
2364 // to boundary parameters of 3d curve
2365 if(theBC.Curve().HasBounds()) {
2366 gp_Pnt tmpp1, tmpp2;
2367 theBC.Curve().Bounds(f1, l1, tmpp1, tmpp2);
2370 atmpShape = myDS->Shape(nE);
2371 TopoDS_Edge anEdge = TopoDS::Edge(atmpShape);
2372 TopoDS_Shape aFace = (bIsOnFirst) ? myDS->Shape(nF1) : myDS->Shape(nF2);
2373 Standard_Real f2=0., l2=0.;
2374 Handle(Geom2d_Curve) aC2 = BRep_Tool::CurveOnSurface(anEdge, TopoDS::Face(aFace), f2, l2);
2375 Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, f2, l2);
2377 if(aC2.IsNull() || aCurve.IsNull())
2380 Geom2dAPI_InterCurveCurve anIntersector(aC1, aC2, Precision::PConfusion());
2382 if(anIntersector.NbPoints() > 0) {
2383 Standard_Integer j = 0;
2385 for(j = 1; j <= anIntersector.NbPoints(); j++) {
2386 Standard_Real t1 = anIntersector.Intersector().Point(j).ParamOnFirst();
2387 Standard_Real t2 = anIntersector.Intersector().Point(j).ParamOnSecond();
2389 if((t1 >= f1) && (t1 <= l1) &&
2390 (t2 >= f2) && (t2 <= l2)) {
2391 gp_Pnt2d aP2dOnFace = anIntersector.Point(j);
2392 atmpShape = (!bIsOnFirst) ? myDS->Shape(nF1) : myDS->Shape(nF2);
2393 TopoDS_Face anOtherFace = TopoDS::Face(atmpShape);
2394 gp_Pnt aP3d = aCurve->Value(t2);
2396 if(myContext->IsPointInOnFace(TopoDS::Face(aFace), aP2dOnFace) &&
2397 myContext->IsValidPointForFace(aP3d, anOtherFace, BRep_Tool::Tolerance(anEdge))) {
2398 BOPTools_Pave aPave1;
2399 aPave1.SetParam(t1);
2400 aPave1.SetIndex(-1);
2401 aPavesOnCurve.Append(aPave1);
2402 BOPTools_Pave aPave2;
2403 aPave2.SetParam(t2);
2404 aPave2.SetIndex(-1);
2405 aPavesOnEdge.Append(aPave2);
2409 } // (anIntersector.NbPoints())
2410 // search intersection in 2d. end
2413 BOPTools_ListIteratorOfListOfPave aPaveIt1(aPavesOnCurve);
2414 BOPTools_ListIteratorOfListOfPave aPaveIt2(aPavesOnEdge);
2416 // test common blocks. begin
2417 Standard_Boolean bFaceCBFound = Standard_False;
2418 Standard_Boolean bEdgeCBFound = Standard_False;
2419 const BOPTools_ListOfCommonBlock& aLCBTest = myCommonBlockPool(myDS->RefEdge(nE));
2420 BOPTools_ListIteratorOfListOfCommonBlock aCBListIt(aLCBTest);
2421 Standard_Boolean bHasCBOnFace = Standard_False;
2422 Standard_Boolean bHasCBOnEdge = Standard_False;
2424 for(; aCBListIt.More(); aCBListIt.Next()) {
2425 if((aCBListIt.Value().Face() == nF1) ||
2426 (aCBListIt.Value().Face() == nF2)) {
2427 bHasCBOnFace = Standard_True;
2430 if(aCBListIt.Value().Face() == 0) {
2431 bHasCBOnEdge = Standard_True;
2435 if(!bHasCBOnFace || !bHasCBOnEdge) {
2436 BOPTools_PaveSet aTestPaveSet;
2437 aTestPaveSet.ChangeSet() = aPS.Set();
2439 for(; aPaveIt2.More(); aPaveIt2.Next()) {
2440 aTestPaveSet.Append(aPaveIt2.Value());
2442 BOPTools_PaveBlockIterator aPBIter(0, aTestPaveSet);
2444 for (; aPBIter.More(); aPBIter.Next()) {
2445 const BOPTools_PaveBlock& aPB = aPBIter.Value();
2446 Standard_Real aT1=aPB.Pave1().Param();
2447 Standard_Real aT2=aPB.Pave2().Param();
2448 gp_Pnt aPMid = aCurve->Value((aT1 + aT2) * 0.5);
2449 Standard_Integer nFOpposite = (bIsOnFirst) ? nF2 : nF1;
2450 TopoDS_Shape aOppFace = myDS->Shape(nFOpposite);
2452 if(!bHasCBOnFace && !bFaceCBFound &&
2453 myContext->IsValidPointForFace(aPMid, TopoDS::Face(aOppFace),
2454 BRep_Tool::Tolerance(anEdge) +
2455 BRep_Tool::Tolerance(TopoDS::Face(aOppFace)))) {
2456 bFaceCBFound = Standard_True;
2459 if(!bHasCBOnEdge && !bEdgeCBFound) {
2460 TopoDS_Vertex aVMid;
2462 aBB.MakeVertex(aVMid, aPMid, BRep_Tool::Tolerance(anEdge));
2463 TopExp_Explorer anExpE(aOppFace, TopAbs_EDGE);
2465 for(; anExpE.More(); anExpE.Next()) {
2466 TopoDS_Shape aTmpEdge = anExpE.Current();
2467 Standard_Real aParameter = 0.;
2469 if(myContext->ComputeVE(aVMid, TopoDS::Edge(aTmpEdge), aParameter) == 0) {
2470 bEdgeCBFound = Standard_True;
2476 aPaveIt2.Initialize(aPavesOnEdge);
2478 // test common blocks. end
2480 Standard_Boolean bChecknAddPaves = Standard_True;
2483 bChecknAddPaves = Standard_False;
2487 bChecknAddPaves = !bFaceCBFound;
2491 if(bChecknAddPaves) {
2492 // add paves chaking if new pave is equal to existent. begin
2493 for(; aPaveIt1.More() && aPaveIt2.More(); aPaveIt1.Next(), aPaveIt2.Next()) {
2494 BOPTools_Pave& aPaveOnCurve = aPaveIt1.Value();
2495 BOPTools_Pave& aPaveOnEdge = aPaveIt2.Value();
2497 gp_Pnt aP1 = theBC.Curve().Curve()->Value(aPaveOnCurve.Param());
2498 gp_Pnt aP2 = aCurve->Value(aPaveOnEdge.Param());
2500 Standard_Boolean bAddNewVertex = Standard_True;
2501 Standard_Boolean bAddOldVertex = Standard_False;
2502 Standard_Integer oldvertexindex = 0;
2504 for(anIt2.Initialize(theBC.Set().Set()); anIt2.More(); anIt2.Next()) {
2505 atmpShape = myDS->Shape(anIt2.Value().Index());
2506 TopoDS_Vertex aVertex = TopoDS::Vertex(atmpShape);
2507 gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
2508 Standard_Real aTolerance = theTolerance + BRep_Tool::Tolerance(aVertex);
2509 if((aPoint.Distance(aP1) < aTolerance) ||
2510 (aPoint.Distance(aP2) < aTolerance)) {
2511 bAddNewVertex = Standard_False;
2512 bAddOldVertex = Standard_True;
2513 oldvertexindex = anIt2.Value().Index();
2518 // treat equality with other vertices.begin
2519 if(bAddNewVertex || bAddOldVertex) {
2520 TopoDS_Vertex aNewVertex;
2521 BOPTools_Tools::MakeNewVertex(anEdge, aPaveOnEdge.Param(),
2522 TopoDS::Face(aFace), aNewVertex);
2524 BOPTools_Pave aPaveToPut;
2525 Standard_Boolean bAddNewVertextmp = bAddNewVertex, bAddOldVertextmp = bAddOldVertex;
2527 if(!CheckNewVertexAndUpdateData(aNewVertex, aPaveOnEdge.Param(), anEdge, aPaveOnCurve.Param(),
2528 nF1, nF2, theTolerance, myIntrPool, myDS, myContext, aPS,
2529 bAddNewVertextmp, bAddOldVertextmp, theBC, aPaveToPut,
2530 bAddNewVertex, bAddOldVertex)) {
2531 bAddNewVertex = Standard_False;
2532 bAddOldVertex = Standard_False;
2535 if((aPaveToPut.Index() != 0) && (aPaveToPut.Param() != 0.) &&
2536 aPaveToPut.Interference() != 0) {
2537 PutPaveOnCurve(aPaveToPut, theTolerance, theBC);
2540 // end for(anIt1.Initialize...
2542 // treat equality with other vertices.end
2544 if(bAddNewVertex || (bAddOldVertex && oldvertexindex)) {
2545 TopoDS_Vertex aNewVertex;
2547 Standard_Integer aNewShapeIndex = 0;
2549 // reject creation new vertex if there is a created one at a too small distance
2550 BOPTools_Tools::MakeNewVertex(anEdge,aPaveOnEdge.Param(),TopoDS::Face(aFace),aNewVertex);
2551 Standard_Real nvTol = BRep_Tool::Tolerance(aNewVertex);
2552 Standard_Integer chShNb = myDS->NumberOfInsertedShapes(), chShInd = 0;
2553 Standard_Boolean completeSearching = Standard_False;
2554 for(chShInd = 1; chShInd <= chShNb; chShInd++) {
2555 if(myDS->GetShapeType(chShInd) != TopAbs_VERTEX)
2557 TopoDS_Vertex chV = TopoDS::Vertex(myDS->Shape(chShInd));
2558 Standard_Real distVV = BRep_Tool::Pnt(chV).Distance(BRep_Tool::Pnt(aNewVertex));
2559 if(distVV <= 1.e-5) {
2560 for(anIt1.Initialize(aPS.Set()); anIt1.More(); anIt1.Next()) {
2561 if(anIt1.Value().Index() == chShInd) {
2562 Standard_Real dParam = fabs(aPaveOnEdge.Param()-anIt1.Value().Param());
2563 if(dParam <= 1.e-7) {
2564 bAddNewVertex = Standard_False;
2565 bAddOldVertex = Standard_True;
2566 oldvertexindex = anIt1.Value().Index();
2567 nvTol += BRep_Tool::Tolerance(chV) + distVV;
2568 completeSearching = Standard_True;
2574 if(completeSearching)
2580 if(!bAddOldVertex) {
2581 BOPTools_Tools::MakeNewVertex(anEdge, aPaveOnEdge.Param(),
2582 TopoDS::Face(aFace), aNewVertex);
2583 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
2584 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
2585 aNewShapeIndex = myDS->NumberOfInsertedShapes();
2588 aNewShapeIndex = oldvertexindex;
2589 aNewVertex = TopoDS::Vertex(myDS->Shape(aNewShapeIndex));
2592 aBB.UpdateVertex(aNewVertex, aPaveOnEdge.Param(), anEdge, nvTol);
2595 BOPTools_ListIteratorOfListOfPave anItAll;
2596 Standard_Boolean samePFound = Standard_False;
2597 for(anItAll.Initialize(aPS.Set()); anItAll.More(); anItAll.Next()) {
2598 if(anItAll.Value().Index() == aNewShapeIndex) {
2599 BOPTools_Pave& aPV = anItAll.Value();
2600 aPV.SetParam(aPaveOnEdge.Param());
2601 samePFound = Standard_True;
2609 myDS->SetState (aNewShapeIndex, BooleanOperations_ON);
2611 IntTools_CommonPrt aCPart;
2612 aCPart.SetEdge1(anEdge);
2613 aCPart.SetType(TopAbs_VERTEX);
2614 aCPart.SetRange1(IntTools_Range(aPaveOnEdge.Param(), aPaveOnEdge.Param()));
2615 aCPart.SetVertexParameter1(aPaveOnEdge.Param());
2617 Standard_Integer nFOpposite = (bIsOnFirst) ? nF2 : nF1;
2618 BOPTools_ESInterference anInterf (nE, nFOpposite, aCPart);
2619 Standard_Integer anIndexIn = aESs.Append(anInterf);
2620 myIntrPool->AddInterference (nE, nFOpposite, BooleanOperations_EdgeSurface, anIndexIn);
2622 BOPTools_ESInterference& aESInterf = aESs(anIndexIn);
2623 aESInterf.SetNewShape(aNewShapeIndex);
2625 // put pave on edge. begin
2626 aPaveOnEdge.SetInterference(anIndexIn);
2627 aPaveOnEdge.SetType (BooleanOperations_EdgeSurface);
2628 aPaveOnEdge.SetIndex(aNewShapeIndex);
2630 BOPTools_PaveSet& aPaveSet1 = myPavePoolNew(myDS->RefEdge(nE));
2631 aPaveSet1.Append(aPaveOnEdge);
2632 // put pave on edge. end
2634 // put pave on curve. begin
2635 aPaveOnCurve.SetIndex(aNewShapeIndex);
2636 aPaveOnCurve.SetType(BooleanOperations_SurfaceSurface);
2637 BOPTools_PaveSet& aPaveSet = theBC.Set();
2638 aPaveSet.Append(aPaveOnCurve);
2640 BOPTools_Tools::UpdateVertex (theBC.Curve(), aPaveOnCurve.Param(), aNewVertex);
2642 // put pave on curve. end
2644 BOPTools_ListOfCommonBlock& aLCB1 = myCommonBlockPool(myDS->RefEdge(nE));
2646 BOPTools_ListIteratorOfListOfCommonBlock anIt(aLCB1);
2648 for(; anIt.More(); anIt.Next()) {
2649 BOPTools_CommonBlock& aCB = anIt.Value();
2655 Standard_Integer anOppIndex = aCB.PaveBlock2().OriginalEdge();
2656 IntTools_Range aRange = aCB.PaveBlock2().Range();
2658 if(anOppIndex == nE) {
2659 anOppIndex = aCB.PaveBlock1().OriginalEdge();
2660 aRange = aCB.PaveBlock1().Range();
2662 TopoDS_Edge anOppEdge = TopoDS::Edge(myDS->Shape(anOppIndex));
2663 Standard_Real aOppParameter = 0.;
2665 if(myContext->ComputeVE(aNewVertex, anOppEdge, aOppParameter) == 0) {
2667 if((aOppParameter > aRange.First()) && (aOppParameter < aRange.Last())) {
2668 // put pave on same domain edge. begin
2670 aBB.UpdateVertex(aNewVertex, aOppParameter, anOppEdge, BRep_Tool::Tolerance(aNewVertex));
2671 BOPTools_Pave aPaveOpp;
2672 aPaveOpp.SetParam(aOppParameter);
2673 aPaveOpp.SetIndex(aNewShapeIndex);
2674 BOPTools_PaveSet& aPaveSetOpp = myPavePoolNew(myDS->RefEdge(anOppIndex));
2675 aPaveSetOpp.Append(aPaveOpp);
2676 // put pave on same domain edge. end
2681 // add SS interference for adjacent face.begin
2682 if(aLCB1.IsEmpty()) {
2683 AddInterfForAdjacentFace(nE, nF1, nF2, myIntrPool, myDS);
2685 // add SS interference for adjacent face.end
2688 myPavePoolNew.Resize(myNbEdges);
2691 RecomputeCommonBlocks(nE);
2694 } // end for(; aPaveIt1.More() && aPaveIt2.More()...
2695 // add paves chaking if new pave is equal to existent. end
2698 myPavePoolNew.Destroy();
2700 //=======================================================================
2701 //function : RecomputeCommonBlocks
2703 //=======================================================================
2704 void BOPTools_PaveFiller::RecomputeCommonBlocks(const Standard_Integer nE)
2706 TopoDS_Shape atmpShape = myDS->Shape(nE);
2707 TopoDS_Edge anEdge = TopoDS::Edge(atmpShape);
2708 BOPTools_ListOfCommonBlock& aLCB1 = myCommonBlockPool(myDS->RefEdge(nE));
2710 BOPTools_ListOfCommonBlock anOldLCB;
2713 BOPTools_ListOfCommonBlock aNewLCB1;
2714 Standard_Boolean bReverse = Standard_False;
2715 BOPTools_ListIteratorOfListOfCommonBlock anIt(anOldLCB);
2717 for(; anIt.More(); anIt.Next()) {
2718 BOPTools_CommonBlock& anOldCB = anIt.Value();
2720 Standard_Integer anIndex = anOldCB.PaveBlock1().OriginalEdge();
2721 Standard_Integer anIndexOpp = anOldCB.PaveBlock2().OriginalEdge();
2722 IntTools_Range aCBRange = anOldCB.PaveBlock1().Range();
2725 aCBRange = anOldCB.PaveBlock2().Range();
2726 anIndex = anOldCB.PaveBlock2().OriginalEdge();
2727 anIndexOpp = anOldCB.PaveBlock1().OriginalEdge();
2728 bReverse = Standard_True;
2731 BOPTools_ListOfPaveBlock& aSplitEdges1 = mySplitShapesPool(myDS->RefEdge(nE));
2732 BOPTools_ListIteratorOfListOfPaveBlock aLPBIt1(aSplitEdges1);
2733 Standard_Boolean found = Standard_False;
2734 BOPTools_ListOfCommonBlock aNewListOfCommonBlock;
2736 for(; aLPBIt1.More(); aLPBIt1.Next()) {
2737 BOPTools_PaveBlock& aPBCurrent1 = aLPBIt1.Value();
2738 IntTools_Range aCurRange1 = aPBCurrent1.Range();
2740 if((aCurRange1.First() > aCBRange.First() && aCurRange1.First() < aCBRange.Last()) ||
2741 (aCurRange1.Last() > aCBRange.First() && aCurRange1.Last() < aCBRange.Last())) {
2742 BOPTools_CommonBlock aNewCB;
2745 aNewCB.SetPaveBlock1(aPBCurrent1);
2747 aNewCB.SetPaveBlock2(aPBCurrent1);
2749 Standard_Boolean foundpaveblock2 = Standard_False;
2751 if(anOldCB.Face()) {
2752 foundpaveblock2 = Standard_True;
2753 aNewCB.SetFace(anOldCB.Face());
2758 BOPTools_ListIteratorOfListOfPaveBlock aLPBIt2(mySplitShapesPool(myDS->RefEdge(anIndexOpp)));
2760 for(; aLPBIt2.More(); aLPBIt2.Next()) {
2761 BOPTools_PaveBlock& aPBCurrent2 = aLPBIt2.Value();
2762 IntTools_Range aCurRange2 = aPBCurrent2.Range();
2764 if(((aPBCurrent1.Pave1().Index() == aPBCurrent2.Pave1().Index()) &&
2765 (aPBCurrent1.Pave2().Index() == aPBCurrent2.Pave2().Index())) ||
2766 ((aPBCurrent1.Pave1().Index() == aPBCurrent2.Pave2().Index()) &&
2767 (aPBCurrent1.Pave2().Index() == aPBCurrent2.Pave1().Index()))) {
2768 Standard_Real f = 0., l = 0.;
2769 Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, f, l);
2770 Standard_Real aMidPar = (aCurRange1.First() + aCurRange1.Last()) * 0.5;
2771 gp_Pnt aMidPnt = aCurve->Value(aMidPar);
2772 Standard_Real aProjPar = 0.;
2773 TopoDS_Vertex aTestpVertex;
2774 TopoDS_Edge aOppEdge = TopoDS::Edge(myDS->Shape(anIndexOpp));
2776 aBB.MakeVertex(aTestpVertex, aMidPnt, BRep_Tool::Tolerance(anEdge));
2778 if(myContext->ComputeVE(aTestpVertex, aOppEdge, aProjPar) == 0) {
2779 if(aProjPar > aCurRange2.First() && aProjPar < aCurRange2.Last()) {
2781 aNewCB.SetPaveBlock2(aPBCurrent2);
2783 aNewCB.SetPaveBlock1(aPBCurrent2);
2784 foundpaveblock2 = Standard_True;
2792 if(foundpaveblock2) {
2793 found = Standard_True;
2794 aNewListOfCommonBlock.Append(aNewCB);
2798 // end for(; aLPBIt1.More()...
2801 aNewLCB1.Append(anOldCB);
2804 BOPTools_ListOfCommonBlock tmplst;
2805 tmplst = aNewListOfCommonBlock;
2806 aNewLCB1.Append(tmplst);
2808 if((anOldCB.Face() == 0) && (anIndexOpp > 0)) {
2809 tmplst = aNewListOfCommonBlock;
2810 BOPTools_ListOfCommonBlock& aLCB2 = myCommonBlockPool(myDS->RefEdge(anIndexOpp));
2812 BOPTools_ListIteratorOfListOfCommonBlock anItLCB2(aLCB2);
2814 for(; anItLCB2.More(); anItLCB2.Next()) {
2815 BOPTools_CommonBlock& anOldCB2 = anItLCB2.Value();
2820 if(anOldCB.PaveBlock1().IsEqual(anOldCB2.PaveBlock1()) &&
2821 anOldCB.PaveBlock2().IsEqual(anOldCB2.PaveBlock2())) {
2822 aLCB2.Remove(anItLCB2);
2823 aLCB2.Append(tmplst);
2830 // end for(; anIt.More()...
2833 //=======================================================================
2834 //function : CheckNewVertexAndUpdateData
2836 //=======================================================================
2837 Standard_Boolean CheckNewVertexAndUpdateData(const TopoDS_Vertex& theVertex,
2838 const Standard_Real theParamOnE,
2839 const TopoDS_Edge& theEdge,
2840 const Standard_Real theParamOnCurve,
2841 const Standard_Integer theIndexF1,
2842 const Standard_Integer theIndexF2,
2843 const Standard_Real theTolerance,
2844 const BOPTools_PInterferencePool& theIntrPool,
2845 const BooleanOperations_PShapesDataStructure& theDS,
2846 const Handle(IntTools_Context)& theContext,
2847 const BOPTools_PaveSet& theEdgePaveSet,
2848 const Standard_Boolean bAddNewVertex,
2849 const Standard_Boolean bAddOldVertex,
2850 BOPTools_Curve& theBC,
2851 BOPTools_Pave& thePaveToPut,
2852 Standard_Boolean& bAddNewVertexOut,
2853 Standard_Boolean& bAddOldVertexOut) {
2855 thePaveToPut.SetParam(0.);
2856 thePaveToPut.SetIndex(0);
2857 thePaveToPut.SetInterference(0);
2859 bAddNewVertexOut = bAddNewVertex;
2860 bAddOldVertexOut = bAddOldVertex;
2861 TopoDS_Shape atmpShape;
2862 gp_Pnt aP1 = theBC.Curve().Curve()->Value(theParamOnCurve);
2863 Standard_Real f = 0., l = 0.;
2864 Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, f, l);
2867 return Standard_False;
2868 gp_Pnt aP2 = aCurve->Value(theParamOnE);
2870 BOPTools_ListIteratorOfListOfPave anIt1, anIt2;
2872 for(anIt1.Initialize(theEdgePaveSet.Set()); anIt1.More(); anIt1.Next()) {
2873 atmpShape = theDS->Shape(anIt1.Value().Index());
2874 TopoDS_Vertex aVertex = TopoDS::Vertex(atmpShape);
2875 gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
2876 Standard_Real aTolerance = theTolerance + BRep_Tool::Tolerance(aVertex);
2879 if((aPoint.Distance(aP1) < aTolerance) ||
2880 (aPoint.Distance(aP2) < aTolerance)) {
2881 IntTools_Range aRange(anIt1.Value().Param(), theParamOnE);
2882 TopoDS_Vertex aV1 = aVertex;
2883 TopoDS_Vertex aV2 = theVertex;
2885 if(anIt1.Value().Param() > theParamOnE) {
2886 aRange.SetFirst(theParamOnE);
2887 aRange.SetLast(anIt1.Value().Param());
2891 gp_Pnt ptest1 = aCurve->Value(aRange.First());
2892 gp_Pnt ptest2 = aCurve->Value(aRange.Last());
2893 Standard_Boolean bUpdateVertex = Standard_True;
2895 if(ptest1.Distance(ptest2) > (BRep_Tool::Tolerance(aVertex) + BRep_Tool::Tolerance(theEdge))) {
2896 IntTools_ShrunkRange aSR (theEdge, aV1, aV2, aRange, theContext);
2897 bUpdateVertex = !aSR.IsDone() || (aSR.ErrorStatus() != 0);
2901 bAddNewVertexOut = Standard_False;
2903 if(bAddOldVertexOut) {
2904 bAddOldVertexOut = Standard_False;
2907 BOPTools_Tools::UpdateVertex (theBC.Curve(), theParamOnCurve, aVertex);
2909 Standard_Boolean bPutPave = Standard_True;
2911 for(anIt2.Initialize(theBC.Set().Set()); anIt2.More(); anIt2.Next()) {
2912 if(anIt1.Value().Index() == anIt2.Value().Index()) {
2913 bPutPave = Standard_False;
2918 Standard_Integer nbbefore = theBC.Set().Set().Extent();
2921 thePaveToPut = anIt1.Value();
2924 if(anIt1.Value().Index() > theDS->NumberOfSourceShapes())
2927 Standard_Integer nbafter = theBC.Set().Set().Extent();
2929 if(nbbefore < nbafter) {
2930 // update interferences.begin
2931 Standard_Integer nF = theIndexF1;
2933 if(theDS->Rank(anIt1.Value().Index()) != theDS->Rank(theIndexF1)) {
2936 atmpShape = theDS->Shape(nF);
2937 TopoDS_Face aF = TopoDS::Face (atmpShape);
2938 BOPTools_CArray1OfVSInterference& aVSs = theIntrPool->VSInterferences();
2939 Standard_Integer vsit = 0;
2940 Standard_Boolean interffound = Standard_False;
2942 for(vsit = 1; vsit <= aVSs.Length(); vsit++) {
2943 if((aVSs.Value(vsit).Index1() == anIt1.Value().Index()) &&
2944 (aVSs.Value(vsit).Index2() == nF)) {
2945 interffound = Standard_True;
2951 BOPTools_CArray1OfVEInterference& aVEs = theIntrPool->VEInterferences();
2953 for(vsit = 1; vsit <= aVEs.Length(); vsit++) {
2954 if((aVEs.Value(vsit).Index1() == anIt1.Value().Index())) {
2955 interffound = Standard_True;
2962 BOPTools_CArray1OfVVInterference& aVVs = theIntrPool->VVInterferences();
2964 for(vsit = 1; vsit <= aVVs.Length(); vsit++) {
2965 if((aVVs.Value(vsit).Index1() == anIt1.Value().Index())) {
2966 interffound = Standard_True;
2973 Standard_Real aU = 0., aV = 0.;
2974 Standard_Integer aFlag = theContext->ComputeVS (aVertex, aF, aU, aV);
2975 Standard_Integer anIndexIn = 0;
2979 // Add Interference to the Pool
2980 BOPTools_VSInterference anInterf (anIt1.Value().Index(), nF, aU, aV);
2981 anIndexIn=aVSs.Append(anInterf);
2983 // SetState for Vertex in DS;
2984 theDS->SetState (anIt1.Value().Index(), BooleanOperations_ON);
2985 // Insert Vertex in Interference Object
2986 BOPTools_VSInterference& aVS = aVSs(anIndexIn);
2987 aVS.SetNewShape(anIt1.Value().Index());
2989 interffound = Standard_False;
2990 const BOPTools_ListOfInterference& aList1 =
2991 theIntrPool->InterferenceTable().Value(anIt1.Value().Index()).GetOnType(BooleanOperations_EdgeSurface);
2992 BOPTools_ListOfInterference& amodifList1 = *((BOPTools_ListOfInterference*)&aList1); // not very good approach
2993 BOPTools_ListIteratorOfListOfInterference anInterfIt(amodifList1);
2995 for(; anInterfIt.More(); anInterfIt.Next()) {
2996 if(anInterfIt.Value().With() == nF) {
2997 anInterfIt.Value().SetIndex(anIndexIn);
2998 interffound = Standard_True;
3001 const BOPTools_ListOfInterference& aList2 =
3002 theIntrPool->InterferenceTable().Value(nF).GetOnType(BooleanOperations_EdgeSurface);
3003 BOPTools_ListOfInterference& amodifList2 = *((BOPTools_ListOfInterference*)&aList2); // not very good approach
3004 anInterfIt.Initialize(amodifList2);
3006 for(; anInterfIt.More(); anInterfIt.Next()) {
3007 if(anInterfIt.Value().With() == anIt1.Value().Index()) {
3008 anInterfIt.Value().SetIndex(anIndexIn);
3009 interffound = Standard_True;
3014 theIntrPool->AddInterference(anIt1.Value().Index(), nF, BooleanOperations_VertexSurface, anIndexIn);
3017 // update interferences.end
3023 // end for(anIt1.Initialize...
3024 return Standard_True;
3026 //=======================================================================
3027 //function : AddInterfForAdjacentFace
3029 //=======================================================================
3030 void AddInterfForAdjacentFace(const Standard_Integer theEdgeIndex,
3031 const Standard_Integer theIndexF1,
3032 const Standard_Integer theIndexF2,
3033 BOPTools_PInterferencePool theIntrPool,
3034 const BooleanOperations_PShapesDataStructure& theDS) {
3035 Standard_Boolean bIsOnFirst = (theDS->Rank(theEdgeIndex) == 1);
3037 IntTools_SequenceOfPntOn2Faces aPnts;
3038 IntTools_SequenceOfCurves aCvs;
3039 Standard_Integer index1 = (bIsOnFirst) ? theIndexF1 : theIndexF2;
3040 Standard_Integer index2 = (bIsOnFirst) ? theIndexF2 : theIndexF1;
3041 Standard_Integer nbw = theDS->NumberOfAncestors(theEdgeIndex);
3042 Standard_Integer ancwit = 0, ancfit = 0;
3043 Standard_Boolean badjacentfound = Standard_False;
3045 for(ancwit = 1; (!badjacentfound) && (ancwit <= nbw); ancwit++) {
3046 Standard_Integer ancestor1 = theDS->GetAncestor(theEdgeIndex, ancwit);
3048 if(ancestor1 == index1)
3051 if(theDS->GetShapeType(ancestor1) == TopAbs_WIRE) {
3052 Standard_Integer nbf = theDS->NumberOfAncestors(ancestor1);
3054 for(ancfit = 1; ancfit <= nbf; ancfit++) {
3055 Standard_Integer ancestor2 = theDS->GetAncestor(ancestor1, ancfit);
3057 if(ancestor2 != index1) {
3059 badjacentfound = Standard_True;
3066 if(index1 > index2) {
3067 Standard_Integer tmp = index1;
3071 Standard_Boolean bAddInterference = Standard_True;
3072 Standard_Integer ffit = 0;
3073 BOPTools_CArray1OfSSInterference& aFFs = theIntrPool->SSInterferences();
3075 for(ffit = 1; ffit <= aFFs.Extent(); ffit++) {
3076 BOPTools_SSInterference& aFFi3 = aFFs(ffit);
3078 if((index1 == aFFi3.Index1()) && (index2 == aFFi3.Index2())) {
3079 bAddInterference = Standard_False;
3083 if(bAddInterference) {
3084 BOPTools_SSInterference anInterfSS (index1, index2, 1.e-07, 1.e-07, aCvs, aPnts);
3085 Standard_Integer anIndexInSS = aFFs.Append(anInterfSS);
3086 theIntrPool->AddInterference (index1, index2, BooleanOperations_SurfaceSurface, anIndexInSS);
3090 //=======================================================================
3091 //function : RejectPaveBlock
3093 //=======================================================================
3094 Standard_Boolean RejectPaveBlock(const IntTools_Curve& theC,
3095 const Standard_Real theT1,
3096 const Standard_Real theT2,
3097 const TopoDS_Vertex& theV,
3098 Standard_Real& theRT)
3100 Standard_Boolean bIsPeriodic, bClosed, isp, c3d;
3101 Standard_Real aPeriod, dt, pf, pl, dp, aTol;
3102 Handle(Geom_Curve) aC;
3104 theRT = BRep_Tool::Tolerance(theV);
3107 pf = aC->FirstParameter();
3108 pl = aC->LastParameter();
3111 bIsPeriodic=aC->IsPeriodic();
3112 bClosed=IntTools_Tools::IsClosed(aC);
3116 aPeriod=aC->Period();
3117 isp=(fabs(aPeriod-dp) <= aTol);
3118 dt = fabs(theT2-theT1);
3119 isp = (isp || fabs(aPeriod-dt) <= aTol);
3121 c3d=(bClosed || isp);
3124 Standard_Boolean isp = (aC->IsPeriodic() && fabs(aC->Period()-dp) <= 1.e-9);
3125 Standard_Real dt = fabs(theT2-theT1);
3126 isp = (isp || (aC->IsPeriodic() && fabs(aC->Period()-dt) <= 1.e-9));
3127 Standard_Boolean c3d = (aC->IsClosed() || isp);
3133 Standard_Real p1, p2, tp, d3d2, aRT2;;
3148 d3d2 = pntf.SquareDistance(pntl);
3153 return Standard_True;
3156 //=======================================================================
3157 //function : ModifFFTol
3159 //=======================================================================
3160 Standard_Boolean ModifFFTol(const TopoDS_Face& theF1,
3161 const TopoDS_Face& theF2,
3162 Standard_Real& theTF)
3164 Standard_Real t1 = BRep_Tool::Tolerance(theF1), t2 = BRep_Tool::Tolerance(theF2);
3165 theTF = 2* (t1 + t2);
3166 BRepAdaptor_Surface BAS1(theF1);
3167 BRepAdaptor_Surface BAS2(theF2);
3169 Standard_Boolean isAna1 = (BAS1.GetType() == GeomAbs_Plane ||
3170 BAS1.GetType() == GeomAbs_Cylinder ||
3171 BAS1.GetType() == GeomAbs_Cone ||
3172 BAS1.GetType() == GeomAbs_Sphere);
3173 Standard_Boolean isAna2 = (BAS2.GetType() == GeomAbs_Plane ||
3174 BAS2.GetType() == GeomAbs_Cylinder ||
3175 BAS2.GetType() == GeomAbs_Cone ||
3176 BAS2.GetType() == GeomAbs_Sphere);
3178 isAna1=isAna1||(BAS1.GetType() == GeomAbs_Torus);
3179 isAna2=isAna2||(BAS2.GetType() == GeomAbs_Torus);
3181 if(isAna1 && isAna2)
3182 return Standard_False;
3184 theTF = Max(theTF, 5.e-6);
3185 return Standard_True;
3189 //=======================================================================
3190 //function : RejectBuildingEdge
3192 //=======================================================================
3193 Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC,
3194 const TopoDS_Vertex& theV1,
3195 const TopoDS_Vertex& theV2,
3196 const Standard_Real theT1,
3197 const Standard_Real theT2,
3198 const TopTools_ListOfShape& theL,
3199 Standard_Real& theTF)
3202 if(theL.Extent() == 0)
3205 Handle(Geom_Curve) aTCurve;
3208 Standard_Integer eIndex = 0;
3209 Standard_Boolean edgeFound = Standard_False;
3210 Handle(Geom_Curve) aCurve = theC.Curve();
3211 TopTools_ListIteratorOfListOfShape anIt(theL);
3212 for(; anIt.More(); anIt.Next()) {
3214 const TopoDS_Edge & aE = TopoDS::Edge(anIt.Value());
3215 if(aE.IsNull()) continue;
3216 TopExp_Explorer ee(aE,TopAbs_VERTEX);
3217 Standard_Boolean v1Found = Standard_False;
3218 Standard_Boolean v2Found = Standard_False;
3219 Standard_Real v1P = 0., v2P = 0;
3220 for(; ee.More(); ee.Next()) {
3221 const TopoDS_Vertex aV = TopoDS::Vertex(ee.Current());
3222 if(aV.IsNull()) continue;
3223 if(aV.IsEqual(theV1)) {
3224 v1Found = Standard_True;
3225 v1P = BRep_Tool::Parameter(aV,aE);
3227 if(aV.IsEqual(theV2)) {
3228 v2Found = Standard_True;
3229 v2P = BRep_Tool::Parameter(aV,aE);
3232 Standard_Boolean sameParam = Standard_False;
3233 if(v1Found && v2Found) {
3234 if(fabs(theT1-v1P) <= 1.e-8 && fabs(theT2-v2P) <= 1.e-8)
3235 sameParam = Standard_True;
3239 aTCurve = BRep_Tool::Curve(aE,f,l);
3240 aTT = BRep_Tool::Tolerance(aE);
3241 edgeFound = Standard_True;
3250 gp_Pnt p1 = aTCurve->Value(theT1);
3251 gp_Pnt p2 = aCurve->Value(theT1);
3252 Standard_Real dpf = p1.Distance(p2);
3253 p1 = aTCurve->Value(theT2);
3254 p2 = aCurve->Value(theT2);
3255 Standard_Real dpl = p1.Distance(p2);
3256 Standard_Real dplf = fabs(dpl-dpf);
3257 Standard_Real dpp = Max(dpl,dpf);
3262 Standard_Real maxD = Max(dpl,dpf);
3263 Standard_Boolean inTol = Standard_True;
3264 Standard_Real dp = fabs(theT2-theT1)/23.;
3265 Standard_Integer di = 0;
3266 for(di = 1; di <= 21; di++) {
3267 Standard_Real cp = theT1 + dp*((Standard_Real)di);
3268 p1 = aTCurve->Value(cp);
3269 p2 = aCurve->Value(cp);
3270 Standard_Real d12 = p1.Distance(p2);
3271 maxD = Max(maxD,d12);
3272 if(fabs(d12-dpp) > 1.e-7) {
3273 inTol = Standard_False;
3284 //=======================================================================
3285 //function : CorrectTolR3D
3287 //=======================================================================
3288 void CorrectTolR3D(BOPTools_PaveFiller& aPF,
3289 const BOPTools_SSInterference& aFF,
3290 const TColStd_MapOfInteger& aMVStick,
3291 Standard_Real& aTolR3D)
3293 Standard_Boolean bHasBounds;
3294 Standard_Integer i, nF[2], nV, aNbCurves;
3295 Standard_Real aT1, aT2, aU, aV, aT, aA, aTolV, aTolVmax;
3296 Standard_Real aTolR, aTolTresh, aAmin, aAmax;
3297 TColStd_MapIteratorOfMapOfInteger aIt;
3298 gp_Pnt aP, aP1, aP2;
3301 Handle(Geom_Surface) aS[2];
3302 Handle(Geom_Curve) aC3D;
3303 GeomAdaptor_Surface aGAS;
3304 GeomAbs_SurfaceType aType;
3307 BooleanOperations_PShapesDataStructure myDS=aPF.DS();
3308 const Handle(IntTools_Context)& myContext=aPF.Context();
3311 aAmin=0.012;// 0.7-7 deg
3314 if (!aMVStick.Extent()) {
3318 BOPTools_SSInterference& aFFi=*((BOPTools_SSInterference*)&aFF);
3319 BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
3320 aNbCurves=aSCvs.Length();
3325 aFFi.Indices(nF[0], nF[1]);
3326 for (i=0; i<2; ++i) {
3327 aF[i]=*((TopoDS_Face*)(&myDS->Shape(nF[i])));
3328 aS[i]=BRep_Tool::Surface(aF[i]);
3330 aType=aGAS.GetType();
3331 if (aType!=GeomAbs_BSplineSurface) {
3336 BOPTools_Curve& aBC=aSCvs(1);
3337 const IntTools_Curve& aIC=aBC.Curve();
3338 bHasBounds=aIC.HasBounds();
3343 aIC.Bounds (aT1, aT2, aP1, aP2);
3344 aT=IntTools_Tools::IntermediatePoint(aT1, aT2);
3348 for (i=0; i<2; ++i) {
3349 GeomAPI_ProjectPointOnSurf& aPPS=myContext->ProjPS(aF[i]);
3351 aPPS.LowerDistanceParameters(aU, aV);
3352 BOPTools_Tools3D::GetNormalToSurface(aS[i], aU, aV, aDN[i]);
3355 aA=aDN[0].Angle(aDN[1]);
3361 if (aA<aAmin || aA>aAmax) {
3366 aIt.Initialize(aMVStick);
3367 for (; aIt.More(); aIt.Next()) {
3369 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)(&myDS->Shape(nV)));
3370 aTolV=BRep_Tool::Tolerance(aV);
3371 if (aTolV>aTolVmax) {
3377 if (aTolR<aTolTresh) {
3381 //=======================================================================
3382 // function: PutClosingPaveOnCurve
3384 //=======================================================================
3385 void BOPTools_PaveFiller::PutClosingPaveOnCurve(BOPTools_Curve& aBC,
3386 BOPTools_SSInterference& aFFi)
3388 Standard_Boolean bIsClosed, bHasBounds, bAdded;
3389 Standard_Integer nVC, j;
3390 Standard_Real aT[2], aTolR3D, aTC, dT, aTx;
3393 BOPTools_ListIteratorOfListOfPave aItLP;
3395 const IntTools_Curve& aIC=aBC.Curve();
3396 const Handle (Geom_Curve)& aC3D=aIC.Curve();
3401 bIsClosed=IntTools_Tools::IsClosed(aC3D);
3406 bHasBounds=aIC.HasBounds ();
3411 bAdded=Standard_False;
3412 dT=Precision::PConfusion();
3413 aTolR3D=aFFi.TolR3D();
3414 aIC.Bounds (aT[0], aT[1], aP[0], aP[1]);
3416 BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
3417 BOPTools_PaveSet& aCPS=aBC.Set();
3419 const BOPTools_ListOfPave& aLP=aCPS.Set();
3420 aItLP.Initialize(aLP);
3421 for (; aItLP.More() && !bAdded; aItLP.Next()) {
3422 const BOPTools_Pave& aPC=aItLP.Value();
3424 const TopoDS_Vertex aVC=TopoDS::Vertex(myDS->Shape(nVC));
3427 for (j=0; j<2; ++j) {
3428 if (fabs(aTC-aT[j]) < dT) {
3429 aTx=(!j) ? aT[1] : aT[0];
3434 aFFiPS.Append(aPVx);
3436 bAdded=Standard_True;