STIR 6.4.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__
20#include "stir/Array.h"
21
22START_NAMESPACE_STIR
23
29template <class elemT, class positionT>
30elemT pull_nearest_neighbour_interpolate(const Array<3, elemT>& in, const BasicCoordinate<3, positionT>& point_in_input_coords);
31
37template <int num_dimensions, class elemT, class positionT, class valueT>
38void push_nearest_neighbour_interpolate(Array<num_dimensions, elemT>& out,
39 const BasicCoordinate<num_dimensions, positionT>& point_in_output_coords,
40 valueT value);
41
45template <class elemT, class positionT>
46elemT pull_linear_interpolate(const Array<3, elemT>& in, const BasicCoordinate<3, positionT>& point_in_input_coords);
47
51template <class elemT, class positionT, class valueT>
52void push_transpose_linear_interpolate(Array<3, elemT>& out,
53 const BasicCoordinate<3, positionT>& point_in_output_coords,
54 valueT value);
55
61template <class elemT>
62class PullLinearInterpolator
63{
64public:
65 PullLinearInterpolator()
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
77private:
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
90template <class elemT>
91class PushTransposeLinearInterpolator
92{
93public:
94 PushTransposeLinearInterpolator()
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
106private:
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
119template <class elemT>
120class PullNearestNeighbourInterpolator
121{
122public:
123 PullNearestNeighbourInterpolator()
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
135private:
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
148template <class elemT>
149class PushNearestNeighbourInterpolator
150{
151public:
152 PushNearestNeighbourInterpolator()
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
164private:
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
172END_NAMESPACE_STIR
173
175
176#endif
defines the stir::Array class for multi-dimensional (numeric) arrays
This file declares class stir::BasicCoordinate and some functions acting on stir::BasicCoordinate obj...
This class defines multi-dimensional (numeric) arrays.
Definition Array.h:78
class BasicCoordinate<int num_dimensions, typename coordT> defines num_dimensions -dimensional coordi...
Definition BasicCoordinate.h:57
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
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
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
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
Functions to interpolate data.