diff --git a/NumLib/Function/SpatialFunctionLinear.h b/NumLib/Function/SpatialFunctionLinear.h new file mode 100644 index 0000000000000000000000000000000000000000..ec8411728cb9833f12636631275a585858b87f67 --- /dev/null +++ b/NumLib/Function/SpatialFunctionLinear.h @@ -0,0 +1,27 @@ +/** + * \author Norihiro Watanabe + * \date 2013-08-13 + * + * \copyright + * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef SPATIALFUNCTIONLINEAR_H_ +#define SPATIALFUNCTIONLINEAR_H_ + +#include "MathLib/LinearFunction.h" +#include "TemplateSpatialFunction.h" + +namespace NumLib +{ + +/// Linear function of space +typedef TemplateSpatialFunction<MathLib::LinearFunction<double, 3> > SpatialFunctionLinear; + +} + +#endif /* SPATIALFUNCTIONLINEAR_H_ */ diff --git a/NumLib/Function/TemplateSpatialFunction.h b/NumLib/Function/TemplateSpatialFunction.h new file mode 100644 index 0000000000000000000000000000000000000000..dbfddcce23cc0a2891cad423191462bea7afe52f --- /dev/null +++ b/NumLib/Function/TemplateSpatialFunction.h @@ -0,0 +1,54 @@ +/** + * \author Norihiro Watanabe + * \date 2013-08-13 + * + * \copyright + * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef TEMPLATESPATIALFUNCTION_H_ +#define TEMPLATESPATIALFUNCTION_H_ + +#include "ISpatialFunction.h" + +namespace NumLib +{ + +/** + * Template class to relate pure mathematical functions with ISpatialFunction + * + * @tparam T_FUNCTION Function object which takes "double const* const" as an argument. + */ +template <class T_FUNCTION> +class TemplateSpatialFunction : public ISpatialFunction +{ +public: + /** + * Constructor + * @param f a function object + */ + TemplateSpatialFunction(const T_FUNCTION &f) + : _f(f) {} + + /** + * evaluate a function + * @param pnt a point object + * @return evaluated value + */ + virtual double operator()(const GeoLib::Point& pnt) const + { + return _f(pnt.getCoords()); + } + +private: + /// a function object + const T_FUNCTION _f; +}; + +} + +#endif /* TEMPLATESPATIALFUNCTION_H_ */