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");
88 /// Attribute name of edge selected for length calculation.
89 inline static const std::string& EDGE_FOR_LENGTH_ID()
91 static const std::string MY_EDGE_FOR_LENGTH_ID("edge_for_length");
92 return MY_EDGE_FOR_LENGTH_ID;
95 /// Attribute name of first shape selected for distance calculation.
96 inline static const std::string& DISTANCE_FROM_OBJECT_ID()
98 static const std::string MY_DISTANCE_FROM_OBJECT_ID("distance_from");
99 return MY_DISTANCE_FROM_OBJECT_ID;
102 /// Attribute name of second shape selected for distance calculation.
103 inline static const std::string& DISTANCE_TO_OBJECT_ID()
105 static const std::string MY_DISTANCE_TO_OBJECT_ID("distance_to");
106 return MY_DISTANCE_TO_OBJECT_ID;
109 // Attribute name of edge or face selected to calculate radius.
110 inline static const std::string& CIRCULAR_OBJECT_ID()
112 static const std::string MY_CIRCULAR_OBJECT_ID("circular");
113 return MY_CIRCULAR_OBJECT_ID;
116 /// Attribute name of first edge selected for angle calculation.
117 inline static const std::string& ANGLE_FROM_EDGE_ID()
119 static const std::string MY_ANGLE_FROM_EDGE_ID("angle_from");
120 return MY_ANGLE_FROM_EDGE_ID;
123 /// Attribute name of second shape selected for distance calculation.
124 inline static const std::string& ANGLE_TO_EDGE_ID()
126 static const std::string MY_ANGLE_TO_EDGE_ID("angle_to");
127 return MY_ANGLE_TO_EDGE_ID;
130 /// Attribute name for result.
131 inline static const std::string& RESULT_ID()
133 static const std::string MY_RESULT_ID("result");
137 /// Attribute name for values of result.
138 inline static const std::string& RESULT_VALUES_ID()
140 static const std::string MY_RESULT_VALUES_ID("result_values");
141 return MY_RESULT_VALUES_ID;
144 /// Creates a new part document if needed
145 FEATURESPLUGIN_EXPORT virtual void execute();
147 /// Request for initialization of data model of the feature: adding all attributes
148 FEATURESPLUGIN_EXPORT virtual void initAttributes();
150 /// Called on change of any argument-attribute of this object
151 /// \param theID identifier of changed attribute
152 FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
154 /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true.
155 virtual bool isMacro() const { return true; }
157 /// Use plugin manager for features creation
158 FeaturesPlugin_Measurement();
161 /// Compute length of the edge
162 void computeLength();
163 /// Compute minimal distance between pair of shapes
164 void computeDistance();
165 /// Compute radius of circular edge or cylindrical face
166 void computeRadius();
167 /// Compute angle(s) between pair of edges if they are intersected