diff --git a/modules/img/base/src/function.hh b/modules/img/base/src/function.hh deleted file mode 100644 index 2961df320ebf8b4f741ab8040905483ef387d1ed..0000000000000000000000000000000000000000 --- a/modules/img/base/src/function.hh +++ /dev/null @@ -1,48 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 by the OpenStructure authors -// Copyright (C) 2003-2010 by the IPLT authors -// -// 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 3.0 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., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -//------------------------------------------------------------------------------ - -/* - real and complex function abstract base class, - implemented in terms of the templated - function implementation - - Author: Ansgar Philippsen -*/ - -#ifndef IMG_FUNCTION_H -#define IMG_FUNCTION_H - -#include "function_base.hh" -#include "function_impl.hh" - -namespace ost { namespace img { - -/// \sa \ref modulate_image.py "Modulate Image Example" -typedef detail::FunctionImpl<Real> RealFunction; -typedef detail::FunctionImpl<Complex> ComplexFunction; - - -}} // namespace img - -#endif - -/// \example modulate_image.py -/// -/// This script shows how to define a python function that modulates an image by a sine. Note the explicit call of RealFunction.__init__ in the modulator class. diff --git a/modules/img/base/src/function_base.cc b/modules/img/base/src/function_base.cc deleted file mode 100644 index 7c3672159d6d336fa1e490c11a31a10b44c49cb7..0000000000000000000000000000000000000000 --- a/modules/img/base/src/function_base.cc +++ /dev/null @@ -1,157 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 by the OpenStructure authors -// Copyright (C) 2003-2010 by the IPLT authors -// -// 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 3.0 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., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -//------------------------------------------------------------------------------ - -/* - function base - - Author: Ansgar Philippsen -*/ - -#include "function_base.hh" -#include "data_algorithm.hh" -#include "image_factory.hh" -#include "image_handle.hh" -namespace ost { -namespace img { - -Function::Function(DataDomain d, const Extent& e): - extent_(e), - domain_(d), - obs_(DataObservable()), - sampling_(Vec3(1.0,1.0,1.0),domain_,extent_) -{} - -Function::Function(const Function& f): - Data(f), - extent_(f.extent_), - domain_(f.domain_), - obs_(f.obs_), // use Observable copy logic - sampling_(f.sampling_) -{} - -Function& Function::operator=(const Function& f) -{ - Data::operator=(f); - extent_=f.extent_; - domain_=f.domain_; - obs_=f.obs_; // use Observable assignement logic - sampling_=f.sampling_; - return *this; -} - -Function::~Function() -{} - -DataDomain Function::GetDomain() const -{ - return domain_; -} - -Extent Function::GetExtent() const -{ - return extent_; -} - -void Function::SetSpatialOrigin(const Point& o) -{ - extent_=Extent(o,extent_.GetSize()); -} - -Point Function::GetSpatialOrigin() const -{ - return extent_.GetStart(); -} - -void Function::SetExtent(const Extent& e) -{ - extent_ = e; - sampling_.SetExtent(extent_); -} - -void Function::Apply(NonModAlgorithm& a) const -{ - a.Visit(*this); -} -void Function::ApplyIP(NonModAlgorithm& a) const -{ - Apply(a); -} - - -void Function::Attach(DataObserver *o) const -{ - obs_.Attach(o); -} - -void Function::Detach(DataObserver *o) const -{ - obs_.Detach(o); -} - -void Function::Notify() const -{ - obs_.Notify(); -} - -PixelSampling& Function::Sampling() -{ - return sampling_; -} - -const PixelSampling& Function::Sampling() const -{ - return sampling_; -} - -Real Function::GetReal(const Point& p) const -{ - return GetIntpolReal(p.ToVec3()); -} - -Complex Function::GetComplex(const Point& p) const -{ - return GetIntpolComplex(p.ToVec3()); -} - -Real Function::GetIntpolReal(const Vec2 &v) const -{ - Vec3 v3(v); - v3[2]=extent_.GetStart()[2]; - return GetIntpolReal(v3); -} -Real Function::GetIntpolReal(const Real &d) const -{ - Vec3 v3(d,extent_.GetStart()[1],extent_.GetStart()[2]); - return GetIntpolReal(v3); -} - -Complex Function::GetIntpolComplex(const Vec2 &v) const -{ - Vec3 v3(v); - v3[2]=extent_.GetStart()[2]; - return GetIntpolComplex(v3); -} -Complex Function::GetIntpolComplex(const Real &d) const -{ - Vec3 v3(d,extent_.GetStart()[1],extent_.GetStart()[2]); - return GetIntpolComplex(v3); -} - -}} //ns diff --git a/modules/img/base/src/function_base.hh b/modules/img/base/src/function_base.hh deleted file mode 100644 index 05fe24e73020c13ac3b1e37f628f4435e034f547..0000000000000000000000000000000000000000 --- a/modules/img/base/src/function_base.hh +++ /dev/null @@ -1,170 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 by the OpenStructure authors -// Copyright (C) 2003-2010 by the IPLT authors -// -// 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 3.0 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., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -//------------------------------------------------------------------------------ - -/* - function base - - Author: Ansgar Philippsen -*/ - -#ifndef IMG_FUNCTION_BASE_H -#define IMG_FUNCTION_BASE_H - -#include "module_config.hh" -#include "data.hh" -#include "data_observer.hh" -#include "observable.hh" -#include "pixel_sampling.hh" - -namespace ost { namespace img { - -// forward declaration -class NonModAlgorithm; -class ImageHandle; - -//! Base class that defines the function interface -/*! - Function only partially implementes the Data interface and - is thus still an abstract base class. In particular, the - methods GetType(), GetReal() and GetComplex() are still - pure virtual methods. - - In contrast to ImageHandle, a ConstFunction class is not - necessary, since assignement and copy-construction do - not share the underlying implementation. -*/ - -/* - Observer implementation will result in empty observer list - upon copy construction or assignement. -*/ - -class DLLEXPORT_OST_IMG_BASE Function: public Data { - typedef Observable<DataObserver> DataObservable; - - public: - /*! @name Initialization and deconstruction - No publically accessible ctors, Function is an abstract base class. - */ - //@{ - virtual ~Function(); - //@} - - /*! @name Properties - */ - //@{ - - //! See Data::GetType - virtual DataType GetType() const = 0; - - //! Returns data domain, defaults to \c SPATIAL - virtual DataDomain GetDomain() const; - - //! Returns extent of function - /*! - defaults to [Point(0,0,0), Point(0,0,0)], may be - modified by using SetExtent - */ - virtual Extent GetExtent() const; - //! set Extent that this function is evaluated in - void SetExtent(const Extent& e); - - //! see Data::SetSpatialOrigin - virtual void SetSpatialOrigin(const Point& o); - //! see Data::GetSpatialOrigin - virtual Point GetSpatialOrigin() const; - - //@} - - /*! @name Value retrieval - The pure virtual methods GetReal() and GetComplex() are - only given here for completeness. They still need to be - implemented by a derived class. - */ - //@{ - - //! see Data:GetReal - virtual Real GetReal(const Point& p) const; - - //! see Data:GetComplex - virtual Complex GetComplex(const Point& p) const; - - //! Get interpolated real value from 3D,2D or 1D vec - virtual Real GetIntpolReal(const Vec3 &v) const=0; - virtual Real GetIntpolReal(const Vec2 &v) const; - virtual Real GetIntpolReal(const Real &d) const; - - //! Get interpolated complex value from 3D,2D or 1D vec - virtual Complex GetIntpolComplex(const Vec3 &v) const=0; - virtual Complex GetIntpolComplex(const Vec2 &v) const; - virtual Complex GetIntpolComplex(const Real &d) const; - - //@} - - - /*! @name Algorithm interface - On the level of Function, only NonModAlgorithms may be applied - */ - //@{ - // use doc from Data - virtual void Apply(NonModAlgorithm& a) const; - virtual void ApplyIP(NonModAlgorithm& a) const; - //@} - - /*! @name Observer interface - */ - // use doc from Data - //@{ - virtual void Attach(DataObserver *o) const; - virtual void Detach(DataObserver *o) const; - virtual void Notify() const; - //@} - - - protected: - //! Initialization with Domain (required) and Extent(defaults to Size(1)) - Function(DataDomain d, const Extent& e=Extent()); - - Function(const Function& f); - - Function& operator=(const Function& f); - - /*! @name Sampling implementation - */ - //@{ - virtual PixelSampling& Sampling(); - virtual const PixelSampling& Sampling() const; - //@} - -private: - Extent extent_; - DataDomain domain_; - - /* - implement logical constness for Attach and Detach - */ - mutable DataObservable obs_; - - PixelSampling sampling_; -}; - -}} // namespace - -#endif diff --git a/modules/img/base/src/function_fw.hh b/modules/img/base/src/function_fw.hh deleted file mode 100644 index 17473cf94ec7ac3266e16bfcaf09696944c79a56..0000000000000000000000000000000000000000 --- a/modules/img/base/src/function_fw.hh +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 by the OpenStructure authors -// Copyright (C) 2003-2010 by the IPLT authors -// -// 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 3.0 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., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -//------------------------------------------------------------------------------ - -/* - convenience header for forward declaration of Function - - Author: Ansgar Philippsen -*/ - -#ifndef IMG_FUNCTION_FW_H -#define IMG_FUNCTION_FW_H - -#include <ost/img/module_config.hh> - -namespace ost { namespace img { - class Function; -}} - -#endif diff --git a/modules/img/base/src/function_impl.cc b/modules/img/base/src/function_impl.cc deleted file mode 100644 index 47cb883488e7c5252964fa9842519ba3810708ce..0000000000000000000000000000000000000000 --- a/modules/img/base/src/function_impl.cc +++ /dev/null @@ -1,76 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 by the OpenStructure authors -// Copyright (C) 2003-2010 by the IPLT authors -// -// 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 3.0 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., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -//------------------------------------------------------------------------------ - -/* - function implementation - - Author: Ansgar Philippsen -*/ - -#include "function_impl.hh" -#include "value_util.hh" - -namespace ost { namespace img { namespace detail { - -template <typename T> -DataType FunctionImpl<T>::GetType() const -{ - return Val2Type<T>(); -} - - -template <typename T> -Real FunctionImpl<T>::GetIntpolReal(const Vec3 &v) const -{ - return Val2Val<T,Real>(Func(v)); -} - -template <typename T> -Complex FunctionImpl<T>::GetIntpolComplex(const Vec3 &v) const -{ - return Val2Val<T,Complex>(Func(v)); -} - -template <typename T> -FunctionImpl<T>::FunctionImpl(DataDomain d): - Function(d) -{} - - -template <typename T> -FunctionImpl<T>::FunctionImpl(const FunctionImpl<T>& f): - Function(f) -{} - -template <typename T> -FunctionImpl<T>& FunctionImpl<T>::operator=(const FunctionImpl<T>& f) -{ - Function::operator=(f); - return *this; -} - - -} // namespace - -// explicit instantiations -template class TEMPLATE_DEF_EXPORT detail::FunctionImpl<Real>; -template class TEMPLATE_DEF_EXPORT detail::FunctionImpl<Complex>; - -}} // namespace diff --git a/modules/img/base/src/function_impl.hh b/modules/img/base/src/function_impl.hh deleted file mode 100644 index 8283b57df9c1f2cd75612144573f672c4c5797c1..0000000000000000000000000000000000000000 --- a/modules/img/base/src/function_impl.hh +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 by the OpenStructure authors -// Copyright (C) 2003-2010 by the IPLT authors -// -// 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 3.0 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., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -//------------------------------------------------------------------------------ - -/* - template function implementation, to serve - as the basis for RealFunction and ComplexFunction - - Author: Ansgar Philippsen -*/ - -#ifndef IMG_FUNCTION_IMPL_H -#define IMG_FUNCTION_IMPL_H - -#include <ost/img/module_config.hh> -#include "function_base.hh" - -namespace ost { namespace img { namespace detail { - -template <typename T> -class TEMPLATE_EXPORT FunctionImpl: public Function { - public: - - //////////////////////////// - // Data interface - - virtual DataType GetType() const; - - ///////////////////////////// - // Function interface - - virtual Real GetIntpolReal(const Vec3 &v) const; - virtual Complex GetIntpolComplex(const Vec3 &v) const; - - ////////////////////////////////// - // FunctionImpl interface - - /*! - abstract method that returns actual function value. Must - be implemented by derived classes - */ - virtual T Func(const Vec3 &v) const = 0; - - protected: - //! instantiation requires domain specification - FunctionImpl(DataDomain d); - - FunctionImpl(const FunctionImpl& f); - - FunctionImpl& operator=(const FunctionImpl& f); -}; - -}}} // namespaces - -#endif