1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef HYDROData_IProfilesInterpolator_HeaderFile
24 #define HYDROData_IProfilesInterpolator_HeaderFile
26 #include "HYDROData.h"
28 #include <TCollection_AsciiString.hxx>
29 #include <NCollection_Sequence.hxx>
39 * Errors that could appear on interpolation calculations.
40 * If there is no error, it is "OK".
42 enum InterpolationError {
44 InvalidParametersError, ///< input parameters are invalid
45 UnknownError ///< problem has unknown nature
48 /**\class HYDROData_IProfilesInterpolator
49 * \brief The base class to provide interface for profiles interpolation.
51 class HYDROData_IProfilesInterpolator
58 HYDRODATA_EXPORT HYDROData_IProfilesInterpolator();
61 * Public virtual destructor.
63 virtual HYDRODATA_EXPORT ~HYDROData_IProfilesInterpolator();
68 * Get description of the interpolation algorithm.
69 * \return the description string
71 HYDRODATA_EXPORT virtual TCollection_AsciiString GetDescription() const = 0;
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
78 HYDRODATA_EXPORT virtual void SetProfiles( const std::vector<double> theProfile1, const std::vector<double> theProfile2 );
81 * Set profiles as sequences of gp_XYZ points.
82 * \param theProfile1 the first profile points
83 * \param theProfile1 the second profile points
85 HYDRODATA_EXPORT virtual void SetProfiles( const NCollection_Sequence<gp_XYZ>& theProfile1,
86 const NCollection_Sequence<gp_XYZ>& theProfile2 );
89 * Set number of profiles to compute.
90 * \param theNumber the number of profiles to be computed
92 HYDRODATA_EXPORT virtual void SetResultProfilesNumber( const int theNumber );
95 * Set the additional parameter.
96 * \param the parameter name
97 * \param the parameter value
99 HYDRODATA_EXPORT virtual void SetParameter( const TCollection_AsciiString& theName,
100 const TCollection_AsciiString& theValue );
103 * Get the last error code.
104 * \return the error code from InterpolationError enumeration
106 HYDRODATA_EXPORT virtual InterpolationError GetErrorCode() const;
109 * Get string description of the last error.
110 * \return the string description
112 HYDRODATA_EXPORT virtual TCollection_AsciiString GetErrorMessage() const;
115 * Reset interpolator state: both input and output data are reset.
117 HYDRODATA_EXPORT virtual void Reset();
121 * Perform interpolation calculations.
123 HYDRODATA_EXPORT virtual void Calculate() = 0;
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
129 HYDRODATA_EXPORT virtual int GetCalculatedProfilesNumber() const;
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
136 HYDRODATA_EXPORT std::vector<double> GetResultProfileCoords( const int theProfileIndex ) const;
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
143 HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetResultProfilePoints( const int theProfileIndex ) const;
147 * Set the error code.
148 * \param theError the error code from InterpolationError enumeration
150 HYDRODATA_EXPORT virtual void SetErrorCode( const InterpolationError& theError );
153 * Set the error string description.
154 * \param the string description
156 HYDRODATA_EXPORT virtual void SetErrorMessage( const std::string& theMessage );
159 * Get the first profile coordinates.
160 * \return the first profile points
162 HYDRODATA_EXPORT std::vector<double> GetFirstProfileCoords() const;
165 * Get the second profile coordinates.
166 * \return the second profile points
168 HYDRODATA_EXPORT std::vector<double> GetSecondProfileCoords() const;
171 * Get the first profile points.
172 * \return the first profile points
174 HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetFirstProfilePoints() const;
177 * Get the second profile points.
178 * \return the second profile points
180 HYDRODATA_EXPORT NCollection_Sequence<gp_XYZ> GetSecondProfilePoints() const;
183 * Get number of profiles to compute.
184 * \return the current value of number of result profiles parameter
186 HYDRODATA_EXPORT virtual int GetNbProfilesToCompute() const;
189 * Clear result data (including errors).
191 HYDRODATA_EXPORT void ClearResults();
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, ...]
197 HYDRODATA_EXPORT void InsertResultProfile( const std::vector<double>& theProfile );
200 * Insert the calculated profile to the resuls as a list of points.
201 * \param theProfile the list of points gp_XYZ
203 HYDRODATA_EXPORT void InsertResultProfile( const NCollection_Sequence<gp_XYZ>& theProfile );
206 NCollection_Sequence<gp_XYZ> GetPoints( const std::vector<double>& theCoords ) const;
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
213 InterpolationError myErrorCode; ///< the last error code
214 std::string myErrorMessage; ///< the last error message
216 std::vector< std::vector<double> > myResultProfiles; ///< the list of result profiles