STIR
6.2.0
|
The base class for all 3 dimensional shapes. More...
#include "stir/Shape/Shape3D.h"
Public Member Functions | |
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... | |
virtual void | scale (const CartesianCoordinate3D< float > &scale3D)=0 |
scale the whole shape 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 Shape3D * | clone () 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 &) | |
ParsingObject & | operator= (const ParsingObject &) |
void | ask_parameters () |
bool | parse (std::istream &f) |
bool | parse (const char *const filename) |
Protected Member Functions | |
Shape3D (const CartesianCoordinate3D< float > &origin) | |
Parsing functions | |
void | set_defaults () override |
Set defaults before parsing. | |
void | initialise_keymap () override |
Initialise all keywords. | |
Protected Member Functions inherited from stir::ParsingObject | |
virtual bool | post_processing () |
This will be called at the end of the parsing. More... | |
virtual void | set_key_values () |
This will be called before parsing or parameter_info is called. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from stir::RegisteredObject< Shape3D > | |
static Shape3D * | read_registered_object (std::istream *in, const std::string ®istered_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 Shape3D * | ask_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_less > | RegistryType |
The type of the registry. | |
Static Protected Member Functions inherited from stir::RegisteredObject< Shape3D > | |
static RegistryType & | registry () |
Static function returning the registry. More... | |
Protected Attributes inherited from stir::ParsingObject | |
KeyParser | parser |
The base class for all 3 dimensional shapes.
Shape3D objects are intended to represent geometrical object with sharp boundaries. So, a point is inside or shape, or it is not (i.e. no fuzzyness).
The only derived class where this is relaxed is DiscretisedShape3D. However, this then needs some special treatment for some member functions, and you have to be somewhat careful with that class.
; specify origin as {z,y,x} origin (in mm):= <float> ;defaults to {0,0,0}
|
inlinepure virtual |
Compare shapes.
This virtual function has to be implemented in each final class of the hierarchy. However, Shape3D::operator== has an implementation that checks equality of the origin (up-to a tolerance of .001). Derived classes can call this implementation.
Implemented in stir::EllipsoidalCylinder, stir::Box3D, stir::DiscretisedShape3D, and stir::Ellipsoid.
References stir::norm().
|
virtual |
Determine (approximately) the intersection volume of a voxel with the shape.
voxel_centre | is a cartesian coordinate in 'absolute' coordinates, i.e. in mm and not relative to the origin member. |
voxel_size | is the voxel size in mm. |
num_samples | determines the number of samples to take in z,y,x direction. |
In the Shape3D implementation, this is simply done by calling is_inside_shape() at various points in the voxel, and returning the average value. Obviously, this will only approximate the intersection volume for very large num_samples, or when the voxel is completely inside the shape.
Reimplemented in stir::DiscretisedShape3D.
|
pure virtual |
determine if a point is inside the shape or not (up to floating point errors)
coord | is a cartesian coordinate in 'absolute' coordinates, i.e. in mm and not relative to the origin member. |
This is really only well defined for shapes with sharp boundaries.
Implemented in stir::EllipsoidalCylinder, stir::DiscretisedShape3D, stir::Box3D, stir::Ellipsoid, and stir::CombinedShape3D< operation >.
|
virtual |
translate the whole shape by shifting its origin
Uses set_origin().
Reimplemented in stir::CombinedShape3D< operation >.
Referenced by scale_around_origin().
|
pure virtual |
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.
Implemented in stir::DiscretisedShape3D, stir::Shape3DWithOrientation, and stir::CombinedShape3D< operation >.
Referenced by scale_around_origin().
|
virtual |
construct an image representation the shape in a discretised manner
In principle, each voxel is sub-sampled to allow smoother edges.
Get rid of restriction to allow only VoxelsOnCartesianGrid<float> (but that's rather hard)
Potentially this should fill a DiscretisedShape3D.
Reimplemented in stir::DiscretisedShape3D.
References stir::DiscretisedDensity< num_dimensions, elemT >::get_origin(), stir::PixelsOnCartesianGrid< elemT >::get_pixel_size(), stir::VoxelsOnCartesianGrid< elemT >::get_voxel_size(), and stir::info().
Referenced by stir::ReconstructionTests< target_type >::construct_input_data(), stir::ROITests::run_tests(), and stir::TestProjDataInfoSubsets::TestProjDataInfoSubsets().
|
virtual |
Compute approximate volume.
As this is not possible/easy for all shapes, the default implementation returns a negative number. The user should check this to see if the returned value makes sense.
Reimplemented in stir::EllipsoidalCylinder, stir::Box3D, and stir::Ellipsoid.