1 // Copyright (C) 2018-20xx CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef FeaturesPlugin_Measurement_H_
22 #define FeaturesPlugin_Measurement_H_
24 #include "FeaturesPlugin.h"
25 #include <ModelAPI_Feature.h>
27 /// \class FeaturesPlugin_Measurement
29 /// \brief Feature for calculation metrics.
31 /// Supported following metrics:
33 /// * distance between shapes,
34 /// * radius of arc or cylindrical faces,
35 /// * angle between edges.
36 class FeaturesPlugin_Measurement : public ModelAPI_Feature
40 inline static const std::string& ID()
42 static const std::string MY_ID("Measurement");
46 /// \return the kind of a feature.
47 virtual const std::string& getKind()
52 /// Attribute name for measurement method.
53 inline static const std::string& MEASURE_KIND()
55 static const std::string MY_MEASURE_KIND_ID("MeasureKind");
56 return MY_MEASURE_KIND_ID;
59 /// Attribute name for length measure.
60 inline static const std::string& MEASURE_LENGTH()
62 static const std::string MY_MEASURE_ID("Length");
66 /// Attribute name for distance measure.
67 inline static const std::string& MEASURE_DISTANCE()
69 static const std::string MY_MEASURE_ID("Distance");
73 /// Attribute name for radius measure.
74 inline static const std::string& MEASURE_RADIUS()
76 static const std::string MY_MEASURE_ID("Radius");
80 /// Attribute name for angle measure.
81 inline static const std::string& MEASURE_ANGLE()
83 static const std::string MY_MEASURE_ID("Angle");
87 /// Attribute name for angle measurement by 3 points.
88 inline static const std::string& MEASURE_ANGLE_POINTS()
90 static const std::string MY_MEASURE_ID("AngleBy3Points");
95 /// Attribute name of edge selected for length calculation.
96 inline static const std::string& EDGE_FOR_LENGTH_ID()
98 static const std::string MY_EDGE_FOR_LENGTH_ID("edge_for_length");
99 return MY_EDGE_FOR_LENGTH_ID;
102 /// Attribute name of first shape selected for distance calculation.
103 inline static const std::string& DISTANCE_FROM_OBJECT_ID()
105 static const std::string MY_DISTANCE_FROM_OBJECT_ID("distance_from");
106 return MY_DISTANCE_FROM_OBJECT_ID;
109 /// Attribute name of second shape selected for distance calculation.
110 inline static const std::string& DISTANCE_TO_OBJECT_ID()
112 static const std::string MY_DISTANCE_TO_OBJECT_ID("distance_to");
113 return MY_DISTANCE_TO_OBJECT_ID;
116 // Attribute name of edge or face selected to calculate radius.
117 inline static const std::string& CIRCULAR_OBJECT_ID()
119 static const std::string MY_CIRCULAR_OBJECT_ID("circular");
120 return MY_CIRCULAR_OBJECT_ID;
123 /// Attribute name of first edge selected for angle calculation.
124 inline static const std::string& ANGLE_FROM_EDGE_ID()
126 static const std::string MY_ANGLE_FROM_EDGE_ID("angle_from");
127 return MY_ANGLE_FROM_EDGE_ID;
130 /// Attribute name of second shape selected for angle calculation.
131 inline static const std::string& ANGLE_TO_EDGE_ID()
133 static const std::string MY_ANGLE_TO_EDGE_ID("angle_to");
134 return MY_ANGLE_TO_EDGE_ID;
137 /// Attribute name of first point selected for angle calculation.
138 inline static const std::string& ANGLE_POINT1_ID()
140 static const std::string MY_ANGLE_POINT1_ID("angle_point_1");
141 return MY_ANGLE_POINT1_ID;
144 /// Attribute name of second point (apex) selected for angle calculation.
145 inline static const std::string& ANGLE_POINT2_ID()
147 static const std::string MY_ANGLE_POINT2_ID("angle_point_2");
148 return MY_ANGLE_POINT2_ID;
151 /// Attribute name of third point selected for angle calculation.
152 inline static const std::string& ANGLE_POINT3_ID()
154 static const std::string MY_ANGLE_POINT3_ID("angle_point_3");
155 return MY_ANGLE_POINT3_ID;
158 /// Attribute name for result.
159 inline static const std::string& RESULT_ID()
161 static const std::string MY_RESULT_ID("result");
165 /// Attribute name for values of result.
166 inline static const std::string& RESULT_VALUES_ID()
168 static const std::string MY_RESULT_VALUES_ID("result_values");
169 return MY_RESULT_VALUES_ID;
172 /// Creates a new part document if needed
173 FEATURESPLUGIN_EXPORT virtual void execute();
175 /// Request for initialization of data model of the feature: adding all attributes
176 FEATURESPLUGIN_EXPORT virtual void initAttributes();
178 /// Called on change of any argument-attribute of this object
179 /// \param theID identifier of changed attribute
180 FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
182 /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true.
183 virtual bool isMacro() const { return true; }
185 /// Use plugin manager for features creation
186 FeaturesPlugin_Measurement();
189 /// Compute length of the edge
190 void computeLength();
191 /// Compute minimal distance between pair of shapes
192 void computeDistance();
193 /// Compute radius of circular edge or cylindrical face
194 void computeRadius();
195 /// Compute angle(s) between pair of edges if they are intersected
197 /// Compute angle by three points
198 void computeAngleByPoints();