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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef HYDROData_IProfilesInterpolator_HeaderFile
20 #define HYDROData_IProfilesInterpolator_HeaderFile
22 #include "HYDROData.h"
24 #include <TCollection_AsciiString.hxx>
25 #include <NCollection_Sequence.hxx>
34 * Errors that could appear on interpolation calculations.
35 * If there is no error, it is "OK".
37 enum InterpolationError {
39 InvalidParametersError, ///< input parameters are invalid
40 UnknownError ///< problem has unknown nature
43 /**\class HYDROData_IProfilesInterpolator
44 * \brief The base class to provide interface for profiles interpolation.
46 class HYDROData_IProfilesInterpolator
53 HYDRODATA_EXPORT HYDROData_IProfilesInterpolator();
56 * Public virtual destructor.
58 virtual HYDRODATA_EXPORT ~HYDROData_IProfilesInterpolator();
63 * Get description of the interpolation algorithm.
64 * \return the description string
66 HYDRODATA_EXPORT virtual TCollection_AsciiString GetDescription() const = 0;
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
73 HYDRODATA_EXPORT virtual void SetProfiles( const std::vector<double> theProfile1, const std::vector<double> theProfile2 );
76 * Set profiles as sequences of gp_XYZ points.
77 * \param theProfile1 the first profile points
78 * \param theProfile1 the second profile points
80 HYDRODATA_EXPORT virtual void SetProfiles( const NCollection_Sequence<gp_XYZ>& theProfile1,
81 const NCollection_Sequence<gp_XYZ>& theProfile2 );
84 * Set number of profiles to compute.
85 * \param theNumber the number of profiles to be computed
87 HYDRODATA_EXPORT virtual void SetResultProfilesNumber( const int theNumber );
90 * Set the additional parameter.
91 * \param the parameter name
92 * \param the parameter value
94 HYDRODATA_EXPORT virtual void SetParameter( const TCollection_AsciiString& theName,
95 const TCollection_AsciiString& theValue );
98 * Get the last error code.
99 * \return the error code from InterpolationError enumeration
101 HYDRODATA_EXPORT virtual InterpolationError GetErrorCode() const;
104 * Get string description of the last error.
105 * \return the string description
107 HYDRODATA_EXPORT virtual TCollection_AsciiString GetErrorMessage() const;
110 * Reset interpolator state: both input and output data are reset.
112 HYDRODATA_EXPORT virtual void Reset();
116 * Perform interpolation calculations.
118 HYDRODATA_EXPORT virtual void Calculate() = 0;
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
124 HYDRODATA_EXPORT virtual int GetCalculatedProfilesNumber() const;
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
131 HYDRODATA_EXPORT std::vector<double> GetResultProfileCoords( const int theProfileIndex ) const;
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
138 HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetResultProfilePoints( const int theProfileIndex ) const;
142 * Set the error code.
143 * \param theError the error code from InterpolationError enumeration
145 HYDRODATA_EXPORT virtual void SetErrorCode( const InterpolationError& theError );
148 * Set the error string description.
149 * \param the string description
151 HYDRODATA_EXPORT virtual void SetErrorMessage( const std::string& theMessage );
154 * Get the first profile coordinates.
155 * \return the first profile points
157 HYDRODATA_EXPORT std::vector<double> GetFirstProfileCoords() const;
160 * Get the second profile coordinates.
161 * \return the second profile points
163 HYDRODATA_EXPORT std::vector<double> GetSecondProfileCoords() const;
166 * Get the first profile points.
167 * \return the first profile points
169 HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetFirstProfilePoints() const;
172 * Get the second profile points.
173 * \return the second profile points
175 HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetSecondProfilePoints() const;
178 * Get number of profiles to compute.
179 * \return the current value of number of result profiles parameter
181 HYDRODATA_EXPORT virtual int GetNbProfilesToCompute() const;
184 * Clear result data (including errors).
186 HYDRODATA_EXPORT void ClearResults();
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, ...]
192 HYDRODATA_EXPORT void InsertResultProfile( const std::vector<double>& theProfile );
195 * Insert the calculated profile to the resuls as a list of points.
196 * \param theProfile the list of points gp_XYZ
198 HYDRODATA_EXPORT void InsertResultProfile( const NCollection_Sequence<gp_XYZ>& theProfile );
201 NCollection_Sequence<gp_XYZ> GetPoints( const std::vector<double>& theCoords ) const;
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
208 InterpolationError myErrorCode; ///< the last error code
209 std::string myErrorMessage; ///< the last error message
211 std::vector< std::vector<double> > myResultProfiles; ///< the list of result profiles