]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp
Salome HOME
87e6d83c210e11c32c19f7afe222ecc0534f5bd3
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_ShapeTools.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAlgoAPI_ShapeTools.h
4 // Created:     3 August 2015
5 // Author:      Dmitry Bobylev
6
7 #include "GeomAlgoAPI_ShapeTools.h"
8
9 #include "GeomAlgoAPI_SketchBuilder.h"
10
11 #include <GeomAPI_Dir.h>
12 #include <GeomAPI_PlanarEdges.h>
13 #include <GeomAPI_Pln.h>
14 #include <GeomAPI_Pnt.h>
15
16 #include <Bnd_Box.hxx>
17 #include <BOPTools.hxx>
18 #include <BRep_Builder.hxx>
19 #include <BRepAdaptor_Curve.hxx>
20 #include <BRepAlgo_FaceRestrictor.hxx>
21 #include <BRepBndLib.hxx>
22 #include <BRepBuilderAPI_FindPlane.hxx>
23 #include <BRepBuilderAPI_MakeEdge.hxx>
24 #include <BRepBuilderAPI_MakeFace.hxx>
25 #include <BRepExtrema_DistShapeShape.hxx>
26 #include <BRepGProp.hxx>
27 #include <BRepTopAdaptor_FClass2d.hxx>
28 #include <Geom_Curve.hxx>
29 #include <Geom2d_Curve.hxx>
30 #include <BRepLib_CheckCurveOnSurface.hxx>
31 #include <BRep_Tool.hxx>
32 #include <Geom_Plane.hxx>
33 #include <GeomLib_IsPlanarSurface.hxx>
34 #include <GeomLib_Tool.hxx>
35 #include <GeomProjLib.hxx>
36 #include <gp_Pln.hxx>
37 #include <GProp_GProps.hxx>
38 #include <IntAna_IntConicQuad.hxx>
39 #include <IntAna_Quadric.hxx>
40 #include <NCollection_Vector.hxx>
41 #include <ShapeAnalysis.hxx>
42 #include <ShapeAnalysis_Surface.hxx>
43 #include <TopoDS_Builder.hxx>
44 #include <TopoDS_Edge.hxx>
45 #include <TopoDS_Face.hxx>
46 #include <TopoDS_Shape.hxx>
47 #include <TopoDS_Shell.hxx>
48 #include <TopoDS_Vertex.hxx>
49 #include <TopoDS.hxx>
50 #include <TopExp_Explorer.hxx>
51
52 //=================================================================================================
53 double GeomAlgoAPI_ShapeTools::volume(const std::shared_ptr<GeomAPI_Shape> theShape)
54 {
55   GProp_GProps aGProps;
56   if(!theShape.get()) {
57     return 0.0;
58   }
59   const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
60   if(aShape.IsNull()) {
61     return 0.0;
62   }
63   const Standard_Real anEps = 1.e-6;
64   BRepGProp::VolumeProperties(aShape, aGProps, anEps);
65   return aGProps.Mass();
66 }
67
68 //=================================================================================================
69 std::shared_ptr<GeomAPI_Pnt> GeomAlgoAPI_ShapeTools::centreOfMass(const std::shared_ptr<GeomAPI_Shape> theShape)
70 {
71   GProp_GProps aGProps;
72   if(!theShape) {
73     return std::shared_ptr<GeomAPI_Pnt>();
74   }
75   const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
76   if(aShape.IsNull()) {
77     return std::shared_ptr<GeomAPI_Pnt>();
78   }
79   gp_Pnt aCentre;
80   if(aShape.ShapeType() == TopAbs_VERTEX) {
81     aCentre = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
82   } else if(aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE) {
83     BRepGProp::LinearProperties(aShape, aGProps);
84     aCentre = aGProps.CentreOfMass();
85   } else {
86     BRepGProp::SurfaceProperties(aShape, aGProps);
87     aCentre = aGProps.CentreOfMass();
88   }
89   return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aCentre.X(), aCentre.Y(), aCentre.Z()));
90 }
91
92 //=================================================================================================
93 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
94                                                                      const GeomAPI_Shape::ShapeType theType,
95                                                                      ListOfShape& theCombinedShapes,
96                                                                      ListOfShape& theFreeShapes)
97 {
98   GeomShapePtr aResult = theCompound;
99
100   if(!theCompound.get()) {
101     return aResult;
102   }
103
104   if(theType != GeomAPI_Shape::SHELL && theType != GeomAPI_Shape::COMPSOLID) {
105     return aResult;
106   }
107
108   TopAbs_ShapeEnum aTS = TopAbs_EDGE;
109   TopAbs_ShapeEnum aTA = TopAbs_FACE;
110   if(theType == GeomAPI_Shape::COMPSOLID) {
111     aTS = TopAbs_FACE;
112     aTA = TopAbs_SOLID;
113   }
114
115   // Get free shapes.
116   const TopoDS_Shape& aShapesComp = theCompound->impl<TopoDS_Shape>();
117   for(TopoDS_Iterator anIter(aShapesComp); anIter.More(); anIter.Next() ) {
118     const TopoDS_Shape& aShape = anIter.Value();
119     if(aShape.ShapeType() > aTA) {
120       std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
121       aGeomShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(aShape));
122       theFreeShapes.push_back(aGeomShape);
123     }
124   }
125
126   // Map subshapes and shapes.
127   BOPCol_IndexedDataMapOfShapeListOfShape aMapSA;
128   BOPTools::MapShapesAndAncestors(aShapesComp, aTS, aTA, aMapSA);
129   if(aMapSA.IsEmpty()) {
130     return aResult;
131   }
132
133   // Get all shapes with common subshapes and free shapes.
134   NCollection_Map<TopoDS_Shape> aFreeShapes;
135   NCollection_Vector<NCollection_Map<TopoDS_Shape>> aShapesWithCommonSubshapes;
136   for(BOPCol_IndexedDataMapOfShapeListOfShape::Iterator anIter(aMapSA); anIter.More(); anIter.Next()) {
137     const TopoDS_Shape& aShape = anIter.Key();
138     BOPCol_ListOfShape& aListOfShape = anIter.ChangeValue();
139     if(aListOfShape.IsEmpty()) {
140       continue;
141     }
142     else if(aListOfShape.Size() == 1) {
143       const TopoDS_Shape& aF = aListOfShape.First();
144       aFreeShapes.Add(aF);
145       aListOfShape.Clear();
146     } else {
147       NCollection_List<TopoDS_Shape> aTempList;
148       NCollection_Map<TopoDS_Shape> aTempMap;
149       const TopoDS_Shape& aF = aListOfShape.First();
150       const TopoDS_Shape& aL = aListOfShape.Last();
151       aTempList.Append(aF);
152       aTempList.Append(aL);
153       aTempMap.Add(aF);
154       aTempMap.Add(aL);
155       aFreeShapes.Remove(aF);
156       aFreeShapes.Remove(aL);
157       aListOfShape.Clear();
158       for(NCollection_List<TopoDS_Shape>::Iterator aTempIter(aTempList); aTempIter.More(); aTempIter.Next()) {
159         const TopoDS_Shape& aTempShape = aTempIter.Value();
160         for(BOPCol_IndexedDataMapOfShapeListOfShape::Iterator anIter(aMapSA); anIter.More(); anIter.Next()) {
161           BOPCol_ListOfShape& aTempListOfShape = anIter.ChangeValue();
162           if(aTempListOfShape.IsEmpty()) {
163             continue;
164           } else if(aTempListOfShape.Size() == 1 && aTempListOfShape.First() == aTempShape) {
165             aTempListOfShape.Clear();
166           } else if(aTempListOfShape.Size() > 1) {
167             if(aTempListOfShape.First() == aTempShape) {
168               const TopoDS_Shape& aTL = aTempListOfShape.Last();
169               if(aTempMap.Add(aTL)) {
170                 aTempList.Append(aTL);
171                 aFreeShapes.Remove(aTL);
172               }
173               aTempListOfShape.Clear();
174             } else if(aTempListOfShape.Last() == aTempShape) {
175               const TopoDS_Shape& aTF = aTempListOfShape.First();
176               if(aTempMap.Add(aTF)) {
177                 aTempList.Append(aTF);
178                 aFreeShapes.Remove(aTF);
179               }
180               aTempListOfShape.Clear();
181             }
182           }
183         }
184       }
185       aShapesWithCommonSubshapes.Append(aTempMap);
186     }
187   }
188
189   // Combine shapes with common subshapes.
190   for(NCollection_Vector<NCollection_Map<TopoDS_Shape>>::Iterator anIter(aShapesWithCommonSubshapes); anIter.More(); anIter.Next()) {
191     TopoDS_Shell aShell;
192     TopoDS_CompSolid aCSolid;
193     TopoDS_Builder aBuilder;
194     theType == GeomAPI_Shape::COMPSOLID ? aBuilder.MakeCompSolid(aCSolid) : aBuilder.MakeShell(aShell);
195     NCollection_Map<TopoDS_Shape>& aShapesMap = anIter.ChangeValue();
196     for(TopExp_Explorer anExp(aShapesComp, aTA); anExp.More(); anExp.Next()) {
197       const TopoDS_Shape& aShape = anExp.Current();
198       if(aShapesMap.Contains(aShape)) {
199         theType == GeomAPI_Shape::COMPSOLID ? aBuilder.Add(aCSolid, aShape) : aBuilder.Add(aShell, aShape);
200         aShapesMap.Remove(aShape);
201       }
202     }
203     std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
204     TopoDS_Shape* aSh = theType == GeomAPI_Shape::COMPSOLID ? new TopoDS_Shape(aCSolid) : new TopoDS_Shape(aShell);
205     aGeomShape->setImpl<TopoDS_Shape>(aSh);
206     theCombinedShapes.push_back(aGeomShape);
207   }
208
209   // Adding free shapes.
210   for(TopExp_Explorer anExp(aShapesComp, aTA); anExp.More(); anExp.Next()) {
211     const TopoDS_Shape& aShape = anExp.Current();
212     if(aFreeShapes.Contains(aShape)) {
213       std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
214       aGeomShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(aShape));
215       theFreeShapes.push_back(aGeomShape);
216     }
217   }
218
219   if(theCombinedShapes.size() == 1 && theFreeShapes.size() == 0) {
220     aResult = theCombinedShapes.front();
221   } else if (theCombinedShapes.size() > 1 || (theCombinedShapes.size() >= 1 && theFreeShapes.size() >= 1)) {
222     TopoDS_Compound aResultComp;
223     TopoDS_Builder aBuilder;
224     aBuilder.MakeCompound(aResultComp);
225     for(ListOfShape::const_iterator anIter = theCombinedShapes.cbegin(); anIter != theCombinedShapes.cend(); anIter++) {
226       aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
227     }
228     for(ListOfShape::const_iterator anIter = theFreeShapes.cbegin(); anIter != theFreeShapes.cend(); anIter++) {
229       aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
230     }
231     aResult->setImpl(new TopoDS_Shape(aResultComp));
232   }
233
234   return aResult;
235 }
236
237 //=================================================================================================
238 std::list<std::shared_ptr<GeomAPI_Pnt> > GeomAlgoAPI_ShapeTools::getBoundingBox(const ListOfShape& theShapes, const double theEnlarge)
239 {
240   // Bounding box of all objects.
241   Bnd_Box aBndBox;
242
243   // Getting box.
244   for (ListOfShape::const_iterator anObjectsIt = theShapes.begin(); anObjectsIt != theShapes.end(); anObjectsIt++) {
245     const TopoDS_Shape& aShape = (*anObjectsIt)->impl<TopoDS_Shape>();
246     BRepBndLib::Add(aShape, aBndBox);
247   }
248
249   if(theEnlarge != 0.0) {
250     // We enlarge bounding box just to be sure that plane will be large enough to cut all objects.
251     aBndBox.Enlarge(theEnlarge);
252   }
253
254   Standard_Real aXArr[2] = {aBndBox.CornerMin().X(), aBndBox.CornerMax().X()};
255   Standard_Real aYArr[2] = {aBndBox.CornerMin().Y(), aBndBox.CornerMax().Y()};
256   Standard_Real aZArr[2] = {aBndBox.CornerMin().Z(), aBndBox.CornerMax().Z()};
257   std::list<std::shared_ptr<GeomAPI_Pnt> > aResultPoints;
258   int aNum = 0;
259   for(int i = 0; i < 2; i++) {
260     for(int j = 0; j < 2; j++) {
261       for(int k = 0; k < 2; k++) {
262         std::shared_ptr<GeomAPI_Pnt> aPnt(new GeomAPI_Pnt(aXArr[i], aYArr[j], aZArr[k]));
263         aResultPoints.push_back(aPnt);
264       }
265     }
266   }
267
268   return aResultPoints;
269 }
270
271 //=================================================================================================
272 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::faceToInfinitePlane(const std::shared_ptr<GeomAPI_Shape> theFace)
273 {
274   if (!theFace.get())
275     return std::shared_ptr<GeomAPI_Shape>();
276
277   TopoDS_Face aPlaneFace = TopoDS::Face(theFace->impl<TopoDS_Shape>());
278   if (aPlaneFace.IsNull())
279     return std::shared_ptr<GeomAPI_Shape>();
280
281   Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(aPlaneFace));
282   if (aPlane.IsNull())
283     return std::shared_ptr<GeomAPI_Shape>();
284
285   // make an infinity face on the plane
286   TopoDS_Shape anInfiniteFace = BRepBuilderAPI_MakeFace(aPlane->Pln()).Shape();
287
288   std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
289   aResult->setImpl(new TopoDS_Shape(anInfiniteFace));
290   return aResult;
291 }
292
293 //=================================================================================================
294 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::fitPlaneToBox(const std::shared_ptr<GeomAPI_Shape> thePlane,
295                                                                      const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints)
296 {
297   std::shared_ptr<GeomAPI_Shape> aResultShape;
298
299   if(!thePlane.get()) {
300     return aResultShape;
301   }
302
303   const TopoDS_Shape& aShape = thePlane->impl<TopoDS_Shape>();
304   if(aShape.ShapeType() != TopAbs_FACE) {
305     return aResultShape;
306   }
307
308   TopoDS_Face aFace = TopoDS::Face(aShape);
309   Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
310   if(aSurf.IsNull()) {
311     return aResultShape;
312   }
313
314   GeomLib_IsPlanarSurface isPlanar(aSurf);
315   if(!isPlanar.IsPlanar()) {
316     return aResultShape;
317   }
318
319   if(thePoints.size() != 8) {
320     return aResultShape;
321   }
322
323   const gp_Pln& aFacePln = isPlanar.Plan();
324   Handle(Geom_Plane) aFacePlane = new Geom_Plane(aFacePln);
325   IntAna_Quadric aQuadric(aFacePln);
326   Standard_Real UMin, UMax, VMin, VMax;
327   UMin = UMax = VMin = VMax = 0;
328   for (std::list<std::shared_ptr<GeomAPI_Pnt> >::const_iterator aPointsIt = thePoints.begin(); aPointsIt != thePoints.end(); aPointsIt++) {
329     const gp_Pnt& aPnt = (*aPointsIt)->impl<gp_Pnt>();
330     gp_Lin aLin(aPnt, aFacePln.Axis().Direction());
331     IntAna_IntConicQuad anIntAna(aLin, aQuadric);
332     const gp_Pnt& aPntOnFace = anIntAna.Point(1);
333     Standard_Real aPntU(0), aPntV(0);
334     GeomLib_Tool::Parameters(aFacePlane, aPntOnFace, Precision::Confusion(), aPntU, aPntV);
335     if(aPntU < UMin) UMin = aPntU;
336     if(aPntU > UMax) UMax = aPntU;
337     if(aPntV < VMin) VMin = aPntV;
338     if(aPntV > VMax) VMax = aPntV;
339   }
340   aResultShape.reset(new GeomAPI_Shape);
341   aResultShape->setImpl(new TopoDS_Shape(BRepLib_MakeFace(aFacePln, UMin, UMax, VMin, VMax).Face()));
342
343   return aResultShape;
344 }
345
346 //=================================================================================================
347 void GeomAlgoAPI_ShapeTools::findBounds(const std::shared_ptr<GeomAPI_Shape> theShape,
348                                         std::shared_ptr<GeomAPI_Vertex>& theV1,
349                                         std::shared_ptr<GeomAPI_Vertex>& theV2)
350 {
351   if(!theShape.get()) {
352     std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex);
353     aVertex->setImpl(new TopoDS_Vertex());
354     theV1 = aVertex;
355     theV2 = aVertex;
356     return;
357   }
358
359   const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
360   TopoDS_Vertex aV1, aV2;
361   ShapeAnalysis::FindBounds(aShape, aV1, aV2);
362
363   std::shared_ptr<GeomAPI_Vertex> aGeomV1(new GeomAPI_Vertex()), aGeomV2(new GeomAPI_Vertex());
364   aGeomV1->setImpl(new TopoDS_Vertex(aV1));
365   aGeomV2->setImpl(new TopoDS_Vertex(aV2));
366   theV1 = aGeomV1;
367   theV2 = aGeomV2;
368 }
369
370 //=================================================================================================
371 void GeomAlgoAPI_ShapeTools::makeFacesWithHoles(const std::shared_ptr<GeomAPI_Pnt> theOrigin,
372                                                 const std::shared_ptr<GeomAPI_Dir> theDirection,
373                                                 const ListOfShape& theWires,
374                                                 ListOfShape& theFaces)
375 {
376   BRepBuilderAPI_MakeFace aMKFace(gp_Pln(theOrigin->impl<gp_Pnt>(),
377                                          theDirection->impl<gp_Dir>()));
378   TopoDS_Face aFace = aMKFace.Face();
379
380   BRepAlgo_FaceRestrictor aFRestrictor;
381   aFRestrictor.Init(aFace, Standard_False, Standard_True);
382   for(ListOfShape::const_iterator anIt = theWires.cbegin();
383       anIt != theWires.cend();
384       ++anIt) {
385     TopoDS_Wire aWire = TopoDS::Wire((*anIt)->impl<TopoDS_Shape>());
386     aFRestrictor.Add(aWire);
387   }
388
389   aFRestrictor.Perform();
390
391   if(!aFRestrictor.IsDone()) {
392     return;
393   }
394
395   for(; aFRestrictor.More(); aFRestrictor.Next()) {
396     GeomShapePtr aShape(new GeomAPI_Shape());
397     aShape->setImpl(new TopoDS_Shape(aFRestrictor.Current()));
398     theFaces.push_back(aShape);
399   }
400 }
401
402 //=================================================================================================
403 std::shared_ptr<GeomAPI_Pln> GeomAlgoAPI_ShapeTools::findPlane(const ListOfShape& theShapes)
404 {
405   TopoDS_Compound aCompound;
406   BRep_Builder aBuilder;
407   aBuilder.MakeCompound(aCompound);
408
409   for(ListOfShape::const_iterator anIt = theShapes.cbegin(); anIt != theShapes.cend(); ++anIt) {
410     aBuilder.Add(aCompound, (*anIt)->impl<TopoDS_Shape>());
411   }
412   BRepBuilderAPI_FindPlane aFindPlane(aCompound);
413
414   if(aFindPlane.Found() != Standard_True) {
415     return std::shared_ptr<GeomAPI_Pln>();
416   }
417
418   Handle(Geom_Plane) aPlane = aFindPlane.Plane();
419   gp_Pnt aLoc = aPlane->Location();
420   gp_Dir aDir = aPlane->Axis().Direction();
421
422   std::shared_ptr<GeomAPI_Pnt> aGeomPnt(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
423   std::shared_ptr<GeomAPI_Dir> aGeomDir(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
424
425   std::shared_ptr<GeomAPI_Pln> aPln(new GeomAPI_Pln(aGeomPnt, aGeomDir));
426
427   return aPln;
428 }
429
430 //=================================================================================================
431 bool GeomAlgoAPI_ShapeTools::isSubShapeInShape(const std::shared_ptr<GeomAPI_Shape> theSubShape,
432                                                const std::shared_ptr<GeomAPI_Shape> theBaseShape)
433 {
434   if(!theSubShape.get() || !theBaseShape.get()) {
435     return false;
436   }
437
438   const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
439   const TopoDS_Shape& aBaseShape = theBaseShape->impl<TopoDS_Shape>();
440
441   if(aSubShape.ShapeType() == TopAbs_VERTEX) {
442     // If sub-shape is a vertex check distance to shape. If it is <= Precision::Confusion() then OK.
443     BRepExtrema_DistShapeShape aDist(aBaseShape, aSubShape);
444     aDist.Perform();
445     if(!aDist.IsDone() || aDist.Value() > Precision::Confusion()) {
446       return false;
447     }
448   } else if (aSubShape.ShapeType() == TopAbs_EDGE) {
449     if(aBaseShape.ShapeType() == TopAbs_FACE) {
450       // Check that edge is on face surface.
451       TopoDS_Face aFace = TopoDS::Face(aBaseShape);
452       TopoDS_Edge anEdge = TopoDS::Edge(aSubShape);
453       BRepLib_CheckCurveOnSurface aCheck(anEdge, aFace);
454       aCheck.Perform();
455       if(!aCheck.IsDone() || aCheck.MaxDistance() > Precision::Confusion()) {
456         return false;
457       }
458
459       // Check intersections.
460       TopoDS_Vertex aV1, aV2;
461       ShapeAnalysis::FindBounds(anEdge, aV1, aV2);
462       gp_Pnt aPnt1 = BRep_Tool::Pnt(aV1);
463       gp_Pnt aPnt2 = BRep_Tool::Pnt(aV2);
464       for(TopExp_Explorer anExp(aBaseShape, TopAbs_EDGE); anExp.More(); anExp.Next()) {
465         const TopoDS_Shape& anEdgeOnFace = anExp.Current();
466         BRepExtrema_DistShapeShape aDist(anEdgeOnFace, anEdge);
467         aDist.Perform();
468         if(aDist.IsDone() && aDist.Value() <= Precision::Confusion()) {
469           // Edge intersect face bound. Check that it is not on edge begin or end.
470           for(Standard_Integer anIndex = 1; anIndex <= aDist.NbSolution(); ++anIndex) {
471             gp_Pnt aPntOnSubShape = aDist.PointOnShape2(anIndex);
472             if(aPntOnSubShape.Distance(aPnt1) > Precision::Confusion()
473                 && aPntOnSubShape.Distance(aPnt2) > Precision::Confusion()) {
474               return false;
475             }
476           }
477         }
478       }
479
480       // No intersections found. Edge is inside or outside face. Check it.
481       BRepAdaptor_Curve aCurveAdaptor(anEdge);
482       gp_Pnt aPointToCheck = aCurveAdaptor.Value((aCurveAdaptor.FirstParameter() + aCurveAdaptor.LastParameter()) / 2.0);
483       Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
484       ShapeAnalysis_Surface aSAS(aSurface);
485       gp_Pnt2d aPointOnFace = aSAS.ValueOfUV(aPointToCheck, Precision::Confusion());
486       BRepTopAdaptor_FClass2d aFClass2d(aFace, Precision::Confusion());
487       if(aFClass2d.Perform(aPointOnFace) == TopAbs_OUT) {
488         return false;
489       }
490
491     } else {
492       return false;
493     }
494   } else {
495     return false;
496   }
497
498   return true;
499 }