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