Salome HOME
compilation on Linux
[modules/hydro.git] / src / HYDROData / HYDROData_IProfilesInterpolator.h
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef HYDROData_IProfilesInterpolator_HeaderFile
24 #define HYDROData_IProfilesInterpolator_HeaderFile
25
26 #include "HYDROData.h"
27
28 #include <string>
29 #include <vector>
30 #include <map>
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 std::string 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 number of profiles to compute.
77    * \param theNumber the number of profiles to be computed
78    */
79   HYDRODATA_EXPORT virtual void SetResultProfilesNumber( const int theNumber );
80
81   /**
82    * Set the additional parameter.
83    * \param the parameter name
84    * \param the parameter value
85    */
86   HYDRODATA_EXPORT virtual void SetParameter( const std::string& theName, const std::string& theValue );
87
88   /**
89    * Get the last error code.
90    * \return the error code from InterpolationError enumeration
91    */
92   HYDRODATA_EXPORT virtual InterpolationError GetErrorCode() const;
93
94   /**
95    * Get string description of the last error.
96    * \return the string description
97    */
98   HYDRODATA_EXPORT virtual std::string GetErrorMessage() const;
99
100   /**
101    * Reset interpolator state: both input and output data are reset.
102    */
103   HYDRODATA_EXPORT virtual void Reset();
104
105 public:
106   /**
107    * Perform interpolation calculations.
108    */
109   HYDRODATA_EXPORT virtual InterpolationError Calculate() = 0;
110
111   HYDRODATA_EXPORT virtual int GetCalculatedProfilesNumber() const;
112
113   /**
114    * Get result profile by index.
115    * \param theProfileIndex the profile index [0, <number of profiles to compute>]
116    * \return the profile with the given index or empty vector if the index is out of range
117    */
118   HYDRODATA_EXPORT std::vector<double> GetResultProfile( const int theProfileIndex ) const;
119
120 protected:
121   /**
122    * Set the error code.
123    * \param theError the error code from InterpolationError enumeration
124    */
125   HYDRODATA_EXPORT virtual void SetErrorCode( const InterpolationError& theError );
126
127   /**
128    * Set the error string description.
129    * \param the string description
130    */
131   HYDRODATA_EXPORT virtual void SetErrorMessage( const std::string& theMessage );
132
133 private:
134   std::vector<double> myProfile1, myProfile2; ///< the two input profiles
135   int myResultProfilesNumber; ///< the number of profiles to compute
136   std::map<std::string, std::string> myParameters; ///< the map of additional parameters
137
138   InterpolationError myErrorCode; ///< the last error code
139   std::string myErrorMessage; ///< the last error message
140
141   std::vector< std::vector<double> > myResultProfiles; ///< the list of result profiles
142 };
143
144 #endif