#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
-#include <GeomAPI_ShapeIterator.h>
#include <GeomAPI_Trsf.h>
#include <FeaturesPlugin_Tools.h>
}
//Getting axis.
- static const std::string aSelectionError = "Error: The axis shape selection is bad.";
- AttributeSelectionPtr anObjRef = selection(AXIS_OBJECT_ID());
- GeomShapePtr aShape = anObjRef->value();
- if (!aShape.get()) {
- if (anObjRef->context().get()) {
- aShape = anObjRef->context()->shape();
- }
- }
- if (!aShape.get()) {
- setError(aSelectionError);
- return;
+ std::shared_ptr<GeomAPI_Ax1> anAxis;
+ std::shared_ptr<GeomAPI_Edge> anEdge;
+ std::shared_ptr<ModelAPI_AttributeSelection> anObjRef =
+ selection(FeaturesPlugin_Rotation::AXIS_OBJECT_ID());
+ if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->value()));
+ } else if (anObjRef && !anObjRef->value() && anObjRef->context() &&
+ anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->context()->shape()));
}
-
- GeomEdgePtr anEdge;
- if (aShape->isEdge())
- {
- anEdge = aShape->edge();
- }
- else if (aShape->isCompound())
- {
- GeomAPI_ShapeIterator anIt(aShape);
- anEdge = anIt.current()->edge();
+ if(anEdge) {
+ anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
+ anEdge->line()->direction()));
}
- else
- {
- setError(aSelectionError);
- return;
- }
-
- if (!anEdge.get())
- {
- setError(aSelectionError);
- return;
- }
-
- std::shared_ptr<GeomAPI_Ax1> anAxis (new GeomAPI_Ax1(anEdge->line()->location(),
- anEdge->line()->direction()));
// Getting angle.
double anAngle = real(FeaturesPlugin_Rotation::ANGLE_ID())->value();