Salome HOME
PAL7441. Pb with MakePartition. Fix done by PKV.
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_6.cxx
1 // File:        NMTTools_PaveFiller_6.cxx
2 // Created:     Fri Dec 19 10:27:31 2003
3 // Author:      Peter KURNEV
4 //              <pkv@irinox>
5
6 #include <NMTTools_PaveFiller.ixx>
7
8 #include <Precision.hxx>
9
10 #include <TColStd_IndexedMapOfInteger.hxx>
11 #include <TColStd_MapOfInteger.hxx>
12
13 #include <Geom2d_Curve.hxx>
14 #include <Geom_TrimmedCurve.hxx>
15
16 #include <GeomAdaptor_Curve.hxx>
17 #include <BndLib_Add3dCurve.hxx>
18
19 #include <TopoDS_Face.hxx>
20 #include <TopoDS.hxx>
21 #include <TopoDS_Compound.hxx>
22
23 #include <TopExp.hxx>
24
25 #include <BRep_Builder.hxx>
26 #include <BRep_Tool.hxx>
27 #include <BRepBndLib.hxx>
28
29 #include <TopTools_IndexedMapOfShape.hxx>
30
31 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
32 #include <BOPTColStd_IndexedDataMapOfIntegerInteger.hxx>
33
34 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
35 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
36 #include <BooleanOperations_OnceExplorer.hxx>
37 #include <BooleanOperations_ShapesDataStructure.hxx>
38
39 #include <IntTools_SequenceOfPntOn2Faces.hxx>
40 #include <IntTools_SequenceOfCurves.hxx>
41 #include <IntTools_FaceFace.hxx>
42 #include <IntTools_Tools.hxx>
43
44 #include <BOPTools_CArray1OfSSInterference.hxx>
45 #include <BOPTools_ListIteratorOfListOfInterference.hxx>
46 #include <BOPTools_CArray1OfInterferenceLine.hxx>
47 #include <BOPTools_InterferenceLine.hxx>
48 #include <BOPTools_ListOfInterference.hxx>
49 #include <BOPTools_Interference.hxx>
50 #include <BOPTools_InterferencePool.hxx>
51 #include <BOPTools_SSInterference.hxx>
52 #include <BOPTools_ListOfPaveBlock.hxx>
53 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
54 #include <BOPTools_PaveBlock.hxx>
55 #include <BOPTools_ListIteratorOfListOfPave.hxx>
56 #include <BOPTools_Tools.hxx>
57 #include <BOPTools_PaveBlockIterator.hxx>
58 #include <BOPTools_Tools2D.hxx>
59
60 #include <NMTDS_ShapesDataStructure.hxx>
61 #include <NMTTools_IndexedDataMapOfShapePaveBlock.hxx>
62 #include <NMTTools_CommonBlockAPI.hxx>
63 #include <Geom2d_Curve.hxx>
64 #include <NMTTools_Tools.hxx>
65 #include <BRepLib.hxx>
66 #include <Geom2d_TrimmedCurve.hxx>
67 //
68 #include <Geom_Surface.hxx>
69 #include <TopLoc_Location.hxx>
70
71 static 
72   Standard_Boolean IsPairFound(const Standard_Integer nF1,
73                                const Standard_Integer nF2,
74                                BOPTools_InterferencePool* myIntrPool,
75                                BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
76                                BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith);
77
78 static
79   void FMapWhat(const Standard_Integer nF,
80                 BOPTools_InterferencePool* myIntrPool,
81                 TColStd_IndexedMapOfInteger& aMapWhat);
82 static
83   void FMapWith(const Standard_Integer nF,
84                 BOPTools_InterferencePool* myIntrPool,
85                 TColStd_IndexedMapOfInteger& aMapWith);
86 static
87   Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
88                            const TColStd_IndexedMapOfInteger& aMapWith);
89
90 //=======================================================================
91 // function: PerformFF
92 // purpose: 
93 //=======================================================================
94   void NMTTools_PaveFiller::PerformFF() 
95 {
96   myIsDone=Standard_False;
97   //
98   Standard_Boolean bIsFound, bJustAdd, bIsComputed;
99   Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs;
100   Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone;
101   Standard_Integer aNbCurves, aNbPoints;
102   Standard_Real anApproxTol, aTolR3D, aTolR2D;
103   BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith;
104   IntTools_SequenceOfPntOn2Faces aPnts;
105   IntTools_SequenceOfCurves aCvs;
106   BooleanOperations_KindOfInterference aTypeFF=BooleanOperations_SurfaceSurface;
107   //
108   BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
109   //
110   //  F/F Interferences  [BooleanOperations_SurfaceSurface]
111   myDSIt.Initialize(TopAbs_FACE, TopAbs_FACE);
112   //
113   // BlockLength correction
114   aNbFFs=ExpectedPoolLength();
115   aBlockLength=aFFs.BlockLength();
116   if (aNbFFs > aBlockLength) {
117     aFFs.SetBlockLength(aNbFFs);
118   }
119   //
120   for (; myDSIt.More(); myDSIt.Next()) {
121     myDSIt.Current(n1, n2, bJustAdd);
122     //
123     bIsComputed=myIntrPool->IsComputed(n1, n2);
124     if (bIsComputed) {
125       continue;
126     }
127     //
128     nF1 = n2;
129     nF2 = n1;
130     if(n1 < n2) {
131       nF1 = n1;
132       nF2 = n2;
133     }
134     anIndexIn=0;
135     aPnts.Clear();
136     aCvs.Clear();
137     //
138     bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith);
139     //
140     if (bJustAdd) {
141       if (!bIsFound) {
142         myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
143       }
144       else{
145         BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
146         anIndexIn=aFFs.Append(anInterf);
147         myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
148       }
149       continue;
150     }
151     //
152     const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
153     const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
154     //
155     // FF
156     bToApproxC3d     = mySectionAttribute.Approximation();
157     bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1();
158     bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2();
159     //
160     anApproxTol=1.e-7;
161     //
162     IntTools_FaceFace aFF;
163     //
164     aFF.SetParameters (bToApproxC3d, bToApproxC2dOnS1, 
165                        bToApproxC2dOnS2, anApproxTol);
166     //
167     aFF.Perform(aF1, aF2);
168     //
169     bIsDone=aFF.IsDone();
170     //
171     if (!bIsDone) {
172       if (!bIsFound) {
173         myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
174       }
175       else {
176         BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
177         anIndexIn=aFFs.Append(anInterf);
178         myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
179       }
180       continue;
181     }
182     //
183     aTolR3D=aFF.TolReached3d();
184     aTolR2D=aFF.TolReached2d();
185     if (aTolR3D < 1.e-7){
186       aTolR3D=1.e-7;
187     } 
188     //
189     aFF.PrepareLines3D();
190     //
191     const IntTools_SequenceOfCurves& aCvsX=aFF.Lines();
192     const IntTools_SequenceOfPntOn2Faces& aPntsX=aFF.Points();
193     //
194     aNbCurves=aCvsX.Length();
195     aNbPoints=aPntsX.Length();
196     //
197     if (!aNbCurves && !aNbPoints) {
198       BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts);
199       anIndexIn=aFFs.Append(anInterf);
200       myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
201       continue;
202     }
203     //
204     {
205       BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvsX, aPntsX);
206       anIndexIn=aFFs.Append(anInterf);
207       myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn);
208     }
209     //
210   }// for (; myDSIt.More(); myDSIt.Next()) 
211   //
212   myIsDone=Standard_True;
213 }
214 //=======================================================================
215 // function: MakeBlocks
216 // purpose: 
217 //=======================================================================
218   void NMTTools_PaveFiller::MakeBlocks()
219 {
220   myIsDone=Standard_False;
221   //
222   Standard_Boolean bIsExistingPaveBlock, bIsValidIn2D;
223   Standard_Integer i, aNbFFs, nF1, nF2, aBid=0;
224   Standard_Integer nV1, nV2, j, aNbCurves;
225   Standard_Real aTolR3D, aTol2D, aT1, aT2, aTolPPC=Precision::PConfusion();
226   TColStd_MapOfInteger aMap;
227   NMTTools_IndexedDataMapOfShapePaveBlock aMEPB;
228   BooleanOperations_IndexedDataMapOfShapeInteger aMapEI;
229   //
230   BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
231   //
232   // 1. Produce Section Edges from intersection curves
233   //    between each pair of faces
234   //
235   aNbFFs=aFFs.Extent();
236   for (i=1; i<=aNbFFs; ++i) {
237     BOPTools_SSInterference& aFFi=aFFs(i);
238     // 
239     // Faces
240     aFFi.Indices(nF1, nF2);
241     const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
242     const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
243     //
244     // Add blocks that are existing ones for this FF-interference
245     BOPTools_ListOfPaveBlock aLPB;
246     RealSplitsInFace (aBid, nF1, nF2, aLPB);
247     RealSplitsInFace (aBid, nF2, nF1, aLPB);
248     RealSplitsOnFace (aBid, nF1, nF2, aLPB);
249     //
250     aMap.Clear();
251     BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
252     for (; anIt.More(); anIt.Next()) {
253       const BOPTools_PaveBlock& aPB=anIt.Value();
254       aFFi.AppendBlock(aPB);
255       nV1=aPB.Pave1().Index();
256       nV2=aPB.Pave2().Index();
257       aMap.Add(nV1);
258       aMap.Add(nV2);
259     }
260     //
261     BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
262     aNbCurves=aSCvs.Length();
263     if (!aNbCurves) {
264       continue;
265     }
266     //
267     aTolR3D=aFFi.TolR3D();
268     aTol2D=(aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D;
269     //
270     BOPTools_PaveSet aPSF;
271     //
272     PrepareSetForFace (nF1, nF2, aPSF);
273     //
274     // Put Paves On Curves
275     for (j=1; j<=aNbCurves; ++j) {
276       BOPTools_Curve& aBC=aSCvs(j);
277       // DEBUG
278       const IntTools_Curve& aC=aBC.Curve();
279       Handle (Geom_Curve) aC3D= aC.Curve();
280       //
281       PutPaveOnCurve (aPSF, aTolR3D, aBC);
282     }
283     //
284     // Put bounding paves on curves
285     for (j=1; j<=aNbCurves; ++j) {
286       BOPTools_Curve& aBC=aSCvs(j);
287       PutBoundPaveOnCurve (aBC, aFFi);
288     }
289     //
290     //  Pave Blocks on Curves
291     for (j=1; j<=aNbCurves; ++j) {
292       BOPTools_Curve& aBC=aSCvs(j);
293       const IntTools_Curve& aIC= aBC.Curve();
294       BOPTools_PaveSet& aPaveSet=aBC.Set();
295       //
296       BOPTools_PaveBlockIterator aPBIter(0, aPaveSet);
297       for (; aPBIter.More(); aPBIter.Next()) {
298         BOPTools_PaveBlock& aPBNew=aPBIter.Value();
299         aPBNew.SetCurve(aIC);
300         aPBNew.SetFace1(nF1);
301         aPBNew.SetFace2(nF2);
302         //
303         nV1=aPBNew.Pave1().Index();
304         nV2=aPBNew.Pave2().Index();
305         aT1=aPBNew.Pave1().Param();
306         aT2=aPBNew.Pave2().Param();
307         // ???
308         if((nV1==nV2) && (Abs(aT2 - aT1) < aTolPPC)) {
309           continue;// mkk ft
310         }
311         //
312         bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aFFi);
313         if (bIsExistingPaveBlock) {
314           // aPBNew was (or just lays) boundary PB 
315           continue;
316         }
317         // Checking of validity in 2D
318         //
319         bIsValidIn2D=myContext.IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D);
320         if (!bIsValidIn2D) {
321           continue;
322         }
323         //
324         //aBC.AppendNewBlock(aPBNew);
325         //
326         // Make Section Edge  
327         TopoDS_Edge aES;
328         //
329         const TopoDS_Vertex& aV1=TopoDS::Vertex(myDS->Shape(nV1));
330         const TopoDS_Vertex& aV2=TopoDS::Vertex(myDS->Shape(nV2));
331         //
332         BOPTools_Tools::MakeSectEdge (aIC, aV1, aT1, aV2, aT2, aES);
333         //
334         {
335           Standard_Real aTolR2D;
336           //
337           aTolR2D=aFFi.TolR2D();
338           Handle(Geom2d_Curve) aC2D1=aIC.FirstCurve2d();
339           Handle(Geom2d_Curve) aC2D2=aIC.SecondCurve2d();
340           //
341           NMTTools_Tools::MakePCurve(aES, aF1, aC2D1, aTolR2D);
342           NMTTools_Tools::MakePCurve(aES, aF2, aC2D2, aTolR2D);
343         }
344         //
345         aMEPB.Add(aES, aPBNew);
346         aMapEI.Add(aES, i);
347       }
348     } // end of for (j=1; j<=aNbCurves; ++j)
349   }// for (i=1; i<=aNbFFs; ++i)
350   //=============================================================
351   //
352   // II. Post treatment 
353   //
354   // Input data: aMEPB, aMapEI
355   // Result    : section edges in myDS
356   //
357   Standard_Integer aNbSE;
358   //
359   aNbSE=aMEPB.Extent();
360   if (!aNbSE) {
361     // there is nothing to do here
362     return;
363   } 
364   //
365   BRep_Builder aBB;
366   TopoDS_Compound aCompound;
367   //
368   // 1. Make compound from SE
369   aBB.MakeCompound(aCompound);
370   for (i=1; i<=aNbSE; ++i) {
371     const TopoDS_Shape& aSE=aMEPB.FindKey(i);
372     aBB.Add(aCompound, aSE);
373   }
374   //
375   //
376   // 2. Intersect SE using auxiliary Filler
377   NMTDS_ShapesDataStructure tDS;
378   //
379   tDS.SetCompositeShape(aCompound);
380   tDS.Init();
381   //
382   BOPTools_InterferencePool tIP(tDS);
383   NMTTools_PaveFiller tPF(tIP);
384   //
385   // 2.1.VV
386   tPF.Init();
387   tPF.PerformVV();
388   tPF.PerformNewVertices();
389   //
390   // 2.2.VE
391   tPF.myPavePool.Resize (tPF.myNbEdges);
392   tPF.PrepareEdges();
393   tPF.PerformVE();
394   //
395   // 2.3.VF
396   tPF.PerformVF();
397   //
398   // 2.4.EE
399   tPF.myCommonBlockPool.Resize (tPF.myNbEdges);
400   tPF.mySplitShapesPool.Resize (tPF.myNbEdges);
401   tPF.myPavePoolNew    .Resize (tPF.myNbEdges);
402   
403   tPF.PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE);
404   tPF.PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE);
405   //
406   tPF.PerformEE();
407   //
408   tPF.RefinePavePool ();
409   //
410   tPF.myPavePoolNew.Destroy();
411   //
412   tPF.MakeSplitEdges();
413   tPF.UpdateCommonBlocks();
414   //
415   // 3. Treatment of the result of intersection
416   //
417   Standard_Integer aNbOld, aNbLines, aNbPB, mV1, mV2, nE, mE, iFF;
418   TopAbs_ShapeEnum aType;
419   BOPTools_ListIteratorOfListOfPaveBlock aIt;
420   BOPTColStd_IndexedDataMapOfIntegerInteger aMNewOld;
421   //
422   const BOPTools_SplitShapesPool& aSSP=tPF.mySplitShapesPool;
423   const NMTTools_CommonBlockPool& aCBP=tPF.myCommonBlockPool;
424   //
425   aNbLines=tDS.NumberOfInsertedShapes();
426   aNbOld=tDS.NumberOfShapesOfTheObject();
427   // 
428   // 3.1 Links between indices in tDS and DS (kept in aMNewOld)
429   //
430   // 3.1.1.Old vertices [ links ]
431   for (i=1; i<=aNbOld; ++i) {
432     const TopoDS_Shape& aV=tDS.Shape(i);
433     aType=aV.ShapeType();
434     if (aType!=TopAbs_VERTEX) {
435       continue;
436     }
437     //
438     for (j=1; j<=aNbSE; ++j) {
439       const BOPTools_PaveBlock& aPBSE=aMEPB(j);
440       nV1=aPBSE.Pave1().Index();
441       const TopoDS_Shape& aV1=myDS->Shape(nV1);
442       if (aV1.IsSame(aV)) {
443         aMNewOld.Add(i, nV1);
444         break;
445       }
446       nV2=aPBSE.Pave2().Index();
447       const TopoDS_Shape& aV2=myDS->Shape(nV2);
448       if (aV2.IsSame(aV)) {
449         aMNewOld.Add(i, nV2);
450         break;
451       }
452     }
453   }
454   //
455   // 3.1.2. New vertices [ links ]
456   i=tDS.NumberOfSourceShapes()+1;
457   for (; i<=aNbLines; ++i) {
458     const TopoDS_Shape& aV=tDS.Shape(i);
459     aType=aV.ShapeType();
460     if (aType!=TopAbs_VERTEX) {
461       continue;
462     }
463     //
464     // Insert new vertex in myDS
465     BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
466     myDS->InsertShapeAndAncestorsSuccessors(aV, anASSeq);
467     nV1=myDS->NumberOfInsertedShapes();
468     // link
469     aMNewOld.Add(i, nV1);
470   }
471   //
472   // 3.2. Treatment of section edges (SE)
473   for (i=1; i<=aNbOld; ++i) {
474     const TopoDS_Shape& aE=tDS.Shape(i);
475     aType=aE.ShapeType();
476     if (aType!=TopAbs_EDGE) {
477       continue;
478     }
479     //
480     //  block of section edge that we already have for this SE
481     BOPTools_PaveBlock& aPBSE=aMEPB.ChangeFromKey(aE);
482     //
483     // Corresponding FF-interference
484     iFF=aMapEI.FindFromKey(aE);
485     BOPTools_SSInterference& aFFi=aFFs(iFF);
486     BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
487     //
488     BOPTools_Curve& aBC=aSCvs(1); 
489     //
490     const BOPTools_ListOfPaveBlock& aLPB=aSSP(tDS.RefEdge(i));
491     aNbPB=aLPB.Extent();
492     //
493     if (!aNbPB) {
494       // no pave blocks -> use aPBSE and whole edge aE
495       BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
496       //
497       nV1=aPBSE.Pave1().Index();
498       const TopoDS_Shape& aV1=myDS->Shape(nV1);
499       nV2=aPBSE.Pave2().Index();
500       const TopoDS_Shape& aV2=myDS->Shape(nV2);
501       //
502       anASSeq.SetNewSuccessor(nV1);
503       anASSeq.SetNewOrientation(aV1.Orientation());
504       anASSeq.SetNewSuccessor(nV2);
505       anASSeq.SetNewOrientation(aV2.Orientation());
506       //
507       myDS->InsertShapeAndAncestorsSuccessors(aE, anASSeq);
508       nE=myDS->NumberOfInsertedShapes();
509       //
510       aPBSE.SetEdge(nE);
511       aBC.AppendNewBlock(aPBSE);
512       //
513       continue;
514     }
515     //
516     nF1=aPBSE.Face1();
517     nF2=aPBSE.Face2();
518     const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
519     const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
520     //
521     const NMTTools_ListOfCommonBlock& aLCB=aCBP(tDS.RefEdge(i));
522     NMTTools_CommonBlockAPI aCBAPI(aLCB);
523     //
524     aIt.Initialize(aLPB);
525     for (; aIt.More(); aIt.Next()) {
526       BOPTools_PaveBlock aPB=aIt.Value();
527       //
528       if (aCBAPI.IsCommonBlock(aPB)) {
529         // it can be Common Block
530         Standard_Real aTolEx;
531         Handle(Geom2d_Curve) aC2D1, aC2D2;
532         TopoDS_Face aF1FWD, aF2FWD;
533         //
534         NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
535         const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
536         //
537         aPB=aCB.PaveBlock1();
538         mE=aPB.Edge(); // index of edge in tDS
539         const TopoDS_Edge& aEx=TopoDS::Edge(tDS.Shape(mE));
540         aTolEx=BRep_Tool::Tolerance(aEx);
541         //
542         //modified by NIZNHY-PKV Mon Dec 27 14:30:15 2004 f
543         //
544         aF1FWD=aF1;
545         aF1FWD.Orientation(TopAbs_FORWARD);
546         NMTTools_Tools::MakePCurve(aEx, aF1FWD, aC2D1, aTolEx);
547         //
548         aF2FWD=aF2;
549         aF2FWD.Orientation(TopAbs_FORWARD);
550         NMTTools_Tools::MakePCurve(aEx, aF2FWD, aC2D2, aTolEx);
551         //
552         // block A has been removed
553         //modified by NIZNHY-PKV Mon Dec 27 14:33:26 2004 t                             
554       } //if (aCBAPI.IsCommonBlock(aPB))
555       //
556       // new SE
557       mE=aPB.Edge(); // index of edge in tDS
558       const TopoDS_Shape& aSp=tDS.Shape(mE);
559       //
560       const BOPTools_Pave& aPave1=aPB.Pave1();
561       aT1=aPave1.Param();
562       mV1=aPave1.Index();            // index in tDS
563       nV1=aMNewOld.FindFromKey(mV1); // index in myDS
564       const TopoDS_Shape& aV1=myDS->Shape(nV1);
565       //
566       const BOPTools_Pave& aPave2=aPB.Pave2();
567       aT2=aPave2.Param();
568       mV2=aPave2.Index();
569       nV2=aMNewOld.FindFromKey(mV2);
570       const TopoDS_Shape& aV2=myDS->Shape(nV2);
571       //
572       if (!aMNewOld.Contains(mE)) {
573         // add new SE to the myDS
574         BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
575         //
576         anASSeq.SetNewSuccessor(nV1);
577         anASSeq.SetNewOrientation(aV1.Orientation());
578
579         anASSeq.SetNewSuccessor(nV2);
580         anASSeq.SetNewOrientation(aV2.Orientation());
581         
582         myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq);
583         nE=myDS->NumberOfInsertedShapes();
584         //
585         aMNewOld.Add(mE, nE);
586       }
587       else {
588         nE=aMNewOld.FindFromKey(mE);
589       }
590       // Form PaveBlock;
591       BOPTools_PaveBlock aPBx;
592       BOPTools_Pave aP1, aP2;
593       //
594       aPBx.SetFace1(nF1);
595       aPBx.SetFace1(nF2);
596       //
597       aP1.SetIndex(nV1);
598       aP1.SetParam(aT1);
599       //
600       aP2.SetIndex(nV2);
601       aP2.SetParam(aT2);
602       //
603       aPBx.SetPave1(aP1);
604       aPBx.SetPave2(aP2);
605       //
606       aPBx.SetEdge(nE);
607       //
608       aBC.AppendNewBlock(aPBx);
609     }// for (; aIt.More(); aIt.Next()) 
610   }// for (i=1; i<=aNbOld; ++i) 
611   //
612   myIsDone=Standard_True;
613 }
614 //=======================================================================
615 // function: MakePCurves
616 // purpose: 
617 //=======================================================================
618   void NMTTools_PaveFiller::MakePCurves()
619 {
620   Standard_Integer i, aNb,  nF1, nF2, nE;
621   TopoDS_Face aF1FWD, aF2FWD;
622   BOPTools_ListIteratorOfListOfPaveBlock anIt;
623   //
624   BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences();
625   //
626   aNb=aFFs.Extent();
627   for (i=1; i<=aNb; i++) {
628     BOPTools_SSInterference& aFF=aFFs(i);
629     aFF.Indices(nF1, nF2);
630     //
631     const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1));
632     const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2));
633     //
634     aF1FWD=aF1;
635     aF1FWD.Orientation(TopAbs_FORWARD);
636     aF2FWD=aF2;
637     aF2FWD.Orientation(TopAbs_FORWARD);
638     //
639     // In, On parts processing
640     const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
641     //
642     anIt.Initialize(aLPBInOn);
643     for (; anIt.More(); anIt.Next()) {
644       const BOPTools_PaveBlock& aPB=anIt.Value();
645       nE=aPB.Edge();
646       const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE));
647       
648       BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
649       BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
650     }
651     //
652     //  Section Edges processing
653     /*
654     Standard_Integer aNbCurves, k, aNbV; 
655     Standard_Real aTolEdge, aTolR2D, aTolFact, aTolV, aTolVmax; 
656     BRep_Builder aBB; 
657     //
658     BOPTools_SequenceOfCurves& aSC=aFF.Curves();
659     aNbCurves=aSC.Length();
660     if (!aNbCurves) {
661       continue;
662     }
663     //
664     const BOPTools_Curve& aBC=aSC(1);
665     const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
666     anIt.Initialize(aLPB);
667     for (; anIt.More(); anIt.Next()) {
668       const BOPTools_PaveBlock& aPB=anIt.Value();
669       nE=aPB.Edge();
670       const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE));
671       //
672       aTolEdge=BRep_Tool::Tolerance(aE);
673       aTolR2D=aFF.TolR2D();
674       aTolFact=Max(aTolEdge, aTolR2D);
675       //
676       // Check vertices tolerances and correct them if necessary 
677       // to prevent situation when TolE > TolV
678       //
679       TopTools_IndexedMapOfShape aVMap;
680       TopExp::MapShapes(aE, TopAbs_VERTEX, aVMap);
681
682       aTolVmax=-1.;
683       aNbV=aVMap.Extent();
684       for (k=1; k<=aNbV; ++k) {
685         const TopoDS_Vertex& aV=TopoDS::Vertex(aVMap(k));
686         aTolV=BRep_Tool::Tolerance(aV);
687         if (aTolV>aTolVmax) {
688           aTolVmax=aTolV;
689         }
690       }
691       //
692       if (aTolFact>aTolVmax) {
693         aTolFact=aTolVmax;
694       }
695       // 
696       Standard_Real aTFirst, aTLast, aOutFirst, aOutLast, aOutTol;
697       Handle(Geom2d_Curve) aC2D1, aC2D1A, aC2D2, aC2D2A;
698       Handle(Geom_TrimmedCurve)aC3DETrim;
699       //
700       const Handle(Geom_Curve)& aC3DE=BRep_Tool::Curve(aE, aTFirst, aTLast);
701       aC3DETrim=new Geom_TrimmedCurve(aC3DE, aTFirst, aTLast);
702       //
703       // first P-Curve
704       BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
705       BOPTools_Tools2D::CurveOnSurface(aE, aF1FWD, aC2D1, aOutFirst, aOutLast, aOutTol, Standard_True);
706       //
707       if (aC3DE->IsPeriodic()) {
708         BOPTools_Tools2D::AdjustPCurveOnFace(aF1FWD, aTFirst, aTLast,  aC2D1, aC2D1A); 
709       }
710       else {
711         BOPTools_Tools2D::AdjustPCurveOnFace(aF1FWD, aC3DETrim, aC2D1, aC2D1A); 
712       }
713       //
714       aBB.UpdateEdge(aE, aC2D1A, aF1FWD, aTolFact);
715       // 
716       // second P-Curve
717       BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
718       BOPTools_Tools2D::CurveOnSurface(aE, aF2FWD, aC2D2, aOutFirst, aOutLast, aOutTol, Standard_True);
719       //
720       if (aC3DE->IsPeriodic()) {
721         BOPTools_Tools2D::AdjustPCurveOnFace(aF2FWD, aTFirst, aTLast, aC2D2, aC2D2A); 
722       }
723       else {
724         BOPTools_Tools2D::AdjustPCurveOnFace(aF2FWD, aC3DETrim, aC2D2, aC2D2A); 
725       }
726       //
727       aBB.UpdateEdge(aE, aC2D2A, aF2FWD, aTolFact);
728     }
729     */
730   } 
731   
732 }
733 //=======================================================================
734 // function: IsExistingPaveBlock
735 // purpose: 
736 //=======================================================================
737    Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew,
738                                                              const BOPTools_SSInterference& aFFi)
739 {
740   Standard_Boolean bFlag=Standard_False;
741   Standard_Integer nVNew1, nVNew2, nV1, nV2, iC;
742   Standard_Real aTolR3D;
743   BOPTools_ListIteratorOfListOfPaveBlock anIt;
744   //
745   aTolR3D=aFFi.TolR3D();
746   //
747   nVNew1=aPBNew.Pave1().Index();
748   nVNew2=aPBNew.Pave2().Index();
749   //
750   const BOPTools_ListOfPaveBlock& aLPBR=aFFi.PaveBlocks();
751   anIt.Initialize(aLPBR);
752   for (; anIt.More(); anIt.Next()) {
753     const BOPTools_PaveBlock& aPBR=anIt.Value();
754     nV1=aPBR.Pave1().Index();
755     nV2=aPBR.Pave2().Index();
756     if (nVNew1==nV1 || nVNew1==nV2 || nVNew2==nV1 || nVNew2==nV2) {
757       //
758       iC=CheckIntermediatePoint(aPBNew, aPBR, aTolR3D);
759       if (!iC) {
760         return !bFlag;
761       }
762     }
763   }
764   return bFlag;
765 }
766 //=======================================================================
767 // function: CheckIntermediatePoint
768 // purpose: 
769 //=======================================================================
770   Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,
771                                                                const BOPTools_PaveBlock& aPBR,
772                                                                const Standard_Real aTolC)
773                                                          
774 {
775   Standard_Real aT11, aT12, aTM, aTmp;
776   Standard_Integer iVM, nE2;
777   gp_Pnt aPM;
778   BRep_Builder aBB;
779   TopoDS_Vertex aVM;
780   // 
781   // Vertex
782   const BOPTools_Pave& aPave11=aPB.Pave1();
783   aT11=aPave11.Param();
784   // 
785   const BOPTools_Pave& aPave12=aPB.Pave2();
786   aT12=aPave12.Param();
787   //
788   aTM=IntTools_Tools::IntermediatePoint (aT11, aT12);
789   //
790   const IntTools_Curve& aIC=aPB.Curve();
791   aIC.D0(aTM, aPM);
792   //
793   aBB.MakeVertex (aVM, aPM, aTolC);
794   //
795   //Edge
796   nE2=aPBR.Edge();
797   const TopoDS_Edge& aE2=TopoDS::Edge(myDS->GetShape(nE2));
798   // VE
799   iVM=myContext.ComputeVE(aVM, aE2, aTmp); 
800   //
801   return iVM;
802 }
803 //=======================================================================
804 // function: PutBoundPaveOnCurve
805 // purpose: 
806 //=======================================================================
807   void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC,
808                                                 BOPTools_SSInterference& aFFi)
809
810   Standard_Boolean bHasBounds, bVF;
811   Standard_Integer nF1, nF2;
812   Standard_Real aT1, aT2, aTolR3D;
813   gp_Pnt aP1, aP2;
814   //
815   const IntTools_Curve& aIC=aBC.Curve();
816   bHasBounds=aIC.HasBounds ();
817   if (!bHasBounds){
818     return;
819   }
820   //
821   // Bounds
822   aIC.Bounds (aT1, aT2, aP1, aP2);
823   //
824   // Faces
825   aFFi.Indices(nF1, nF2);
826   aTolR3D=aFFi.TolR3D();
827   //
828   const TopoDS_Face& aF1=TopoDS::Face(myDS->GetShape(nF1));
829   const TopoDS_Face& aF2=TopoDS::Face(myDS->GetShape(nF2));
830   //
831   bVF=myContext.IsValidPointForFaces (aP1, aF1, aF2, aTolR3D);
832   if (bVF) {
833     PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi);
834   }
835   //
836   bVF=myContext.IsValidPointForFaces (aP2, aF1, aF2, aTolR3D);
837   if (bVF) {
838     PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi);
839   }
840 }
841 //=======================================================================
842 // function: PutBoundPaveOnCurve
843 // purpose: 
844 //=======================================================================
845   void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP,
846                                                 const Standard_Real aT,
847                                                 BOPTools_Curve& aBC,
848                                                 BOPTools_SSInterference& aFFi)
849
850   Standard_Boolean bFound1, bFound2;
851   Standard_Integer nV;
852   Standard_Real aTolV=aFFi.TolR3D();
853
854   BOPTools_Pave aPave1, aPave2, aPave;
855   BOPTools_PaveSet& aCPS=aBC.Set();
856   BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet();
857   const IntTools_Curve& aIC=aBC.Curve();
858   //
859   bFound1=FindPave(aP, aTolV, aCPS  , aPave1);
860   bFound2=FindPave(aP, aTolV, aFFiPS, aPave2);
861   //
862   if (!bFound1 && !bFound2) {
863     TopoDS_Vertex aNewVertex;
864     BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex);
865     //
866     BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
867     myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
868     nV=myDS->NumberOfInsertedShapes();
869     aPave.SetIndex(nV);
870     aPave.SetParam(aT);
871
872     aCPS.Append(aPave);
873     aFFiPS.Append(aPave);
874     //
875     // Append Techno Vertex to the Curve
876     TColStd_ListOfInteger& aTVs=aBC.TechnoVertices();
877     aTVs.Append(nV);
878   }
879   
880   if (bFound1 && !bFound2) {
881     nV=aPave1.Index();
882     aPave.SetIndex(nV);
883     aPave.SetParam(aT);
884     aFFiPS.Append(aPave);
885     //
886     const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
887     BOPTools_Tools::UpdateVertex (aIC, aT, aV);
888   }
889   
890   if (!bFound1 && bFound2) {
891     nV=aPave2.Index();
892     aPave.SetIndex(nV);
893     aPave.SetParam(aT);
894     aCPS.Append(aPave);
895     //
896     const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
897     BOPTools_Tools::UpdateVertex (aIC, aT, aV);
898   }
899 }
900 //=======================================================================
901 // function: FindPave
902 // purpose: 
903 //=======================================================================
904   Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP,
905                                                  const Standard_Real aTolPV, 
906                                                  const BOPTools_PaveSet& aPS,
907                                                  BOPTools_Pave& aPave)
908 {
909   Standard_Integer nV;
910   Standard_Boolean bIsVertex=Standard_False;
911  
912   const BOPTools_ListOfPave& aLP=aPS.Set();
913   BOPTools_ListIteratorOfListOfPave anIt(aLP);
914   for (; anIt.More(); anIt.Next()) {
915     const BOPTools_Pave& aPC=anIt.Value();
916     nV=aPC.Index();
917     const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
918     bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV);
919     if (bIsVertex) {
920       aPave=aPC;
921       return bIsVertex;
922     }
923   }
924   return bIsVertex;
925 }
926 //=======================================================================
927 // function: PrepareSetForFace
928 // purpose: 
929 //=======================================================================
930   void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer nF1,
931                                               const Standard_Integer nF2,
932                                                BOPTools_PaveSet& aPSF)
933 {
934   Standard_Integer nV1, nV2; 
935   TColStd_MapOfInteger aMap;
936   BOPTools_ListOfPaveBlock aLPB1, aLPB2;
937   BOPTools_ListIteratorOfListOfPaveBlock anIt;
938   //
939   RealSplitsFace(nF1, aLPB1);
940   RealSplitsFace(nF2, aLPB2);
941   //
942   aLPB1.Append(aLPB2);
943   //
944   anIt.Initialize(aLPB1);
945   for (; anIt.More(); anIt.Next()) {
946     const BOPTools_PaveBlock& aPB=anIt.Value();
947     const BOPTools_Pave& aPave1=aPB.Pave1();
948     nV1=aPave1.Index();
949     if (!aMap.Contains(nV1)) {
950       aMap.Add(nV1);
951       aPSF.Append(aPave1);
952     }
953     const BOPTools_Pave& aPave2=aPB.Pave2();
954     nV2=aPave2.Index();
955     if (!aMap.Contains(nV2)) {
956       aMap.Add(nV2);
957       aPSF.Append(aPave2);
958     }
959   }
960 }
961 //=======================================================================
962 // function: PutPaveOnCurve
963 // purpose: 
964 //=======================================================================
965   void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
966                                            const Standard_Real aTolR3D,
967                                            BOPTools_Curve& aBC)
968
969   Standard_Integer nV;
970   Standard_Boolean bIsVertexOnLine;
971   Standard_Real aT;
972   BOPTools_ListIteratorOfListOfPave anIt;
973   Bnd_Box aBBC;
974   GeomAdaptor_Curve aGAC;
975   //
976   const IntTools_Curve& aC=aBC.Curve();
977   Handle (Geom_Curve) aC3D= aC.Curve();
978   aGAC.Load(aC3D);
979   BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBBC);
980   //
981   const BOPTools_ListOfPave& aLP=aPaveSet.Set();
982   anIt.Initialize(aLP);
983   for (; anIt.More(); anIt.Next()) {
984     const BOPTools_Pave& aPave=anIt.Value();
985     //
986     nV=aPave.Index();
987     const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV));
988     //
989     Bnd_Box aBBV;
990     BRepBndLib::Add(aV, aBBV);
991     if (aBBC.IsOut(aBBV)){
992       continue; 
993     }
994     //
995     bIsVertexOnLine=myContext.IsVertexOnLine(aV, aC, aTolR3D, aT);
996     //
997     if (bIsVertexOnLine) {
998       BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface);
999       BOPTools_PaveSet& aPS=aBC.Set();
1000       aPS.Append(aPaveNew);
1001       //<-B
1002       BOPTools_Tools::UpdateVertex (aC, aT, aV);
1003     }
1004   }
1005 }
1006 /////////////
1007 //=======================================================================
1008 // function: IsPairFound
1009 // purpose: 
1010 //=======================================================================
1011 Standard_Boolean IsPairFound(const Standard_Integer nF1,
1012                              const Standard_Integer nF2,
1013                              BOPTools_InterferencePool* myIntrPool,
1014                              BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat,
1015                              BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith)
1016 {
1017   Standard_Boolean bIsFound;
1018   //
1019   if (!aMapWhat.Contains(nF1)) {
1020     TColStd_IndexedMapOfInteger aMWhat;
1021     FMapWhat(nF1, myIntrPool, aMWhat);
1022     aMapWhat.Add(nF1, aMWhat);
1023   }
1024   //
1025   if (!aMapWith.Contains(nF2)) {
1026     TColStd_IndexedMapOfInteger aMWith;
1027     FMapWith(nF2, myIntrPool, aMWith);
1028     aMapWith.Add(nF2, aMWith);
1029   }
1030   //
1031   const TColStd_IndexedMapOfInteger& aMWht=aMapWhat.FindFromKey(nF1);
1032   const TColStd_IndexedMapOfInteger& aMWit=aMapWith.FindFromKey(nF2);
1033   //
1034   bIsFound=IsFound(aMWht, aMWit);
1035   //
1036   return bIsFound;
1037 }
1038 //=======================================================================
1039 // function: FMapWhat
1040 // purpose: 
1041 //=======================================================================
1042 void FMapWhat(const Standard_Integer nF,
1043               BOPTools_InterferencePool* myIntrPool,
1044               TColStd_IndexedMapOfInteger& aMapWhat)
1045                     
1046 {
1047   Standard_Integer nE, nV;
1048  
1049   
1050
1051   BooleanOperations_ShapesDataStructure* myDS=myIntrPool->DS();
1052   BooleanOperations_OnceExplorer aExp(*myDS);
1053   //
1054   //  What
1055   aMapWhat.Add(nF);
1056   aExp.Init(nF, TopAbs_VERTEX);
1057   for (; aExp.More(); aExp.Next()) {
1058     nV=aExp.Current();
1059     aMapWhat.Add(nV);
1060   }
1061   //
1062   aExp.Init(nF, TopAbs_EDGE);
1063   for (; aExp.More(); aExp.Next()) {
1064     nE=aExp.Current();
1065     aMapWhat.Add(nE);
1066   }
1067 }
1068 //=======================================================================
1069 // function: FMapWith
1070 // purpose: 
1071 //=======================================================================
1072 void FMapWith(const Standard_Integer nF,
1073               BOPTools_InterferencePool* myIntrPool,
1074               TColStd_IndexedMapOfInteger& aMapWith)
1075 {
1076   TColStd_IndexedMapOfInteger aMapWhat;
1077   
1078   FMapWhat(nF, myIntrPool, aMapWhat);
1079   //
1080   // With
1081   Standard_Integer i, aNb, anIndex, aWhat, aWith;
1082   BOPTools_ListIteratorOfListOfInterference anIt;
1083   
1084   const BOPTools_CArray1OfInterferenceLine& anArrIL= myIntrPool->InterferenceTable();
1085
1086   aNb=aMapWhat.Extent();
1087   for (i=1; i<=aNb; i++) {
1088     aWhat=aMapWhat(i);
1089     
1090     const BOPTools_InterferenceLine& aWithLine=anArrIL(aWhat);
1091   
1092     const BOPTools_ListOfInterference& aLI=aWithLine.List();
1093     anIt.Initialize(aLI);
1094     for (; anIt.More(); anIt.Next()) {
1095       const BOPTools_Interference& anIntf=anIt.Value();
1096       anIndex=anIntf.Index();
1097       if (anIndex) {
1098         aWith=anIntf.With();
1099         aMapWith.Add(aWith);
1100       }
1101     }
1102   }
1103 }
1104 //=======================================================================
1105 // function: IsFound
1106 // purpose: 
1107 //=======================================================================
1108 Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat,
1109                          const TColStd_IndexedMapOfInteger& aMapWith)
1110 {
1111   Standard_Boolean bFlag=Standard_False;
1112   Standard_Integer i, aNb, aWhat;
1113
1114   aNb=aMapWhat.Extent();
1115   for (i=1; i<=aNb; i++) {
1116     aWhat=aMapWhat(i);
1117     if (aMapWith.Contains(aWhat)) {
1118       return !bFlag;
1119     }
1120   }
1121   return bFlag;
1122 }
1123 /* 
1124 // block A
1125         for (k=0; k<2; ++k) {   
1126           nF=(!k) ? nF1 : nF2;
1127           const TopoDS_Face& aF=TopoDS::Face(myDS->Shape(nF));
1128           //
1129           bHasPCOnF=BOPTools_Tools2D::HasCurveOnSurface(aEx, aF); 
1130           if (bHasPCOnF) {
1131             continue;
1132           }
1133           //
1134           bFound=Standard_False;
1135           aItPBx.Initialize(aLPBx);
1136           for (; aItPBx.More(); aItPBx.Next()) {
1137             BOPTools_PaveBlock& aPBx=aIt.Value();
1138             nEOrx=aPBx.OriginalEdge();
1139             const TopoDS_Shape& aEOrx=tDS.Shape(nEOrx);
1140             BOPTools_PaveBlock& aPBSEx=aMEPB.ChangeFromKey(aEOrx);
1141             aT1x=aPBSEx.Pave1().Param();
1142             aT2x=aPBSEx.Pave2().Param();
1143             const IntTools_Curve& aICx=aPBSEx.Curve();
1144             //
1145             nF1x=aPBSEx.Face1();
1146             nF2x=aPBSEx.Face2();
1147             //
1148             if (nF1x==nF) {
1149               Handle(Geom2d_Curve) aC2D1x=aICx.FirstCurve2d();
1150               Handle(Geom2d_TrimmedCurve)aC2D1xT =new Geom2d_TrimmedCurve(aC2D1x, aT1x, aT2x);
1151               aBB.UpdateEdge(aEx, aC2D1xT, aF, aTolEx);
1152               bFound=!bFound;
1153               break;
1154             }
1155             //
1156             if (nF2x==nF) {
1157               Handle(Geom2d_Curve) aC2D2x=aICx.SecondCurve2d();
1158               Handle(Geom2d_TrimmedCurve)aC2D2xT =new Geom2d_TrimmedCurve(aC2D2x, aT1x, aT2x);
1159               aBB.UpdateEdge(aEx, aC2D2xT, aF, aTolEx);
1160               bFound=!bFound;
1161               break;
1162             }
1163           }
1164           if (bFound){
1165             BRepLib::SameParameter(aEx, aTolEx, Standard_True);
1166           }
1167         } 
1168         */