Salome HOME
SketchShapePlugin package is removed as not used.
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Revolution.cpp
index fd06b5f961e9dcd16761ca806a9aece60a5c451e..6d2c233d604891801e1e9e94fe594f9e03b369ea 100644 (file)
@@ -4,7 +4,7 @@
 // Created:     12 May 2015
 // Author:      Dmitry Bobylev
 
-#include <FeaturesPlugin_Revolution.h>
+#include "FeaturesPlugin_Revolution.h"
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
@@ -58,34 +58,26 @@ void FeaturesPlugin_Revolution::execute()
   ListOfShape aFacesList;
   AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
   for(int anIndex = 0; anIndex < aFacesSelectionList->size(); anIndex++) {
-    std::shared_ptr<ModelAPI_AttributeSelection> aFaceSel = aFacesSelectionList->value(anIndex);
-    ResultPtr aContext = aFaceSel->context();
-    std::shared_ptr<GeomAPI_Shape> aContextShape = aContext->shape();
-    if(!aContextShape.get()) {
-      static const std::string aContextError = "The selection context is bad";
-      setError(aContextError);
-      break;
-    }
-
+    AttributeSelectionPtr aFaceSel = aFacesSelectionList->value(anIndex);
     std::shared_ptr<GeomAPI_Shape> aFaceShape = aFaceSel->value();
-    int aFacesNum = -1; // this mean that "aFace" is used
-    ResultConstructionPtr aConstruction = 
-      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
-    if(!aFaceShape.get()) { // this may be the whole sketch result selected, check and get faces
-      if (aConstruction.get()) {
-        aFacesNum = aConstruction->facesNum();
-      } else {
+    if(aFaceShape.get() && !aFaceShape->isNull()) { // Getting face.
+      aFacesList.push_back(aFaceShape);
+    } else { // This may be the whole sketch result selected, check and get faces.
+      ResultPtr aContext = aFaceSel->context();
+      std::shared_ptr<GeomAPI_Shape> aContextShape = aContext->shape();
+      if(!aContextShape.get()) {
+        static const std::string aContextError = "The selection context is bad";
+        setError(aContextError);
+        return;
+      }
+      ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+      if(!aConstruction.get()) {
         static const std::string aFaceError = "Can not find basis for revolution";
         setError(aFaceError);
-        break;
+        return;
       }
-    }
-    for(int aFaceIndex = 0; aFaceIndex < aFacesNum || aFacesNum == -1; aFaceIndex++) {
-      std::shared_ptr<GeomAPI_Shape> aBaseShape;
-      if (aFacesNum == -1) {
-        aFacesList.push_back(aFaceShape);
-        break;
-      } else {
+      int aFacesNum = aConstruction->facesNum();
+      for(int aFaceIndex = 0; aFaceIndex < aFacesNum || aFacesNum == -1; aFaceIndex++) {
         aFaceShape = std::dynamic_pointer_cast<GeomAPI_Shape>(aConstruction->face(aFaceIndex));
         aFacesList.push_back(aFaceShape);
       }
@@ -189,12 +181,12 @@ void FeaturesPlugin_Revolution::loadNamingDS(GeomAlgoAPI_Revolution& theRevolAlg
   //load result
   theResultBody->storeGenerated(theBasis, theRevolAlgo.shape());
 
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theRevolAlgo.mapOfShapes();
+  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theRevolAlgo.mapOfSubShapes();
 
   //Insert lateral face : Face from Edge
   const std::string aLatName = "LateralFace";
   const int aLatTag = 1;
-  theResultBody->loadAndOrientGeneratedShapes(theRevolAlgo.makeShape().get(), theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes);
+  theResultBody->loadAndOrientGeneratedShapes(&theRevolAlgo, theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes);
 
   //Insert to faces
   const std::string aToName = "ToFace";