Salome HOME
7b72c0de7c250c06a6fa010ccb7f8541676b9eb3
[modules/shaper.git] / src / BuildPlugin / BuildPlugin_Interpolation.h
1 // Copyright (C) 2014-2023  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 email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef BuildPlugin_Interpolation_H_
21 #define BuildPlugin_Interpolation_H_
22
23 #include "BuildPlugin.h"
24
25 #include <ModelAPI_Feature.h>
26
27 /// \class BuildPlugin_Interpolation
28 /// \ingroup Plugins
29 /// \brief Feature for creation of interpolation curve from set of points.
30 class BuildPlugin_Interpolation : public ModelAPI_Feature
31 {
32 public:
33   /// Use plugin manager for features creation
34   BuildPlugin_Interpolation();
35
36   /// Feature kind.
37   inline static const std::string& ID()
38   {
39     static const std::string MY_ID("Interpolation");
40     return MY_ID;
41   }
42
43   /// Attribute name of creation method.
44   inline static const std::string& CREATION_METHOD_ID()
45   {
46     static const std::string MY_CREATION_METHOD_ID("interpolation_method");
47     return MY_CREATION_METHOD_ID;
48   }
49
50   /// Attribute name of creation method by selection
51   inline static const std::string& CREATION_METHOD_BY_SELECTION_ID()
52   {
53     static const std::string MY_CREATION_METHOD_BY_SELECTION_ID("by_selection");
54     return MY_CREATION_METHOD_BY_SELECTION_ID;
55   }
56
57   /// Attribute name of creation method analytical
58   inline static const std::string& CREATION_METHOD_ANALYTICAL_ID()
59   {
60     static const std::string MY_CREATION_METHOD_ANALYTICAL_ID("analytical");
61     return MY_CREATION_METHOD_ANALYTICAL_ID;
62   }
63
64   /// Attribute name of base objects.
65   inline static const std::string& BASE_OBJECTS_ID()
66   {
67     static const std::string MY_BASE_OBJECTS_ID("base_objects");
68     return MY_BASE_OBJECTS_ID;
69   }
70
71   /// Attribute name of closed flag.
72   inline static const std::string& CLOSED_ID()
73   {
74     static const std::string MY_CLOSED_ID("closed");
75     return MY_CLOSED_ID;
76   }
77
78   /// Attribute name of reorder flag.
79   inline static const std::string& REORDER_ID()
80   {
81     static const std::string MY_REORDER_ID("reorder");
82     return MY_REORDER_ID;
83   }
84
85   /// Attribute name of use tangents flag.
86   inline static const std::string& USE_TANGENTS_ID()
87   {
88     static const std::string MY_USE_TANGENTS_ID("use_tangents");
89     return MY_USE_TANGENTS_ID;
90   }
91
92   /// Attribute name of tangent for start point.
93   inline static const std::string& TANGENT_START_ID()
94   {
95     static const std::string MY_TANGENT_START_ID("tangent_start");
96     return MY_TANGENT_START_ID;
97   }
98
99   /// Attribute name of tangent for end point.
100   inline static const std::string& TANGENT_END_ID()
101   {
102     static const std::string MY_TANGENT_END_ID("tangent_end");
103     return MY_TANGENT_END_ID;
104   }
105
106   /// Attribute name of x(t) equation.
107   inline static const std::string& XT_ID()
108   {
109     static const std::string MY_XT_ID("xt");
110     return MY_XT_ID;
111   }
112
113   /// Attribute name of y(t) equation.
114   inline static const std::string& YT_ID()
115   {
116     static const std::string MY_YT_ID("yt");
117     return MY_YT_ID;
118   }
119
120   /// Attribute name of z(t) equation.
121   inline static const std::string& ZT_ID()
122   {
123     static const std::string MY_ZT_ID("zt");
124     return MY_ZT_ID;
125   }
126
127   /// Attribute name of min t.
128   inline static const std::string& MINT_ID()
129   {
130     static const std::string MY_MINT_ID("mint");
131     return MY_MINT_ID;
132   }
133
134   /// Attribute name of max t.
135   inline static const std::string& MAXT_ID()
136   {
137     static const std::string MY_MAXT_ID("maxt");
138     return MY_MAXT_ID;
139   }
140
141   /// Attribute of parameter name of variable
142   inline static const std::string& VARIABLE_ID()
143   {
144     static const std::string MY_VARIABLE_ID("variable");
145     return MY_VARIABLE_ID;
146   }
147
148   /// Attribute of parameter name of value
149   inline static const std::string& VALUE_ID()
150   {
151     static const std::string MY_VALUE_ID("value");
152     return MY_VALUE_ID;
153   }
154
155   /// Attribute of parameter expression error
156   inline static const std::string& EXPRESSION_ERROR_ID()
157   {
158     static const std::string MY_EXPRESSION_ERROR_ID("ExpressionError");
159     return MY_EXPRESSION_ERROR_ID;
160   }
161
162   /// Attribute name of number of steps
163   inline static const std::string& NUMSTEP_ID()
164   {
165     static const std::string MY_NUMSTEP_ID("numstep");
166     return MY_NUMSTEP_ID;
167   }
168
169   /// Default value of the closed attribute
170   inline static bool CLOSED_DEFAULT() { return false; }
171
172   /// List of references to the arguments of this expression
173   inline static const std::string& ARGUMENTS_ID()
174   {
175     static const std::string MY_ARGUMENTS_ID("arguments");
176     return MY_ARGUMENTS_ID;
177   }
178
179   /// \return the kind of a feature.
180   BUILDPLUGIN_EXPORT virtual const std::string& getKind()
181   {
182     static std::string MY_KIND = BuildPlugin_Interpolation::ID();
183     return MY_KIND;
184   }
185
186   /// Request for initialization of data model of the feature: adding all attributes.
187   BUILDPLUGIN_EXPORT virtual void initAttributes();
188
189   /// Creates a new part document if needed.
190   BUILDPLUGIN_EXPORT virtual void execute();
191
192   /// Called on change of any argument-attribute of this object.
193   /// \param[in] theID identifier of changed attribute.
194   BUILDPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
195
196   protected:
197   /// Evaluates the expression x(t), y(t),z(t) in value table.
198   void evaluate(std::string& theError);
199
200   /// Update coordinates x,y,z
201   void updateCoordinates();
202
203   /// Output error for python interpreter
204   std::string outErrorMessage;
205
206 };
207
208 #endif