- AttributeSelectionListPtr aFaceRefs = selectionList(FeaturesPlugin_Extrusion::LIST_ID());
-
- // 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;
- }
- double aSize = real(FeaturesPlugin_Extrusion::SIZE_ID())->value();
- if (boolean(FeaturesPlugin_Extrusion::REVERSE_ID())->value())
- aSize = -aSize;
-
- 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;
+ 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++);
+ }
+
+ removeResults(aResultIndex);
+}
+
+//=================================================================================================
+bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
+ ListOfShape& theBoundaryShapes,
+ ListOfMakeShape& theMakeShapes)
+{
+ theMakeShapes.clear();
+
+ // Getting base shapes.
+ getBaseShapes(theBaseShapes);
+
+ //Getting direction.
+ std::shared_ptr<GeomAPI_Dir> aDir;
+ getDirection(aDir);
+
+ // Getting sizes.
+ double aToSize = 0.0;
+ double aFromSize = 0.0;
+ getSizes(aToSize, aFromSize);
+
+ // Getting bounding planes.
+ GeomShapePtr aToShape;
+ GeomShapePtr aFromShape;
+
+ if(string(CREATION_METHOD())->value() == CREATION_METHOD_BY_PLANES()) {
+ AttributeSelectionPtr 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();
+ }
+ if (aToShape.get() && aToShape->isCompound()) {
+ GeomAPI_ShapeIterator anIt(aToShape);
+ aToShape = anIt.current();