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