1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
3 // File: ConstructionPlugin_Axis.h
4 // Created: 12 Dec 2014
5 // Author: Vitaly Smetannikov
7 // Modified by CEA (delegation to Alyotech) : 29 Mar 2016
9 #ifndef ConstructionPlugin_Axis_H
10 #define ConstructionPlugin_Axis_H
12 #include "ConstructionPlugin.h"
13 #include <ModelAPI_Feature.h>
14 #include <ModelAPI_Result.h>
15 #include <GeomAPI_ICustomPrs.h>
17 /**\class ConstructionPlugin_Axis
19 * \brief Feature for creation of the new axis in PartSet.
21 class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomPrs
24 /// Returns the kind of a feature
25 CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
27 static std::string MY_KIND = ConstructionPlugin_Axis::ID();
32 inline static const std::string& ID()
34 static const std::string CONSTRUCTION_AXIS_KIND("Axis");
35 return CONSTRUCTION_AXIS_KIND;
38 /// attribute name for first point
39 inline static const std::string& METHOD()
41 static const std::string METHOD_ATTR("CreationMethod");
45 /// Attribute name for creation method.
46 inline static const std::string& CREATION_METHOD_BY_LINE()
48 static const std::string METHOD_ATTR("by_line");
52 /// Attribute name for creation method.
53 inline static const std::string& CREATION_METHOD_BY_PLANE_AND_POINT()
55 static const std::string METHOD_ATTR("by_plane_and_point");
59 /// Attribute name for creation method.
60 inline static const std::string& CREATION_METHOD_BY_TWO_PLANES()
62 static const std::string METHOD_ATTR("by_two_planes");
66 /// attribute name for first point
67 inline static const std::string& POINT_FIRST()
69 static const std::string POINT_ATTR_FIRST("FirstPoint");
70 return POINT_ATTR_FIRST;
72 /// attribute name for second point
73 inline static const std::string& POINT_SECOND()
75 static const std::string POINT_ATTR_SECOND("SecondPoint");
76 return POINT_ATTR_SECOND;
78 /// attribute name for second point
79 inline static const std::string& CYLINDRICAL_FACE()
81 static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
82 return CYLINDRICAL_FACE_ATTR;
84 /// attribute name for the X dimension
85 inline static const std::string& DX()
87 static const std::string DX_ATTR("DX");
90 /// attribute name for the Y dimension
91 inline static const std::string& DY()
93 static const std::string DY_ATTR("DY");
96 /// attribute name for the Z dimension
97 inline static const std::string& DZ()
99 static const std::string DZ_ATTR("DZ");
103 /// attribute name for X direction
104 inline static const std::string& X_DIRECTION()
106 static const std::string ATTR_X_DIRECTION("X_Direction");
107 return ATTR_X_DIRECTION;
110 /// attribute name for Y direction
111 inline static const std::string& Y_DIRECTION()
113 static const std::string ATTR_Y_DIRECTION("Y_Direction");
114 return ATTR_Y_DIRECTION;
117 /// attribute name for Y direction
118 inline static const std::string& Z_DIRECTION()
120 static const std::string ATTR_Z_DIRECTION("Z_Direction");
121 return ATTR_Z_DIRECTION;
124 /// Attribute name for line.
125 inline static const std::string& LINE()
127 static const std::string ATTR_ID("line");
131 /// Attribute name for plane.
132 inline static const std::string& PLANE()
134 static const std::string ATTR_ID("plane");
138 /// Attribute name for point.
139 inline static const std::string& POINT()
141 static const std::string ATTR_ID("point");
145 /// Attribute name for plane 1.
146 inline static const std::string& PLANE1()
148 static const std::string ATTR_ID("plane1");
152 /// Attribute name for use offset for plane 1.
153 inline static const std::string& USE_OFFSET1()
155 static const std::string ATTR_ID("use_offset1");
159 /// Attribute name for offset for plane 1.
160 inline static const std::string& OFFSET1()
162 static const std::string ATTR_ID("offset1");
166 /// Attribute name for reverse offset for plane 1.
167 inline static const std::string& REVERSE_OFFSET1()
169 static const std::string ATTR_ID("reverse_offset1");
173 /// Attribute name for plane 2.
174 inline static const std::string& PLANE2()
176 static const std::string ATTR_ID("plane2");
180 /// Attribute name for use offset for plane 2.
181 inline static const std::string& USE_OFFSET2()
183 static const std::string ATTR_ID("use_offset2");
187 /// Attribute name for offset for plane 2.
188 inline static const std::string& OFFSET2()
190 static const std::string ATTR_ID("offset2");
194 /// Attribute name for reverse offset for plane 2.
195 inline static const std::string& REVERSE_OFFSET2()
197 static const std::string ATTR_ID("reverse_offset2");
201 /// Returns a minimal length for axis
202 inline static const double MINIMAL_LENGTH() { return 1.e-5; }
204 /// Creates a new part document if needed
205 CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
207 /// Request for initialization of data model of the feature: adding all attributes
208 CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
210 /// Construction result is allways recomuted on the fly
211 CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
213 /// Use plugin manager for features creation
214 ConstructionPlugin_Axis();
216 /// Customize presentation of the feature
217 virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
218 std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
221 /// Creates a new axis by two defined points
222 void createAxisByTwoPoints();
223 /// Creates a new axis using three dimensions
224 void createAxisByDimensions();
225 /// Creates a new axis as copy of cylindrical face axis
226 void createAxisByCylindricalFace();
227 /// Creates a new axis by point and direction
228 void createAxisByPointAndDirection();
229 void createAxisByLine();
230 void createAxisByPlaneAndPoint();
231 void createAxisByTwoPlanes();