Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_BuilderFace.cxx
1 // Copyright (C) 2007-2012  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:        GEOMAlgo_BuilderFace.cxx
24 // Created:
25 // Author:      Peter KURNEV
26 //
27 #include <GEOMAlgo_BuilderFace.hxx>
28
29 #include <gp_Pnt2d.hxx>
30 #include <gp_Pln.hxx>
31 #include <gp_Vec.hxx>
32 #include <gp_Dir.hxx>
33 #include <gp_Pnt.hxx>
34
35 #include <Geom_Surface.hxx>
36
37 #include <TopAbs.hxx>
38 #include <TopLoc_Location.hxx>
39
40 #include <TopoDS_Iterator.hxx>
41 #include <TopoDS_Face.hxx>
42 #include <TopoDS.hxx>
43 #include <TopoDS_Shape.hxx>
44 #include <TopoDS_Wire.hxx>
45 #include <TopoDS_Edge.hxx>
46 #include <TopoDS_Vertex.hxx>
47
48 #include <BRep_Builder.hxx>
49 #include <BRep_Tool.hxx>
50 #include <BRepTools.hxx>
51
52 #include <TopExp.hxx>
53 #include <TopExp_Explorer.hxx>
54
55 #include <TopTools_MapOfShape.hxx>
56 #include <TopTools_MapIteratorOfMapOfShape.hxx>
57 #include <TopTools_MapOfOrientedShape.hxx>
58 #include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
59 #include <TopTools_ListOfShape.hxx>
60 #include <TopTools_ListIteratorOfListOfShape.hxx>
61 #include <TopTools_DataMapOfShapeShape.hxx>
62 #include <TopTools_IndexedMapOfShape.hxx>
63 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
64 #include <TopTools_DataMapOfShapeListOfShape.hxx>
65 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
66
67 #include <IntTools_FClass2d.hxx>
68 #include <IntTools_Context.hxx>
69
70 #include <BOPTools_Tools2D.hxx>
71 #include <BOP_WireEdgeSet.hxx>
72 #include <BOP_WESCorrector.hxx>
73
74 #include <NMTTools_ListOfCoupleOfShape.hxx>
75 #include <NMTTools_CoupleOfShape.hxx>
76 #include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
77
78 #include <GEOMAlgo_Tools3D.hxx>
79 #include <GEOMAlgo_BuilderTools.hxx>
80 #include <GEOMAlgo_WireEdgeSet.hxx>
81 #include <GEOMAlgo_WESCorrector.hxx>
82
83 //
84 static
85   Standard_Boolean IsGrowthWire(const TopoDS_Shape& ,
86
87                                 const TopTools_IndexedMapOfShape& );
88
89 static
90   Standard_Boolean IsInside(const TopoDS_Shape& ,
91                             const TopoDS_Shape& ,
92                             const Handle(IntTools_Context)& );
93 static
94   void MakeInternalWires(const TopTools_MapOfShape& ,
95                          TopTools_ListOfShape& );
96
97 //=======================================================================
98 //function :
99 //purpose  :
100 //=======================================================================
101   GEOMAlgo_BuilderFace::GEOMAlgo_BuilderFace()
102 :
103   GEOMAlgo_BuilderArea()
104 {
105 }
106 //=======================================================================
107 //function : ~
108 //purpose  :
109 //=======================================================================
110   GEOMAlgo_BuilderFace::~GEOMAlgo_BuilderFace()
111 {
112 }
113 //=======================================================================
114 //function : SetFace
115 //purpose  :
116 //=======================================================================
117   void GEOMAlgo_BuilderFace::SetFace(const TopoDS_Face& theFace)
118 {
119   myFace=theFace;
120 }
121 //=======================================================================
122 //function : Face
123 //purpose  :
124 //=======================================================================
125   const TopoDS_Face& GEOMAlgo_BuilderFace::Face()const
126 {
127   return myFace;
128 }
129 //=======================================================================
130 //function : Perform
131 //purpose  :
132 //=======================================================================
133   void GEOMAlgo_BuilderFace::Perform()
134 {
135   myErrorStatus=0;
136   //
137   if (myFace.IsNull()) {
138     myErrorStatus=12;// Null face generix
139     return;
140   }
141   // Initialize the context
142   GEOMAlgo_BuilderArea::Perform();
143   //
144   PerformShapesToAvoid();
145   if (myErrorStatus) {
146     return;
147   }
148   //
149   PerformLoops();
150   if (myErrorStatus) {
151     return;
152   }
153   //
154   PerformAreas();
155   if (myErrorStatus) {
156     return;
157   }
158   //
159   PerformInternalShapes();
160   if (myErrorStatus) {
161     return;
162   }
163 }
164 //=======================================================================
165 //function :PerformShapesToAvoid
166 //purpose  :
167 //=======================================================================
168   void GEOMAlgo_BuilderFace::PerformShapesToAvoid()
169 {
170   Standard_Boolean bFound;
171   Standard_Integer i, iCnt, aNbV, aNbE;
172   TopTools_IndexedDataMapOfShapeListOfShape aMVE;
173   TopTools_ListIteratorOfListOfShape aIt;
174   //
175   myShapesToAvoid.Clear();
176   //
177   iCnt=0;
178   while (1) {
179     ++iCnt;
180     bFound=Standard_False;
181     //
182     // 1. MEF
183     aMVE.Clear();
184     aIt.Initialize (myShapes);
185     for (; aIt.More(); aIt.Next()) {
186       const TopoDS_Shape& aE=aIt.Value();
187       if (!myShapesToAvoid.Contains(aE)) {
188         TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
189       }
190 //       else {
191 //         int a=0;
192 //       }
193     }
194     aNbV=aMVE.Extent();
195     //
196     // 2. myEdgesToAvoid
197     for (i=1; i<=aNbV; ++i) {
198       const TopoDS_Vertex& aV=TopoDS::Vertex(aMVE.FindKey(i));
199       //
200       TopTools_ListOfShape& aLE=aMVE.ChangeFromKey(aV);
201       aNbE=aLE.Extent();
202       if (!aNbE) {
203         continue;
204       }
205       //
206       const TopoDS_Edge& aE1=TopoDS::Edge(aLE.First());
207       if (aNbE==1) {
208         if (BRep_Tool::Degenerated(aE1)) {
209           continue;
210         }
211         if (aV.Orientation()==TopAbs_INTERNAL) {
212           continue;
213         }
214         bFound=Standard_True;
215         myShapesToAvoid.Add(aE1);
216       }
217       else if (aNbE==2) {
218         const TopoDS_Edge& aE2=TopoDS::Edge(aLE.Last());
219         if (aE2.IsSame(aE1)) {
220           TopoDS_Vertex aV1x, aV2x;
221           //
222           TopExp::Vertices(aE1, aV1x, aV2x);
223           if (aV1x.IsSame(aV2x)) {
224             continue;
225           }
226           bFound=Standard_True;
227           myShapesToAvoid.Add(aE1);
228           myShapesToAvoid.Add(aE2);
229         }
230       }
231     }// for (i=1; i<=aNbE; ++i) {
232     //
233     if (!bFound) {
234       break;
235     }
236     //
237   }//while (1)
238   //printf(" EdgesToAvoid=%d, iCnt=%d\n", EdgesToAvoid.Extent(), iCnt);
239 }
240 //=======================================================================
241 //function : PerformLoops
242 //purpose  :
243 //=======================================================================
244   void GEOMAlgo_BuilderFace::PerformLoops()
245 {
246   myErrorStatus=0;
247   //
248   Standard_Boolean bFlag;
249   Standard_Integer aNbEA;
250   TopTools_ListIteratorOfListOfShape aIt;
251   TopTools_MapIteratorOfMapOfOrientedShape aItM;
252   TopTools_IndexedDataMapOfShapeListOfShape aVEMap;
253   TopTools_MapOfOrientedShape aMAdded;
254   TopoDS_Iterator aItW;
255   BRep_Builder aBB;
256   GEOMAlgo_WireEdgeSet aWES;
257   GEOMAlgo_WESCorrector aWESCor;
258   //
259   // 1. Usual Wires
260   myLoops.Clear();
261   aWES.SetFace(myFace);
262   //
263   aIt.Initialize (myShapes);
264   for (; aIt.More(); aIt.Next()) {
265     const TopoDS_Shape& aE=aIt.Value();
266     if (!myShapesToAvoid.Contains(aE)) {
267       aWES.AddStartElement(aE);
268     }
269   }
270   //
271   aWESCor.SetWES(aWES);
272   aWESCor.Perform();
273   //
274   GEOMAlgo_WireEdgeSet& aWESN=aWESCor.NewWES();
275   const TopTools_ListOfShape& aLW=aWESN.Shapes();
276   //
277   aIt.Initialize (aLW);
278   for (; aIt.More(); aIt.Next()) {
279     const TopoDS_Shape& aW=aIt.Value();
280     myLoops.Append(aW);
281   }
282   //modified by NIZNHY-PKV Tue Aug  5 15:09:29 2008f
283   // Post Treatment
284   TopTools_MapOfOrientedShape aMEP;
285   //
286   // a. collect all edges that are in loops
287   aIt.Initialize (myLoops);
288   for (; aIt.More(); aIt.Next()) {
289     const TopoDS_Shape& aW=aIt.Value();
290     aItW.Initialize(aW);
291     for (; aItW.More(); aItW.Next()) {
292       const TopoDS_Shape& aE=aItW.Value();
293       aMEP.Add(aE);
294     }
295   }
296   //
297   // b. collect all edges that are to avoid
298   aItM.Initialize(myShapesToAvoid);
299   for (; aItM.More(); aItM.Next()) {
300     const TopoDS_Shape& aE=aItM.Key();
301     aMEP.Add(aE);
302   }
303   //
304   // c. add all edges that are not processed to myShapesToAvoid
305   aIt.Initialize (myShapes);
306   for (; aIt.More(); aIt.Next()) {
307     const TopoDS_Shape& aE=aIt.Value();
308     if (!aMEP.Contains(aE)) {
309       myShapesToAvoid.Add(aE);
310     }
311   }
312   //modified by NIZNHY-PKV Tue Aug  5 15:09:35 2008t
313   //
314   // 2. Internal Wires
315   myLoopsInternal.Clear();
316   //
317   aNbEA=myShapesToAvoid.Extent();
318   aItM.Initialize(myShapesToAvoid);
319   for (; aItM.More(); aItM.Next()) {
320     const TopoDS_Shape& aEE=aItM.Key();
321     TopExp::MapShapesAndAncestors(aEE, TopAbs_VERTEX, TopAbs_EDGE, aVEMap);
322   }
323   //
324   bFlag=Standard_True;
325   aItM.Initialize(myShapesToAvoid);
326   for (; aItM.More()&&bFlag; aItM.Next()) {
327     const TopoDS_Shape& aEE=aItM.Key();
328     if (!aMAdded.Add(aEE)) {
329       continue;
330     }
331     //
332     // make new wire
333     TopoDS_Wire aW;
334     aBB.MakeWire(aW);
335     aBB.Add(aW, aEE);
336     //
337     aItW.Initialize(aW);
338     for (; aItW.More()&&bFlag; aItW.Next()) {
339       const TopoDS_Edge& aE=TopoDS::Edge(aItW.Value());
340       //
341       TopoDS_Iterator aItE(aE);
342       for (; aItE.More()&&bFlag; aItE.Next()) {
343         const TopoDS_Vertex& aV = TopoDS::Vertex(aItE.Value());
344         const TopTools_ListOfShape& aLE=aVEMap.FindFromKey(aV);
345         aIt.Initialize(aLE);
346         for (; aIt.More()&&bFlag; aIt.Next()) {
347           const TopoDS_Shape& aEx=aIt.Value();
348           if (aMAdded.Add(aEx)) {
349             aBB.Add(aW, aEx);
350             if(aMAdded.Extent()==aNbEA) {
351               bFlag=!bFlag;
352             }
353           }
354         }//for (; aIt.More(); aIt.Next()) {
355       }//for (; aItE.More(); aItE.Next()) {
356     }//for (; aItW.More(); aItW.Next()) {
357     myLoopsInternal.Append(aW);
358   }//for (; aItM.More(); aItM.Next()) {
359 }
360 //=======================================================================
361 //function : PerformAreas
362 //purpose  :
363 //=======================================================================
364   void GEOMAlgo_BuilderFace::PerformAreas()
365 {
366   myErrorStatus=0;
367   //
368   Standard_Boolean bIsGrowth, bIsHole;
369   Standard_Real aTol;
370   TopTools_ListOfShape aNewFaces, aHoleWires;
371   TopoDS_Shape anInfinitePointShape;
372   TopTools_DataMapOfShapeShape aInOutMap;
373   TopTools_DataMapOfShapeListOfShape aMSH;
374   TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH;
375   TopTools_ListIteratorOfListOfShape aIt1, aIt2;
376   TopTools_IndexedMapOfShape aMHE;
377   BRep_Builder aBB;
378   Handle(Geom_Surface) aS;
379   TopLoc_Location aLoc;
380   //
381   aTol=BRep_Tool::Tolerance(myFace);
382   aS=BRep_Tool::Surface(myFace, aLoc);
383   //
384   myAreas.Clear();
385   //
386   //  Draft faces [aNewFaces]
387   aIt1.Initialize(myLoops);
388   for ( ; aIt1.More(); aIt1.Next()) {
389     const TopoDS_Shape& aWire=aIt1.Value();
390     //
391     bIsGrowth=IsGrowthWire(aWire, aMHE);
392     if (bIsGrowth) {
393       // make a growth face from a wire
394       TopoDS_Face aFace;
395       aBB.MakeFace(aFace, aS, aLoc, aTol);
396       aBB.Add (aFace, aWire);
397       //
398       aNewFaces.Append (aFace);
399     }
400     else{
401       // check if a wire is a hole
402       //XX
403       //bIsHole=IsHole(aWire, myFace, myContext);
404       bIsHole=GEOMAlgo_BuilderTools::IsHole(aWire, myFace);
405       //XX
406       if (bIsHole) {
407         aHoleWires.Append(aWire);
408         TopExp::MapShapes(aWire, TopAbs_EDGE, aMHE);
409       }
410       else {
411         // make a growth face from a wire
412         TopoDS_Face aFace;
413         aBB.MakeFace(aFace, aS, aLoc, aTol);
414         aBB.Add (aFace, aWire);
415         //
416         aNewFaces.Append (aFace);
417       }
418     }
419   }
420   //
421   // 2. Find outer growth shell that is most close to each hole shell
422   aIt2.Initialize(aHoleWires);
423   for (; aIt2.More(); aIt2.Next()) {
424     const TopoDS_Shape& aHole = aIt2.Value();
425     //
426     aIt1.Initialize(aNewFaces);
427     for ( ; aIt1.More(); aIt1.Next()) {
428       const TopoDS_Shape& aF=aIt1.Value();
429       //
430       if (!IsInside(aHole, aF, myContext)){
431         continue;
432       }
433       //
434       if ( aInOutMap.IsBound (aHole)){
435         const TopoDS_Shape& aF2=aInOutMap(aHole);
436         if (IsInside(aF, aF2, myContext)) {
437           aInOutMap.UnBind(aHole);
438           aInOutMap.Bind (aHole, aF);
439         }
440       }
441       else{
442         aInOutMap.Bind (aHole, aF);
443       }
444     }
445     //
446     // Add aHole to a map Face/ListOfHoles [aMSH]
447     if (aInOutMap.IsBound(aHole)){
448       const TopoDS_Shape& aF=aInOutMap(aHole);
449       if (aMSH.IsBound(aF)) {
450         TopTools_ListOfShape& aLH=aMSH.ChangeFind(aF);
451         aLH.Append(aHole);
452       }
453       else {
454         TopTools_ListOfShape aLH;
455         aLH.Append(aHole);
456         aMSH.Bind(aF, aLH);
457       }
458     }
459   }// for (; aIt2.More(); aIt2.Next())
460   //
461   // 3. Add aHoles to Faces
462   aItMSH.Initialize(aMSH);
463   for (; aItMSH.More(); aItMSH.Next()) {
464     TopoDS_Face aF=TopoDS::Face(aItMSH.Key());
465     //
466     const TopTools_ListOfShape& aLH=aItMSH.Value();
467     aIt2.Initialize(aLH);
468     for (; aIt2.More(); aIt2.Next()) {
469       const TopoDS_Shape& aHole = aIt2.Value();
470       aBB.Add (aF, aHole);
471     }
472     //
473     // update classifier
474     aTol=BRep_Tool::Tolerance(aF);
475     IntTools_FClass2d& aClsf=myContext->FClass2d(aF);
476     aClsf.Init(aF, aTol);
477   }
478   //
479   // These aNewFaces are draft faces that
480   // do not contain any internal shapes
481   //
482   myAreas.Append(aNewFaces);
483 }
484 //=======================================================================
485 //function : PerformInternalShapes
486 //purpose  :
487 //=======================================================================
488   void GEOMAlgo_BuilderFace::PerformInternalShapes()
489 {
490   myErrorStatus=0;
491   //
492   Standard_Integer aNbWI=myLoopsInternal.Extent();
493   if (!aNbWI) {// nothing to do
494     return;
495   }
496   //
497   //Standard_Real aTol;
498   BRep_Builder aBB;
499   TopTools_ListIteratorOfListOfShape aIt1, aIt2;
500   TopoDS_Iterator aIt;
501   TopTools_MapOfShape aME, aMEP;
502   TopTools_MapIteratorOfMapOfShape aItME;
503   TopTools_IndexedDataMapOfShapeListOfShape aMVE;
504   TopTools_ListOfShape aLSI;
505   //
506   // 1. All internal edges
507   aIt1.Initialize(myLoopsInternal);
508   for (; aIt1.More(); aIt1.Next()) {
509     const TopoDS_Shape& aWire=aIt1.Value();
510     aIt.Initialize(aWire);
511     for (; aIt.More(); aIt.Next()) {
512       const TopoDS_Shape& aE=aIt.Value();
513       aME.Add(aE);
514     }
515   }
516   aNbWI=aME.Extent();
517   //
518   // 2 Process faces
519   aIt2.Initialize(myAreas);
520   for ( ; aIt2.More(); aIt2.Next()) {
521     TopoDS_Face& aF=TopoDS::Face(aIt2.Value());
522     //
523     aMVE.Clear();
524     TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
525     //
526     // 2.1 Separate faces to process aMEP
527     aMEP.Clear();
528     aItME.Initialize(aME);
529     for (; aItME.More(); aItME.Next()) {
530       const TopoDS_Edge& aE=TopoDS::Edge(aItME.Key());
531       if (IsInside(aE, aF, myContext)) {
532         aMEP.Add(aE);
533       }
534     }
535     //
536     // 2.2 Make Internal Wires
537     aLSI.Clear();
538     MakeInternalWires(aMEP, aLSI);
539     //
540     // 2.3 Add them to aF
541     aIt1.Initialize(aLSI);
542     for (; aIt1.More(); aIt1.Next()) {
543       const TopoDS_Shape& aSI=aIt1.Value();
544       aBB.Add (aF, aSI);
545     }
546     //
547     // 2.4 Remove faces aMFP from aMF
548     aItME.Initialize(aMEP);
549     for (; aItME.More(); aItME.Next()) {
550       const TopoDS_Shape& aE=aItME.Key();
551       aME.Remove(aE);
552     }
553     //
554     aNbWI=aME.Extent();
555     if (!aNbWI) {
556       break;
557     }
558   } //for ( ; aIt2.More(); aIt2.Next()) {
559 }
560 //=======================================================================
561 //function : MakeInternalWires
562 //purpose  :
563 //=======================================================================
564 void MakeInternalWires(const TopTools_MapOfShape& theME,
565                        TopTools_ListOfShape& theWires)
566 {
567   TopTools_MapIteratorOfMapOfShape aItM;
568   TopTools_MapOfShape aAddedMap;
569   TopTools_ListIteratorOfListOfShape aItE;
570   TopTools_IndexedDataMapOfShapeListOfShape aMVE;
571   BRep_Builder aBB;
572   //
573   aItM.Initialize(theME);
574   for (; aItM.More(); aItM.Next()) {
575     const TopoDS_Shape& aE=aItM.Key();
576     TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
577   }
578   //
579   aItM.Initialize(theME);
580   for (; aItM.More(); aItM.Next()) {
581     TopoDS_Shape aEE=aItM.Key();
582     if (!aAddedMap.Add(aEE)) {
583       continue;
584     }
585     //
586     // make a new shell
587     TopoDS_Wire aW;
588     aBB.MakeWire(aW);
589     aEE.Orientation(TopAbs_INTERNAL);
590     aBB.Add(aW, aEE);
591     //
592     TopoDS_Iterator aItAdded (aW);
593     for (; aItAdded.More(); aItAdded.Next()) {
594       const TopoDS_Shape& aE =aItAdded.Value();
595       //
596       TopExp_Explorer aExp(aE, TopAbs_VERTEX);
597       for (; aExp.More(); aExp.Next()) {
598         const TopoDS_Shape& aV =aExp.Current();
599         const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV);
600         aItE.Initialize(aLE);
601         for (; aItE.More(); aItE.Next()) {
602           TopoDS_Shape aEL=aItE.Value();
603           if (aAddedMap.Add(aEL)){
604             aEL.Orientation(TopAbs_INTERNAL);
605             aBB.Add(aW, aEL);
606           }
607         }
608       }
609     }
610     theWires.Append(aW);
611   }
612 }
613 //=======================================================================
614 //function : IsInside
615 //purpose  :
616 //=======================================================================
617 Standard_Boolean IsInside(const TopoDS_Shape& theHole,
618                           const TopoDS_Shape& theF2,
619                           const Handle(IntTools_Context)& theContext)
620 {
621   Standard_Boolean bRet;
622   Standard_Real aT, aU, aV;
623
624   TopAbs_State aState;
625   TopExp_Explorer aExp;
626   TopTools_IndexedMapOfShape aME2;
627   gp_Pnt2d aP2D;
628   //
629   bRet=Standard_False;
630   aState=TopAbs_UNKNOWN;
631   const TopoDS_Face& aF2=TopoDS::Face(theF2);
632   //
633   TopExp::MapShapes(aF2, TopAbs_EDGE, aME2);
634   //
635   aExp.Init(theHole, TopAbs_EDGE);
636   if (aExp.More()) {
637     const TopoDS_Edge& aE = TopoDS::Edge(aExp.Current());
638     if (aME2.Contains(aE)) {
639       return bRet;
640     }
641     //
642     aT=BOPTools_Tools2D::IntermediatePoint(aE);
643     BOPTools_Tools2D::PointOnSurface(aE, aF2, aT, aU, aV);
644     aP2D.SetCoord(aU, aV);
645     //
646     IntTools_FClass2d& aClsf=theContext->FClass2d(aF2);
647     aState=aClsf.Perform(aP2D);
648     bRet=(aState==TopAbs_IN);
649   }
650   //
651   return bRet;
652 }
653
654 //=======================================================================
655 //function : IsGrowthWire
656 //purpose  :
657 //=======================================================================
658 Standard_Boolean IsGrowthWire(const TopoDS_Shape& theWire,
659                               const TopTools_IndexedMapOfShape& theMHE)
660 {
661   Standard_Boolean bRet;
662   TopoDS_Iterator aIt;
663   //
664   bRet=Standard_False;
665   if (theMHE.Extent()) {
666     aIt.Initialize(theWire);
667     for(; aIt.More(); aIt.Next()) {
668       const TopoDS_Shape& aE=aIt.Value();
669       if (theMHE.Contains(aE)) {
670         return !bRet;
671       }
672     }
673   }
674   return bRet;
675 }
676
677 //BRepTools::Write(aFF, "ff");
678 //
679 //  ErrorStatus :
680 // 11 - Null Context
681 // 12 - Null face generix
682
683 /*
684 //=======================================================================
685 //function : IsInside
686 //purpose  :
687 //=======================================================================
688 Standard_Boolean IsInside(const TopoDS_Shape& theHole,
689                           const TopoDS_Shape& theF2,
690                           IntTools_PContext& theContext)
691 {
692   Standard_Real aT, aU, aV;
693   TopExp_Explorer aExp;
694   TopAbs_State aState=TopAbs_UNKNOWN;
695   gp_Pnt2d aP2D;
696   //
697   const TopoDS_Face& aF2=TopoDS::Face(theF2);
698   //
699   aExp.Init(theHole, TopAbs_EDGE);
700   if (aExp.More()){
701     const TopoDS_Edge& aE = TopoDS::Edge(aExp.Current());
702     aT=BOPTools_Tools2D::IntermediatePoint(aE);
703     BOPTools_Tools2D::PointOnSurface(aE, aF2, aT, aU, aV);
704     aP2D.SetCoord(aU, aV);
705     //
706     IntTools_FClass2d& aClsf=theContext->FClass2d(aF2);
707     aState=aClsf.Perform(aP2D);
708   }
709   return (aState==TopAbs_IN);
710 }
711 */