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