STIR  6.2.0
more_interpolators.h
Go to the documentation of this file.
1 //
2 //
3 /*
4  Copyright (C) 2005- 2005, Hammersmith Imanet Ltd
5  For internal GE use only.
6 */
7 #ifndef __stir_numerics_more_interpolators_H__
8 #define __stir_numerics_more_interpolators_H__
9 
19 #include "stir/BasicCoordinate.h"
20 #include "stir/Array.h"
21 
22 START_NAMESPACE_STIR
23 
29 template <class elemT, class positionT>
30 elemT pull_nearest_neighbour_interpolate(const Array<3, elemT>& in, const BasicCoordinate<3, positionT>& point_in_input_coords);
31 
37 template <int num_dimensions, class elemT, class positionT, class valueT>
38 void push_nearest_neighbour_interpolate(Array<num_dimensions, elemT>& out,
39  const BasicCoordinate<num_dimensions, positionT>& point_in_output_coords,
40  valueT value);
41 
45 template <class elemT, class positionT>
46 elemT pull_linear_interpolate(const Array<3, elemT>& in, const BasicCoordinate<3, positionT>& point_in_input_coords);
47 
51 template <class elemT, class positionT, class valueT>
52 void push_transpose_linear_interpolate(Array<3, elemT>& out,
53  const BasicCoordinate<3, positionT>& point_in_output_coords,
54  valueT value);
55 
61 template <class elemT>
63 {
64 public:
66  : _input_ptr(0)
67  {}
68 
69  void set_input(const Array<3, elemT>& input) const { this->_input_ptr = &input; }
70 
71  template <class positionT>
72  elemT operator()(const BasicCoordinate<3, positionT>& point_in_input_coords) const
73  {
74  return pull_linear_interpolate(*(this->_input_ptr), point_in_input_coords);
75  }
76 
77 private:
78  // todo terribly dangerous
79  // we have it such that we can have a default constructor without any arguments
80  // this means we cannot use a reference
81  // we could use a shared_ptr, but then we can only interpolate data for which we have a shared_ptr
82  mutable const Array<3, elemT>* _input_ptr;
83 };
84 
90 template <class elemT>
92 {
93 public:
95  : _output_ptr(0)
96  {}
97 
98  void set_output(Array<3, elemT>& output) const { this->_output_ptr = &output; }
99 
100  template <class positionT, class valueT>
101  void add_to(const BasicCoordinate<3, positionT>& point_in_output_coords, const valueT value) const
102  {
103  push_transpose_linear_interpolate(*(this->_output_ptr), point_in_output_coords, value);
104  }
105 
106 private:
107  // todo terribly dangerous
108  // we have it such that we can have a default constructor without any arguments
109  // this means we cannot use a reference
110  // we could use a shared_ptr, but then we can only interpolate data for which we have a shared_ptr
111  mutable Array<3, elemT>* _output_ptr;
112 };
113 
119 template <class elemT>
121 {
122 public:
124  : _input_ptr(0)
125  {}
126 
127  void set_input(const Array<3, elemT>& input) const { this->_input_ptr = &input; }
128 
129  template <class positionT>
130  elemT operator()(const BasicCoordinate<3, positionT>& point_in_input_coords) const
131  {
132  return pull_nearest_neighbour_interpolate(*(this->_input_ptr), point_in_input_coords);
133  }
134 
135 private:
136  // todo terribly dangerous
137  // we have it such that we can have a default constructor without any arguments
138  // this means we cannot use a reference
139  // we could use a shared_ptr, but then we can only interpolate data for which we have a shared_ptr
140  mutable const Array<3, elemT>* _input_ptr;
141 };
142 
148 template <class elemT>
150 {
151 public:
153  : _output_ptr(0)
154  {}
155 
156  void set_output(Array<3, elemT>& output) const { this->_output_ptr = &output; }
157 
158  template <class positionT, class valueT>
159  void add_to(const BasicCoordinate<3, positionT>& point_in_output_coords, const valueT value) const
160  {
161  push_nearest_neighbour_interpolate(*(this->_output_ptr), point_in_output_coords, value);
162  }
163 
164 private:
165  // todo terribly dangerous
166  // we have it such that we can have a default constructor without any arguments
167  // this means we cannot use a reference
168  // we could use a shared_ptr, but then we can only interpolate data for which we have a shared_ptr
169  mutable Array<3, elemT>* _output_ptr;
170 };
171 
172 END_NAMESPACE_STIR
173 
175 
176 #endif
A function object to pull interpolated values from the input array into the grid points of the output...
Definition: more_interpolators.h:120
A function object to pull interpolated values from the input array into the grid points of the output...
Definition: more_interpolators.h:62
elemT pull_linear_interpolate(const Array< 3, elemT > &in, const BasicCoordinate< 3, positionT > &point_in_input_coords)
Returns an interpolated value according to point_in_input_coords.
Definition: more_interpolators.inl:61
defines the Array class for multi-dimensional (numeric) arrays
This file declares class stir::BasicCoordinate and some functions acting on stir::BasicCoordinate obj...
A function object to push values at the grid of the input array into the output array.
Definition: more_interpolators.h:91
A function object to push values at the grid of the input array into the output array.
Definition: more_interpolators.h:149
elemT pull_nearest_neighbour_interpolate(const Array< 3, elemT > &in, const BasicCoordinate< 3, positionT > &point_in_input_coords)
Pull value from the input array using nearest neigbour interpolation.
Definition: more_interpolators.inl:24
void push_nearest_neighbour_interpolate(Array< num_dimensions, elemT > &out, const BasicCoordinate< num_dimensions, positionT > &point_in_output_coords, valueT value)
Push value into the output array using nearest neigbour interpolation.
Definition: more_interpolators.inl:43
class BasicCoordinate<int num_dimensions, typename coordT> defines num_dimensions -dimensional coordi...
Definition: BasicCoordinate.h:53
Functions to interpolate data.
void push_transpose_linear_interpolate(Array< 3, elemT > &out, const BasicCoordinate< 3, positionT > &point_in_output_coords, valueT value)
Push value into the output array using the transpose of linear interpolation.
Definition: more_interpolators.inl:96