00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2010 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/function.hh> 00034 00035 #include "image_state_visitor_fw.hh" 00036 #include "type_fw.hh" 00037 00038 namespace ost { namespace img { 00039 00040 class PixelSampling; 00041 00042 namespace image_state { 00043 00044 /* 00045 Abstract base class for the image state. A polymorphic pointer 00046 to this is managed by instantiations of the Image class. 00047 00048 At this level, the SpatialOrigin and SpatialSampling are 00049 stored, but the interpretation is left to the 'user' of 00050 the image state, either the Image class or any ImageStateVisitor 00051 */ 00052 class DLLEXPORT_OST_IMG_BASE ImageStateBase { 00053 public: 00054 00055 virtual ~ImageStateBase() {} 00056 00057 // provide deep copy 00058 virtual ImageStateBasePtr Clone(bool cc=true) const = 0; 00059 00060 virtual long MemSize() const = 0; 00061 00063 // abstract virtual methods 00064 // to be implemented in ImageState 00065 00066 // Reset extent, only re-allocating memory 00067 /* 00068 still needed ? its probably better to offer this 00069 on the lower level of ImageStateImpl 00070 */ 00071 //virtual void ResetExtent(const Extent& e) = 0; 00072 00074 virtual DataType GetType() const = 0; 00075 00077 virtual DataDomain GetDomain() const = 0; 00078 00080 virtual void SetSpatialOrigin(const Point& o) = 0; 00081 00083 virtual Point GetSpatialOrigin() const = 0; 00084 00085 00087 00092 virtual Extent GetExtent() const = 0; 00093 00095 00099 virtual Extent GetLogicalExtent() const = 0; 00100 00102 00105 virtual Real GetReal(const Point &p) const = 0; 00106 00108 00111 virtual void SetReal(const Point &p, const Real& r) = 0; 00112 00113 // retrive value at Point as Complex 00114 /* 00115 This call is potentially slow, but boundary checked 00116 */ 00117 virtual Complex GetComplex(const Point &p) const = 0; 00118 00120 00123 virtual void SetComplex(const Point &p, const Complex& c) = 0; 00124 00125 virtual Real GetIntpolReal(const Vec3 &v) const = 0; 00126 virtual Real GetIntpolReal(const Vec2 &v) const = 0; 00127 virtual Real GetIntpolReal(const Real &d) const = 0; 00128 00129 virtual Complex GetIntpolComplex(const Vec3 &v) const = 0; 00130 virtual Complex GetIntpolComplex(const Vec2 &v) const = 0; 00131 virtual Complex GetIntpolComplex(const Real &d) const = 0; 00132 00133 virtual PixelSampling& GetSampling() = 0; 00134 00135 virtual const PixelSampling& GetSampling() const = 0; 00136 00137 virtual void SetSampling(const PixelSampling& s) = 0; 00138 00139 virtual Vec3 GetAbsoluteOrigin() const = 0; 00140 00141 virtual void SetAbsoluteOrigin(const Vec3& c) = 0; 00142 00143 // Index to coordinate conversion 00144 /* 00145 Returns the physical dimensions of a given Point based on 00146 the sampling of the current domain and the absolute coordinates 00147 of the origin of the image 00148 */ 00149 virtual Vec3 IndexToCoord(const Point &p) const = 0; 00150 00151 // Convert coordinates back to (fractional) indices 00152 /* 00153 Returns the location within the Data that corresponds to 00154 the given physical coordinate, bases on the sampling of 00155 the current domain and the absolute coordinates 00156 of the origin of the image 00157 */ 00158 virtual Vec3 CoordToIndex(const Vec3& c) const = 0; 00159 00160 /* 00161 Returns the physical dimensions of a given Vec which contains 00162 fractional Point coordinated. The returned value is based on 00163 the sampling of the current domain and the absolute coordinates 00164 of the origin of the image 00165 */ 00166 virtual Vec3 FractionalIndexToCoord(const Vec3 &p) const =0; 00167 00168 // visitor interface 00169 00170 // apply const visitor, ie to extract info 00171 virtual void ApplyIP(ImageStateNonModVisitorBase& v) const = 0; 00172 // apply const visitor (same as ApplyIP(ImageStateNonModVisitorBase&) 00173 virtual void Apply(ImageStateNonModVisitorBase& v) const = 0; 00174 00175 // apply in-place visitor, usually modifies this 00176 virtual void ApplyIP(ImageStateModIPVisitorBase& v) = 0; 00177 // apply in-place visitor to clone of this, return result 00178 virtual ImageStateBasePtr Apply(ImageStateModIPVisitorBase& v) const = 0; 00179 00180 // apply in-place const visitor, usually modifies this 00181 virtual void ApplyIP(const ImageStateConstModIPVisitorBase& v) = 0; 00182 // apply in-place const visitor to clone of this, return result 00183 virtual ImageStateBasePtr Apply(const ImageStateConstModIPVisitorBase& v) const = 0; 00184 00185 // apply out-of-place visitor and return result 00186 // NOTE: it is not possible to apply an out-of-place visitor in-place! 00187 // that is handled by the calling API (ie ImageHandle) 00188 virtual ImageStateBasePtr Apply(ImageStateModOPVisitorBase& v) const = 0; 00189 00190 // apply out-of-place const visitor and return result 00191 virtual ImageStateBasePtr Apply(const ImageStateConstModOPVisitorBase& v) const = 0; 00192 00193 // apply morph visitor, with the expectation that returning state has modified this 00194 virtual ImageStateBasePtr Apply(ImageStateMorphVisitorBase& v) = 0; 00195 00196 // operators 00197 virtual ImageStateBase& operator+=(Real v) = 0; 00198 virtual ImageStateBase& operator+=(const Complex& v) = 0; 00199 virtual ImageStateBase& operator-=(Real v) = 0; 00200 virtual ImageStateBase& operator-=(const Complex& v) = 0; 00201 virtual ImageStateBase& operator*=(Real v) = 0; 00202 virtual ImageStateBase& operator*=(const Complex& v) = 0; 00203 virtual ImageStateBase& operator/=(Real v) = 0; 00204 virtual ImageStateBase& operator/=(const Complex& v) = 0; 00205 00206 ImageStateBase& operator+=(const ImageStateBase& b); 00207 ImageStateBase& operator-=(const ImageStateBase& b); 00208 ImageStateBase& operator*=(const ImageStateBase& b); 00209 ImageStateBase& operator/=(const ImageStateBase& b); 00210 00211 virtual void operator+=(const Function& b) = 0; 00212 virtual void operator-=(const Function& b) = 0; 00213 virtual void operator*=(const Function& b) = 0; 00214 virtual void operator/=(const Function& b) = 0; 00215 00216 protected: 00217 ImageStateBase() {} 00218 ImageStateBase(const ImageStateBase& s) {} 00219 00220 private: 00221 // assignement is forbidden 00222 ImageStateBase& operator=(const ImageStateBase& s); 00223 }; 00224 00225 }}} // namespaces 00226 00227 #endif
1.5.8