]> SALOME platform Git repositories - modules/geom.git/blob - src/NMTTools/NMTTools_PaveFiller_5.cxx
Salome HOME
Added help page and revert some changes for a better ergonomy
[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 <Basics_OCCTVersion.hxx>
31
32 #include <TColStd_IndexedMapOfInteger.hxx>
33
34 #include <BRep_Tool.hxx>
35 #include <BRep_Builder.hxx>
36
37 #include <Bnd_Box.hxx>
38
39 #include <TopAbs_ShapeEnum.hxx>
40
41 #include <TopoDS.hxx>
42 #include <TopoDS_Face.hxx>
43 #include <TopoDS_Edge.hxx>
44 #include <TopoDS_Vertex.hxx>
45 #include <TopoDS_Compound.hxx>
46
47 #include <TopExp.hxx>
48
49 #include <TopTools_IndexedMapOfShape.hxx>
50
51 #include <IntTools_ShrunkRange.hxx>
52 #include <IntTools_Range.hxx>
53 #include <IntTools_EdgeFace.hxx>
54 #if OCC_VERSION_LARGE <= 0x06050200
55 #include <IntTools_PContext.hxx>
56 #endif
57 #include <IntTools_SequenceOfCommonPrts.hxx>
58 #include <IntTools_CommonPrt.hxx>
59 #include <IntTools_Tools.hxx>
60
61 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
62 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
63 #include <BooleanOperations_OnceExplorer.hxx>
64
65 #include <BOPTools_Tools.hxx>
66 #include <BOPTools_Pave.hxx>
67 #include <BOPTools_PaveSet.hxx>
68 #include <BOPTools_ListOfPave.hxx>
69 #include <BOPTools_ListIteratorOfListOfPave.hxx>
70 #include <BOPTools_PaveBlock.hxx>
71 #include <BOPTools_ListOfPaveBlock.hxx>
72 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
73 #include <BOPTools_ESInterference.hxx>
74
75 #include <BOPTools_CArray1OfVVInterference.hxx>
76 #include <BOPTools_CArray1OfESInterference.hxx>
77 #include <BOPTools_VVInterference.hxx>
78 #include <BOPTools_ESInterference.hxx>
79 #include <BOPTools_IDMapOfPaveBlockIMapOfInteger.hxx>
80 #include <BOPTools_IMapOfPaveBlock.hxx>
81
82 #include <NMTDS_ShapesDataStructure.hxx>
83 #include <NMTDS_Iterator.hxx>
84 #include <NMTDS_InterfPool.hxx>
85
86 #include <NMTTools_ListOfCommonBlock.hxx>
87 #include <NMTTools_CommonBlockAPI.hxx>
88 #include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
89 #include <NMTTools_CommonBlockAPI.hxx>
90 #include <NMTTools_ListOfCommonBlock.hxx>
91
92
93 static
94   void VertexParameter(const IntTools_CommonPrt& aCPart,
95                        Standard_Real& aT);
96 static
97   Standard_Boolean IsOnPave(const Standard_Real& aTR,
98                             const IntTools_Range& aCPRange,
99                             const Standard_Real& aTolerance);
100 //
101 //=======================================================================
102 // function: PerformEF
103 // purpose: 
104 //=======================================================================
105   void NMTTools_PaveFiller::PerformEF() 
106 {
107   Standard_Boolean bJustAdd;
108   Standard_Integer n1, n2, anIndexIn, nE, nF, aNbEFs, aBlockLength;
109   Standard_Integer aDiscretize;
110   Standard_Real aTolE, aTolF, aDeflection;
111   BooleanOperations_IndexedDataMapOfShapeInteger aMapVI;
112   BOPTools_IDMapOfPaveBlockIMapOfInteger aMapCB;
113   BOPTools_IMapOfPaveBlock aIMPBx;
114   //
115   myIsDone=Standard_False;
116   aDeflection=0.01;
117   aDiscretize=35;
118   //
119   BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
120   //
121   myDSIt->Initialize(TopAbs_EDGE, TopAbs_FACE);
122   //
123   // BlockLength correction
124   aNbEFs=myDSIt->BlockLength();
125   aBlockLength=aEFs.BlockLength();
126   if (aNbEFs > aBlockLength) {
127     aEFs.SetBlockLength(aNbEFs);
128   }
129   //
130   for (; myDSIt->More(); myDSIt->Next()) {
131     myDSIt->Current(n1, n2, bJustAdd);
132     //
133     if(bJustAdd) {
134       continue;
135     }
136     //
137     anIndexIn = 0;
138     //
139     nE=n1; 
140     nF=n2;
141     if (myDS->GetShapeType(n2)==TopAbs_EDGE) {
142       nE=n2; 
143       nF=n1;
144     }
145     //
146     // all Common Blocks for face nF
147     NMTTools_ListOfCommonBlock aLCBF;
148     CommonBlocksFace(nF, aLCBF);
149     NMTTools_CommonBlockAPI aCBAPIF(aLCBF);
150     //
151     // Edge
152     const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));
153     if (BRep_Tool::Degenerated(aE)){
154       continue;
155     }
156     //
157     // Face
158     const TopoDS_Face aF=TopoDS::Face(myDS->Shape(nF));
159     //
160     TopTools_IndexedMapOfShape aME;
161     TopExp::MapShapes(aF, TopAbs_EDGE, aME);
162     if (aME.Contains(aE)) {
163       continue;
164     }
165     //
166     aTolF=BRep_Tool::Tolerance(aF);
167     aTolE=BRep_Tool::Tolerance(aE);
168     
169     const Bnd_Box& aBBF=myDS->GetBoundingBox(nF); 
170     //
171     // Process each PaveBlock on edge nE
172     BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
173     //
174     BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
175     for (; anIt.More(); anIt.Next()) {
176       BOPTools_PaveBlock& aPB=anIt.Value();
177       if (aCBAPIF.IsCommonBlock(aPB)) {
178         continue;
179       }
180       //
181       const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange();
182       const IntTools_Range& aSR =aShrunkRange.ShrunkRange();
183       const Bnd_Box& aBBE=aShrunkRange.BndBox();
184       //
185       if (aBBF.IsOut (aBBE)) {
186         continue;
187       }
188       // 
189       // EF
190       IntTools_EdgeFace aEF;
191       aEF.SetEdge (aE);
192       aEF.SetFace (aF);
193       aEF.SetTolE (aTolE);
194       aEF.SetTolF (aTolF);
195       aEF.SetDiscretize (aDiscretize);
196       aEF.SetDeflection (aDeflection);
197       // 
198 #if OCC_VERSION_LARGE > 0x06050200
199       aEF.SetContext(myContext);
200 #else
201       aEF.SetContext((IntTools_PContext)&myContext);
202 #endif
203       // 
204       IntTools_Range anewSR = aSR;
205       // 
206       // Correction of the Shrunk Range 
207       BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR);
208       aEF.SetRange (anewSR);
209       //
210       aEF.Perform();
211       //
212       if (aEF.IsDone()) {
213         Standard_Boolean bCoinsideFlag;
214         Standard_Integer i, aNbCPrts;
215         TopAbs_ShapeEnum aType;
216         //
217         const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts();
218         //
219         aNbCPrts=aCPrts.Length();
220         for (i=1; i<=aNbCPrts; ++i) {
221           anIndexIn=0;
222           //
223           const IntTools_CommonPrt& aCPart=aCPrts(i);
224           aType=aCPart.Type();
225           //
226           switch (aType) {
227             //
228             case TopAbs_VERTEX:  {
229               Standard_Boolean bIsOnPave1, bIsOnPave2;
230               Standard_Integer nVF;
231               Standard_Real aT, aTolToDecide; 
232               TopoDS_Vertex aNewVertex;
233               //
234               const IntTools_Range& aR=aCPart.Range1();
235               //
236               // New Vertex
237               VertexParameter(aCPart, aT);
238               BOPTools_Tools::MakeNewVertex(aE, aT, aF, aNewVertex);
239               //
240               //decide to add pave or not
241               aTolToDecide=5.e-8;
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                   //
257                   myIP->Add(nE, nF, Standard_True, NMTDS_TI_EF);
258                   //
259                 }// if (!nVF)
260               }// if (!bIsOnPave1 && !bIsOnPave2) 
261               //
262               //modified by NIZNHY-PKV Fri Apr 18 10:55:38 2008f
263               else {
264                 const BOPTools_Pave& aPave=(bIsOnPave1)? aPB.Pave1() : aPB.Pave2();
265                 nVF=aPave.Index();
266                 const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF));
267                 BOPTools_Tools::UpdateVertex (aVF, aNewVertex);
268               }
269               //modified by NIZNHY-PKV Fri Apr 18 10:55:40 2008t
270               //
271             }// case TopAbs_VERTEX:
272               break;
273             //
274             case TopAbs_EDGE: {
275               bCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext);
276               if (!bCoinsideFlag) {
277                 break;
278               }
279               //
280               // Fill aMapCB
281               if (aMapCB.Contains(aPB)) {
282                 TColStd_IndexedMapOfInteger& aMapF=aMapCB.ChangeFromKey(aPB);
283                 aMapF.Add(nF);
284               }
285               else {
286                 TColStd_IndexedMapOfInteger aMapF;
287                 aMapF.Add(nF);
288                 aMapCB.Add(aPB, aMapF);
289               }
290               //
291               aIMPBx.Add(aPB);
292               myIP->Add(nE, nF, Standard_True, NMTDS_TI_EF);
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
347     (const BOPTools_IDMapOfPaveBlockIMapOfInteger& aMapCB)
348 {
349   Standard_Integer i, aNbPB, nE, j, aNbF, nF;
350   //
351   aNbPB=aMapCB.Extent();
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 
386     (const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) 
387 {
388   Standard_Integer i, j, aNb, aNewShape, aFlag, iX, aNbVV, aNbSimple;
389   Standard_Integer aWhat, aWith, nE, nF, nV, aNbIEF, aNbEdges, iTmp;
390   Standard_Real aT;
391   TopoDS_Compound aCompound;
392   TopoDS_Vertex aNewVertex;
393   BRep_Builder aBB;
394   BOPTools_Pave aPave;
395   NMTTools_IndexedDataMapOfIndexedMapOfInteger aMNVE, aMNVIEF;
396   BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
397   TopTools_IndexedMapOfShape aMNVComplex, aMNVSimple;
398   //
399   aNb=aMapVI.Extent();
400   if (!aNb) { // no new vertices, no new problems 
401     return;
402   }
403   //
404   BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
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   //
429   NMTDS_ShapesDataStructure& tDS=*(tPF.DS());
430   NMTDS_InterfPool& tInterfPool=*(tPF.IP());
431   BOPTools_CArray1OfVVInterference& aVVInterfs=tInterfPool.VVInterferences();
432   //
433   // 3. Separate Comlex and Simple new vertices
434   aNbVV=aVVInterfs.Extent();
435    for (i=1; i<=aNbVV; ++i) {
436     const BOPTools_VVInterference& aVV=aVVInterfs(i);
437     aVV.Indices(aWhat, aWith);
438     const TopoDS_Shape& aV1=tDS.Shape(aWhat);
439     const TopoDS_Shape& aV2=tDS.Shape(aWith);
440     aMNVComplex.Add(aV1);
441     aMNVComplex.Add(aV2);
442   }
443   //
444   for (i=1; i<=aNb; ++i) {
445     const TopoDS_Shape& aV=aMapVI.FindKey(i);
446     if (!aMNVComplex.Contains(aV)) {
447       aMNVSimple.Add(aV);
448     }
449   }
450   //
451   // 4. Treat Simple new Vertices
452   aNbSimple=aMNVSimple.Extent();
453   for (i=1; i<=aNbSimple; ++i) {
454     const TopoDS_Vertex& aV=TopoDS::Vertex(aMNVSimple(i));
455     EFNewVertices(aV, aMapVI);
456   }
457   //
458   // 3. Fill Maps : NewVertex-edges (aMNVE) 
459   //                NewVertex-interferences (aMNVIEE)
460   aNb=aVVInterfs.Extent();
461   for (i=1; i<=aNb; ++i) {
462     const BOPTools_VVInterference& aVV=aVVInterfs(i);
463     aNewShape=aVV.NewShape();
464     if (!aNewShape) {
465       continue;
466     }
467     //
468     if (!aMNVE.Contains(aNewShape)) {
469       TColStd_IndexedMapOfInteger aMx;
470       aMNVE.Add(aNewShape, aMx);
471     }
472     if (!aMNVIEF.Contains(aNewShape)) {
473       TColStd_IndexedMapOfInteger aMx;
474       aMNVIEF.Add(aNewShape, aMx);
475     }
476     //
477     TColStd_IndexedMapOfInteger& aME=aMNVE.ChangeFromKey(aNewShape);
478     TColStd_IndexedMapOfInteger& aMIEF=aMNVIEF.ChangeFromKey(aNewShape);
479     //
480     aVV.Indices(aWhat, aWith);
481     //aWhat
482     const TopoDS_Shape& aV1=tDS.Shape(aWhat);
483     iX=aMapVI.FindFromKey(aV1);
484     const BOPTools_ESInterference& aEF1=aEFs(iX);
485     aEF1.Indices(nE, nF);
486     //
487     if (myDS->GetShapeType(nF)==TopAbs_EDGE) {
488       iTmp=nE;
489       nE=nF;
490       nF=iTmp;
491     }
492     aME.Add(nE);
493     aMIEF.Add(iX);
494     //aWith
495     const TopoDS_Shape& aV2=tDS.Shape(aWith);
496     iX=aMapVI.FindFromKey(aV2);
497     const BOPTools_ESInterference& aEF2=aEFs(iX);
498     aEF2.Indices(nE, nF);
499     //
500     if (myDS->GetShapeType(nF)==TopAbs_EDGE) {
501       iTmp=nE;
502       nE=nF;
503       nF=iTmp;
504     }
505     aME.Add(nE);
506     aMIEF.Add(iX);
507   }// for (i=1; i<=aNb; ++i) {
508   //
509   // 4. Process new vertices
510   aNb=aMNVE.Extent();
511   for (i=1; i<=aNb; ++i) { // xx
512     //
513     //  new Vertex
514     nV=aMNVE.FindKey(i);
515     aNewVertex=TopoDS::Vertex(tDS.Shape(nV));
516     //
517     // Insert New Vertex in DS;
518     myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
519     aNewShape=myDS->NumberOfInsertedShapes();
520     myDS->SetState (aNewShape, BooleanOperations_ON);
521     //
522     // Update index of NewShape in EF interferences
523     const TColStd_IndexedMapOfInteger& aMIEF=aMNVIEF.FindFromKey(nV);
524     aNbIEF=aMIEF.Extent();
525     for (j=1; j<=aNbIEF; ++j) {
526       iX=aMIEF(j);
527       BOPTools_ESInterference& aEF=aEFs(iX);
528       aEF.SetNewShape(aNewShape);
529     }
530     // 
531     // Update Paves on all edges 
532     const TColStd_IndexedMapOfInteger& aME=aMNVE(i);
533     aNbEdges=aME.Extent();
534     for (j=1; j<=aNbEdges; ++j) {
535       nE=aME(j);
536       const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));//mpv
537       //
538 #if OCC_VERSION_LARGE > 0x06050200
539       aFlag=myContext->ComputeVE (aNewVertex, aE, aT);
540 #else
541       aFlag=myContext.ComputeVE (aNewVertex, aE, aT);
542 #endif
543       //
544       if (!aFlag) {
545         aPave.SetInterference(-1);
546         aPave.SetType (BooleanOperations_EdgeSurface);
547         aPave.SetIndex(aNewShape);
548         aPave.SetParam(aT);
549         //
550         BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
551         aPaveSet.Append(aPave);
552       }
553     }
554   }
555 }
556 //=======================================================================
557 // function:EFNewVertices
558 // purpose: 
559 //=======================================================================
560   void NMTTools_PaveFiller::EFNewVertices 
561     (const TopoDS_Vertex& aNewVertex,
562      const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) 
563 {
564   Standard_Integer i, aNewShape, nE, nF;
565   Standard_Real aT;
566   BOPTools_Pave aPave;
567   BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
568   //
569   BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
570   //
571   // Insert New Vertex in DS;
572   myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
573   aNewShape=myDS->NumberOfInsertedShapes();
574   myDS->SetState (aNewShape, BooleanOperations_ON);
575   //
576   // Insert New Vertex in EFInterference
577   i=aMapVI.FindFromKey(aNewVertex);
578   BOPTools_ESInterference& aEFInterf= aEFs(i);
579   aEFInterf.SetNewShape(aNewShape);
580   // Extract interference info
581   aEFInterf.Indices(nE, nF);
582   if (myDS->GetShapeType(nF)==TopAbs_EDGE) {
583     nE=nF;
584   }
585   const IntTools_CommonPrt& aCPart=aEFInterf.CommonPrt();
586   VertexParameter(aCPart, aT);
587   //
588   // Pave for edge nE
589   aPave.SetInterference(i);
590   aPave.SetType (BooleanOperations_EdgeSurface);
591   aPave.SetIndex(aNewShape);
592   aPave.SetParam(aT);
593   // Append the Pave to the myPavePoolNew
594   BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
595   aPaveSet.Append(aPave);
596   //
597 }
598 //=======================================================================
599 // function: CheckFacePaves
600 // purpose: 
601 //=======================================================================
602   Standard_Integer NMTTools_PaveFiller::CheckFacePaves 
603     (const TopoDS_Vertex& aNewVertex,
604      const Standard_Integer nF)
605 {
606   Standard_Integer nEF, nVF, iFlag, i, aNbV, iRet;
607   BOPTools_ListIteratorOfListOfPave anIt;
608   TColStd_IndexedMapOfInteger aMVF;
609   //
610   iRet=0; 
611   //
612   BooleanOperations_OnceExplorer aExp(*myDS);
613   aExp.Init(nF, TopAbs_EDGE);
614   for (; aExp.More(); aExp.Next()) {
615     nEF=aExp.Current();
616     BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(nEF));
617     const BOPTools_ListOfPave& aLP=aPaveSet.Set();
618     anIt.Initialize(aLP);
619     for (; anIt.More(); anIt.Next()) {
620       const BOPTools_Pave& aPave=anIt.Value();
621       nVF=aPave.Index();
622       aMVF.Add(nVF);
623     }
624   }
625   //
626   aNbV=aMVF.Extent();
627   for (i=1; i<=aNbV; ++i) {
628     nVF=aMVF(i);
629     const TopoDS_Vertex aVF=TopoDS::Vertex(myDS->Shape(nVF));
630     iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF);
631     if (!iFlag) {
632       return nVF;
633     }
634   }
635   return iRet;
636 }
637 //
638 //=======================================================================
639 // function: VertexParameter
640 // purpose: 
641 //=======================================================================
642 void VertexParameter(const IntTools_CommonPrt& aCPart,
643                      Standard_Real& aT)
644 {
645   const IntTools_Range& aR=aCPart.Range1();
646   aT=0.5*(aR.First()+aR.Last());
647   if((aCPart.VertexParameter1() >= aR.First()) &&
648      (aCPart.VertexParameter1() <= aR.Last())) {
649     aT = aCPart.VertexParameter1();
650   }
651 }
652 //=======================================================================
653 // function: IsOnPave
654 // purpose: 
655 //=======================================================================
656 Standard_Boolean IsOnPave(const Standard_Real& aTR,
657                           const IntTools_Range& aCPRange,
658                           const Standard_Real& aTolerance)
659 {
660   Standard_Boolean bIsOnPave;
661   Standard_Real aT1, aT2, dT1, dT2;
662   //
663   aT1=aCPRange.First();
664   aT2=aCPRange.Last();
665   bIsOnPave=(aTR>=aT1 && aTR<=aT1);
666   if (bIsOnPave) {
667     return bIsOnPave;
668   }
669   //
670   dT1=Abs(aTR-aT1);  
671   dT2=Abs(aTR-aT2);
672   bIsOnPave=(dT1<=aTolerance || dT2<=aTolerance);
673   return bIsOnPave;
674 }