- // If bounding faces was not set creating them.
- 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);
-
- 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(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(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))));
- aBoundingFromShape = GeomAlgoAPI_FaceBuilder::planarFace(aFromPnt, aFromDir);
-
- std::shared_ptr<GeomAPI_Pnt> aToPnt(new GeomAPI_Pnt(aToLoc->xyz()->added(aBaseDir->xyz()->multiplied(aSign ? -aToSize : aToSize))));
- aBoundingToShape = GeomAlgoAPI_FaceBuilder::planarFace(aToPnt, aToDir);
-
- //GeomAlgoAPI_Extrusion aFeature(aFace, aFromSize);
- GeomAlgoAPI_Prism aFeature(aBaseShape, aBoundingFromShape, aBoundingToShape);
- if(!aFeature.isDone()) {
- static const std::string aFeatureError = "Extrusion algorithm failed";
- setError(aFeatureError);
- break;
+ // Getting bounding planes.
+ GeomShapePtr aToShape;
+ GeomShapePtr aFromShape;
+
+ if(string(CREATION_METHOD())->value() == CREATION_METHOD_BY_PLANES()) {
+ aSelection = selection(TO_OBJECT_ID());
+ if(aSelection.get()) {
+ aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(aSelection->value());
+ if(!aToShape.get() && aSelection->context().get()) {
+ aToShape = aSelection->context()->shape();