Salome HOME
patch for compilation on Windows
[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 /**
35  * Errors that could appear on interpolation calculations.
36  * If there is no error, it is "OK".
37  */
38 enum InterpolationError {
39   OK = 0, ///< success
40   InvalidParametersError, ///< input parameters are invalid
41   UnknownError ///< problem has unknown nature
42 };
43
44 /**\class HYDROData_IProfilesInterpolator
45  * \brief The base class to provide interface for profiles interpolation.
46  */
47 class HYDROData_IProfilesInterpolator
48 {
49 public:
50
51   /**
52    * Public constructor.
53    */
54   HYDRODATA_EXPORT HYDROData_IProfilesInterpolator();
55
56   /**
57    * Public virtual destructor.
58    */
59   virtual HYDRODATA_EXPORT ~HYDROData_IProfilesInterpolator();
60
61 public:
62
63   /**
64    * Get description of the interpolation algorithm.
65    * \return the description string
66    */
67   HYDRODATA_EXPORT virtual TCollection_AsciiString GetDescription() const = 0;
68
69   /**
70    * Set profiles as vectors of point coordinates [x1, y1, z1, x2, y2, z2, ...].
71    * \param theProfile1 the first profile points
72    * \param theProfile1 the second profile points
73    */
74   HYDRODATA_EXPORT virtual void SetProfiles( const std::vector<double> theProfile1, const std::vector<double> theProfile2 );
75
76   /**
77    * Set profiles as sequences of gp_XYZ points.
78    * \param theProfile1 the first profile points
79    * \param theProfile1 the second profile points
80    */
81   HYDRODATA_EXPORT virtual void SetProfiles( const NCollection_Sequence<gp_XYZ>& theProfile1, 
82                                              const NCollection_Sequence<gp_XYZ>& theProfile2 );
83
84   /**
85    * Set number of profiles to compute.
86    * \param theNumber the number of profiles to be computed
87    */
88   HYDRODATA_EXPORT virtual void SetResultProfilesNumber( const int theNumber );
89
90   /**
91    * Set the additional parameter.
92    * \param the parameter name
93    * \param the parameter value
94    */
95   HYDRODATA_EXPORT virtual void SetParameter( const TCollection_AsciiString& theName, 
96                                               const TCollection_AsciiString& theValue );
97
98   /**
99    * Get the last error code.
100    * \return the error code from InterpolationError enumeration
101    */
102   HYDRODATA_EXPORT virtual InterpolationError GetErrorCode() const;
103
104   /**
105    * Get string description of the last error.
106    * \return the string description
107    */
108   HYDRODATA_EXPORT virtual TCollection_AsciiString GetErrorMessage() const;
109
110   /**
111    * Reset interpolator state: both input and output data are reset.
112    */
113   HYDRODATA_EXPORT virtual void Reset();
114
115 public:
116   /**
117    * Perform interpolation calculations.
118    */
119   HYDRODATA_EXPORT virtual void Calculate() = 0;
120
121   /**
122    * Get number of calculated profiles ( could be less than the number of profiles to be computed set as a parameter ).
123    * \return the number of really calculated profiles
124    */
125   HYDRODATA_EXPORT virtual int GetCalculatedProfilesNumber() const;
126
127   /**
128    * Get result profile by index as a vector of point coordinates [x1, y1, z1, x2, y2, z2, ...].
129    * \param theProfileIndex the profile index [0, <number of profiles to compute>]
130    * \return the profile with the given index or empty vector if the index is out of range
131    */
132   HYDRODATA_EXPORT std::vector<double> GetResultProfileCoords( const int theProfileIndex ) const;
133
134   /**
135    * Get result profile by index as a sequence of gp_XYZ points.
136    * \param theProfileIndex the profile index [0, <number of profiles to compute>]
137    * \return the profile with the given index or empty sequence if the index is out of range
138    */
139   HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetResultProfilePoints( const int theProfileIndex ) const;
140
141 protected:
142   /**
143    * Set the error code.
144    * \param theError the error code from InterpolationError enumeration
145    */
146   HYDRODATA_EXPORT virtual void SetErrorCode( const InterpolationError& theError );
147
148   /**
149    * Set the error string description.
150    * \param the string description
151    */
152   HYDRODATA_EXPORT virtual void SetErrorMessage( const std::string& theMessage );
153
154   /**
155    * Get the first profile coordinates.
156    * \return the first profile points
157    */
158   HYDRODATA_EXPORT std::vector<double> GetFirstProfileCoords() const;
159
160   /**
161    * Get the second profile coordinates.
162    * \return the second profile points
163    */
164   HYDRODATA_EXPORT std::vector<double> GetSecondProfileCoords() const;
165
166   /**
167    * Get the first profile points.
168    * \return the first profile points
169    */
170   HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetFirstProfilePoints() const;
171
172   /**
173    * Get the second profile points.
174    * \return the second profile points
175    */
176   HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetSecondProfilePoints() const;
177
178   /**
179    * Get number of profiles to compute.
180    * \return the current value of number of result profiles parameter
181    */
182   HYDRODATA_EXPORT virtual int GetNbProfilesToCompute() const;
183
184   /**
185    * Clear result data (including errors).
186    */
187   HYDRODATA_EXPORT void ClearResults();
188
189   /**
190    * Insert the calculated profile to the resuls as a list of coordinates.
191    * \param theProfile the list of coordinates [x1, y1, z1, x2, y2, z2, ...]
192    */
193   HYDRODATA_EXPORT void InsertResultProfile( const std::vector<double>& theProfile );
194
195   /**
196    * Insert the calculated profile to the resuls as a list of points.
197    * \param theProfile the list of points gp_XYZ
198    */
199   HYDRODATA_EXPORT void InsertResultProfile( const NCollection_Sequence<gp_XYZ>& theProfile );
200
201 private:
202   NCollection_Sequence<gp_XYZ> GetPoints( const std::vector<double>& theCoords ) const;
203
204 private:
205   std::vector<double> myProfile1, myProfile2; ///< the two input profiles
206   int myResultProfilesNumber; ///< the number of profiles to compute
207   std::map<std::string, std::string> myParameters; ///< the map of additional parameters
208
209   InterpolationError myErrorCode; ///< the last error code
210   std::string myErrorMessage; ///< the last error message
211
212   std::vector< std::vector<double> > myResultProfiles; ///< the list of result profiles
213 };
214
215 #endif