STIR  6.2.0
DiscretisedDensity.h
Go to the documentation of this file.
1 //
2 //
3 /*
4  Copyright (C) 2000 PARAPET partners
5  Copyright (C) 2000- 2009-07-08, Hammersmith Imanet Ltd
6  Copyright (C) 2011-07-01 - 2011, Kris Thielemans
7  Copyright (C) 2018, University College London
8  Copyright (C) 2018, Commonwealth Scientific and Industrial Research Organisation
9  Australian eHealth Research Centre
10  This file is part of STIR.
11 
12  SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
13 
14  See STIR/LICENSE.txt for details
15 */
16 #ifndef __stir_DiscretisedDensity_H__
17 #define __stir_DiscretisedDensity_H__
18 
35 #include "stir/Array.h"
36 #include "stir/ExamData.h"
37 #include "stir/shared_ptr.h"
38 #include <string>
39 
40 START_NAMESPACE_STIR
41 
94 template <int num_dimensions, typename elemT>
95 class DiscretisedDensity : public ExamData, public Array<num_dimensions, elemT>
96 {
97 #ifdef SWIG
98  // work-around swig problem. It gets confused when using a private (or protected)
99  // typedef in a definition of a public typedef/member
100  public:
101 #else
102 private:
103 #endif
104  typedef Array<num_dimensions, elemT> base_type;
105  typedef DiscretisedDensity<num_dimensions, elemT> self_type;
106 
107 public:
109 
115 
117  static DiscretisedDensity* read_from_file(const std::string& filename);
118 
120  inline DiscretisedDensity();
121 
124 
126  inline DiscretisedDensity(const shared_ptr<const ExamInfo>& exam_info_sptr,
127  const IndexRange<num_dimensions>& range,
128  const CartesianCoordinate3D<float>& origin);
129 
131  inline const CartesianCoordinate3D<float>& get_origin() const;
132 
134  inline void set_origin(const CartesianCoordinate3D<float>& origin);
135 
137 
153 
155 
162  get_physical_coordinates_for_indices(const BasicCoordinate<num_dimensions, int>& indices) const;
163 
166 
169  get_physical_coordinates_for_indices(const BasicCoordinate<num_dimensions, float>& indices) const;
170 
172 
175  get_relative_coordinates_for_indices(const BasicCoordinate<num_dimensions, int>& indices) const;
176 
179 
185  get_relative_coordinates_for_indices(const BasicCoordinate<num_dimensions, float>& indices) const;
186 
188 
195  get_indices_closest_to_physical_coordinates(const CartesianCoordinate3D<float>& coords) const;
196 
198 
203  get_indices_closest_to_relative_coordinates(const CartesianCoordinate3D<float>& coords) const;
204 
206 
210  get_index_coordinates_for_physical_coordinates(const CartesianCoordinate3D<float>& coords) const;
211 
213 
217  get_index_coordinates_for_relative_coordinates(const CartesianCoordinate3D<float>& coords) const;
218 
221  get_index_coordinates_for_LPS_coordinates(const CartesianCoordinate3D<float>& coords) const;
222 
225  get_LPS_coordinates_for_physical_coordinates(const CartesianCoordinate3D<float>& indices) const;
226 
228  inline CartesianCoordinate3D<float> get_LPS_coordinates_for_indices(const BasicCoordinate<num_dimensions, int>& indices) const;
229 
232  get_LPS_coordinates_for_indices(const BasicCoordinate<num_dimensions, float>& indices) const;
233 
236  get_physical_coordinates_for_LPS_coordinates(const CartesianCoordinate3D<float>& coords) const;
237 
240  get_indices_closest_to_LPS_coordinates(const CartesianCoordinate3D<float>& coords) const;
241 
243 
245  virtual DiscretisedDensity<num_dimensions, elemT>* get_empty_copy() const = 0;
246 
248  virtual DiscretisedDensity<num_dimensions, elemT>* clone() const = 0;
249 
251  //*! \deprecated Use get_empty_copy() instead
253  {
254  return get_empty_copy();
255  }
256 
258 
259 
263  inline bool has_same_characteristics(self_type const&, std::string& explanation) const;
264 
266 
268  inline bool has_same_characteristics(self_type const&) const;
269 
271 
275  inline bool operator==(const self_type&) const;
276 
278  inline bool operator!=(const self_type&) const;
280 
281 protected:
283 
291  virtual bool actual_has_same_characteristics(DiscretisedDensity<num_dimensions, elemT> const&, std::string& explanation) const;
292 
294 
300  actual_get_relative_coordinates_for_indices(const BasicCoordinate<num_dimensions, float>& indices) const = 0;
301 
303  actual_get_index_coordinates_for_relative_coordinates(const CartesianCoordinate3D<float>& coords) const = 0;
304 
305 private:
307 
308  static inline CartesianCoordinate3D<float> swap_axes_based_on_orientation(const CartesianCoordinate3D<float>& coordinates,
309  const PatientPosition patient_position);
310 };
311 
312 END_NAMESPACE_STIR
313 
315 #endif
Definition: PatientPosition.h:28
This class defines ranges which can be &#39;irregular&#39;.
Definition: ArrayFunctionObject.h:32
inline implementation for stir::DiscretisedDensity
declaration of stir::ExamData
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast (or corresponding b...
defines the Array class for multi-dimensional (numeric) arrays
unique_ptr< DataT > read_from_file(const FileSignature &signature, FileT file)
Function that reads data from file using the default InputFileFormatRegistry, using the provided File...
Definition: read_from_file.h:46
DiscretisedDensity< num_dimensions, elemT > * get_empty_discretised_density() const
Allocate a new DiscretisedDensity object with same characteristics as the current one...
Definition: DiscretisedDensity.h:252
defines the stir::CartesianCoordinate3D<coordT> class
DiscretisedDensity< num_dimensions, elemT > hierarchy_base_type
A typedef that can be used what the base of the hierarchy is.
Definition: DiscretisedDensity.h:114
This abstract class is the basis for all image representations.
Definition: FBP2DReconstruction.h:35