HYDROData_Warning.h
HYDROData_Zone.h
HYDROData_GeomTool.h
+ HYDROData_IProfilesInterpolator.h
+ HYDROData_LinearInterpolator.h
+ HYDROData_InterpolatorsFactory.h
)
set(PROJECT_SOURCES
HYDROData_VisualState.cxx
HYDROData_Zone.cxx
HYDROData_GeomTool.cxx
+ HYDROData_IProfilesInterpolator.cxx
+ HYDROData_LinearInterpolator.cxx
+ HYDROData_InterpolatorsFactory.cxx
)
add_definitions(
#include <HYDROData_Application.h>
#include <HYDROData_Iterator.h>
#include <HYDROData_Tool.h>
+#include <HYDROData_InterpolatorsFactory.h>
#include <TDataStd_Integer.hxx>
#include <TDataXtd_Position.hxx>
myTransactionsAfterSave = 0;
myLX = -1;
myLY = -1;
+
+ myInterpolatorsFactory = 0;
}
HYDROData_Document::HYDROData_Document(const Handle(TDocStd_Document)& theDoc)
myTransactionsAfterSave = 0;
myLX = -1;
myLY = -1;
+
+ myInterpolatorsFactory = 0;
}
HYDROData_Document::~HYDROData_Document()
Transform( X, Y, IsToLocalCS );
thePnt = gp_XY( X, Y );
}
+
+HYDROData_InterpolatorsFactory* HYDROData_Document::GetInterpolatorsFactory()
+{
+ if ( !myInterpolatorsFactory ) {
+ myInterpolatorsFactory = new HYDROData_InterpolatorsFactory();
+ }
+
+ return myInterpolatorsFactory;
+}
\ No newline at end of file
#include <TDocStd_Document.hxx>
+class HYDROData_InterpolatorsFactory;
+
class QFile;
class gp_Pnt2d;
class gp_Pnt;
const QStringList& theNames,
const ObjectKind theObjectKind = KIND_UNKNOWN ) const;
+public:
+
+ //! Returns interpolator factory instance
+ HYDROData_InterpolatorsFactory* GetInterpolatorsFactory();
+
protected:
friend class HYDROData_Iterator;
Handle(TDocStd_Document) myDoc; ///< OCAF document instance corresponding for keeping all persistent data
int myTransactionsAfterSave; ///< number of transactions after the last "save" call, used for "IsModified" method
double myLX, myLY;
+
+ HYDROData_InterpolatorsFactory* myInterpolatorsFactory; ///< iterpolators factory
};
#endif
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROData_IProfilesInterpolator.h"
+
+
+const int DEFAULT_RESULT_PROFILES_NB = 1; ///< default number of results profiles
+
+HYDROData_IProfilesInterpolator::HYDROData_IProfilesInterpolator()
+ : myResultProfilesNumber( DEFAULT_RESULT_PROFILES_NB ),
+ myErrorCode( OK )
+{
+}
+
+HYDROData_IProfilesInterpolator::~HYDROData_IProfilesInterpolator()
+{
+}
+
+void HYDROData_IProfilesInterpolator::SetProfiles( const std::vector<double> theProfile1, const std::vector<double> theProfile2 )
+{
+ myProfile1 = theProfile1;
+ myProfile2 = theProfile2;
+}
+
+void HYDROData_IProfilesInterpolator::SetParameter( const std::string& theName, const std::string& theValue )
+{
+ myParameters[theName] = theValue;
+}
+
+InterpolationError HYDROData_IProfilesInterpolator::GetErrorCode() const
+{
+ return myErrorCode;
+}
+
+void HYDROData_IProfilesInterpolator::SetErrorCode( const InterpolationError& theError )
+{
+ myErrorCode = theError;
+}
+
+std::string HYDROData_IProfilesInterpolator::GetErrorMessage() const
+{
+ return myErrorMessage;
+}
+
+void HYDROData_IProfilesInterpolator::SetErrorMessage( const std::string& theMessage )
+{
+ myErrorMessage = theMessage;
+}
+
+void HYDROData_IProfilesInterpolator::SetResultProfilesNumber( const int theNumber )
+{
+ myResultProfilesNumber = theNumber;
+}
+
+std::vector<double> HYDROData_IProfilesInterpolator::GetResultProfile( const int theProfileIndex ) const
+{
+ std::vector<double> aResultProfile;
+
+ if ( theProfileIndex > 0 && theProfileIndex < (int) myResultProfiles.size() ) {
+ aResultProfile = myResultProfiles.at( theProfileIndex );
+ }
+
+ return aResultProfile;
+}
+
+void HYDROData_IProfilesInterpolator::Reset()
+{
+ myProfile1.clear();
+ myProfile2.clear();
+ myParameters.clear();
+
+ SetResultProfilesNumber( DEFAULT_RESULT_PROFILES_NB );
+
+ myResultProfiles.clear();
+
+ SetErrorCode( OK );
+ SetErrorMessage( "" );
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROData_IProfilesInterpolator_HeaderFile
+#define HYDROData_IProfilesInterpolator_HeaderFile
+
+#include "HYDROData.h"
+
+#include <string>
+#include <vector>
+#include <map>
+
+
+/**
+ * Errors that could appear on interpolation calculations.
+ * If there is no error, it is "OK".
+ */
+enum InterpolationError {
+ OK = 0, ///< success
+ InvalidParametersError, ///< input parameters are invalid
+ UnknownError ///< problem has unknown nature
+};
+
+/**\class HYDROData_IProfilesInterpolator
+ * \brief The base class to provide interface for profiles interpolation.
+ */
+class HYDROData_IProfilesInterpolator
+{
+public:
+
+ /**
+ * Public constructor.
+ */
+ HYDRODATA_EXPORT HYDROData_IProfilesInterpolator();
+
+ /**
+ * Public virtual destructor.
+ */
+ virtual HYDRODATA_EXPORT ~HYDROData_IProfilesInterpolator();
+
+public:
+
+ /**
+ * Get description of the interpolation algorithm.
+ * \return the description string
+ */
+ HYDRODATA_EXPORT virtual std::string GetDescription() const = 0;
+
+ /**
+ * Set profiles as vectors of point coordinates [x1, y1, z1, x2, y2, z2, ...].
+ * \param theProfile1 the first profile points
+ * \param theProfile1 the second profile points
+ */
+ HYDRODATA_EXPORT virtual void SetProfiles( const std::vector<double> theProfile1, const std::vector<double> theProfile2 );
+
+ /**
+ * Set number of profiles to compute.
+ * \param theNumber the number of profiles to be computed
+ */
+ HYDRODATA_EXPORT virtual void SetResultProfilesNumber( const int theNumber );
+
+ /**
+ * Set the additional parameter.
+ * \param the parameter name
+ * \param the parameter value
+ */
+ HYDRODATA_EXPORT virtual void SetParameter( const std::string& theName, const std::string& theValue );
+
+ /**
+ * Get the last error code.
+ * \return the error code from InterpolationError enumeration
+ */
+ HYDRODATA_EXPORT virtual InterpolationError GetErrorCode() const;
+
+ /**
+ * Get string description of the last error.
+ * \return the string description
+ */
+ HYDRODATA_EXPORT virtual std::string GetErrorMessage() const;
+
+ /**
+ * Reset interpolator state: both input and output data are reset.
+ */
+ HYDRODATA_EXPORT virtual void Reset();
+
+public:
+ /**
+ * Perform interpolation calculations.
+ */
+ HYDRODATA_EXPORT virtual InterpolationError Calculate() = 0;
+
+ /**
+ * Get result profile by index.
+ * \param theProfileIndex the profile index [0, <number of profiles to compute>]
+ * \return the profile with the given index or empty vector if the index is out of range
+ */
+ std::vector<double> GetResultProfile( const int theProfileIndex ) const;
+
+protected:
+ /**
+ * Set the error code.
+ * \param theError the error code from InterpolationError enumeration
+ */
+ HYDRODATA_EXPORT virtual void SetErrorCode( const InterpolationError& theError );
+
+ /**
+ * Set the error string description.
+ * \param the string description
+ */
+ HYDRODATA_EXPORT virtual void SetErrorMessage( const std::string& theMessage );
+
+private:
+ std::vector<double> myProfile1, myProfile2; ///< the two input profiles
+ int myResultProfilesNumber; ///< the number of profiles to compute
+ std::map<std::string, std::string> myParameters; ///< the map of additional parameters
+
+ InterpolationError myErrorCode; ///< the last error code
+ std::string myErrorMessage; ///< the last error message
+
+ std::vector<std::vector<double>> myResultProfiles; ///< the list of result profiles
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROData_InterpolatorsFactory.h"
+
+#include "HYDROData_LinearInterpolator.h"
+
+HYDROData_InterpolatorsFactory::HYDROData_InterpolatorsFactory()
+{
+ Register<HYDROData_LinearInterpolator>( "Linear" );
+}
+
+HYDROData_InterpolatorsFactory::~HYDROData_InterpolatorsFactory()
+{
+}
+
+HYDROData_IProfilesInterpolator* HYDROData_InterpolatorsFactory::GetInterpolator( const std::string& theName ) const
+{
+ HYDROData_IProfilesInterpolator* anInterpolator = NULL;
+
+ FactoryInterpolators::const_iterator anIt = myInterpolators.find(theName);
+ if ( anIt != myInterpolators.end() ) {
+ anInterpolator = anIt->second;
+ }
+
+ return anInterpolator;
+}
+
+std::vector<std::string> HYDROData_InterpolatorsFactory::GetInterpolatorNames() const
+{
+ std::vector<std::string> aNames;
+
+ FactoryInterpolators::const_iterator anIt = myInterpolators.begin();
+ for ( ; anIt != myInterpolators.end(); anIt++ ) {
+ aNames.push_back( anIt->first );
+ }
+
+ return aNames;
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROData_InterpolatorsFactory_HeaderFile
+#define HYDROData_InterpolatorsFactory_HeaderFile
+
+#include <HYDROData.h>
+
+#include <string>
+#include <vector>
+#include <map>
+
+class HYDROData_IProfilesInterpolator;
+
+/**\class HYDROData_InterpolatorsFactory
+ *
+ * \brief Profile interpolators factory.
+ *
+ * Allows to register different types of interpolatotors (these interpolators should inherit HYDROData_IProfilesInterpolator).
+ * Once the interpolator of a certain type is registered it should be got by its name.
+ */
+
+class HYDROData_InterpolatorsFactory
+{
+public:
+
+ HYDROData_InterpolatorsFactory();
+ virtual ~HYDROData_InterpolatorsFactory();
+
+ /**
+ * Registers the interpolator of a certain type with the given name.
+ * \param theName the interpolator name used as identifier
+ */
+ template <class T> HYDRODATA_EXPORT void Register( const std::string& theName )
+ {
+ myInterpolators[theName] = new T();
+ }
+
+ /**
+ * Get the appropriate interpolator by the name.
+ * \param theName name of the interpolator
+ * \returns the appropriate interpolator or NULL if interpolator with such name is not registered
+ */
+ HYDRODATA_EXPORT HYDROData_IProfilesInterpolator* GetInterpolator( const std::string& theName ) const;
+
+ /**
+ * Get list of registered interpolator names.
+ * \return the list of unique names
+ */
+ std::vector<std::string> GetInterpolatorNames() const;
+
+private:
+ //! Map that stores all interpolators, identified by interpolator name (string)
+ typedef std::map<std::string, HYDROData_IProfilesInterpolator*> FactoryInterpolators;
+
+ FactoryInterpolators myInterpolators; ///< all interpolators stored by factory
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROData_LinearInterpolator.h"
+
+
+HYDROData_LinearInterpolator::HYDROData_LinearInterpolator()
+{
+}
+
+HYDROData_LinearInterpolator::~HYDROData_LinearInterpolator()
+{
+}
+
+std::string HYDROData_LinearInterpolator::GetDescription() const
+{
+ std::string aDescription( "Simple linear interpolator" );
+
+ return aDescription;
+}
+
+InterpolationError HYDROData_LinearInterpolator::Calculate()
+{
+ return OK;
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROData_LinearInterpolator_HeaderFile
+#define HYDROData_LinearInterpolator_HeaderFile
+
+#include "HYDROData_IProfilesInterpolator.h"
+
+
+/**\class HYDROData_LinearInterpolator
+ * \brief The class implementing the linear interpolation of profiles.
+ */
+class HYDROData_LinearInterpolator : public HYDROData_IProfilesInterpolator
+{
+public:
+
+ /**
+ * Public constructor.
+ */
+ HYDRODATA_EXPORT HYDROData_LinearInterpolator();
+
+ /**
+ * Public virtual destructor.
+ */
+ virtual HYDRODATA_EXPORT ~HYDROData_LinearInterpolator();
+
+public:
+
+ /**
+ *
+ */
+ HYDRODATA_EXPORT virtual std::string GetDescription() const;
+
+ /**
+ *
+ */
+ HYDRODATA_EXPORT virtual InterpolationError Calculate();
+};
+
+#endif