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