STIR  6.2.0
Public Member Functions | Static Public Attributes | List of all members

A class for shapes that have been discretised as a volume. More...

#include "stir/Shape/DiscretisedShape3D.h"

Inheritance diagram for stir::DiscretisedShape3D:
Inheritance graph
[legend]

Public Member Functions

 DiscretisedShape3D (const VoxelsOnCartesianGrid< float > &image)
 Constructor that will copy the image to an internal member. More...
 
 DiscretisedShape3D (const shared_ptr< const DiscretisedDensity< 3, float >> &density_sptr)
 Constructor that will copy the shared_ptr image. More...
 
bool operator== (const Shape3D &) const override
 Compare shapes. More...
 
void set_origin (const CartesianCoordinate3D< float > &) override
 set origin of the shape
 
void scale (const CartesianCoordinate3D< float > &scale3D) override
 Scale shape. More...
 
bool is_inside_shape (const CartesianCoordinate3D< float > &index) const override
 determine if a point is inside a non-zero voxel or not More...
 
float get_voxel_weight (const CartesianCoordinate3D< float > &coord, const CartesianCoordinate3D< float > &voxel_size, const CartesianCoordinate3D< int > &num_samples) const override
 get weight for a voxel centred around coord More...
 
void construct_volume (VoxelsOnCartesianGrid< float > &image, const CartesianCoordinate3D< int > &num_samples) const override
 Construct a new image from the underlying density. More...
 
Shape3Dclone () const override
 Allocate a new Shape3D object which is a copy of the current one.
 
DiscretisedDensity< 3, float > & get_discretised_density ()
 provide access to the underlying density
 
const DiscretisedDensity< 3, float > & get_discretised_density () const
 provide (const) access to the underlying density
 
int get_label_index () const
 Return label index.
 
void set_label_index (int label_index)
 Set label index.
 
- Public Member Functions inherited from stir::RegisteredParsingObject< DiscretisedShape3D, Shape3D, Shape3D >
std::string get_registered_name () const override
 Returns Derived::registered_name.
 
std::string parameter_info () override
 Returns a string with all parameters and their values, in a form suitable for parsing again.
 
- Public Member Functions inherited from stir::Shape3D
bool operator!= (const Shape3D &) const
 Compare shapes.
 
virtual void translate (const CartesianCoordinate3D< float > &direction)
 translate the whole shape by shifting its origin More...
 
void scale_around_origin (const CartesianCoordinate3D< float > &scale3D)
 scale the whole shape, keeping the centre at the same place
 
virtual float get_geometric_volume () const
 Compute approximate volume. More...
 
CartesianCoordinate3D< float > get_origin () const
 get the origin of the shape-coordinate system
 
- Public Member Functions inherited from stir::ParsingObject
 ParsingObject (const ParsingObject &)
 
ParsingObjectoperator= (const ParsingObject &)
 
void ask_parameters ()
 
bool parse (std::istream &f)
 
bool parse (const char *const filename)
 

Static Public Attributes

static const char *const registered_name = "Discretised Shape3D"
 Name which will be used when parsing a Shape3D object.
 

Additional Inherited Members

- Static Public Member Functions inherited from stir::RegisteredParsingObject< DiscretisedShape3D, Shape3D, Shape3D >
static Shape3Dread_from_stream (std::istream *)
 Construct a new object (of type Derived) by parsing the istream. More...
 
- Static Public Member Functions inherited from stir::RegisteredObject< Shape3D >
static Shape3Dread_registered_object (std::istream *in, const std::string &registered_name)
 Construct a new object (of a type derived from Root, its actual type determined by the registered_name parameter) by parsing the istream. More...
 
static Shape3Dask_type_and_parameters ()
 ask the user for the type, and then calls read_registered_object(0, type) More...
 
static void list_registered_names (std::ostream &stream)
 List all possible registered names to the stream. More...
 
- Protected Types inherited from stir::RegisteredObject< Shape3D >
typedef Shape3D *(* RootFactory) (std::istream *)
 The type of a root factory is a function, taking an istream* as argument, and returning a Root*.
 
typedef FactoryRegistry< std::string, RootFactory, interfile_lessRegistryType
 The type of the registry.
 
- Protected Member Functions inherited from stir::Shape3D
 Shape3D (const CartesianCoordinate3D< float > &origin)
 
void set_defaults () override
 Set defaults before parsing.
 
void initialise_keymap () override
 Initialise all keywords.
 
- Protected Member Functions inherited from stir::ParsingObject
virtual void set_key_values ()
 This will be called before parsing or parameter_info is called. More...
 
