#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
+#include <GeomAPI_ShapeIterator.h>
//=================================================================================================
FeaturesPlugin_Revolution::FeaturesPlugin_Revolution()
// Getting base shapes.
getBaseShapes(theBaseShapes);
- //Getting axis.
- std::shared_ptr<GeomAPI_Ax1> anAxis;
- std::shared_ptr<GeomAPI_Edge> anEdge;
+ // Getting axis.
+ static const std::string aSelectionError = "Error: The axis shape selection is bad.";
AttributeSelectionPtr aSelection = selection(AXIS_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()));
+ GeomShapePtr aShape = aSelection->value();
+ if (!aShape.get()) {
+ if (aSelection->context().get()) {
+ aShape = aSelection->context()->shape();
+ }
+ }
+ if (!aShape.get()) {
+ setError(aSelectionError);
+ return false;
+ }
+
+ GeomEdgePtr anEdge;
+ if (aShape->isEdge())
+ {
+ anEdge = aShape->edge();
+ }
+ else if (aShape->isCompound())
+ {
+ GeomAPI_ShapeIterator anIt(aShape);
+ anEdge = anIt.current()->edge();
}
+ else
+ {
+ setError(aSelectionError);
+ return false;
+ }
+
+ std::shared_ptr<GeomAPI_Ax1> anAxis;
if(anEdge.get()) {
if(anEdge->isLine()) {
anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
if(!aToShape.get() && aSelection->context().get()) {
aToShape = aSelection->context()->shape();
}
+ if (aToShape->isCompound()) {
+ GeomAPI_ShapeIterator anIt(aToShape);
+ aToShape = anIt.current();
+ }
}
aSelection = selection(FROM_OBJECT_ID());
if(aSelection.get()) {
if(!aFromShape.get() && aSelection->context().get()) {
aFromShape = aSelection->context()->shape();
}
+ if (aFromShape->isCompound()) {
+ GeomAPI_ShapeIterator anIt(aFromShape);
+ aFromShape = anIt.current();
+ }
}
}