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>
35 * Errors that could appear on interpolation calculations.
36 * If there is no error, it is "OK".
38 enum InterpolationError {
40 InvalidParametersError, ///< input parameters are invalid
41 UnknownError ///< problem has unknown nature
44 /**\class HYDROData_IProfilesInterpolator
45 * \brief The base class to provide interface for profiles interpolation.
47 class HYDROData_IProfilesInterpolator
54 HYDRODATA_EXPORT HYDROData_IProfilesInterpolator();
57 * Public virtual destructor.
59 virtual HYDRODATA_EXPORT ~HYDROData_IProfilesInterpolator();
64 * Get description of the interpolation algorithm.
65 * \return the description string
67 HYDRODATA_EXPORT virtual TCollection_AsciiString GetDescription() const = 0;
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
74 HYDRODATA_EXPORT virtual void SetProfiles( const std::vector<double> theProfile1, const std::vector<double> theProfile2 );
77 * Set profiles as sequences of gp_XYZ points.
78 * \param theProfile1 the first profile points
79 * \param theProfile1 the second profile points
81 HYDRODATA_EXPORT virtual void SetProfiles( const NCollection_Sequence<gp_XYZ>& theProfile1,
82 const NCollection_Sequence<gp_XYZ>& theProfile2 );
85 * Set number of profiles to compute.
86 * \param theNumber the number of profiles to be computed
88 HYDRODATA_EXPORT virtual void SetResultProfilesNumber( const int theNumber );
91 * Set the additional parameter.
92 * \param the parameter name
93 * \param the parameter value
95 HYDRODATA_EXPORT virtual void SetParameter( const TCollection_AsciiString& theName,
96 const TCollection_AsciiString& theValue );
99 * Get the last error code.
100 * \return the error code from InterpolationError enumeration
102 HYDRODATA_EXPORT virtual InterpolationError GetErrorCode() const;
105 * Get string description of the last error.
106 * \return the string description
108 HYDRODATA_EXPORT virtual TCollection_AsciiString GetErrorMessage() const;
111 * Reset interpolator state: both input and output data are reset.
113 HYDRODATA_EXPORT virtual void Reset();
117 * Perform interpolation calculations.
119 HYDRODATA_EXPORT virtual void Calculate() = 0;
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
125 HYDRODATA_EXPORT virtual int GetCalculatedProfilesNumber() const;
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
132 HYDRODATA_EXPORT std::vector<double> GetResultProfileCoords( const int theProfileIndex ) const;
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
139 HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetResultProfilePoints( const int theProfileIndex ) const;
143 * Set the error code.
144 * \param theError the error code from InterpolationError enumeration
146 HYDRODATA_EXPORT virtual void SetErrorCode( const InterpolationError& theError );
149 * Set the error string description.
150 * \param the string description
152 HYDRODATA_EXPORT virtual void SetErrorMessage( const std::string& theMessage );
155 * Get the first profile coordinates.
156 * \return the first profile points
158 HYDRODATA_EXPORT std::vector<double> GetFirstProfileCoords() const;
161 * Get the second profile coordinates.
162 * \return the second profile points
164 HYDRODATA_EXPORT std::vector<double> GetSecondProfileCoords() const;
167 * Get the first profile points.
168 * \return the first profile points
170 HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetFirstProfilePoints() const;
173 * Get the second profile points.
174 * \return the second profile points
176 HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetSecondProfilePoints() const;
179 * Get number of profiles to compute.
180 * \return the current value of number of result profiles parameter
182 HYDRODATA_EXPORT virtual int GetNbProfilesToCompute() const;
185 * Clear result data (including errors).
187 HYDRODATA_EXPORT void ClearResults();
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, ...]
193 HYDRODATA_EXPORT void InsertResultProfile( const std::vector<double>& theProfile );
196 * Insert the calculated profile to the resuls as a list of points.
197 * \param theProfile the list of points gp_XYZ
199 HYDRODATA_EXPORT void InsertResultProfile( const NCollection_Sequence<gp_XYZ>& theProfile );
202 NCollection_Sequence<gp_XYZ> GetPoints( const std::vector<double>& theCoords ) const;
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
209 InterpolationError myErrorCode; ///< the last error code
210 std::string myErrorMessage; ///< the last error message
212 std::vector< std::vector<double> > myResultProfiles; ///< the list of result profiles