STIR  6.3.0
VoxelsOnCartesianGrid.h
Go to the documentation of this file.
1 //
2 //
3 /*
4  Copyright (C) 2000 PARAPET partners
5  Copyright (C) 2000- 2007, Hammersmith Imanet Ltd
6  Copyright (C) 2018-2019, 2025, University College London
7  This file is part of STIR.
8 
9  SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
10 
11  See STIR/LICENSE.txt for details
12 */
13 
14 #ifndef __stir_VoxelsOnCartesianGrid_H__
15 #define __stir_VoxelsOnCartesianGrid_H__
16 
30 
31 START_NAMESPACE_STIR
32 
33 class ProjDataInfo;
34 template <typename elemT>
35 class PixelsOnCartesianGrid;
36 
44 template <class elemT>
45 class VoxelsOnCartesianGrid : public DiscretisedDensityOnCartesianGrid<3, elemT>
46 {
47 #ifdef STIR_COMPILING_SWIG_WRAPPER
48  // work-around swig problem. It gets confused when using a private (or protected)
49  // typedef in a definition of a public typedef/member
50 public:
51 #endif
52  typedef VoxelsOnCartesianGrid<elemT> self_type;
53  typedef DiscretisedDensityOnCartesianGrid<3, elemT> base_type;
54 
55 public:
56 #if 0
57 static VoxelsOnCartesianGrid ask_parameters();
59 #endif
60 
62  VoxelsOnCartesianGrid();
63 
65  VoxelsOnCartesianGrid(const Array<3, elemT>& v,
66  const CartesianCoordinate3D<float>& origin,
67  const BasicCoordinate<3, float>& grid_spacing);
68 
70 
71  VoxelsOnCartesianGrid(const IndexRange<3>& range,
72  const CartesianCoordinate3D<float>& origin,
73  const BasicCoordinate<3, float>& grid_spacing);
74 
76  VoxelsOnCartesianGrid(const shared_ptr<const ExamInfo>& exam_info_sptr,
77  const Array<3, elemT>& v,
78  const CartesianCoordinate3D<float>& origin,
79  const BasicCoordinate<3, float>& grid_spacing);
80 
82 
83  VoxelsOnCartesianGrid(const shared_ptr<const ExamInfo>& exam_info_sptr,
84  const IndexRange<3>& range,
85  const CartesianCoordinate3D<float>& origin,
86  const BasicCoordinate<3, float>& grid_spacing);
87 
88  // KT 10/12/2001 replace 2 constructors with the more general one below
90 
113  VoxelsOnCartesianGrid(const ProjDataInfo& proj_data_info_ptr,
114  const float zoom = 1.F,
115  const CartesianCoordinate3D<float>& origin = CartesianCoordinate3D<float>(0.F, 0.F, 0.F),
116  const CartesianCoordinate3D<int>& sizes = CartesianCoordinate3D<int>(-1, -1, -1));
117 
119 
124  VoxelsOnCartesianGrid(const shared_ptr<const ExamInfo>& exam_info_sptr,
125  const ProjDataInfo& proj_data_info,
126  const float zoom = 1.F,
127  const CartesianCoordinate3D<float>& origin = CartesianCoordinate3D<float>(0.F, 0.F, 0.F),
128  const CartesianCoordinate3D<int>& sizes = CartesianCoordinate3D<int>(-1, -1, -1));
129 
131 
136  VoxelsOnCartesianGrid(const shared_ptr<const ExamInfo>& exam_info_sptr_v,
137  const ProjDataInfo& proj_data_info,
138  const CartesianCoordinate3D<float>& zooms,
139  const CartesianCoordinate3D<float>& origin = CartesianCoordinate3D<float>(0.F, 0.F, 0.F),
140  const CartesianCoordinate3D<int>& sizes = CartesianCoordinate3D<int>(-1, -1, -1));
141 
143 #ifdef STIR_NO_COVARIANT_RETURN_TYPES
144  DiscretisedDensity<3, elemT>*
145 #else
146  VoxelsOnCartesianGrid<elemT>*
147 #endif
148  get_empty_copy() const override;
149 
151  VoxelsOnCartesianGrid<elemT>* get_empty_voxels_on_cartesian_grid() const;
152 
153 #ifdef STIR_NO_COVARIANT_RETURN_TYPES
154  virtual DiscretisedDensity<3, elemT>*
155 #else
156  VoxelsOnCartesianGrid<elemT>*
157 #endif
158  clone() const override;
159 
161  PixelsOnCartesianGrid<elemT> get_plane(const int z) const;
162 
164  void set_plane(const PixelsOnCartesianGrid<elemT>& plane, const int z);
165 
167  inline CartesianCoordinate3D<float> get_voxel_size() const;
168 
170  void set_voxel_size(const BasicCoordinate<3, float>&);
171 
173  void grow_z_range(const int min_z, const int max_z);
174 
176 
179  inline int get_x_size() const;
180 
181  inline int get_y_size() const;
182 
183  inline int get_z_size() const;
184 
185  inline int get_min_x() const;
186 
187  inline int get_min_y() const;
188 
189  inline int get_min_z() const;
190 
191  inline int get_max_x() const;
192 
193  inline int get_max_y() const;
194 
195  inline int get_max_z() const;
196 
197  BasicCoordinate<3, int> get_lengths() const;
198  BasicCoordinate<3, int> get_min_indices() const;
199  BasicCoordinate<3, int> get_max_indices() const;
200 
202 
204 
205  // tedious reimplementation to fix return types. This could be avoided by using boost::operators.
206  // However, reimplementing them explicitly helps SWIG.
207  inline self_type& operator+=(const self_type& x)
208  {
209  base_type::operator+=(x);
210  return *this;
211  }
212  inline self_type& operator-=(const self_type& x)
213  {
214  base_type::operator-=(x);
215  return *this;
216  }
217  inline self_type& operator*=(const self_type& x)
218  {
219  base_type::operator*=(x);
220  return *this;
221  }
222  inline self_type& operator/=(const self_type& x)
223  {
224  base_type::operator/=(x);
225  return *this;
226  }
227  inline self_type& operator+=(const elemT x)
228  {
229  base_type::operator+=(x);
230  return *this;
231  }
232  inline self_type& operator-=(const elemT x)
233  {
234  base_type::operator-=(x);
235  return *this;
236  }
237  inline self_type& operator*=(const elemT x)
238  {
239  base_type::operator*=(x);
240  return *this;
241  }
242  inline self_type& operator/=(const elemT x)
243  {
244  base_type::operator/=(x);
245  return *this;
246  }
247  inline self_type operator+(const self_type& x) const
248  {
249  self_type c(*this);
250  return c += x;
251  }
252  inline self_type operator+(const elemT x) const
253  {
254  self_type c(*this);
255  return c += x;
256  }
257  inline self_type operator-(const self_type& x) const
258  {
259  self_type c(*this);
260  return c -= x;
261  }
262  inline self_type operator-(const elemT x) const
263  {
264  self_type c(*this);
265  return c -= x;
266  }
267  inline self_type operator*(const self_type& x) const
268  {
269  self_type c(*this);
270  return c *= x;
271  }
272  inline self_type operator*(const elemT x) const
273  {
274  self_type c(*this);
275  return c *= x;
276  }
277  inline self_type operator/(const self_type& x) const
278  {
279  self_type c(*this);
280  return c /= x;
281  }
282  inline self_type operator/(const elemT x) const
283  {
284  self_type c(*this);
285  return c /= x;
286  }
288 
289 private:
290  void construct_from_projdata_info(const shared_ptr<const ExamInfo>& exam_info_sptr_v,
291  const ProjDataInfo& proj_data_info,
292  const CartesianCoordinate3D<float>& zooms,
293  const CartesianCoordinate3D<float>& origin,
294  const CartesianCoordinate3D<int>& sizes);
295 };
296 
297 END_NAMESPACE_STIR
298 
300 #endif
BasicCoordinate< num_dimensions, int > get_min_indices(const Array< num_dimensions, T > &a)
Get the first multi-dimensional index of the array.
Definition: array_index_functions.inl:100
inline implementations for the stir::VoxelsOnCartesianGrid class
defines the stir::DiscretisedDensityOnCartesianGrid class
defines the stir::CartesianCoordinate3D<coordT> class