Salome HOME
Extrusion fix
authordbv <dbv@opencascade.com>
Fri, 22 May 2015 16:57:13 +0000 (19:57 +0300)
committerdbv <dbv@opencascade.com>
Fri, 22 May 2015 16:57:13 +0000 (19:57 +0300)
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.h

index f8a6bfc55e0c7388efc47f4f94a3b43c1e3ebdbb..b5250e8c37263d9831aa051be6a574cc3b7ce8b5 100644 (file)
@@ -57,8 +57,8 @@ void FeaturesPlugin_Extrusion::execute()
 {
   AttributeSelectionListPtr aFaceRefs = selectionList(FeaturesPlugin_Extrusion::LIST_ID());
 
-  std::shared_ptr<GeomAPI_Shape> aFromShape(new GeomAPI_Shape);
-  std::shared_ptr<GeomAPI_Shape> aToShape(new GeomAPI_Shape);
+  std::shared_ptr<GeomAPI_Shape> aFromShape;
+  std::shared_ptr<GeomAPI_Shape> aToShape;
 
   // Getting bounding planes.
   std::shared_ptr<ModelAPI_AttributeSelection> anObjRef = selection(FeaturesPlugin_Extrusion::FROM_OBJECT_ID());
@@ -110,39 +110,36 @@ void FeaturesPlugin_Extrusion::execute()
       }
 
       // If bounding faces was not set creating them.
-      std::shared_ptr<GeomAPI_Face> aBaseFace(new GeomAPI_Face(aBaseShape));
-      std::shared_ptr<GeomAPI_Pln> aBasePlane = aBaseFace->getPlane();
-      std::shared_ptr<GeomAPI_Dir> aBaseDir = aBasePlane->direction();
-      std::shared_ptr<GeomAPI_Pnt> aBaseLoc = aBasePlane->location();
+      std::shared_ptr<GeomAPI_Face>  aBaseFace(new GeomAPI_Face(aBaseShape));
+      std::shared_ptr<GeomAPI_Pln>   aBasePln = aBaseFace->getPlane();
+      std::shared_ptr<GeomAPI_Dir>   aBaseDir = aBasePln->direction();
+      std::shared_ptr<GeomAPI_Pnt>   aBaseLoc = aBasePln->location();
+      std::shared_ptr<GeomAPI_Shape> aBasePlane = GeomAlgoAPI_FaceBuilder::planarFace(aBaseLoc, aBaseDir);
 
-      if(!aFromShape) {
-        aFromShape = GeomAlgoAPI_FaceBuilder::plane(aBaseLoc, aBaseDir);
-      }
-      if(!aToShape) {
-        aToShape = GeomAlgoAPI_FaceBuilder::plane(aBaseLoc, aBaseDir);
-      }
+      std::shared_ptr<GeomAPI_Shape> aBoundingFromShape = aFromShape ? aFromShape : aBasePlane;
+      std::shared_ptr<GeomAPI_Shape> aBoundingToShape   = aToShape   ? aToShape   : aBasePlane;
 
       // Moving bounding faces according to "from" and "to" sizes.
-      std::shared_ptr<GeomAPI_Face> aFromFace(new GeomAPI_Face(aFromShape));
-      std::shared_ptr<GeomAPI_Pln> aFromPlane = aFromFace->getPlane();
-      std::shared_ptr<GeomAPI_Pnt> aFromLoc = aFromPlane->location();
-      std::shared_ptr<GeomAPI_Dir> aFromDir = aFromPlane->direction();
+      std::shared_ptr<GeomAPI_Face> aFromFace(new GeomAPI_Face(aBoundingFromShape));
+      std::shared_ptr<GeomAPI_Pln>  aFromPln = aFromFace->getPlane();
+      std::shared_ptr<GeomAPI_Pnt>  aFromLoc = aFromPln->location();
+      std::shared_ptr<GeomAPI_Dir>  aFromDir = aFromPln->direction();
 
