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