Salome HOME
Update copyright
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_5.cxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:        NMTTools_PaveFiller_5.cxx
24 // Created:     Mon Dec 15 11:28:33 2003
25 // Author:      Peter KURNEV
26 //              <pkv@irinox>
27 //
28 #include <NMTTools_PaveFiller.ixx>
29
30 #include <TColStd_IndexedMapOfInteger.hxx>
31
32 #include <BRep_Tool.hxx>
33 #include <BRep_Builder.hxx>
34
35 #include <Bnd_Box.hxx>
36
37 #include <TopAbs_ShapeEnum.hxx>
38
39 #include <TopoDS.hxx>
40 #include <TopoDS_Face.hxx>
41 #include <TopoDS_Edge.hxx>
42 #include <TopoDS_Vertex.hxx>
43 #include <TopoDS_Compound.hxx>
44
45 #include <TopExp.hxx>
46
47 #include <TopTools_IndexedMapOfShape.hxx>
48
49 #include <IntTools_ShrunkRange.hxx>
50 #include <IntTools_Range.hxx>
51 #include <IntTools_EdgeFace.hxx>
52 #include <IntTools_PContext.hxx>
53 #include <IntTools_SequenceOfCommonPrts.hxx>
54 #include <IntTools_CommonPrt.hxx>
55 #include <IntTools_Tools.hxx>
56
57 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
58 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
59 #include <BooleanOperations_OnceExplorer.hxx>
60
61 #include <BOPTools_Tools.hxx>
62 #include <BOPTools_Pave.hxx>
63 #include <BOPTools_PaveSet.hxx>
64 #include <BOPTools_ListOfPave.hxx>
65 #include <BOPTools_ListIteratorOfListOfPave.hxx>
66 #include <BOPTools_PaveBlock.hxx>
67 #include <BOPTools_ListOfPaveBlock.hxx>
68 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
69 #include <BOPTools_ESInterference.hxx>
70
71 #include <BOPTools_CArray1OfVVInterference.hxx>
72 #include <BOPTools_CArray1OfESInterference.hxx>
73 #include <BOPTools_VVInterference.hxx>
74 #include <BOPTools_ESInterference.hxx>
75 #include <BOPTools_IDMapOfPaveBlockIMapOfInteger.hxx>
76 #include <BOPTools_IMapOfPaveBlock.hxx>
77
78 #include <NMTDS_ShapesDataStructure.hxx>
79 #include <NMTDS_Iterator.hxx>
80 #include <NMTDS_InterfPool.hxx>
81
82 #include <NMTTools_ListOfCommonBlock.hxx>
83 #include <NMTTools_CommonBlockAPI.hxx>
84 #include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
85 #include <NMTTools_CommonBlockAPI.hxx>
86 #include <NMTTools_ListOfCommonBlock.hxx>
87
88
89 static
90   void VertexParameter(const IntTools_CommonPrt& aCPart,
91                        Standard_Real& aT);
92 static
93   Standard_Boolean IsOnPave(const Standard_Real& aTR,
94                             const IntTools_Range& aCPRange,
95                             const Standard_Real& aTolerance);
96 //
97 //=======================================================================
98 // function: PerformEF
99 // purpose: 
100 //=======================================================================
101   void NMTTools_PaveFiller::PerformEF() 
102 {
103   Standard_Boolean bJustAdd;
104   Standard_Integer n1, n2, anIndexIn, nE, nF, aNbEFs, aBlockLength;
105   Standard_Integer aDiscretize;
106   Standard_Real aTolE, aTolF, aDeflection;
107   BooleanOperations_IndexedDataMapOfShapeInteger aMapVI;
108   BOPTools_IDMapOfPaveBlockIMapOfInteger aMapCB;
109   BOPTools_IMapOfPaveBlock aIMPBx;
110   //
111   myIsDone=Standard_False;
112   aDeflection=0.01;
113   aDiscretize=35;
114   //
115   BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
116   //
117   myDSIt->Initialize(TopAbs_EDGE, TopAbs_FACE);
118   //
119   // BlockLength correction
120   aNbEFs=myDSIt->BlockLength();
121   aBlockLength=aEFs.BlockLength();
122   if (aNbEFs > aBlockLength) {
123     aEFs.SetBlockLength(aNbEFs);
124   }
125   //
126   for (; myDSIt->More(); myDSIt->Next()) {
127     myDSIt->Current(n1, n2, bJustAdd);
128     //
129     if(bJustAdd) {
130       continue;
131     }
132     //
133     anIndexIn = 0;
134     //
135     nE=n1; 
136     nF=n2;
137     if (myDS->GetShapeType(n2)==TopAbs_EDGE) {
138       nE=n2; 
139       nF=n1;
140     }
141     //
142     // all Common Blocks for face nF
143     NMTTools_ListOfCommonBlock aLCBF;
144     CommonBlocksFace(nF, aLCBF);
145     NMTTools_CommonBlockAPI aCBAPIF(aLCBF);
146     //
147     // Edge
148     const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));
149     if (BRep_Tool::Degenerated(aE)){
150       continue;
151     }
152     //
153     // Face
154     const TopoDS_Face aF=TopoDS::Face(myDS->Shape(nF));
155     //
156     TopTools_IndexedMapOfShape aME;
157     TopExp::MapShapes(aF, TopAbs_EDGE, aME);
158     if (aME.Contains(aE)) {
159       continue;
160     }
161     //
162     aTolF=BRep_Tool::Tolerance(aF);
163     aTolE=BRep_Tool::Tolerance(aE);
164     
165     const Bnd_Box& aBBF=myDS->GetBoundingBox(nF); 
166     //
167     // Process each PaveBlock on edge nE
168     BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
169     //
170     BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
171     for (; anIt.More(); anIt.Next()) {
172       BOPTools_PaveBlock& aPB=anIt.Value();
173       if (aCBAPIF.IsCommonBlock(aPB)) {
174         continue;
175       }
176       //
177       const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange();
178       const IntTools_Range& aSR =aShrunkRange.ShrunkRange();
179       const Bnd_Box& aBBE=aShrunkRange.BndBox();
180       //
181       if (aBBF.IsOut (aBBE)) {
182         continue;
183       }
184       // 
185       // EF
186       IntTools_EdgeFace aEF;
187       aEF.SetEdge (aE);
188       aEF.SetFace (aF);
189       aEF.SetTolE (aTolE);
190       aEF.SetTolF (aTolF);
191       aEF.SetDiscretize (aDiscretize);
192       aEF.SetDeflection (aDeflection);
193       // 
194       aEF.SetContext((IntTools_PContext)&myContext);
195       // 
196       IntTools_Range anewSR = aSR;
197       // 
198       // Correction of the Shrunk Range 
199       BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR);
200       aEF.SetRange (anewSR);
201       //
202       aEF.Perform();
203       //
204       if (aEF.IsDone()) {
205         Standard_Boolean bCoinsideFlag;
206         Standard_Integer i, aNbCPrts;
207         TopAbs_ShapeEnum aType;
208         //
209         const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts();
210         //
211         aNbCPrts=aCPrts.Length();
212         for (i=1; i<=aNbCPrts; ++i) {
213           anIndexIn=0;
214           //
215           const IntTools_CommonPrt& aCPart=aCPrts(i);
216           aType=aCPart.Type();
217           //
218           switch (aType) {
219             //
220             case TopAbs_VERTEX:  {
221               Standard_Boolean bIsOnPave1, bIsOnPave2;
222               Standard_Integer nVF;
223               Standard_Real aT, aTolToDecide; 
224               TopoDS_Vertex aNewVertex;
225               //
226               const IntTools_Range& aR=aCPart.Range1();
227               //
228               // New Vertex
229               VertexParameter(aCPart, aT);
230               BOPTools_Tools::MakeNewVertex(aE, aT, aF, aNewVertex);
231               //
232               //decide to add pave or not
233               aTolToDecide=5.e-8;
234               bIsOnPave1=IsOnPave(anewSR.First(), aR, aTolToDecide); 
235               bIsOnPave2=IsOnPave(anewSR.Last() , aR, aTolToDecide); 
236               //
237               if (!bIsOnPave1 && !bIsOnPave2) {
238                 nVF=CheckFacePaves(aNewVertex, nF);
239                 if (!nVF) {
240                   // really new vertex
241                   // Add Interference to the Pool
242                   BOPTools_ESInterference anInterf (nE, nF, aCPart);
243                   anIndexIn=aEFs.Append(anInterf);
244                   anInterf.SetNewShape(0);
245                   //
246                   aMapVI.Add(aNewVertex, anIndexIn);
247                   aIMPBx.Add(aPB);
248                   //
249                   myIP->Add(nE, nF, Standard_True, NMTDS_TI_EF);
250                   //
251                 }// if (!nVF)
252               }// if (!bIsOnPave1 && !bIsOnPave2) 
253               //
254               //modified by NIZNHY-PKV Fri Apr 18 10:55:38 2008f
255               else {
256                 const BOPTools_Pave& aPave=(bIsOnPave1)? aPB.Pave1() : aPB.Pave2();
257                 nVF=aPave.Index();
258                 const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF));
259                 BOPTools_Tools::UpdateVertex (aVF, aNewVertex);
260               }
261               //modified by NIZNHY-PKV Fri Apr 18 10:55:40 2008t
262               //
263             }// case TopAbs_VERTEX:
264               break;
265             //
266             case TopAbs_EDGE: {
267               bCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext);
268               if (!bCoinsideFlag) {
269                 break;
270               }
271               //
272               // Fill aMapCB
273               if (aMapCB.Contains(aPB)) {
274                 TColStd_IndexedMapOfInteger& aMapF=aMapCB.ChangeFromKey(aPB);
275                 aMapF.Add(nF);
276               }
277               else {
278                 TColStd_IndexedMapOfInteger aMapF;
279                 aMapF.Add(nF);
280                 aMapCB.Add(aPB, aMapF);
281               }
282               //
283               aIMPBx.Add(aPB);
284               myIP->Add(nE, nF, Standard_True, NMTDS_TI_EF);
285             }// case TopAbs_EDGE:
286               break;
287
288             default:
289               break;
290           } // switch (aType) 
291         } // for (i=1; i<=aNbCPrts; i++) 
292       } //if (aEF.IsDone())
293     } // for (; anIt.More(); anIt.Next()) 
294   }// for (; myDSIt.More(); myDSIt.Next()) 
295   //
296   // Treat New vertices
297   EFNewVertices(aMapVI);
298   //
299   // Add draft Common Blocks of EF type 
300   EFCommonBlocks(aMapCB);
301   //
302   // Collect all CB we suspected to split by new vertices
303   NMTTools_ListOfCommonBlock aLCBx;
304   {
305     Standard_Integer i, aNbPBx, nEx;
306     BOPTools_IMapOfPaveBlock aMx;
307     //
308     aNbPBx=aIMPBx.Extent();
309     for (i=1; i<=aNbPBx; ++i) {
310       const BOPTools_PaveBlock& aPBx=aIMPBx(i);
311       nEx=aPBx.OriginalEdge();
312       NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nEx));
313       if (aLCB.Extent()) {
314         NMTTools_CommonBlockAPI aCBAPIx(aLCB);
315         if (aCBAPIx.IsCommonBlock(aPBx)) {
316           NMTTools_CommonBlock& aCBx=aCBAPIx.CommonBlock(aPBx);
317           const BOPTools_PaveBlock& aPB1=aCBx.PaveBlock1();
318           if (!aMx.Contains(aPB1)){
319             aMx.Add(aPB1);
320             aLCBx.Append(aCBx);
321           }
322         }
323       }
324     }
325   }
326   //
327   // Split the common blocks above
328   if (aLCBx.Extent()) {
329     ReplaceCommonBlocks(aLCBx);
330   }
331   //
332   myIsDone=Standard_True;
333 }
334 //=======================================================================
335 // function:EFCommonBlocks
336 // purpose: 
337 //=======================================================================
338   void NMTTools_PaveFiller::EFCommonBlocks
339     (const BOPTools_IDMapOfPaveBlockIMapOfInteger& aMapCB)
340 {
341   Standard_Integer i, aNbPB, nE, j, aNbF, nF;
342   //
343   aNbPB=aMapCB.Extent();
344   for (i=1; i<=aNbPB; ++i) {
345     const BOPTools_PaveBlock& aPB=aMapCB.FindKey(i);
346     const TColStd_IndexedMapOfInteger& aMapF=aMapCB.FindFromIndex(i);
347     aNbF=aMapF.Extent();
348     //
349     nE=aPB.OriginalEdge();
350     //
351     NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE));
352     //
353     NMTTools_CommonBlockAPI aCBAPI(aLCB);
354     if (aCBAPI.IsCommonBlock(aPB)) {
355       NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
356       for (j=1; j<=aNbF; ++j) {
357         nF=aMapF(j);
358         aCB.AddFace(nF);
359       }
360     }
361     else {
362       NMTTools_CommonBlock aCB;
363       //
364       aCB.AddPaveBlock(aPB);
365       for (j=1; j<=aNbF; ++j) {
366         nF=aMapF(j);
367         aCB.AddFace(nF);
368       }
369       aLCB.Append(aCB);
370     }
371   }
372 }
373 //=======================================================================
374 // function:EFNewVertices
375 // purpose: 
376 //=======================================================================
377   void NMTTools_PaveFiller::EFNewVertices 
378     (const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) 
379 {
380   Standard_Integer i, j, aNb, aNewShape, aFlag, iX, aNbVV, aNbSimple;
381   Standard_Integer aWhat, aWith, nE, nF, nV, aNbIEF, aNbEdges, iTmp;
382   Standard_Real aT;
383   TopoDS_Compound aCompound;
384   TopoDS_Vertex aNewVertex;
385   BRep_Builder aBB;
386   BOPTools_Pave aPave;
387   NMTTools_IndexedDataMapOfIndexedMapOfInteger aMNVE, aMNVIEF;
388   BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
389   TopTools_IndexedMapOfShape aMNVComplex, aMNVSimple;
390   //
391   aNb=aMapVI.Extent();
392   if (!aNb) { // no new vertices, no new problems 
393     return;
394   }
395   //
396   BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
397   //
398   // 0.
399   if (aNb==1) {
400     aNewVertex=TopoDS::Vertex(aMapVI.FindKey(1));
401     EFNewVertices(aNewVertex, aMapVI);
402     return;
403   }
404   //
405   // 1. Make compound from new vertices
406   aBB.MakeCompound(aCompound);
407   for (i=1; i<=aNb; ++i) {
408     const TopoDS_Shape& aV=aMapVI.FindKey(i);
409     aBB.Add(aCompound, aV);
410   }
411   //
412   // 2. VV intersection between these vertices 
413   //       using the auxiliary Filler
414   NMTTools_PaveFiller tPF;
415   //
416   tPF.SetCompositeShape(aCompound);
417   //
418   tPF.Init();
419   tPF.PerformVV();
420   //
421   NMTDS_ShapesDataStructure& tDS=*(tPF.DS());
422   NMTDS_InterfPool& tInterfPool=*(tPF.IP());
423   BOPTools_CArray1OfVVInterference& aVVInterfs=tInterfPool.VVInterferences();
424   //
425   // 3. Separate Comlex and Simple new vertices
426   aNbVV=aVVInterfs.Extent();
427    for (i=1; i<=aNbVV; ++i) {
428     const BOPTools_VVInterference& aVV=aVVInterfs(i);
429     aVV.Indices(aWhat, aWith);
430     const TopoDS_Shape& aV1=tDS.Shape(aWhat);
431     const TopoDS_Shape& aV2=tDS.Shape(aWith);
432     aMNVComplex.Add(aV1);
433     aMNVComplex.Add(aV2);
434   }
435   //
436   for (i=1; i<=aNb; ++i) {
437     const TopoDS_Shape& aV=aMapVI.FindKey(i);
438     if (!aMNVComplex.Contains(aV)) {
439       aMNVSimple.Add(aV);
440     }
441   }
442   //
443   // 4. Treat Simple new Vertices
444   aNbSimple=aMNVSimple.Extent();
445   for (i=1; i<=aNbSimple; ++i) {
446     const TopoDS_Vertex& aV=TopoDS::Vertex(aMNVSimple(i));
447     EFNewVertices(aV, aMapVI);
448   }
449   //
450   // 3. Fill Maps : NewVertex-edges (aMNVE) 
451   //                NewVertex-interferences (aMNVIEE)
452   aNb=aVVInterfs.Extent();
453   for (i=1; i<=aNb; ++i) {
454     const BOPTools_VVInterference& aVV=aVVInterfs(i);
455     aNewShape=aVV.NewShape();
456     if (!aNewShape) {
457       continue;
458     }
459     //
460     if (!aMNVE.Contains(aNewShape)) {
461       TColStd_IndexedMapOfInteger aMx;
462       aMNVE.Add(aNewShape, aMx);
463     }
464     if (!aMNVIEF.Contains(aNewShape)) {
465       TColStd_IndexedMapOfInteger aMx;
466       aMNVIEF.Add(aNewShape, aMx);
467     }
468     //
469     TColStd_IndexedMapOfInteger& aME=aMNVE.ChangeFromKey(aNewShape);
470     TColStd_IndexedMapOfInteger& aMIEF=aMNVIEF.ChangeFromKey(aNewShape);
471     //
472     aVV.Indices(aWhat, aWith);
473     //aWhat
474     const TopoDS_Shape& aV1=tDS.Shape(aWhat);
475     iX=aMapVI.FindFromKey(aV1);
476     const BOPTools_ESInterference& aEF1=aEFs(iX);
477     aEF1.Indices(nE, nF);
478     //
479     if (myDS->GetShapeType(nF)==TopAbs_EDGE) {
480       iTmp=nE;
481       nE=nF;
482       nF=iTmp;
483     }
484     aME.Add(nE);
485     aMIEF.Add(iX);
486     //aWith
487     const TopoDS_Shape& aV2=tDS.Shape(aWith);
488     iX=aMapVI.FindFromKey(aV2);
489     const BOPTools_ESInterference& aEF2=aEFs(iX);
490     aEF2.Indices(nE, nF);
491     //
492     if (myDS->GetShapeType(nF)==TopAbs_EDGE) {
493       iTmp=nE;
494       nE=nF;
495       nF=iTmp;
496     }
497     aME.Add(nE);
498     aMIEF.Add(iX);
499   }// for (i=1; i<=aNb; ++i) {
500   //
501   // 4. Process new vertices
502   aNb=aMNVE.Extent();
503   for (i=1; i<=aNb; ++i) { // xx
504     //
505     //  new Vertex
506     nV=aMNVE.FindKey(i);
507     aNewVertex=TopoDS::Vertex(tDS.Shape(nV));
508     //
509     // Insert New Vertex in DS;
510     myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
511     aNewShape=myDS->NumberOfInsertedShapes();
512     myDS->SetState (aNewShape, BooleanOperations_ON);
513     //
514     // Update index of NewShape in EF interferences
515     const TColStd_IndexedMapOfInteger& aMIEF=aMNVIEF.FindFromKey(nV);
516     aNbIEF=aMIEF.Extent();
517     for (j=1; j<=aNbIEF; ++j) {
518       iX=aMIEF(j);
519       BOPTools_ESInterference& aEF=aEFs(iX);
520       aEF.SetNewShape(aNewShape);
521     }
522     // 
523     // Update Paves on all edges 
524     const TColStd_IndexedMapOfInteger& aME=aMNVE(i);
525     aNbEdges=aME.Extent();
526     for (j=1; j<=aNbEdges; ++j) {
527       nE=aME(j);
528       const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));//mpv
529       //
530       aFlag=myContext.ComputeVE (aNewVertex, aE, aT);
531       //
532       if (!aFlag) {
533         aPave.SetInterference(-1);
534         aPave.SetType (BooleanOperations_EdgeSurface);
535         aPave.SetIndex(aNewShape);
536         aPave.SetParam(aT);
537         //
538         BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
539         aPaveSet.Append(aPave);
540       }
541     }
542   }
543 }
544 //=======================================================================
545 // function:EFNewVertices
546 // purpose: 
547 //=======================================================================
548   void NMTTools_PaveFiller::EFNewVertices 
549     (const TopoDS_Vertex& aNewVertex,
550      const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) 
551 {
552   Standard_Integer i, aNewShape, nE, nF;
553   Standard_Real aT;
554   BOPTools_Pave aPave;
555   BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
556   //
557   BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
558   //
559   // Insert New Vertex in DS;
560   myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
561   aNewShape=myDS->NumberOfInsertedShapes();
562   myDS->SetState (aNewShape, BooleanOperations_ON);
563   //
564   // Insert New Vertex in EFInterference
565   i=aMapVI.FindFromKey(aNewVertex);
566   BOPTools_ESInterference& aEFInterf= aEFs(i);
567   aEFInterf.SetNewShape(aNewShape);
568   // Extract interference info
569   aEFInterf.Indices(nE, nF);
570   if (myDS->GetShapeType(nF)==TopAbs_EDGE) {
571     nE=nF;
572   }
573   const IntTools_CommonPrt& aCPart=aEFInterf.CommonPrt();
574   VertexParameter(aCPart, aT);
575   //
576   // Pave for edge nE
577   aPave.SetInterference(i);
578   aPave.SetType (BooleanOperations_EdgeSurface);
579   aPave.SetIndex(aNewShape);
580   aPave.SetParam(aT);
581   // Append the Pave to the myPavePoolNew
582   BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
583   aPaveSet.Append(aPave);
584   //
585 }
586 //=======================================================================
587 // function: CheckFacePaves
588 // purpose: 
589 //=======================================================================
590   Standard_Integer NMTTools_PaveFiller::CheckFacePaves 
591     (const TopoDS_Vertex& aNewVertex,
592      const Standard_Integer nF)
593 {
594   Standard_Integer nEF, nVF, iFlag, i, aNbV, iRet;
595   BOPTools_ListIteratorOfListOfPave anIt;
596   TColStd_IndexedMapOfInteger aMVF;
597   //
598   iRet=0; 
599   //
600   BooleanOperations_OnceExplorer aExp(*myDS);
601   aExp.Init(nF, TopAbs_EDGE);
602   for (; aExp.More(); aExp.Next()) {
603     nEF=aExp.Current();
604     BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(nEF));
605     const BOPTools_ListOfPave& aLP=aPaveSet.Set();
606     anIt.Initialize(aLP);
607     for (; anIt.More(); anIt.Next()) {
608       const BOPTools_Pave& aPave=anIt.Value();
609       nVF=aPave.Index();
610       aMVF.Add(nVF);
611     }
612   }
613   //
614   aNbV=aMVF.Extent();
615   for (i=1; i<=aNbV; ++i) {
616     nVF=aMVF(i);
617     const TopoDS_Vertex aVF=TopoDS::Vertex(myDS->Shape(nVF));
618     iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF);
619     if (!iFlag) {
620       return nVF;
621     }
622   }
623   return iRet;
624 }
625 //
626 //=======================================================================
627 // function: VertexParameter
628 // purpose: 
629 //=======================================================================
630 void VertexParameter(const IntTools_CommonPrt& aCPart,
631                      Standard_Real& aT)
632 {
633   const IntTools_Range& aR=aCPart.Range1();
634   aT=0.5*(aR.First()+aR.Last());
635   if((aCPart.VertexParameter1() >= aR.First()) &&
636      (aCPart.VertexParameter1() <= aR.Last())) {
637     aT = aCPart.VertexParameter1();
638   }
639 }
640 //=======================================================================
641 // function: IsOnPave
642 // purpose: 
643 //=======================================================================
644 Standard_Boolean IsOnPave(const Standard_Real& aTR,
645                           const IntTools_Range& aCPRange,
646                           const Standard_Real& aTolerance)
647 {
648   Standard_Boolean bIsOnPave;
649   Standard_Real aT1, aT2, dT1, dT2;
650   //
651   aT1=aCPRange.First();
652   aT2=aCPRange.Last();
653   bIsOnPave=(aTR>=aT1 && aTR<=aT1);
654   if (bIsOnPave) {
655     return bIsOnPave;
656   }
657   //
658   dT1=Abs(aTR-aT1);  
659   dT2=Abs(aTR-aT2);
660   bIsOnPave=(dT1<=aTolerance || dT2<=aTolerance);
661   return bIsOnPave;
662 }