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