+ // Getting faces.
+ ListOfShape aFacesList;
+ AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
+ for(int anIndex = 0; anIndex < aFacesSelectionList->size(); anIndex++) {
+ std::shared_ptr<ModelAPI_AttributeSelection> aFaceSel = aFacesSelectionList->value(anIndex);
+ ResultPtr aContext = aFaceSel->context();
+ std::shared_ptr<GeomAPI_Shape> aContextShape = aContext->shape();
+ if(!aContextShape.get()) {
+ static const std::string aContextError = "The selection context is bad";
+ setError(aContextError);
+ break;
+ }
+
+ std::shared_ptr<GeomAPI_Shape> aFaceShape = aFaceSel->value();
+ int aFacesNum = -1; // this mean that "aFace" is used
+ ResultConstructionPtr aConstruction =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+ if(!aFaceShape.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;
+ }
+ }
+ for(int aFaceIndex = 0; aFaceIndex < aFacesNum || aFacesNum == -1; aFaceIndex++) {
+ std::shared_ptr<GeomAPI_Shape> aBaseShape;
+ if (aFacesNum == -1) {
+ if (!aFaceShape->isNull()) {
+ aFacesList.push_back(aFaceShape);
+ }
+ break;
+ } else {
+ aFaceShape = std::dynamic_pointer_cast<GeomAPI_Shape>(aConstruction->face(aFaceIndex));
+ aFacesList.push_back(aFaceShape);
+ }
+ }
+ }