Salome HOME
Change icons for chamfer
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Split.cpp
index d9e0cc2527b5b0814f4d5ab6cc42468d4ebade37..ac6a15d6d78d2094735b93585d9541e29e7ffb9f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "SketchPlugin_Split.h"
@@ -235,6 +234,8 @@ void SketchPlugin_Split::execute()
   std::cout << std::endl;
 #endif
 
+  keepCurrentFeature();
+
   std::string aFeatureKind = aBaseFeature->getKind();
   FeaturePtr aSplitFeature, anAfterFeature;
   std::set<AttributePoint2DPtr> aFurtherCoincidences;
@@ -247,6 +248,9 @@ void SketchPlugin_Split::execute()
   else if (aFeatureKind == SketchPlugin_Arc::ID())
     aNewFeature = splitArc(aSplitFeature, aBaseFeature, anAfterFeature, aFurtherCoincidences,
                            aCreatedFeatures, aModifiedAttributes);
+
+  restoreCurrentFeature();
+
   if (aFeatureKind == SketchPlugin_Circle::ID()) {
     FeaturePtr aCircleFeature = aBaseFeature;
     aReplacingFeature = splitCircle(aSplitFeature, aBaseFeature, anAfterFeature,
@@ -421,6 +425,7 @@ void SketchPlugin_Split::execute()
 #endif
 }
 
+// LCOV_EXCL_START
 std::string SketchPlugin_Split::processEvent(const std::shared_ptr<Events_Message>& theMessage)
 {
 #ifdef DEBUG_SPLIT
@@ -484,6 +489,7 @@ std::string SketchPlugin_Split::processEvent(const std::shared_ptr<Events_Messag
   }
   return aFilledAttributeName;
 }
+// LCOV_EXCL_STOP
 
 AISObjectPtr SketchPlugin_Split::getAISObject(AISObjectPtr thePrevious)
 {
@@ -619,7 +625,8 @@ void SketchPlugin_Split::fillObjectShapes(const ObjectPtr& theObject,
     ModelGeomAlgo_Point2D::getPointsInsideShape_p(aFeatureShape, aRefAttributes, aC->pnt(),
                                                 aX->dir(), aY, aPoints, aPointToAttributes);
 
-    GeomAlgoAPI_ShapeTools::splitShape_p(aFeatureShape, aPoints, aShapes);
+    if (!aPoints.empty())
+      GeomAlgoAPI_ShapeTools::splitShape_p(aFeatureShape, aPoints, aShapes);
   }
   myCashedShapes[theObject] = aShapes;
   myCashedReferences[theObject] = aPointToAttributes;
@@ -713,23 +720,6 @@ GeomShapePtr SketchPlugin_Split::getSubShape(const std::string& theObjectAttribu
   return aBaseShape;
 }
 
-std::shared_ptr<GeomDataAPI_Point2D> SketchPlugin_Split::getPointOfRefAttr(
-                                                      const AttributePtr& theAttribute)
-{
-  AttributePoint2DPtr aPointAttribute;
-
-  if (theAttribute->attributeType() == ModelAPI_AttributeRefAttr::typeId()) {
-    AttributeRefAttrPtr aRefAttr =
-      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
-    if (aRefAttr.get() && aRefAttr->isInitialized()) {
-      AttributePtr anAttribute = aRefAttr->attr();
-      if (anAttribute.get() && anAttribute->attributeType() == GeomDataAPI_Point2D::typeId())
-        aPointAttribute = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttribute);
-    }
-  }
-  return aPointAttribute;
-}
-
 void SketchPlugin_Split::getFeaturePoints(const FeaturePtr& theFeature,
                                                     AttributePoint2DPtr& theStartPointAttr,
                                                     AttributePoint2DPtr& theEndPointAttr)
@@ -1566,6 +1556,7 @@ std::shared_ptr<ModelAPI_Result> SketchPlugin_Split::getFeatureResult(
   return aResult;
 }
 
+#ifdef _DEBUG
 std::set<std::shared_ptr<ModelAPI_Attribute> > SketchPlugin_Split::getEdgeAttributes(
                                            const std::shared_ptr<ModelAPI_Feature>& theFeature)
 {
@@ -1585,6 +1576,7 @@ std::set<std::shared_ptr<ModelAPI_Attribute> > SketchPlugin_Split::getEdgeAttrib
 
   return anAttributes;
 }
+#endif
 
 std::shared_ptr<GeomDataAPI_Point2D> SketchPlugin_Split::getPointAttribute
                                                               (const bool isFirstAttribute)