OpenStructure
image_state_base.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 
21 /*
22  image state base
23 
24  Author: Ansgar Philippsen
25 */
26 
27 #ifndef IMAGE_STATE_BASE_H
28 #define IMAGE_STATE_BASE_H
29 
30 #include "image_state_base_fw.hh"
31 
32 #include <ost/base.hh>
33 #include <ost/img/module_config.hh>
34 #include <ost/img/data.hh>
35 
37 #include "type_fw.hh"
38 
39 namespace ost { namespace img {
40 
41 class PixelSampling;
42 
43 namespace image_state {
44 
45 /*
46  Abstract base class for the image state. A polymorphic pointer
47  to this is managed by instantiations of the Image class.
48 
49  At this level, the SpatialOrigin and SpatialSampling are
50  stored, but the interpretation is left to the 'user' of
51  the image state, either the Image class or any ImageStateVisitor
52 */
54 public:
55 
56  virtual ~ImageStateBase() {}
57 
58  // provide deep copy
59  virtual ImageStateBasePtr Clone(bool cc=true) const = 0;
60 
61  virtual size_t MemSize() const = 0;
62 
64  // abstract virtual methods
65  // to be implemented in ImageState
66 
67  // Reset extent, only re-allocating memory
68  /*
69  still needed ? its probably better to offer this
70  on the lower level of ImageStateImpl
71  */
72  //virtual void ResetExtent(const Extent& e) = 0;
73 
75  virtual DataType GetType() const = 0;
76 
78  virtual DataDomain GetDomain() const = 0;
79 
81  virtual void SetSpatialOrigin(const Point& o) = 0;
82 
84  virtual Point GetSpatialOrigin() const = 0;
85 
86 
88 
93  virtual Extent GetExtent() const = 0;
94 
96 
100  virtual Extent GetLogicalExtent() const = 0;
101 
103 
106  virtual Real GetReal(const Point &p) const = 0;
107 
109 
112  virtual void SetReal(const Point &p, const Real& r) = 0;
113 
114  // retrive value at Point as Complex
115  /*
116  This call is potentially slow, but boundary checked
117  */
118  virtual Complex GetComplex(const Point &p) const = 0;
119 
121 
124  virtual void SetComplex(const Point &p, const Complex& c) = 0;
125 
126  virtual Real GetIntpolReal(const Vec3 &v) const = 0;
127  virtual Real GetIntpolReal(const Vec2 &v) const = 0;
128  virtual Real GetIntpolReal(const Real &d) const = 0;
129 
130  virtual Complex GetIntpolComplex(const Vec3 &v) const = 0;
131  virtual Complex GetIntpolComplex(const Vec2 &v) const = 0;
132  virtual Complex GetIntpolComplex(const Real &d) const = 0;
133 
134  virtual PixelSampling& GetSampling() = 0;
135 
136  virtual const PixelSampling& GetSampling() const = 0;
137 
138  virtual void SetSampling(const PixelSampling& s) = 0;
139 
140  virtual Vec3 GetAbsoluteOrigin() const = 0;
141 
142  virtual void SetAbsoluteOrigin(const Vec3& c) = 0;
143 
144  // Index to coordinate conversion
145  /*
146  Returns the physical dimensions of a given Point based on
147  the sampling of the current domain and the absolute coordinates
148  of the origin of the image
149  */
150  virtual Vec3 IndexToCoord(const Point &p) const = 0;
151 
152  // Convert coordinates back to (fractional) indices
153  /*
154  Returns the location within the Data that corresponds to
155  the given physical coordinate, bases on the sampling of
156  the current domain and the absolute coordinates
157  of the origin of the image
158  */
159  virtual Vec3 CoordToIndex(const Vec3& c) const = 0;
160 
161  /*
162  Returns the physical dimensions of a given Vec which contains
163  fractional Point coordinated. The returned value is based on
164  the sampling of the current domain and the absolute coordinates
165  of the origin of the image
166  */
167  virtual Vec3 FractionalIndexToCoord(const Vec3 &p) const =0;
168 
169  // visitor interface
170 
171  // apply const visitor, ie to extract info
172  virtual void ApplyIP(ImageStateNonModVisitorBase& v) const = 0;
173  // apply const visitor (same as ApplyIP(ImageStateNonModVisitorBase&)
174  virtual void Apply(ImageStateNonModVisitorBase& v) const = 0;
175 
176  // apply in-place visitor, usually modifies this
177  virtual void ApplyIP(ImageStateModIPVisitorBase& v) = 0;
178  // apply in-place visitor to clone of this, return result
180 
181  // apply in-place const visitor, usually modifies this
182  virtual void ApplyIP(const ImageStateConstModIPVisitorBase& v) = 0;
183  // apply in-place const visitor to clone of this, return result
185 
186  // apply out-of-place visitor and return result
187  // NOTE: it is not possible to apply an out-of-place visitor in-place!
188  // that is handled by the calling API (ie ImageHandle)
190 
191  // apply out-of-place const visitor and return result
193 
194  // apply morph visitor, with the expectation that returning state has modified this
196 
197  // operators
198  virtual ImageStateBase& operator+=(Real v) = 0;
199  virtual ImageStateBase& operator+=(const Complex& v) = 0;
200  virtual ImageStateBase& operator-=(Real v) = 0;
201  virtual ImageStateBase& operator-=(const Complex& v) = 0;
202  virtual ImageStateBase& operator*=(Real v) = 0;
203  virtual ImageStateBase& operator*=(const Complex& v) = 0;
204  virtual ImageStateBase& operator/=(Real v) = 0;
205  virtual ImageStateBase& operator/=(const Complex& v) = 0;
206 
211 
212 protected:
215 
216 private:
217  // assignement is forbidden
218  ImageStateBase& operator=(const ImageStateBase& s);
219 };
220 
221 }}} // namespaces
222 
223 #endif
Defines lower and upper valid indices.
Definition: extent.hh:60
Helper class to handle pixel sampling.
class encapsulating 1D to 3D point
Definition: point.hh:47
virtual void SetReal(const Point &p, const Real &r)=0
set real value at Point
virtual void ApplyIP(ImageStateModIPVisitorBase &v)=0
virtual Point GetSpatialOrigin() const =0
Retrieve spatial origin.
virtual ImageStateBasePtr Clone(bool cc=true) const =0
virtual ImageStateBase & operator+=(Real v)=0
virtual ImageStateBasePtr Apply(ImageStateMorphVisitorBase &v)=0
virtual Complex GetIntpolComplex(const Vec3 &v) const =0
virtual void SetSampling(const PixelSampling &s)=0
virtual void SetAbsoluteOrigin(const Vec3 &c)=0
virtual PixelSampling & GetSampling()=0
virtual ImageStateBasePtr Apply(const ImageStateConstModOPVisitorBase &v) const =0
virtual ImageStateBase & operator/=(const Complex &v)=0
virtual ImageStateBase & operator-=(const Complex &v)=0
ImageStateBase & operator*=(const ImageStateBase &b)
virtual Extent GetExtent() const =0
Retrieve Extent.
virtual size_t MemSize() const =0
virtual const PixelSampling & GetSampling() const =0
virtual ImageStateBase & operator+=(const Complex &v)=0
virtual Complex GetComplex(const Point &p) const =0
virtual void ApplyIP(const ImageStateConstModIPVisitorBase &v)=0
virtual Extent GetLogicalExtent() const =0
Retrieve logical extent.
virtual Real GetIntpolReal(const Vec3 &v) const =0
ImageStateBase(const ImageStateBase &s)
virtual void SetComplex(const Point &p, const Complex &c)=0
set complex value at Point
virtual void Apply(ImageStateNonModVisitorBase &v) const =0
virtual Real GetIntpolReal(const Vec2 &v) const =0
ImageStateBase & operator/=(const ImageStateBase &b)
virtual Vec3 GetAbsoluteOrigin() const =0
virtual void ApplyIP(ImageStateNonModVisitorBase &v) const =0
ImageStateBase & operator+=(const ImageStateBase &b)
virtual Real GetIntpolReal(const Real &d) const =0
virtual ImageStateBasePtr Apply(const ImageStateConstModIPVisitorBase &v) const =0
virtual void SetSpatialOrigin(const Point &o)=0
Set spatial origin.
virtual Vec3 CoordToIndex(const Vec3 &c) const =0
virtual Real GetReal(const Point &p) const =0
retrieve value at Point as Real
virtual ImageStateBase & operator*=(const Complex &v)=0
ImageStateBase & operator-=(const ImageStateBase &b)
virtual ImageStateBase & operator-=(Real v)=0
virtual DataDomain GetDomain() const =0
Retrieve domain.
virtual ImageStateBasePtr Apply(ImageStateModOPVisitorBase &v) const =0
virtual Complex GetIntpolComplex(const Real &d) const =0
virtual ImageStateBasePtr Apply(ImageStateModIPVisitorBase &v) const =0
virtual ImageStateBase & operator/=(Real v)=0
virtual ImageStateBase & operator*=(Real v)=0
virtual Complex GetIntpolComplex(const Vec2 &v) const =0
virtual Vec3 FractionalIndexToCoord(const Vec3 &p) const =0
virtual DataType GetType() const =0
Retrieve data type: REAL or COMPLEX.
virtual Vec3 IndexToCoord(const Point &p) const =0
in-place modifying image state const visitor base class
out-of-place modifying image state const visitor base class
in-place modifying image state visitor base class
out-of-place modifying image state visitor base class
morphing image state visitor base class
non-modifying image state visitor base class
#define DLLEXPORT_OST_IMG_BASE
float Real
Definition: base.hh:44
std::complex< Real > Complex
Definition: base.hh:51
boost::shared_ptr< ImageStateBase > ImageStateBasePtr
DataDomain
underlying data type
Definition: data_types.hh:42
Definition: base.dox:1