From: dbv Date: Thu, 14 Jul 2016 15:03:38 +0000 (+0300) Subject: Issue #1649: Added options to create plane by rotation around axis; X-Git-Tag: V_2.5.0~190 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b663f22dc23f1e64dbcdfdcea51b5fe67e6797b6;p=modules%2Fshaper.git Issue #1649: Added options to create plane by rotation around axis; --- diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp index 368bc3236..ff3030055 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp @@ -9,9 +9,12 @@ #include #include +#include #include +#include #include +#include #include #include #include @@ -65,6 +68,8 @@ void ConstructionPlugin_Plane::initAttributes() 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()); } //================================================================================================== @@ -85,6 +90,8 @@ void ConstructionPlugin_Plane::execute() aShape = createByDistanceFromOther(); } else if(aCreationMethodOption == CREATION_METHOD_BY_COINCIDENT_TO_POINT()) { aShape = createByCoincidentPoint(); + } else if(aCreationMethodOption == CREATION_METHOD_BY_ROTATION()) { + aShape = createByRotation(); } } @@ -272,6 +279,41 @@ std::shared_ptr ConstructionPlugin_Plane::createByCoincidentPoint return makeRectangularFace(aFace, aNewPln); } +//================================================================================================== +std::shared_ptr ConstructionPlugin_Plane::createByRotation() +{ + // Get face. + AttributeSelectionPtr aFaceSelection = selection(PLANE()); + GeomShapePtr aFaceShape = aFaceSelection->value(); + if(!aFaceShape.get()) { + aFaceShape = aFaceSelection->context()->shape(); + } + std::shared_ptr 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 anEdge(new GeomAPI_Edge(anAxisShape)); + + std::shared_ptr anAxis = std::shared_ptr(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 aRes(new GeomAPI_Face(aRotationAlgo.shape())); + std::shared_ptr aNewPln = aRes->getPlane(); + + aRes = makeRectangularFace(aRes, aNewPln); + + return aRes; +} + //================================================================================================== GeomShapePtr faceByThreeVertices(const std::shared_ptr theV1, const std::shared_ptr theV2, diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.h b/src/ConstructionPlugin/ConstructionPlugin_Plane.h index d92f00811..eb2ae37c4 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plane.h +++ b/src/ConstructionPlugin/ConstructionPlugin_Plane.h @@ -166,6 +166,20 @@ public: 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() { @@ -213,6 +227,7 @@ protected: std::shared_ptr createByThreePoints(); std::shared_ptr createByLineAndPoint(); std::shared_ptr createByCoincidentPoint(); + std::shared_ptr createByRotation(); /// Creates a new plane by copy of face plane with translation along the normal /// to the specified distance. std::shared_ptr createByDistanceFromOther(); diff --git a/src/ConstructionPlugin/icons/angle.png b/src/ConstructionPlugin/icons/angle.png new file mode 100644 index 000000000..e401acd67 Binary files /dev/null and b/src/ConstructionPlugin/icons/angle.png differ diff --git a/src/ConstructionPlugin/plane_widget.xml b/src/ConstructionPlugin/plane_widget.xml index 6c8e2f966..4162ebfdd 100644 --- a/src/ConstructionPlugin/plane_widget.xml +++ b/src/ConstructionPlugin/plane_widget.xml @@ -85,6 +85,18 @@ title="By rotation" tooltip="Plane by rotation around axis." icon="icons/Construction/plane_by_rotation_32x32.png"> + + + +