#include <Config_PropManager.h>
#include <GeomAlgoAPI_FaceBuilder.h>
+#include <GeomAlgoAPI_Rotation.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAPI_Ax1.h>
#include <GeomAPI_Edge.h>
+#include <GeomAPI_Lin.h>
#include <GeomAPI_Pln.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Pnt2d.h>
data()->addAttribute(PLANE(), ModelAPI_AttributeSelection::typeId());
data()->addAttribute(DISTANCE(), ModelAPI_AttributeDouble::typeId());
data()->addAttribute(COINCIDENT_POINT(), ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(AXIS(), ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(ANGLE(), ModelAPI_AttributeDouble::typeId());
}
//==================================================================================================
aShape = createByDistanceFromOther();
} else if(aCreationMethodOption == CREATION_METHOD_BY_COINCIDENT_TO_POINT()) {
aShape = createByCoincidentPoint();
+ } else if(aCreationMethodOption == CREATION_METHOD_BY_ROTATION()) {
+ aShape = createByRotation();
}
}
return makeRectangularFace(aFace, aNewPln);
}
+//==================================================================================================
+std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByRotation()
+{
+ // Get face.
+ AttributeSelectionPtr aFaceSelection = selection(PLANE());
+ GeomShapePtr aFaceShape = aFaceSelection->value();
+ if(!aFaceShape.get()) {
+ aFaceShape = aFaceSelection->context()->shape();
+ }
+ std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aFaceShape));
+
+ // Get axis.
+ AttributeSelectionPtr anAxisSelection = selection(AXIS());
+ GeomShapePtr anAxisShape = anAxisSelection->value();
+ if(!anAxisShape.get()) {
+ anAxisShape = anAxisSelection->context()->shape();
+ }
+ std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(anAxisShape));
+
+ std::shared_ptr<GeomAPI_Ax1> anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
+ anEdge->line()->direction()));
+
+ // Getting angle.
+ double anAngle = real(ANGLE())->value();
+
+ GeomAlgoAPI_Rotation aRotationAlgo(aFace, anAxis, anAngle);
+
+ std::shared_ptr<GeomAPI_Face> aRes(new GeomAPI_Face(aRotationAlgo.shape()));
+ std::shared_ptr<GeomAPI_Pln> aNewPln = aRes->getPlane();
+
+ aRes = makeRectangularFace(aRes, aNewPln);
+
+ return aRes;
+}
+
//==================================================================================================
GeomShapePtr faceByThreeVertices(const std::shared_ptr<GeomAPI_Vertex> theV1,
const std::shared_ptr<GeomAPI_Vertex> theV2,
return ATTR_ID;
}
+ /// Attribute name for axis.
+ inline static const std::string& AXIS()
+ {
+ static const std::string ATTR_ID("axis");
+ return ATTR_ID;
+ }
+
+ /// Attribute name for angle.
+ inline static const std::string& ANGLE()
+ {
+ static const std::string ATTR_ID("angle");
+ return ATTR_ID;
+ }
+
/// Attribute name for a parameter for the general equation of a plane (ax+by+cz+d=0)
inline static const std::string& A()
{
std::shared_ptr<GeomAPI_Shape> createByThreePoints();
std::shared_ptr<GeomAPI_Shape> createByLineAndPoint();
std::shared_ptr<GeomAPI_Shape> createByCoincidentPoint();
+ std::shared_ptr<GeomAPI_Shape> createByRotation();
/// Creates a new plane by copy of face plane with translation along the normal
/// to the specified distance.
std::shared_ptr<GeomAPI_Shape> createByDistanceFromOther();