]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp
Salome HOME
[Code coverage]: Move checking the algorithm's result into separate function
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_CompositeSketch.cpp
index 272b43001f51c77bfcd0cd5563caf18ec39b9d64..e3d5803ba2ae256197942166cc5d11c3dd031893 100644 (file)
@@ -84,11 +84,12 @@ int FeaturesPlugin_CompositeSketch::numberOfSubs(bool forTree) const
 std::shared_ptr<ModelAPI_Feature> FeaturesPlugin_CompositeSketch::subFeature(const int theIndex,
                                                                              bool forTree)
 {
+  FeaturePtr aSubFeature;
   if(theIndex == 0) {
-    return std::dynamic_pointer_cast<ModelAPI_Feature>(data()->reference(SKETCH_ID())->value());
+    aSubFeature =
+        std::dynamic_pointer_cast<ModelAPI_Feature>(data()->reference(SKETCH_ID())->value());
   }
-
-  return std::shared_ptr<ModelAPI_Feature>();
+  return aSubFeature;
 }
 
 //=================================================================================================
@@ -108,14 +109,14 @@ int FeaturesPlugin_CompositeSketch::subFeatureId(const int theIndex) const
 //=================================================================================================
 bool FeaturesPlugin_CompositeSketch::isSub(ObjectPtr theObject) const
 {
+  bool isSubFeature = false;
   // Check is this feature of result
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
-  if(!aFeature.get()) {
-    return false;
+  if (aFeature.get()) {
+    ObjectPtr aSub = data()->reference(SKETCH_ID())->value();
+    isSubFeature = aSub == theObject;
   }
-
-  ObjectPtr aSub = data()->reference(SKETCH_ID())->value();
-  return aSub == theObject;
+  return isSubFeature;
 }
 
 //=================================================================================================
@@ -235,31 +236,6 @@ void FeaturesPlugin_CompositeSketch::getBaseShapes(ListOfShape& theBaseShapesLis
   }
 }
 
-//=================================================================================================
-bool FeaturesPlugin_CompositeSketch::isMakeShapeValid(
-  const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
-{
-  // Check that algo is done.
-  if(!theMakeShape->isDone()) {
-    setError("Error: " + getKind() + " algorithm failed.");
-    return false;
-  }
-
-  // Check if shape is not null.
-  if(!theMakeShape->shape().get() || theMakeShape->shape()->isNull()) {
-    setError("Error: Resulting shape is null.");
-    return false;
-  }
-
-  // Check that resulting shape is valid.
-  if(!theMakeShape->isValid()) {
-    setError("Error: Resulting shape is not valid.");
-    return false;
-  }
-
-  return true;
-}
-
 //=================================================================================================
 void FeaturesPlugin_CompositeSketch::storeResult(const GeomShapePtr theBaseShape,
                                         const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,