+ }
+
+ // 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) {
+ storeResult(*aBaseIt, *anAlgoIt, aResultIndex++);
+ }
+
+ removeResults(aResultIndex);
+}
+
+//=================================================================================================
+bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
+ ListOfMakeShape& theMakeShapes)
+{
+ theMakeShapes.clear();
+
+ // Getting base shapes.
+ getBaseShapes(theBaseShapes);
+
+ //Getting direction.
+ std::shared_ptr<GeomAPI_Dir> aDir;
+ std::shared_ptr<GeomAPI_Edge> anEdge;
+ AttributeSelectionPtr aSelection = selection(DIRECTION_OBJECT_ID());
+ if(aSelection.get() && aSelection->value().get() && aSelection->value()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aSelection->value()));
+ } else if(aSelection->context().get() &&
+ aSelection->context()->shape().get() &&
+ aSelection->context()->shape()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aSelection->context()->shape()));
+ }
+ if(anEdge.get()) {
+ if(anEdge->isLine()) {
+ aDir = anEdge->line()->direction();
+ }
+ }
+
+ // Getting sizes.
+ double aToSize = 0.0;
+ double aFromSize = 0.0;
+
+ if(string(CREATION_METHOD())->value() == CREATION_METHOD_BY_SIZES()) {
+ aToSize = real(TO_SIZE_ID())->value();
+ aFromSize = real(FROM_SIZE_ID())->value();
+ } else {
+ aToSize = real(TO_OFFSET_ID())->value();
+ aFromSize = real(FROM_OFFSET_ID())->value();
+ }
+
+ // 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();
+ }
+ }
+ aSelection = selection(FROM_OBJECT_ID());
+ if(aSelection.get()) {
+ aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(aSelection->value());
+ if(!aFromShape.get() && aSelection->context().get()) {
+ aFromShape = aSelection->context()->shape();
+ }
+ }
+ }
+
+ // Generating result for each base shape.
+ for(ListOfShape::const_iterator
+ anIter = theBaseShapes.cbegin(); anIter != theBaseShapes.cend(); anIter++) {
+ std::shared_ptr<GeomAPI_Shape> aBaseShape = *anIter;
+
+ std::shared_ptr<GeomAlgoAPI_Prism> aPrismAlgo(new GeomAlgoAPI_Prism(aBaseShape, aDir,
+ aToShape, aToSize,
+ aFromShape, aFromSize));
+ if(!isMakeShapeValid(aPrismAlgo)) {
+ return false;
+ }
+
+ theMakeShapes.push_back(aPrismAlgo);
+ }