Salome HOME
Increase sensitivity for vertexes selection
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_SketchBuilder.cpp
index 4e894827d7f63d037da9748132f9784a6107f721..8359b32448f7c4364eba15947190893696733dbb 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_SketchBuilder.cpp
 // Created:     02 Jun 2014
 // Author:      Artem ZHIDKOV
@@ -80,8 +82,9 @@ static void removeWasteEdges(std::list<TopoDS_Vertex>::iterator& theStartVertex,
 
 
 void GeomAlgoAPI_SketchBuilder::createFaces(
-    const std::shared_ptr<GeomAPI_Pnt>& theOrigin, const std::shared_ptr<GeomAPI_Dir>& theDirX,
-    const std::shared_ptr<GeomAPI_Dir>& theDirY, const std::shared_ptr<GeomAPI_Dir>& theNorm,
+    const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
+    const std::shared_ptr<GeomAPI_Dir>& theDirX,
+    const std::shared_ptr<GeomAPI_Dir>& theNorm,
     const std::list<std::shared_ptr<GeomAPI_Shape> >& theFeatures,
     std::list<std::shared_ptr<GeomAPI_Shape> >& theResultFaces,
     std::list<std::shared_ptr<GeomAPI_Shape> >& theResultWires)
@@ -130,8 +133,8 @@ void GeomAlgoAPI_SketchBuilder::createFaces(
     return;
 
   gp_Dir aDirX = theDirX->impl<gp_Dir>();
-  gp_Dir aDirY = theDirY->impl<gp_Dir>();
   gp_Dir aNorm = theNorm->impl<gp_Dir>();
+  gp_Dir aDirY = aNorm.Crossed(aDirX);
 
   gp_Pln aPlane(theOrigin->impl<gp_Pnt>(), aNorm);
 
@@ -373,18 +376,28 @@ void GeomAlgoAPI_SketchBuilder::createFaces(
 
 void GeomAlgoAPI_SketchBuilder::createFaces(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
                                             const std::shared_ptr<GeomAPI_Dir>& theDirX,
-                                            const std::shared_ptr<GeomAPI_Dir>& theDirY,
                                             const std::shared_ptr<GeomAPI_Dir>& theNorm,
                                             const std::shared_ptr<GeomAPI_Shape>& theWire,
                                             std::list<std::shared_ptr<GeomAPI_Shape> >& theResultFaces)
 {
-  std::shared_ptr<GeomAPI_PlanarEdges> aWire = std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(theWire);
-  if(!aWire)
-    return;
-  // Filter wires, return only faces.
   std::list<std::shared_ptr<GeomAPI_Shape> > aFilteredWires;
-  createFaces(theOrigin, theDirX, theDirY, theNorm,
-              aWire->getEdges(), theResultFaces, aFilteredWires);
+  std::shared_ptr<GeomAPI_PlanarEdges> aWire = 
+    std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(theWire);
+  if(aWire) {
+    // Filter wires, return only faces.
+    createFaces(theOrigin, theDirX, theNorm,
+                aWire->getEdges(), theResultFaces, aFilteredWires);
+
+    return;
+  } else { // it may be only one circle
+    std::shared_ptr<GeomAPI_Edge> anEdge = std::dynamic_pointer_cast<GeomAPI_Edge>(theWire);
+    if (anEdge) {
+      std::list<std::shared_ptr<GeomAPI_Shape> > aList;
+      aList.push_back(anEdge);
+      createFaces(theOrigin, theDirX, theNorm,
+                  aList, theResultFaces, aFilteredWires);
+    }
+  }
 }