STIR  6.2.0
DiscretisedShape3D.h
Go to the documentation of this file.
1 //
2 //
3 /*
4  Copyright (C) 2000- 2007, Hammersmith Imanet Ltd
5  Copyright (C) 2023, University College London
6  This file is part of STIR.
7 
8  SPDX-License-Identifier: Apache-2.0
9 
10  See STIR/LICENSE.txt for details
11 */
20 #ifndef __stir_Shape_DiscretisedShape3D_H__
21 #define __stir_Shape_DiscretisedShape3D_H__
22 
24 #include "stir/Shape/Shape3D.h"
25 #include "stir/shared_ptr.h"
26 #include "stir/error.h"
27 
28 START_NAMESPACE_STIR
29 
30 template <int num_dimensions, typename elemT>
31 class DiscretisedDensity;
32 
52 class DiscretisedShape3D : public RegisteredParsingObject<DiscretisedShape3D, Shape3D, Shape3D>
53 {
54 public:
56  static const char* const registered_name;
57 
59 
61 
67 
69 
74  DiscretisedShape3D(const shared_ptr<const DiscretisedDensity<3, float>>& density_sptr);
75 
77 
78  bool operator==(const Shape3D&) const override
79  {
80  error("DiscretisedShape3D::operator== not implemented. Sorry");
81  return false;
82  }
83 
85  void set_origin(const CartesianCoordinate3D<float>&) override;
86 
88 
89  void scale(const CartesianCoordinate3D<float>& scale3D) override
90  {
91  error("TODO: DiscretisedShape3D::scale not implemented. Sorry.");
92  }
93 
95 
104  bool is_inside_shape(const CartesianCoordinate3D<float>& index) const override;
105 
107 
116  float get_voxel_weight(const CartesianCoordinate3D<float>& coord,
117  const CartesianCoordinate3D<float>& voxel_size,
118  const CartesianCoordinate3D<int>& num_samples) const override;
119 
121 
128  void construct_volume(VoxelsOnCartesianGrid<float>& image, const CartesianCoordinate3D<int>& num_samples) const override;
129  // void construct_slice(PixelsOnCartesianGrid<float> &plane, const CartesianCoordinate3D<int>& num_samples) const;
130 
131  Shape3D* clone() const override;
132 
134  DiscretisedDensity<3, float>& get_discretised_density();
135 
137  const DiscretisedDensity<3, float>& get_discretised_density() const;
138 
140  int get_label_index() const;
142  void set_label_index(int label_index);
143 
144 private:
145  int _label_index;
146  shared_ptr<DiscretisedDensity<3, float>> density_sptr;
147 
148  inline const VoxelsOnCartesianGrid<float>& image() const;
149  // inline VoxelsOnCartesianGrid<float>& image();
150 
152 
153  void set_defaults() override;
155  void initialise_keymap() override;
157 
161  bool post_processing() override;
163  std::string filename;
164 };
165 
166 END_NAMESPACE_STIR
167 
169 
170 #endif
This class is used to represent voxelised densities on a cuboid grid (3D).
Definition: FBP3DRPReconstruction.h:43
Inline-implementations of class stir::DiscretisedShape3D.
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast (or corresponding b...
bool operator==(const Shape3D &) const override
Compare shapes.
Definition: DiscretisedShape3D.h:78
The base class for all 3 dimensional shapes.
Definition: Shape3D.h:65
Declaration of stir::error()
Declaration of class stir::Shape3D.
static const char *const registered_name
Name which will be used when parsing a Shape3D object.
Definition: DiscretisedShape3D.h:56
void scale(const CartesianCoordinate3D< float > &scale3D) override
Scale shape.
Definition: DiscretisedShape3D.h:89
Parent class for all leaves in a RegisteredObject hierarchy that do parsing of parameter files...
Definition: RegisteredParsingObject.h:77
void error(const char *const s,...)
Print error with format string a la printf and throw exception.
Definition: error.cxx:42
Declaration of class stir::RegisteredParsingObject.
A class for shapes that have been discretised as a volume.
Definition: DiscretisedShape3D.h:52