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_TWO_POINTS()
48 static const std::string METHOD_ATTR("AxisByPointsCase");
52 /// Attribute name for creation method.
53 inline static const std::string& CREATION_METHOD_BY_CYLINDRICAL_FACE()
55 static const std::string METHOD_ATTR("AxisByCylindricalFaceCase");
59 /// Attribute name for creation method.
60 inline static const std::string& CREATION_METHOD_BY_POINT_AND_DIRECTION()
62 static const std::string METHOD_ATTR("AxisByPointAndDirection");
66 /// Attribute name for creation method.
67 inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
69 static const std::string METHOD_ATTR("AxisByDimensionsCase");
73 /// Attribute name for creation method.
74 inline static const std::string& CREATION_METHOD_BY_LINE()
76 static const std::string METHOD_ATTR("by_line");
80 /// Attribute name for creation method.
81 inline static const std::string& CREATION_METHOD_BY_PLANE_AND_POINT()
83 static const std::string METHOD_ATTR("by_plane_and_point");
87 /// Attribute name for creation method.
88 inline static const std::string& CREATION_METHOD_BY_TWO_PLANES()
90 static const std::string METHOD_ATTR("by_two_planes");
94 /// attribute name for first point
95 inline static const std::string& POINT_FIRST()
97 static const std::string POINT_ATTR_FIRST("FirstPoint");
98 return POINT_ATTR_FIRST;
100 /// attribute name for second point
101 inline static const std::string& POINT_SECOND()
103 static const std::string POINT_ATTR_SECOND("SecondPoint");
104 return POINT_ATTR_SECOND;
106 /// attribute name for second point
107 inline static const std::string& CYLINDRICAL_FACE()
109 static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
110 return CYLINDRICAL_FACE_ATTR;
112 /// attribute name for the X dimension
113 inline static const std::string& DX()
115 static const std::string DX_ATTR("DX");
118 /// attribute name for the Y dimension
119 inline static const std::string& DY()
121 static const std::string DY_ATTR("DY");
124 /// attribute name for the Z dimension
125 inline static const std::string& DZ()
127 static const std::string DZ_ATTR("DZ");
131 /// attribute name for X direction
132 inline static const std::string& X_DIRECTION()
134 static const std::string ATTR_X_DIRECTION("X_Direction");
135 return ATTR_X_DIRECTION;
138 /// attribute name for Y direction
139 inline static const std::string& Y_DIRECTION()
141 static const std::string ATTR_Y_DIRECTION("Y_Direction");
142 return ATTR_Y_DIRECTION;
145 /// attribute name for Y direction
146 inline static const std::string& Z_DIRECTION()
148 static const std::string ATTR_Z_DIRECTION("Z_Direction");
149 return ATTR_Z_DIRECTION;
152 /// Attribute name for line.
153 inline static const std::string& LINE()
155 static const std::string ATTR_ID("line");
159 /// Attribute name for plane.
160 inline static const std::string& PLANE()
162 static const std::string ATTR_ID("plane");
166 /// Attribute name for point.
167 inline static const std::string& POINT()
169 static const std::string ATTR_ID("point");
173 /// Attribute name for plane 1.
174 inline static const std::string& PLANE1()
176 static const std::string ATTR_ID("plane1");
180 /// Attribute name for use offset for plane 1.
181 inline static const std::string& USE_OFFSET1()
183 static const std::string ATTR_ID("use_offset1");
187 /// Attribute name for offset for plane 1.
188 inline static const std::string& OFFSET1()
190 static const std::string ATTR_ID("offset1");
194 /// Attribute name for reverse offset for plane 1.
195 inline static const std::string& REVERSE_OFFSET1()
197 static const std::string ATTR_ID("reverse_offset1");
201 /// Attribute name for plane 2.
202 inline static const std::string& PLANE2()
204 static const std::string ATTR_ID("plane2");
208 /// Attribute name for use offset for plane 2.
209 inline static const std::string& USE_OFFSET2()
211 static const std::string ATTR_ID("use_offset2");
215 /// Attribute name for offset for plane 2.
216 inline static const std::string& OFFSET2()
218 static const std::string ATTR_ID("offset2");
222 /// Attribute name for reverse offset for plane 2.
223 inline static const std::string& REVERSE_OFFSET2()
225 static const std::string ATTR_ID("reverse_offset2");
229 /// Returns a minimal length for axis
230 inline static const double MINIMAL_LENGTH() { return 1.e-5; }
232 /// Creates a new part document if needed
233 CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
235 /// Request for initialization of data model of the feature: adding all attributes
236 CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
238 /// Construction result is allways recomuted on the fly
239 CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
241 /// Use plugin manager for features creation
242 ConstructionPlugin_Axis();
244 /// Customize presentation of the feature
245 virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
246 std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
249 /// Creates a new axis by two defined points
250 void createAxisByTwoPoints();
251 /// Creates a new axis using three dimensions
252 void createAxisByDimensions();
253 /// Creates a new axis as copy of cylindrical face axis
254 void createAxisByCylindricalFace();
255 /// Creates a new axis by point and direction
256 void createAxisByPointAndDirection();
257 void createAxisByLine();
258 void createAxisByPlaneAndPoint();
259 void createAxisByTwoPlanes();