- Static Protected Member Functions inherited from stir::RegisteredObject< Shape3D >
static RegistryTyperegistry ()
 Static function returning the registry. More...
 
- Protected Attributes inherited from stir::ParsingObject
KeyParser parser
 

Detailed Description

A class for shapes that have been discretised as a volume.

Currently only supports discretisation via VoxelsOnCartesianGrid.

This class supports 2 options:

Parameters for parsing
Discretised Shape3D Parameters:=
input filename := <filename>
label index := -1 ; if less than 1 (default), we will use "weights"
END:=
where filename needs to specify a volume that can be read by STIR.

Constructor & Destructor Documentation

◆ DiscretisedShape3D() [1/2]

stir::DiscretisedShape3D::DiscretisedShape3D ( const VoxelsOnCartesianGrid< float > &  image)

Constructor that will copy the image to an internal member.

The filename member is set to "FROM MEMORY" such that parameter_info() returns somewhat useful info. This has a consequence that the object cannot be constructed from its own parameter_info(). This is in contrast with most other shapes.

References stir::DiscretisedDensity< num_dimensions, elemT >::get_origin(), and set_origin().

◆ DiscretisedShape3D() [2/2]

stir::DiscretisedShape3D::DiscretisedShape3D ( const shared_ptr< const DiscretisedDensity< 3, float >> &  density_sptr)

Constructor that will copy the shared_ptr image.

The filename member is set to "FROM MEMORY" such that parameter_info() returns somewhat useful info. This has a consequence that the object cannot be constructed from its own parameter_info(). This is in contrast with most other shapes.

References stir::KeyParser::add_key(), stir::KeyParser::add_start_key(), stir::KeyParser::add_stop_key(), stir::error(), stir::Shape3D::get_origin(), stir::Shape3D::initialise_keymap(), stir::ParsingObject::post_processing(), registered_name, stir::Shape3D::set_defaults(), set_origin(), and stir::warning().

Member Function Documentation

◆ operator==()

bool stir::DiscretisedShape3D::operator== ( const Shape3D ) const
inlineoverridevirtual

Compare shapes.

Todo:
currently not implemented (will call error()

Implements stir::Shape3D.

References stir::error().

◆ scale()

void stir::DiscretisedShape3D::scale ( const CartesianCoordinate3D< float > &  scale3D)
inlineoverridevirtual

Scale shape.

Todo:
Not implemented (will call error())

Implements stir::Shape3D.

References stir::error().

◆ is_inside_shape()

bool stir::DiscretisedShape3D::is_inside_shape ( const CartesianCoordinate3D< float > &  index) const
overridevirtual

determine if a point is inside a non-zero voxel or not

Warning
For voxels at the edges, it is somewhat ill-defined if a point in the voxel is inside the shape. The current implementation will return true for every point in the voxel, even if the voxel value is .001. In particular, this means that this definition of is_inside_shape() cannot be used to find the voxel_weight. So, we have to redefine get_voxel_weight() in the present class.

Implements stir::Shape3D.

◆ get_voxel_weight()

float stir::DiscretisedShape3D::get_voxel_weight ( const CartesianCoordinate3D< float > &  coord,
const CartesianCoordinate3D< float > &  voxel_size,
const CartesianCoordinate3D< int > &  num_samples 
) const
overridevirtual

get weight for a voxel centred around coord

Warning
Presently only works when coord is the centre of a voxel and voxel_size is identical to the image's voxel_size

The argument num_samples is ignored.

If get_label_index() >= 0, the weight will be 1 for those voxels whose value is equal to the label_index and zero otherwise. If get_label_index() < 0 (default), the weight will be the actual voxel value.

Reimplemented from stir::Shape3D.

References stir::round().

◆ construct_volume()

void stir::DiscretisedShape3D::construct_volume ( VoxelsOnCartesianGrid< float > &  image,
const CartesianCoordinate3D< int > &  num_samples 
) const
overridevirtual

Construct a new image from the underlying density.

If get_label_index() >= 0, the imags need to have the same characteristics, but in the other case, zoom_image is called for interpolation. The result is then scaled such that mean ROI values remain the same (at least for ROIs which avoid edges).

The argument num_samples is ignored.

Reimplemented from stir::Shape3D.

References stir::Array< num_dimensions, elemT >::begin_all(), stir::Array< num_dimensions, elemT >::end_all(), stir::error(), stir::round(), and stir::zoom_image().


The documentation for this class was generated from the following files: