Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / PartSet / PartSet_Tools.cpp
index a92364d0594b30c0c7d950c77e94bfc4995f720a..b488201750a4866ff82aa1ff3d150af14b2a2223 100644 (file)
@@ -431,19 +431,30 @@ std::shared_ptr<GeomAPI_Pnt> PartSet_Tools::point3D(std::shared_ptr<GeomAPI_Pnt2
   return thePoint2D->to3D(aC->pnt(), aX->dir(), aY);
 }
 
-ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape, 
-                                                 const ObjectPtr& theObject, 
-                                                 CompositeFeaturePtr theSketch)
+ResultPtr PartSet_Tools::findFixedObjectByExternal(const TopoDS_Shape& theShape,
+                                                   const ObjectPtr& theObject,
+                                                   CompositeFeaturePtr theSketch)
 {
+  ResultPtr aResult;
   if (theShape.ShapeType() == TopAbs_EDGE) {
     // Check that we already have such external edge
     std::shared_ptr<GeomAPI_Edge> aInEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge());
     aInEdge->setImpl(new TopoDS_Shape(theShape));
-    ResultPtr aResult = findExternalEdge(theSketch, aInEdge);
-    if (aResult)
-      return aResult;
+    aResult = findExternalEdge(theSketch, aInEdge);
+  }
+  if (theShape.ShapeType() == TopAbs_VERTEX) {
+    std::shared_ptr<GeomAPI_Vertex> aInVert = std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex());
+    aInVert->setImpl(new TopoDS_Shape(theShape));
+    aResult = findExternalVertex(theSketch, aInVert);
+  }
+  return aResult;
+}
 
-    // If not found then we have to create new
+ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape, 
+                                                 const ObjectPtr& theObject, 
+                                                 CompositeFeaturePtr theSketch)
+{
+  if (theShape.ShapeType() == TopAbs_EDGE) {
     Standard_Real aStart, aEnd;
     Handle(V3d_View) aNullView;
     FeaturePtr aMyFeature;
@@ -454,13 +465,16 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap
       // Create line
       aMyFeature = theSketch->addFeature(SketchPlugin_Line::ID());
     } else if (aAdaptor.GetType() == GeomAbs_Circle) {
-      if (aAdaptor.IsClosed()) {
-        // Create circle
-        aMyFeature = theSketch->addFeature(SketchPlugin_Circle::ID());
-      } else {
+      std::shared_ptr<GeomAPI_Edge> anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge);
+      anEdge->setImpl(new TopoDS_Shape(theShape));
+      if (anEdge->isArc()) {
         // Create arc
         aMyFeature = theSketch->addFeature(SketchPlugin_Arc::ID());
       }
+      else {
+        // Create circle
+        aMyFeature = theSketch->addFeature(SketchPlugin_Circle::ID());
+      }
     }
     if (aMyFeature) {
       DataPtr aData = aMyFeature->data();
@@ -487,12 +501,6 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap
     }
   }
   if (theShape.ShapeType() == TopAbs_VERTEX) {
-    std::shared_ptr<GeomAPI_Vertex> aInVert = std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex());
-    aInVert->setImpl(new TopoDS_Shape(theShape));
-    ResultPtr aResult = findExternalVertex(theSketch, aInVert);
-    if (aResult)
-      return aResult;
-
     FeaturePtr aMyFeature = theSketch->addFeature(SketchPlugin_Point::ID());
 
     if (aMyFeature) {