X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Extrusion.cpp;h=1decb449c2ebb77ed1bdd4a67ffa1312a507d4b1;hb=48a4bd38c2b9d1b6b51ebca992a5eab30e85d99b;hp=f8a6bfc55e0c7388efc47f4f94a3b43c1e3ebdbb;hpb=5352bbb1915f98d1f02b1cb953a2de19b286a28c;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index f8a6bfc55..1decb449c 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); @@ -184,7 +181,7 @@ void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Prism& theFeature, if(theBasis->isEqual(theContext)) theResultBody->store(theFeature.shape()); else - theResultBody->storeGenerated(theContext, theFeature.shape()); + theResultBody->storeGenerated(theBasis, theFeature.shape()); GeomAPI_DataMapOfShapeShape* aSubShapes = new GeomAPI_DataMapOfShapeShape(); theFeature.mapOfShapes(*aSubShapes); @@ -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); -}