From: dbv Date: Fri, 22 May 2015 16:57:13 +0000 (+0300) Subject: Extrusion fix X-Git-Tag: V_1.2.0~109 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ae8bd95146715024bc42cce9337b352e13717853;p=modules%2Fshaper.git Extrusion fix --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index f8a6bfc55..b5250e8c3 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -57,8 +57,8 @@ void FeaturesPlugin_Extrusion::execute() { AttributeSelectionListPtr aFaceRefs = selectionList(FeaturesPlugin_Extrusion::LIST_ID()); - std::shared_ptr aFromShape(new GeomAPI_Shape); - std::shared_ptr aToShape(new GeomAPI_Shape); + std::shared_ptr aFromShape; + std::shared_ptr aToShape; // Getting bounding planes. std::shared_ptr 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 aBaseFace(new GeomAPI_Face(aBaseShape)); - std::shared_ptr aBasePlane = aBaseFace->getPlane(); - std::shared_ptr aBaseDir = aBasePlane->direction(); - std::shared_ptr aBaseLoc = aBasePlane->location(); + std::shared_ptr aBaseFace(new GeomAPI_Face(aBaseShape)); + std::shared_ptr aBasePln = aBaseFace->getPlane(); + std::shared_ptr aBaseDir = aBasePln->direction(); + std::shared_ptr aBaseLoc = aBasePln->location(); + std::shared_ptr 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 aBoundingFromShape = aFromShape ? aFromShape : aBasePlane; + std::shared_ptr aBoundingToShape = aToShape ? aToShape : aBasePlane; // Moving bounding faces according to "from" and "to" sizes. - std::shared_ptr aFromFace(new GeomAPI_Face(aFromShape)); - std::shared_ptr aFromPlane = aFromFace->getPlane(); - std::shared_ptr aFromLoc = aFromPlane->location(); - std::shared_ptr aFromDir = aFromPlane->direction(); + std::shared_ptr aFromFace(new GeomAPI_Face(aBoundingFromShape)); + std::shared_ptr aFromPln = aFromFace->getPlane(); + std::shared_ptr aFromLoc = aFromPln->location(); + std::shared_ptr aFromDir = aFromPln->direction(); - std::shared_ptr aToFace(new GeomAPI_Face(aToShape)); - std::shared_ptr aToPlane = aToFace->getPlane(); - std::shared_ptr aToLoc = aToPlane->location(); - std::shared_ptr aToDir = aToPlane->direction(); + std::shared_ptr aToFace(new GeomAPI_Face(aBoundingToShape)); + std::shared_ptr aToPln = aToFace->getPlane(); + std::shared_ptr aToLoc = aToPln->location(); + std::shared_ptr aToDir = aToPln->direction(); bool aSign = aFromLoc->xyz()->dot(aBaseDir->xyz()) > aToLoc->xyz()->dot(aBaseDir->xyz()); std::shared_ptr 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 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 aResultBody = document()->createBody(data()); - std::shared_ptr anEmptyShape(new GeomAPI_Shape); - aResultBody->store(anEmptyShape); - setResult(aResultBody); -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h index 42c0dc1d6..3a97d81bb 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h @@ -7,12 +7,12 @@ #ifndef FeaturesPlugin_Extrusion_H_ #define FeaturesPlugin_Extrusion_H_ -#include "FeaturesPlugin.h" +#include #include -#include -#include #include -#include + +class GeomAPI_Shape; +class ModelAPI_ResultBody; /**\class FeaturesPlugin_Extrusion * \ingroup Plugins @@ -95,9 +95,6 @@ private: void LoadNamingDS(GeomAlgoAPI_Prism& theFeature, std::shared_ptr theResultBody, std::shared_ptr theBasis, std::shared_ptr theContext); - - /// Set an empty shape to the result of extrusion - void clearResult(); }; #endif