]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/FeaturesPlugin/FeaturesPlugin_Scale.cpp
Salome HOME
Meet the coding style (line length <= 100)
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Scale.cpp
index ee82f611d3b9fffcae52f1cdb978b49955db503e..2584cc786eed7b64632c465779c132b922938fae 100644 (file)
@@ -14,6 +14,8 @@
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultPart.h>
 
+#include <iostream>
+
 //=================================================================================================
 FeaturesPlugin_Scale::FeaturesPlugin_Scale()
 {
@@ -104,47 +106,35 @@ void FeaturesPlugin_Scale::performScaleByFactor()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
-
-    // Setting result.
-    if (isPart) {
-      std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
-      //aTrsf->setSymmetry(anAxis);
-      ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
-      ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
-      aResultPart->setTrsf(*aContext, aTrsf);
-      setResult(aResultPart, aResultIndex);
-    } else {
-      GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint, aScaleFactor);
-
-      if (!aScaleAlgo.check()) {
-        setError(aScaleAlgo.getError());
-        return;
-      }
-
-      aScaleAlgo.build();
-
-      // Checking that the algorithm worked properly.
-      if(!aScaleAlgo.isDone()) {
-        static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
-        setError(aFeatureError);
-        break;
-      }
-      if(aScaleAlgo.shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        break;
-      }
-      if(!aScaleAlgo.isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
-        break;
-      }
-
-      ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      loadNamingDS(aScaleAlgo, aResultBody, aBaseShape);
-      setResult(aResultBody, aResultIndex);
+    GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint, aScaleFactor);
+
+    if (!aScaleAlgo.check()) {
+      setError(aScaleAlgo.getError());
+      return;
     }
+
+    aScaleAlgo.build();
+
+    // Checking that the algorithm worked properly.
+    if(!aScaleAlgo.isDone()) {
+      static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
+      setError(aFeatureError);
+      break;
+    }
+    if(aScaleAlgo.shape()->isNull()) {
+      static const std::string aShapeError = "Error: Resulting shape is Null.";
+      setError(aShapeError);
+      break;
+    }
+    if(!aScaleAlgo.isValid()) {
+      std::string aFeatureError = "Error: Resulting shape is not valid.";
+      setError(aFeatureError);
+      break;
+    }
+
+    ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+    loadNamingDS(aScaleAlgo, aResultBody, aBaseShape);
+    setResult(aResultBody, aResultIndex);
     aResultIndex++;
   }
 
@@ -200,48 +190,36 @@ void FeaturesPlugin_Scale::performScaleByDimensions()
   for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
         anObjectsIt++, aContext++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
-
-    // Setting result.
-    if (isPart) {
-      std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
-      //aTrsf->setSymmetry(anAxis);
-      ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
-      ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
-      aResultPart->setTrsf(*aContext, aTrsf);
-      setResult(aResultPart, aResultIndex);
-    } else {
-      GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint,
-                                   aScaleFactorX, aScaleFactorY, aScaleFactorZ);
-
-      if (!aScaleAlgo.check()) {
-        setError(aScaleAlgo.getError());
-        return;
-      }
-
-      aScaleAlgo.build();
-
-      // Checking that the algorithm worked properly.
-      if(!aScaleAlgo.isDone()) {
-        static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
-        setError(aFeatureError);
-        break;
-      }
-      if(aScaleAlgo.shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        break;
-      }
-      if(!aScaleAlgo.isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
-        break;
-      }
-
-      ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      loadNamingDS(aScaleAlgo, aResultBody, aBaseShape);
-      setResult(aResultBody, aResultIndex);
+    GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint,
+                                 aScaleFactorX, aScaleFactorY, aScaleFactorZ);
+
+    if (!aScaleAlgo.check()) {
+      setError(aScaleAlgo.getError());
+      return;
+    }
+
+    aScaleAlgo.build();
+
+    // Checking that the algorithm worked properly.
+    if(!aScaleAlgo.isDone()) {
+      static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
+      setError(aFeatureError);
+      break;
     }
+    if(aScaleAlgo.shape()->isNull()) {
+      static const std::string aShapeError = "Error: Resulting shape is Null.";
+      setError(aShapeError);
+      break;
+    }
+    if(!aScaleAlgo.isValid()) {
+      std::string aFeatureError = "Error: Resulting shape is not valid.";
+      setError(aFeatureError);
+      break;
+    }
+
+    ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+    loadNamingDS(aScaleAlgo, aResultBody, aBaseShape);
+    setResult(aResultBody, aResultIndex);
     aResultIndex++;
   }
 
@@ -264,4 +242,4 @@ void FeaturesPlugin_Scale::loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo,
   theResultBody->loadAndOrientModifiedShapes(&theScaleAlgo,
                                               theBaseShape, GeomAPI_Shape::FACE,
                                               aReflectedTag, aReflectedName, *aSubShapes.get());
-}
\ No newline at end of file
+}