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