- // Getting faces.
- ListOfShape aFacesList;
- AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
- for(int anIndex = 0; anIndex < aFacesSelectionList->size(); anIndex++) {
- AttributeSelectionPtr aFaceSel = aFacesSelectionList->value(anIndex);
- std::shared_ptr<GeomAPI_Shape> aFaceShape = aFaceSel->value();
- if(aFaceShape.get() && !aFaceShape->isNull()) { // Getting face.
- aFacesList.push_back(aFaceShape);
- } else { // This may be the whole sketch result selected, check and get faces.
- 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);
- return;
- }
- ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
- if(!aConstruction.get()) {
- static const std::string aFaceError = "Can not find basis for extrusion";
- setError(aFaceError);
- return;
- }
- int aFacesNum = aConstruction->facesNum();
- for(int aFaceIndex = 0; aFaceIndex < aFacesNum || aFacesNum == -1; aFaceIndex++) {
- aFaceShape = std::dynamic_pointer_cast<GeomAPI_Shape>(aConstruction->face(aFaceIndex));
- aFacesList.push_back(aFaceShape);
- }
- }
+ ListOfShape aBaseShapesList, aBoundaryShapes;
+ ListOfMakeShape aMakeShapesList;
+
+ // Make extrusions.
+ if(!makeExtrusions(aBaseShapesList, aBoundaryShapes, aMakeShapesList)) {
+ return;
+ }
+
+ // Store results.
+ int aResultIndex = 0;
+ ListOfShape::const_iterator aBaseIt = aBaseShapesList.cbegin();
+ ListOfMakeShape::const_iterator anAlgoIt = aMakeShapesList.cbegin();
+ for(; aBaseIt != aBaseShapesList.cend() && anAlgoIt != aMakeShapesList.cend();
+ ++aBaseIt, ++anAlgoIt) {
+ if (aBoundaryShapes.empty())
+ storeResult(*aBaseIt, *anAlgoIt, aResultIndex++);
+ else
+ storeResultWithBoundaries(*aBaseIt, aBoundaryShapes, *anAlgoIt, aResultIndex++);