OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
image_state_frequency_domain.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  Author: Ansgar Philippsen
23 */
24 
25 #ifndef IMAGE_STATE_FREQUENCY_DOMAIN_HH
26 #define IMAGE_STATE_FREQUENCY_DOMAIN_HH
27 
28 #include <ost/base.hh>
29 #include <ost/img/point.hh>
30 #include <ost/img/size.hh>
31 #include <ost/img/extent.hh>
33 
34 #include "value_holder.hh"
35 #include "index.hh"
36 
37 namespace ost { namespace img { namespace image_state {
38 
39 /*
40  frequency domain implementation
41 */
42 
44 public:
46  extent_(Extent(e.GetSize(),Point(0,0,0))),
47  spat_ori_(extent_.GetStart())
48  {}
49 
50  // interface for ImageStateImpl
51  DataDomain GetDomain() const {return FREQUENCY;}
52 
53  void SetSpatialOrigin(const Point& o) {spat_ori_=o;}
54 
55  Point GetSpatialOrigin() const {return spat_ori_;}
56 
57  Extent GetExtent() const {return extent_;}
58 
59  Extent GetLogicalExtent() const {return extent_;}
60 
61  Extent GetPhysicalExtent() const {return extent_;}
62 
63  template <typename V>
64  Real GetReal(const Point &p, const ValueHolder<V>& data) const {
65  if(extent_.Contains(p)) {
66  return Val2Val<V,Real>(data.Value(Point2Index(p)));
67  } else {
68  return 0.0;
69  }
70  }
71 
72  template <typename V>
73  void SetReal(const Point &p, const Real& r, ValueHolder<V>& data) {
74  if(extent_.Contains(p)) {
75  data.Value(Point2Index(p))=Val2Val<Real,V>(r);
76  }
77  }
78 
79  template <typename V>
80  Complex GetComplex(const Point &p, const ValueHolder<V>& data) const {
81  if(extent_.Contains(p)) {
82  return Val2Val<V,Complex>(data.Value(Point2Index(p)));
83  } else {
84  return Complex(0.0,0.0);
85  }
86  }
87 
88  template <typename V>
89  void SetComplex(const Point &p, const Complex& c, ValueHolder<V>& data) {
90  if(extent_.Contains(p)) {
91  data.Value(Point2Index(p))=Val2Val<Complex,V>(c);
92  }
93  }
94 
95  Index Point2Index(const Point& p) const {
96  const Size& size=extent_.GetSize();
97  return Index(p[0]<0 ? size[0]+p[0] : p[0],
98  p[1]<0 ? size[1]+p[1] : p[1],
99  p[2]<0 ? size[2]+p[2] : p[2]);
100  }
101 
102 private:
103  Extent extent_;
104  Point spat_ori_;
105 
106 };
107 
108 }}} // ns
109 
110 #endif
DataDomain
underlying data type
Definition: data_types.hh:42
float Real
Definition: base.hh:44
std::complex< Real > Complex
Definition: base.hh:51
void SetReal(const Point &p, const Real &r, ValueHolder< V > &data)
V & Value(const Index &i)
return direct r/w access to the value without boundary check
class encapsulating 1D to 3D size
Definition: size.hh:39
Defines lower and upper valid indices.
Definition: extent.hh:60
void SetComplex(const Point &p, const Complex &c, ValueHolder< V > &data)
Complex GetComplex(const Point &p, const ValueHolder< V > &data) const
Real GetReal(const Point &p, const ValueHolder< V > &data) const
class encapsulating 1D to 3D point
Definition: point.hh:43
#define DLLEXPORT_OST_IMG_BASE