- std::shared_ptr<GeomAPI_Shape> aToShape;
- std::shared_ptr<GeomAPI_Shape> aFromShape;
-
- if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
- anObjRef = selection(TO_OBJECT_ID());
- if(anObjRef.get() != NULL) {
- aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
- if(aToShape.get() == NULL && anObjRef->context().get() != NULL) {
- aToShape = anObjRef->context()->shape();
- }
- }
- anObjRef = selection(FROM_OBJECT_ID());
- if(anObjRef.get() != NULL) {
- aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
- if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
- aFromShape = anObjRef->context()->shape();
- }
- }
- }
-
- // for each selected face generate a result
- int anIndex = 0, aResultIndex = 0;
- for(; anIndex < aFaceRefs->size(); anIndex++) {
- std::shared_ptr<ModelAPI_AttributeSelection> aFaceRef = aFaceRefs->value(anIndex);
- ResultPtr aContextRes = aFaceRef->context();
- std::shared_ptr<GeomAPI_Shape> aContext = aContextRes->shape();
- if (!aContext.get()) {
- static const std::string aContextError = "The selection context is bad";
- setError(aContextError);
- break;
- }
-
- std::shared_ptr<GeomAPI_Shape> aValueFace = aFaceRef->value();
- int aFacesNum = -1; // this mean that "aFace" is used
- ResultConstructionPtr aConstruction =
- std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContextRes);
- if (!aValueFace.get()) { // this may be the whole sketch result selected, check and get faces
- if (aConstruction.get()) {
- aFacesNum = aConstruction->facesNum();
- } else {
- static const std::string aFaceError = "Can not find basis for extrusion";
- setError(aFaceError);
- break;
+ 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();