Salome HOME
lots 3,8
[modules/hydro.git] / src / HYDROData / HYDROData_IProfilesInterpolator.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROData_IProfilesInterpolator_HeaderFile
20 #define HYDROData_IProfilesInterpolator_HeaderFile
21
22 #include "HYDROData.h"
23
24 #include <TCollection_AsciiString.hxx>
25 #include <NCollection_Sequence.hxx>
26
27 #include <string>
28 #include <vector>
29 #include <map>
30 #include <gp_XYZ.hxx>
31
32
33 /**
34  * Errors that could appear on interpolation calculations.
35  * If there is no error, it is "OK".
36  */
37 enum InterpolationError {
38   OK = 0, ///< success
39   InvalidParametersError, ///< input parameters are invalid
40   UnknownError ///< problem has unknown nature
41 };
42
43 /**\class HYDROData_IProfilesInterpolator
44  * \brief The base class to provide interface for profiles interpolation.
45  */
46 class HYDROData_IProfilesInterpolator
47 {
48 public:
49
50   /**
51    * Public constructor.
52    */
53   HYDRODATA_EXPORT HYDROData_IProfilesInterpolator();
54
55   /**
56    * Public virtual destructor.
57    */
58   virtual HYDRODATA_EXPORT ~HYDROData_IProfilesInterpolator();
59
60 public:
61
62   /**
63    * Get description of the interpolation algorithm.
64    * \return the description string
65    */
66   HYDRODATA_EXPORT virtual TCollection_AsciiString GetDescription() const = 0;
67
68   /**
69    * Set profiles as vectors of point coordinates [x1, y1, z1, x2, y2, z2, ...].
70    * \param theProfile1 the first profile points
71    * \param theProfile1 the second profile points
72    */
73   HYDRODATA_EXPORT virtual void SetProfiles( const std::vector<double> theProfile1, const std::vector<double> theProfile2 );
74
75   /**
76    * Set profiles as sequences of gp_XYZ points.
77    * \param theProfile1 the first profile points
78    * \param theProfile1 the second profile points
79    */
80   HYDRODATA_EXPORT virtual void SetProfiles( const NCollection_Sequence<gp_XYZ>& theProfile1, 
81                                              const NCollection_Sequence<gp_XYZ>& theProfile2 );
82
83   /**
84    * Set number of profiles to compute.
85    * \param theNumber the number of profiles to be computed
86    */
87   HYDRODATA_EXPORT virtual void SetResultProfilesNumber( const int theNumber );
88
89   /**
90    * Set the additional parameter.
91    * \param the parameter name
92    * \param the parameter value
93    */
94   HYDRODATA_EXPORT virtual void SetParameter( const TCollection_AsciiString& theName, 
95                                               const TCollection_AsciiString& theValue );
96
97   /**
98    * Get the last error code.
99    * \return the error code from InterpolationError enumeration
100    */
101   HYDRODATA_EXPORT virtual InterpolationError GetErrorCode() const;
102
103   /**
104    * Get string description of the last error.
105    * \return the string description
106    */
107   HYDRODATA_EXPORT virtual TCollection_AsciiString GetErrorMessage() const;
108
109   /**
110    * Reset interpolator state: both input and output data are reset.
111    */
112   HYDRODATA_EXPORT virtual void Reset();
113
114 public:
115   /**
116    * Perform interpolation calculations.
117    */
118   HYDRODATA_EXPORT virtual void Calculate() = 0;
119
120   /**
121    * Get number of calculated profiles ( could be less than the number of profiles to be computed set as a parameter ).
122    * \return the number of really calculated profiles
123    */
124   HYDRODATA_EXPORT virtual int GetCalculatedProfilesNumber() const;
125
126   /**
127    * Get result profile by index as a vector of point coordinates [x1, y1, z1, x2, y2, z2, ...].
128    * \param theProfileIndex the profile index [0, <number of profiles to compute>]
129    * \return the profile with the given index or empty vector if the index is out of range
130    */
131   HYDRODATA_EXPORT std::vector<double> GetResultProfileCoords( const int theProfileIndex ) const;
132
133   /**
134    * Get result profile by index as a sequence of gp_XYZ points.
135    * \param theProfileIndex the profile index [0, <number of profiles to compute>]
136    * \return the profile with the given index or empty sequence if the index is out of range
137    */
138   HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetResultProfilePoints( const int theProfileIndex ) const;
139
140 protected:
141   /**
142    * Set the error code.
143    * \param theError the error code from InterpolationError enumeration
144    */
145   HYDRODATA_EXPORT virtual void SetErrorCode( const InterpolationError& theError );
146
147   /**
148    * Set the error string description.
149    * \param the string description
150    */
151   HYDRODATA_EXPORT virtual void SetErrorMessage( const std::string& theMessage );
152
153   /**
154    * Get the first profile coordinates.
155    * \return the first profile points
156    */
157   HYDRODATA_EXPORT std::vector<double> GetFirstProfileCoords() const;
158
159   /**
160    * Get the second profile coordinates.
161    * \return the second profile points
162    */
163   HYDRODATA_EXPORT std::vector<double> GetSecondProfileCoords() const;
164
165   /**
166    * Get the first profile points.
167    * \return the first profile points
168    */
169   HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetFirstProfilePoints() const;
170
171   /**
172    * Get the second profile points.
173    * \return the second profile points
174    */
175   HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetSecondProfilePoints() const;
176
177   /**
178    * Get number of profiles to compute.
179    * \return the current value of number of result profiles parameter
180    */
181   HYDRODATA_EXPORT virtual int GetNbProfilesToCompute() const;
182
183   /**
184    * Clear result data (including errors).
185    */
186   HYDRODATA_EXPORT void ClearResults();
187
188   /**
189    * Insert the calculated profile to the resuls as a list of coordinates.
190    * \param theProfile the list of coordinates [x1, y1, z1, x2, y2, z2, ...]
191    */
192   HYDRODATA_EXPORT void InsertResultProfile( const std::vector<double>& theProfile );
193
194   /**
195    * Insert the calculated profile to the resuls as a list of points.
196    * \param theProfile the list of points gp_XYZ
197    */
198   HYDRODATA_EXPORT void InsertResultProfile( const NCollection_Sequence<gp_XYZ>& theProfile );
199
200 private:
201   NCollection_Sequence<gp_XYZ> GetPoints( const std::vector<double>& theCoords ) const;
202
203 private:
204   std::vector<double> myProfile1, myProfile2; ///< the two input profiles
205   int myResultProfilesNumber; ///< the number of profiles to compute
206   std::map<std::string, std::string> myParameters; ///< the map of additional parameters
207
208   InterpolationError myErrorCode; ///< the last error code
209   std::string myErrorMessage; ///< the last error message
210
211   std::vector< std::vector<double> > myResultProfiles; ///< the list of result profiles
212 };
213
214 #endif