STIR  6.2.0
Public Member Functions | Protected Member Functions | List of all members
stir::Shape3DWithOrientation Class Reference

Class for shapes with orientation. More...

#include "stir/Shape/Shape3DWithOrientation.h"

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

Public Member Functions

bool operator== (const Shape3DWithOrientation &s) const
 
void scale (const CartesianCoordinate3D< float > &scale3D) override
 scale the whole shape More...
 
const Array< 2, float > & get_direction_vectors () const
 get direction vectors currently in use More...
 
Succeeded set_direction_vectors (const Array< 2, float > &)
 set direction vectors More...
 
- Public Member Functions inherited from stir::Shape3D
virtual bool operator== (const Shape3D &) const =0
 Compare shapes. More...
 
bool operator!= (const Shape3D &) const
 Compare shapes.
 
virtual float get_voxel_weight (const CartesianCoordinate3D< float > &voxel_centre, const CartesianCoordinate3D< float > &voxel_size, const CartesianCoordinate3D< int > &num_samples) const
 Determine (approximately) the intersection volume of a voxel with the shape. More...
 
virtual bool is_inside_shape (const CartesianCoordinate3D< float > &coord) const =0
 determine if a point is inside the shape or not (up to floating point errors) More...
 
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 void construct_volume (VoxelsOnCartesianGrid< float > &image, const CartesianCoordinate3D< int > &num_samples) const
 construct an image representation the shape in a discretised manner More...
 
virtual float get_geometric_volume () const
 Compute approximate volume. More...
 
CartesianCoordinate3D< float > get_origin () const
 get the origin of the shape-coordinate system
 
virtual void set_origin (const CartesianCoordinate3D< float > &)
 set the origin of the shape-coordinate system
 
virtual Shape3Dclone () const =0
 Allocate a new Shape3D object which is a copy of the current one.
 
std::string parameter_info () override
 
- Public Member Functions inherited from stir::RegisteredObjectBase
virtual std::string get_registered_name () const =0
 Returns the name of the type of the object. More...
 
- 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)
 

Protected Member Functions

 Shape3DWithOrientation ()
 default constructor (NO initialisation of values)
 
 Shape3DWithOrientation (const CartesianCoordinate3D< float > &origin, const Array< 2, float > &directions=diagonal_matrix(3, 1.F))
 
float get_volume_of_unit_cell () const
 gets the volume of the cell spanned by the direction vectors More...
 
CartesianCoordinate3D< float > transform_to_shape_coords (const CartesianCoordinate3D< float > &) const
 Transform a 'real-world' coordinate to the coordinate system used by the shape.
 
void set_defaults () override
 sets defaults for parsing More...
 
void initialise_keymap () override
 Initialise all keywords.
 
bool post_processing () override
 This will be called at the end of the parsing. More...
 
void set_key_values () override
 This will be called before parsing or parameter_info is called. More...
 
- Protected Member Functions inherited from stir::Shape3D
 Shape3D (const CartesianCoordinate3D< float > &origin)
 

Additional Inherited Members

- 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.
 
- 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

Class for shapes with orientation.

Orientation is specified by giving a 3x3 matrix specifying 3 direction vectors. Note that these vectors do not necessarily have to be orthogonal nor have unit-norm (in fact, scale() will rescale these direction vectors). Of course, they should not be parallel, but this is not checked.

Functions like is_inside_shape(coord) should compute the coordinate to be used in the calculation as matrix_multiply(direction_vectors, coord-origin), or best practice is to call transform_to_shape_coords(coords).

Todo:
A previous release had Euler angle code. However, it is currently disabled as there were bugs in it.
Parameters
   ; any parameters of Shape3D

   ; parameters that enable to use non-default axes
   ; values below are give a rotation around y for 90 degrees (swapping x and z)
   ; Warning: this uses the STIR convention {z,y,x}
   direction vectors (in mm) := { {0,0,1}, {0,1,0}, {-1,0,0}}
   End:=

Member Function Documentation

◆ scale()

void stir::Shape3DWithOrientation::scale ( const CartesianCoordinate3D< float > &  scale3D)
overridevirtual

scale the whole shape

Scaling the shape also shifts the origin of the shape: new_origin = old_origin * scale3D. This is necessary such that combined shapes keep their correct relative positions. This means that scaling and translating is non-commutative.

shape1=shape;
shape1.translate(offset); shape1.scale(scale);
shape2=shape;
shape2.scale(scale); shape2.translate(offset*scale);
assert(shape1==shape2);

Implements stir::Shape3D.

References stir::square().

◆ get_direction_vectors()

const Array<2, float>& stir::Shape3DWithOrientation::get_direction_vectors ( ) const
inline

get direction vectors currently in use

Index offsets will always be 1

References stir::diagonal_matrix().

◆ set_direction_vectors()

Succeeded stir::Shape3DWithOrientation::set_direction_vectors ( const Array< 2, float > &  directions)

set direction vectors

Any index offset will be accepted.

Note that scaling the direction vectors is equivalent to a call to scale_around_origin()

References stir::VectorWithOffset< T >::set_min_index().

Referenced by stir::EllipsoidalCylinder::EllipsoidalCylinder().

◆ get_volume_of_unit_cell()

float stir::Shape3DWithOrientation::get_volume_of_unit_cell ( ) const
protected

gets the volume of the cell spanned by the direction vectors

this should be used when computing volumes etc

References stir::determinant().

Referenced by stir::EllipsoidalCylinder::is_inside_shape().

◆ set_defaults()

void stir::Shape3DWithOrientation::set_defaults ( )
overrideprotectedvirtual

sets defaults for parsing

sets direction vectors to the normal unit vectors.

Reimplemented from stir::Shape3D.

References stir::diagonal_matrix().

◆ post_processing()

bool stir::Shape3DWithOrientation::post_processing ( )
overrideprotectedvirtual

This will be called at the end of the parsing.

Returns
false if everything OK, true if not

Reimplemented from stir::ParsingObject.

References _PI, and stir::warning().

◆ set_key_values()

void stir::Shape3DWithOrientation::set_key_values ( )
overrideprotectedvirtual

This will be called before parsing or parameter_info is called.

This virtual function should be overloaded when the values for the keywords depend on other variables in the derived class that can be set independently of the parsing.

Example:

A derived class has a public member angle_in_radians, while a keyword sets a private member angle_in_degrees.

Reimplemented from stir::ParsingObject.

References _PI.


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