]> SALOME platform Git repositories - modules/shaper.git/blob - src/FeaturesPlugin/FeaturesPlugin_Measurement.h
Salome HOME
Merge remote-tracking branch 'remotes/origin/2018_Lot1_Tasks'
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Measurement.h
1 // Copyright (C) 2018-20xx  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef FeaturesPlugin_Measurement_H_
22 #define FeaturesPlugin_Measurement_H_
23
24 #include "FeaturesPlugin.h"
25 #include <ModelAPI_Feature.h>
26
27 /// \class FeaturesPlugin_Measurement
28 /// \ingroup Plugins
29 /// \brief Feature for calculation metrics.
30 ///
31 /// Supported following metrics:
32 /// * length of edge,
33 /// * distance between shapes,
34 /// * radius of arc or cylindrical faces,
35 /// * angle between edges.
36 class FeaturesPlugin_Measurement : public ModelAPI_Feature
37 {
38 public:
39   /// Feature kind.
40   inline static const std::string& ID()
41   {
42     static const std::string MY_ID("Measurement");
43     return MY_ID;
44   }
45
46   /// \return the kind of a feature.
47   virtual const std::string& getKind()
48   {
49     return ID();
50   }
51
52   /// Attribute name for measurement method.
53   inline static const std::string& MEASURE_KIND()
54   {
55     static const std::string MY_MEASURE_KIND_ID("MeasureKind");
56     return MY_MEASURE_KIND_ID;
57   }
58
59   /// Attribute name for length measure.
60   inline static const std::string& MEASURE_LENGTH()
61   {
62     static const std::string MY_MEASURE_ID("Length");
63     return MY_MEASURE_ID;
64   }
65
66   /// Attribute name for distance measure.
67   inline static const std::string& MEASURE_DISTANCE()
68   {
69     static const std::string MY_MEASURE_ID("Distance");
70     return MY_MEASURE_ID;
71   }
72
73   /// Attribute name for radius measure.
74   inline static const std::string& MEASURE_RADIUS()
75   {
76     static const std::string MY_MEASURE_ID("Radius");
77     return MY_MEASURE_ID;
78   }
79
80   /// Attribute name for angle measure.
81   inline static const std::string& MEASURE_ANGLE()
82   {
83     static const std::string MY_MEASURE_ID("Angle");
84     return MY_MEASURE_ID;
85   }
86
87
88   /// Attribute name of edge selected for length calculation.
89   inline static const std::string& EDGE_FOR_LENGTH_ID()
90   {
91     static const std::string MY_EDGE_FOR_LENGTH_ID("edge_for_length");
92     return MY_EDGE_FOR_LENGTH_ID;
93   }
94
95   /// Attribute name of first shape selected for distance calculation.
96   inline static const std::string& DISTANCE_FROM_OBJECT_ID()
97   {
98     static const std::string MY_DISTANCE_FROM_OBJECT_ID("distance_from");
99     return MY_DISTANCE_FROM_OBJECT_ID;
100   }
101
102   /// Attribute name of second shape selected for distance calculation.
103   inline static const std::string& DISTANCE_TO_OBJECT_ID()
104   {
105     static const std::string MY_DISTANCE_TO_OBJECT_ID("distance_to");
106     return MY_DISTANCE_TO_OBJECT_ID;
107   }
108
109   // Attribute name of edge or face selected to calculate radius.
110   inline static const std::string& CIRCULAR_OBJECT_ID()
111   {
112     static const std::string MY_CIRCULAR_OBJECT_ID("circular");
113     return MY_CIRCULAR_OBJECT_ID;
114   }
115
116   /// Attribute name of first edge selected for angle calculation.
117   inline static const std::string& ANGLE_FROM_EDGE_ID()
118   {
119     static const std::string MY_ANGLE_FROM_EDGE_ID("angle_from");
120     return MY_ANGLE_FROM_EDGE_ID;
121   }
122
123   /// Attribute name of second shape selected for distance calculation.
124   inline static const std::string& ANGLE_TO_EDGE_ID()
125   {
126     static const std::string MY_ANGLE_TO_EDGE_ID("angle_to");
127     return MY_ANGLE_TO_EDGE_ID;
128   }
129
130   /// Attribute name for result.
131   inline static const std::string& RESULT_ID()
132   {
133     static const std::string MY_RESULT_ID("result");
134     return MY_RESULT_ID;
135   }
136
137   /// Attribute name for values of result.
138   inline static const std::string& RESULT_VALUES_ID()
139   {
140     static const std::string MY_RESULT_VALUES_ID("result_values");
141     return MY_RESULT_VALUES_ID;
142   }
143
144   /// Creates a new part document if needed
145   FEATURESPLUGIN_EXPORT virtual void execute();
146
147   /// Request for initialization of data model of the feature: adding all attributes
148   FEATURESPLUGIN_EXPORT virtual void initAttributes();
149
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);
153
154   /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true.
155   virtual bool isMacro() const { return true; }
156
157   /// Use plugin manager for features creation
158   FeaturesPlugin_Measurement();
159
160 private:
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
168   void computeAngle();
169 };
170
171 #endif