-      std::shared_ptr<GeomAPI_Face> aToFace(new GeomAPI_Face(aToShape));
-      std::shared_ptr<GeomAPI_Pln> aToPlane = aToFace->getPlane();
-      std::shared_ptr<GeomAPI_Pnt> aToLoc = aToPlane->location();
-      std::shared_ptr<GeomAPI_Dir> aToDir = aToPlane->direction();
+      std::shared_ptr<GeomAPI_Face> aToFace(new GeomAPI_Face(aBoundingToShape));
+      std::shared_ptr<GeomAPI_Pln>  aToPln = aToFace->getPlane();
+      std::shared_ptr<GeomAPI_Pnt>  aToLoc = aToPln->location();
+      std::shared_ptr<GeomAPI_Dir>  aToDir = aToPln->direction();
 
       bool aSign = aFromLoc->xyz()->dot(aBaseDir->xyz()) > aToLoc->xyz()->dot(aBaseDir->xyz());
 
       std::shared_ptr<GeomAPI_Pnt> aFromPnt(new GeomAPI_Pnt(aFromLoc->xyz()->added(aBaseDir->xyz()->multiplied(aSign ? aFromSize : -aFromSize))));
-      aFromShape = GeomAlgoAPI_FaceBuilder::plane(aFromPnt, aFromDir);
+      aBoundingFromShape = GeomAlgoAPI_FaceBuilder::planarFace(aFromPnt, aFromDir);
 
       std::shared_ptr<GeomAPI_Pnt> aToPnt(new GeomAPI_Pnt(aToLoc->xyz()->added(aBaseDir->xyz()->multiplied(aSign ? -aToSize : aToSize))));
-      aToShape = GeomAlgoAPI_FaceBuilder::plane(aToPnt, aToDir);
+      aBoundingToShape = GeomAlgoAPI_FaceBuilder::planarFace(aToPnt, aToDir);
 
       //GeomAlgoAPI_Extrusion aFeature(aFace, aFromSize);
-      GeomAlgoAPI_Prism aFeature(aBaseShape, aFromShape, aToShape);
+      GeomAlgoAPI_Prism aFeature(aBaseShape, aBoundingFromShape, aBoundingToShape);
       if(!aFeature.isDone()) {
         static const std::string aFeatureError = "Extrusion algorithm failed";
         setError(aFeatureError);
@@ -213,12 +210,3 @@ void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Prism& theFeature,
     theResultBody->generated(aTopFace, aTopName, _LAST_TAG);
   }
 }
-
-//============================================================================
-void FeaturesPlugin_Extrusion::clearResult()
-{
-  std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
-  std::shared_ptr<GeomAPI_Shape> anEmptyShape(new GeomAPI_Shape);
-  aResultBody->store(anEmptyShape);
-  setResult(aResultBody);
-}
index 42c0dc1d67b2fef738bc4b95569e7cdda38eb02a..3a97d81bb308f5509c81caf63d9824501dbd45c3 100644 (file)
@@ -7,12 +7,12 @@
 #ifndef FeaturesPlugin_Extrusion_H_
 #define FeaturesPlugin_Extrusion_H_
 
-#include "FeaturesPlugin.h"
+#include <FeaturesPlugin.h>
 #include <ModelAPI_Feature.h>
-#include <ModelAPI_ResultBody.h>
-#include <GeomAlgoAPI_Extrusion.h>
 #include <GeomAlgoAPI_Prism.h>
-#include <GeomAPI_Shape.h>
+
+class GeomAPI_Shape;
+class ModelAPI_ResultBody;
 
 /**\class FeaturesPlugin_Extrusion
  * \ingroup Plugins
@@ -95,9 +95,6 @@ private:
   void LoadNamingDS(GeomAlgoAPI_Prism& theFeature, std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                     std::shared_ptr<GeomAPI_Shape> theBasis,
                     std::shared_ptr<GeomAPI_Shape> theContext);
-
-  /// Set an empty shape to the result of extrusion
-  void clearResult();
 };
 
 #endif