1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ConstructionPlugin_Plane.h
4 // Created: 12 Dec 2014
5 // Author: Vitaly Smetannikov
7 #ifndef ConstructionPlugin_Plane_H
8 #define ConstructionPlugin_Plane_H
10 #include "ConstructionPlugin.h"
12 #include <ModelAPI_Feature.h>
13 #include <ModelAPI_Result.h>
14 #include <GeomAPI_ICustomPrs.h>
16 /// \class ConstructionPlugin_Plane
18 /// \brief Feature for creation of the new planar surface in PartSet.
19 class ConstructionPlugin_Plane: public ModelAPI_Feature, public GeomAPI_ICustomPrs
22 /// \return the kind of a feature.
23 CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
25 static std::string MY_KIND = ConstructionPlugin_Plane::ID();
29 /// Default color for a plane.
30 inline static const std::string& DEFAULT_COLOR()
32 static const std::string CONSTRUCTION_PLANE_COLOR("150,150,180");
33 return CONSTRUCTION_PLANE_COLOR;
37 inline static const std::string& ID()
39 static const std::string CONSTRUCTION_PLANE_KIND("Plane");
40 return CONSTRUCTION_PLANE_KIND;
43 /// Attribute name for creation method.
44 inline static const std::string& CREATION_METHOD()
46 static const std::string MY_CREATION_METHOD_ID("creation_method");
47 return MY_CREATION_METHOD_ID;
50 /// Attribute name for creation method.
51 inline static const std::string& CREATION_METHOD_BY_GENERAL_EQUATION()
53 static const std::string MY_CREATION_METHOD_ID("by_general_equation");
54 return MY_CREATION_METHOD_ID;
57 /// Attribute name for creation method.
58 inline static const std::string& CREATION_METHOD_BY_THREE_POINTS()
60 static const std::string MY_CREATION_METHOD_ID("by_three_points");
61 return MY_CREATION_METHOD_ID;
64 /// Attribute name for creation method.
65 inline static const std::string& CREATION_METHOD_BY_LINE_AND_POINT()
67 static const std::string MY_CREATION_METHOD_ID("by_line_and_point");
68 return MY_CREATION_METHOD_ID;
71 /// Attribute name for creation method.
72 inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE()
74 static const std::string MY_CREATION_METHOD_ID("by_other_plane");
75 return MY_CREATION_METHOD_ID;
78 /// Attribute name for creation method.
79 inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE_OPTION()
81 static const std::string MY_CREATION_METHOD_ID("by_other_plane_option");
82 return MY_CREATION_METHOD_ID;
85 /// Attribute name for creation method.
86 inline static const std::string& CREATION_METHOD_BY_DISTANCE_FROM_OTHER()
88 static const std::string MY_CREATION_METHOD_ID("by_distance_from_other");
89 return MY_CREATION_METHOD_ID;
92 /// Attribute name for creation method.
93 inline static const std::string& CREATION_METHOD_BY_COINCIDENT_TO_POINT()
95 static const std::string MY_CREATION_METHOD_ID("by_coincident_to_point");
96 return MY_CREATION_METHOD_ID;
99 /// Attribute name for creation method.
100 inline static const std::string& CREATION_METHOD_BY_ROTATION()
102 static const std::string MY_CREATION_METHOD_ID("by_rotation");
103 return MY_CREATION_METHOD_ID;
106 /// Attribute name for creation method.
107 inline static const std::string& CREATION_METHOD_BY_TWO_PARALLEL_PLANES()
109 static const std::string MY_CREATION_METHOD_ID("by_two_parallel_planes");
110 return MY_CREATION_METHOD_ID;
113 /// Attribute name for first point.
114 inline static const std::string& POINT1()
116 static const std::string ATTR_ID("point1");
120 /// Attribute name for second point.
121 inline static const std::string& POINT2()
123 static const std::string ATTR_ID("point2");
127 /// Attribute name for third point.
128 inline static const std::string& POINT3()
130 static const std::string ATTR_ID("point3");
134 /// Attribute name for line.
135 inline static const std::string& LINE()
137 static const std::string ATTR_ID("line");
141 /// Attribute name for point.
142 inline static const std::string& POINT()
144 static const std::string ATTR_ID("point");
148 /// Attribute name for selected plane.
149 inline static const std::string& PLANE()
151 static const std::string ATTR_ID("plane");
155 /// Attribute name for distance.
156 inline static const std::string& DISTANCE()
158 static const std::string ATTR_ID("distance");
162 /// Attribute name for coincident point.
163 inline static const std::string& COINCIDENT_POINT()
165 static const std::string ATTR_ID("coincident_point");
169 /// Attribute name for a parameter for the general equation of a plane (ax+by+cz+d=0)
170 inline static const std::string& A()
172 static const std::string ATTR_ID("A");
175 /// Attribute name for b parameter for the general equation of a plane (ax+by+cz+d=0)
176 inline static const std::string& B()
178 static const std::string ATTR_ID("B");
181 /// Attribute name for c parameter for the general equation of a plane (ax+by+cz+d=0)
182 inline static const std::string& C()
184 static const std::string ATTR_ID("C");
187 /// Attribute name for d parameter for the general equation of a plane (ax+by+cz+d=0)
188 inline static const std::string& D()
190 static const std::string ATTR_ID("D");
194 /// Creates a new part document if needed
195 CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
197 /// Request for initialization of data model of the feature: adding all attributes
198 CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
200 /// Construction result is always recomputed on the fly
201 CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
203 /// Use plugin manager for features creation
204 ConstructionPlugin_Plane();
206 /// Customize presentation of the feature
207 virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
208 std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
211 /// Creates a new plane by general equation.
212 std::shared_ptr<GeomAPI_Shape> createByGeneralEquation();
213 std::shared_ptr<GeomAPI_Shape> createByThreePoints();
214 std::shared_ptr<GeomAPI_Shape> createByLineAndPoint();
215 std::shared_ptr<GeomAPI_Shape> createByCoincidentPoint();
216 /// Creates a new plane by copy of face plane with translation along the normal
217 /// to the specified distance.
218 std::shared_ptr<GeomAPI_Shape> createByDistanceFromOther();