00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2011 by the OpenStructure authors 00005 // Copyright (C) 2003-2010 by the IPLT authors 00006 // 00007 // This library is free software; you can redistribute it and/or modify it under 00008 // the terms of the GNU Lesser General Public License as published by the Free 00009 // Software Foundation; either version 3.0 of the License, or (at your option) 00010 // any later version. 00011 // This library is distributed in the hope that it will be useful, but WITHOUT 00012 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00013 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00014 // details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with this library; if not, write to the Free Software Foundation, Inc., 00018 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 //------------------------------------------------------------------------------ 00020 00021 /* 00022 image state base 00023 00024 Author: Ansgar Philippsen 00025 */ 00026 00027 #ifndef IMAGE_STATE_BASE_H 00028 #define IMAGE_STATE_BASE_H 00029 00030 #include "image_state_base_fw.hh" 00031 00032 #include <ost/base.hh> 00033 #include <ost/img/module_config.hh> 00034 #include <ost/img/data.hh> 00035 00036 #include "image_state_visitor_fw.hh" 00037 #include "type_fw.hh" 00038 00039 namespace ost { namespace img { 00040 00041 class PixelSampling; 00042 00043 namespace image_state { 00044 00045 /* 00046 Abstract base class for the image state. A polymorphic pointer 00047 to this is managed by instantiations of the Image class. 00048 00049 At this level, the SpatialOrigin and SpatialSampling are 00050 stored, but the interpretation is left to the 'user' of 00051 the image state, either the Image class or any ImageStateVisitor 00052 */ 00053 class DLLEXPORT_OST_IMG_BASE ImageStateBase { 00054 public: 00055 00056 virtual ~ImageStateBase() {} 00057 00058 // provide deep copy 00059 virtual ImageStateBasePtr Clone(bool cc=true) const = 0; 00060 00061 virtual size_t MemSize() const = 0; 00062 00064 // abstract virtual methods 00065 // to be implemented in ImageState 00066 00067 // Reset extent, only re-allocating memory 00068 /* 00069 still needed ? its probably better to offer this 00070 on the lower level of ImageStateImpl 00071 */ 00072 //virtual void ResetExtent(const Extent& e) = 0; 00073 00075 virtual DataType GetType() const = 0; 00076 00078 virtual DataDomain GetDomain() const = 0; 00079 00081 virtual void SetSpatialOrigin(const Point& o) = 0; 00082 00084 virtual Point GetSpatialOrigin() const = 0; 00085 00086 00088 00093 virtual Extent GetExtent() const = 0; 00094 00096 00100 virtual Extent GetLogicalExtent() const = 0; 00101 00103 00106 virtual Real GetReal(const Point &p) const = 0; 00107 00109 00112 virtual void SetReal(const Point &p, const Real& r) = 0; 00113 00114 // retrive value at Point as Complex 00115 /* 00116 This call is potentially slow, but boundary checked 00117 */ 00118 virtual Complex GetComplex(const Point &p) const = 0; 00119 00121 00124 virtual void SetComplex(const Point &p, const Complex& c) = 0; 00125 00126 virtual Real GetIntpolReal(const Vec3 &v) const = 0; 00127 virtual Real GetIntpolReal(const Vec2 &v) const = 0; 00128 virtual Real GetIntpolReal(const Real &d) const = 0; 00129 00130 virtual Complex GetIntpolComplex(const Vec3 &v) const = 0; 00131 virtual Complex GetIntpolComplex(const Vec2 &v) const = 0; 00132 virtual Complex GetIntpolComplex(const Real &d) const = 0; 00133 00134 virtual PixelSampling& GetSampling() = 0; 00135 00136 virtual const PixelSampling& GetSampling() const = 0; 00137 00138 virtual void SetSampling(const PixelSampling& s) = 0; 00139 00140 virtual Vec3 GetAbsoluteOrigin() const = 0; 00141 00142 virtual void SetAbsoluteOrigin(const Vec3& c) = 0; 00143 00144 // Index to coordinate conversion 00145 /* 00146 Returns the physical dimensions of a given Point based on 00147 the sampling of the current domain and the absolute coordinates 00148 of the origin of the image 00149 */ 00150 virtual Vec3 IndexToCoord(const Point &p) const = 0; 00151 00152 // Convert coordinates back to (fractional) indices 00153 /* 00154 Returns the location within the Data that corresponds to 00155 the given physical coordinate, bases on the sampling of 00156 the current domain and the absolute coordinates 00157 of the origin of the image 00158 */ 00159 virtual Vec3 CoordToIndex(const Vec3& c) const = 0; 00160 00161 /* 00162 Returns the physical dimensions of a given Vec which contains 00163 fractional Point coordinated. The returned value is based on 00164 the sampling of the current domain and the absolute coordinates 00165 of the origin of the image 00166 */ 00167 virtual Vec3 FractionalIndexToCoord(const Vec3 &p) const =0; 00168 00169 // visitor interface 00170 00171 // apply const visitor, ie to extract info 00172 virtual void ApplyIP(ImageStateNonModVisitorBase& v) const = 0; 00173 // apply const visitor (same as ApplyIP(ImageStateNonModVisitorBase&) 00174 virtual void Apply(ImageStateNonModVisitorBase& v) const = 0; 00175 00176 // apply in-place visitor, usually modifies this 00177 virtual void ApplyIP(ImageStateModIPVisitorBase& v) = 0; 00178 // apply in-place visitor to clone of this, return result 00179 virtual ImageStateBasePtr Apply(ImageStateModIPVisitorBase& v) const = 0; 00180 00181 // apply in-place const visitor, usually modifies this 00182 virtual void ApplyIP(const ImageStateConstModIPVisitorBase& v) = 0; 00183 // apply in-place const visitor to clone of this, return result 00184 virtual ImageStateBasePtr Apply(const ImageStateConstModIPVisitorBase& v) const = 0; 00185 00186 // apply out-of-place visitor and return result 00187 // NOTE: it is not possible to apply an out-of-place visitor in-place! 00188 // that is handled by the calling API (ie ImageHandle) 00189 virtual ImageStateBasePtr Apply(ImageStateModOPVisitorBase& v) const = 0; 00190 00191 // apply out-of-place const visitor and return result 00192 virtual ImageStateBasePtr Apply(const ImageStateConstModOPVisitorBase& v) const = 0; 00193 00194 // apply morph visitor, with the expectation that returning state has modified this 00195 virtual ImageStateBasePtr Apply(ImageStateMorphVisitorBase& v) = 0; 00196 00197 // operators 00198 virtual ImageStateBase& operator+=(Real v) = 0; 00199 virtual ImageStateBase& operator+=(const Complex& v) = 0; 00200 virtual ImageStateBase& operator-=(Real v) = 0; 00201 virtual ImageStateBase& operator-=(const Complex& v) = 0; 00202 virtual ImageStateBase& operator*=(Real v) = 0; 00203 virtual ImageStateBase& operator*=(const Complex& v) = 0; 00204 virtual ImageStateBase& operator/=(Real v) = 0; 00205 virtual ImageStateBase& operator/=(const Complex& v) = 0; 00206 00207 ImageStateBase& operator+=(const ImageStateBase& b); 00208 ImageStateBase& operator-=(const ImageStateBase& b); 00209 ImageStateBase& operator*=(const ImageStateBase& b); 00210 ImageStateBase& operator/=(const ImageStateBase& b); 00211 00212 protected: 00213 ImageStateBase() {} 00214 ImageStateBase(const ImageStateBase& s) {} 00215 00216 private: 00217 // assignement is forbidden 00218 ImageStateBase& operator=(const ImageStateBase& s); 00219 }; 00220 00221 }}} // namespaces 00222 00223 #endif