Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit

Mapper to resample and display 2D slices of a 3D image. More...

#include <mitkImageVtkMapper2D.h>

Inheritance diagram for mitk::ImageVtkMapper2D:
Collaboration diagram for mitk::ImageVtkMapper2D:

Classes

class  LocalStorage
 Internal class holding the mapper, actor, etc. for each of the 3 2D render windows. More...
 

Public Types

typedef ImageVtkMapper2D Self
 
typedef VtkMapper Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 
- Public Types inherited from mitk::VtkMapper
typedef VtkMapper Self
 
typedef Mapper Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 
- Public Types inherited from mitk::Mapper
typedef Mapper Self
 
typedef itk::Object Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 

Public Member Functions

virtual std::vector< std::string > GetClassHierarchy () const override
 
virtual const char * GetClassName () const
 
Pointer Clone () const
 
const mitk::ImageGetInput (void)
 Get the Image to map. More...
 
virtual void Update (mitk::BaseRenderer *renderer) override
 Checks whether this mapper needs to update itself and generate data. More...
 
virtual vtkProp * GetVtkProp (mitk::BaseRenderer *renderer) override
 
LocalStorageGetLocalStorage (mitk::BaseRenderer *renderer)
 Get the LocalStorage corresponding to the current renderer. More...
 
void ApplyRenderingMode (mitk::BaseRenderer *renderer)
 This method switches between different rendering modes (e.g. use a lookup table or a transfer function). Detailed documentation about the modes can be found here: mitk::RenderingerModeProperty. More...
 
- Public Member Functions inherited from mitk::VtkMapper
virtual bool IsVtkBased () const override
 Returns whether this is an vtk-based mapper. More...
 
void MitkRender (mitk::BaseRenderer *renderer, mitk::VtkPropRenderer::RenderType type) override
 Determines which geometry should be rendered (opaque, translucent, volumetric, overlay) and calls the appropriate function. More...
 
virtual void MitkRenderOverlay (BaseRenderer *renderer)
 Checks visibility and renders the overlay. More...
 
virtual void MitkRenderOpaqueGeometry (BaseRenderer *renderer)
 Checks visibility and renders untransparent geometry. More...
 
virtual void MitkRenderTranslucentGeometry (BaseRenderer *renderer)
 Checks visiblity and renders transparent geometry. More...
 
virtual void MitkRenderVolumetricGeometry (BaseRenderer *renderer)
 Checks visibility and renders volumes. More...
 
virtual bool HasVtkProp (const vtkProp *prop, BaseRenderer *renderer)
 Returns true if this mapper owns the specified vtkProp for the given BaseRenderer. More...
 
virtual void UpdateVtkTransform (mitk::BaseRenderer *renderer)
 Set the vtkTransform of the m_Prop3D for the current time step of renderer. More...
 
virtual void ApplyProperties (vtkActor *actor, mitk::BaseRenderer *renderer)
 Apply color and opacity properties read from the PropertyList. More...
 
void ApplyShaderProperties (mitk::BaseRenderer *renderer)
 SHADERTODO. More...
 
virtual void ApplyColorAndOpacityProperties (mitk::BaseRenderer *renderer, vtkActor *actor) override
 Apply color and opacity properties read from the PropertyList. Called by mapper subclasses. More...
 
virtual void ReleaseGraphicsResources (mitk::BaseRenderer *)
 Release vtk-based graphics resources that are being consumed by this mapper. More...
 
- Public Member Functions inherited from mitk::Mapper
virtual void SetDataNode (DataNode *_arg)
 Set the DataNode containing the data to map. More...
 
virtual DataNodeGetDataNode () const
 Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper belongs to a data node. Otherwise, the returned DataNode Pointer might be invalid. More...
 
BaseDataGetData () const
 Get the data to map. More...
 
virtual bool GetColor (float rgb[3], BaseRenderer *renderer, const char *name="color") const
 Convenience access method for color properties (instances of ColorProperty) More...
 
virtual bool GetVisibility (bool &visible, BaseRenderer *renderer, const char *name="visible") const
 Convenience access method for visibility properties (instances of BoolProperty) More...
 
virtual bool GetOpacity (float &opacity, BaseRenderer *renderer, const char *name="opacity") const
 Convenience access method for opacity properties (instances of FloatProperty) More...
 
virtual bool GetLevelWindow (LevelWindow &levelWindow, BaseRenderer *renderer, const char *name="levelwindow") const
 Convenience access method for color properties (instances of LevelWindoProperty) More...
 
virtual bool IsVisible (BaseRenderer *renderer, const char *name="visible") const
 Convenience access method for visibility properties (instances of BoolProperty). Return value is the visibility. Default is visible==true, i.e., true is returned even if the property (propertyKey) is not found. More...
 
int GetTimestep () const
 Returns the current time step as calculated from the renderer. More...
 
virtual bool IsLODEnabled (BaseRenderer *) const
 

Static Public Member Functions

static const char * GetStaticNameOfClass ()
 
static Pointer New ()
 
static void SetDefaultProperties (mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
 Set the default properties for general image rendering. More...
 
- Static Public Member Functions inherited from mitk::VtkMapper
static const char * GetStaticNameOfClass ()
 
static void SetVtkMapperImmediateModeRendering (vtkMapper *mapper)
 Re-issues all drawing commands required to describe the entire scene each time a new frame is required, regardless of actual changes. More...
 
- Static Public Member Functions inherited from mitk::Mapper
static const char * GetStaticNameOfClass ()
 
static void SetDefaultProperties (DataNode *node, BaseRenderer *renderer=nullptr, bool overwrite=false)
 Set default values of properties used by this mapper to node. More...
 

Public Attributes

mitk::LocalStorageHandler< LocalStoragem_LSH
 The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows. More...
 
- Public Attributes inherited from mitk::VtkMapper
mitk::LocalStorageHandler< VtkMapperLocalStoragem_VtkMapperLSH
 

Protected Member Functions

void TransformActor (mitk::BaseRenderer *renderer)
 Transforms the actor to the actual position in 3D. More...
 
void GeneratePlane (mitk::BaseRenderer *renderer, double planeBounds[6])
 Generates a plane according to the size of the resliced image in milimeters. More...
 
template<typename TPixel >
vtkSmartPointer< vtkPolyData > CreateOutlinePolyData (mitk::BaseRenderer *renderer)
 Generates a vtkPolyData object containing the outline of a given binary slice. More...
 
 ImageVtkMapper2D ()
 
virtual ~ImageVtkMapper2D ()
 
virtual void GenerateDataForRenderer (mitk::BaseRenderer *renderer) override
 Does the actual resampling, without rendering the image yet. All the data is generated inside this method. The vtkProp (or Actor) is filled with content (i.e. the resliced image). More...
 
float CalculateLayerDepth (mitk::BaseRenderer *renderer)
 This method uses the vtkCamera clipping range and the layer property to calcualte the depth of the object (e.g. image or contour). The depth is used to keep the correct order for the final VTK rendering. More...
 
void ApplyLookuptable (mitk::BaseRenderer *renderer)
 This method applies (or modifies) the lookuptable for all types of images. More...
 
void ApplyColorTransferFunction (mitk::BaseRenderer *renderer)
 This method applies a color transfer function. Internally, a vtkColorTransferFunction is used. This is usefull for coloring continous images (e.g. float) More...
 
void ApplyLevelWindow (mitk::BaseRenderer *renderer)
 ApplyLevelWindow Apply the level window for the given renderer. More...
 
void ApplyColor (mitk::BaseRenderer *renderer)
 Set the color of the image/polydata. More...
 
void ApplyOpacity (mitk::BaseRenderer *renderer)
 Set the opacity of the actor. More...
 
bool RenderingGeometryIntersectsImage (const PlaneGeometry *renderingGeometry, SlicedGeometry3D *imageGeometry)
 Calculates whether the given rendering geometry intersects the given SlicedGeometry3D. More...
 
- Protected Member Functions inherited from mitk::VtkMapper
 VtkMapper ()
 
virtual ~VtkMapper ()
 
- Protected Member Functions inherited from mitk::Mapper
 Mapper ()
 explicit constructor which disallows implicit conversions More...
 
virtual ~Mapper ()
 virtual destructor in order to derive from this class More...
 
virtual void GenerateData ()
 Generate the data needed for rendering (independent of a specific renderer) More...
 
virtual void CalculateTimeStep (BaseRenderer *renderer)
 Updates the time step, which is sometimes needed in subclasses. More...
 
virtual void ResetMapper (BaseRenderer *)
 Reset the mapper (i.e., make sure that nothing is displayed) if no valid data is present. In most cases the reimplemented function disables the according actors (toggling visibility off) More...
 
virtual OverlayManagerGetOverlayManager () const
 

Additional Inherited Members

- Protected Attributes inherited from mitk::Mapper
mitk::DataNodem_DataNode
 

Detailed Description

Mapper to resample and display 2D slices of a 3D image.

The following image gives a brief overview of the mapping and the involved parts.

imageVtkMapper2Darchitecture.png

First, the image is resliced by means of vtkImageReslice. The volume image serves as input to the mapper in addition to spatial placement of the slice and a few other properties such as thick slices. This code was already present in the old version (mitkImageMapperGL2D).

Next, the obtained slice (m_ReslicedImage) is put into a vtkMitkLevelWindowFilter and the scalar levelwindow, opacity levelwindow and optional clipping to local image bounds are applied

Next, the output of the vtkMitkLevelWindowFilter is used to create a texture (m_Texture) and a plane onto which the texture is rendered (m_Plane). For mapping purposes, a vtkPolyDataMapper (m_Mapper) is utilized. Orthographic projection is applied to create the effect of a 2D image. The mapper and the texture are assigned to the actor (m_Actor) which is passed to the VTK rendering pipeline via the method GetVtkProp().

In order to transform the textured plane to the correct position in space, the same transformation as used for reslicing is applied to both the camera and the vtkActor. All important steps are explained in more detail below. The resulting 2D image (by reslicing the underlying 3D input image appropriately) can either be directly rendered in a 2D view or just be calculated to be used later by another rendering entity, e.g. in texture mapping in a 3D view.

Properties that can be set for images and influence the imageMapper2D are:

  • "opacity": (FloatProperty) Opacity of the image
  • "color": (ColorProperty) Color of the image
  • "LookupTable": (mitkLookupTableProperty) If this property is set, the default lookuptable will be ignored and the "LookupTable" value will be used instead.
  • "Image Rendering.Mode": This property decides which mode is used to render images. (E.g. if a lookup table or a transferfunction is applied). Detailed documentation about the modes can be found here: mitk::RenderingerModeProperty
  • "Image Rendering.Transfer Function": (mitkTransferFunctionProperty) If this property is set, a color transferfunction will be used to color the image.
  • "binary": (BoolProperty) is the image a binary image or not
  • "outline binary": (BoolProperty) show outline of the image or not
  • "texture interpolation": (BoolProperty) texture interpolation of the image
  • "reslice interpolation": (VtkResliceInterpolationProperty) reslice interpolation of the image
  • "in plane resample extent by geometry": (BoolProperty) Do it or not
  • "bounding box": (BoolProperty) Is the Bounding Box of the image shown or not
  • "layer": (IntProperty) Layer of the image
  • "volume annotation color": (ColorProperty) color of the volume annotation, TODO has to be reimplemented
  • "volume annotation unit": (StringProperty) annotation unit as string (does not implicit convert the unit!) unit is ml or cm3, TODO has to be reimplemented

The default properties are:

  • "opacity", mitk::FloatProperty::New(0.3f), renderer, overwrite )
  • "color", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite )
  • "binary", mitk::BoolProperty::New( true ), renderer, overwrite )
  • "outline binary", mitk::BoolProperty::New( false ), renderer, overwrite )
  • "texture interpolation", mitk::BoolProperty::New( mitk::DataNodeFactory::m_TextureInterpolationActive ) )
  • "reslice interpolation", mitk::VtkResliceInterpolationProperty::New() )
  • "in plane resample extent by geometry", mitk::BoolProperty::New( false ) )
  • "bounding box", mitk::BoolProperty::New( false ) )
  • "layer", mitk::IntProperty::New(10), renderer, overwrite)
  • "Image Rendering.Transfer Function": Default color transfer function for CTs
  • "LookupTable": Rainbow color.

If the modality-property is set for an image, the mapper uses modality-specific default properties, e.g. color maps, if they are defined.

Definition at line 120 of file mitkImageVtkMapper2D.h.

Member Typedef Documentation

Standard class typedefs.

Definition at line 124 of file mitkImageVtkMapper2D.h.

Constructor & Destructor Documentation

mitk::ImageVtkMapper2D::ImageVtkMapper2D ( )
protected

Default constructor

Definition at line 62 of file mitkImageVtkMapper2D.cpp.

mitk::ImageVtkMapper2D::~ImageVtkMapper2D ( )
protectedvirtual

Default deconstructor

Definition at line 66 of file mitkImageVtkMapper2D.cpp.

Member Function Documentation

void mitk::ImageVtkMapper2D::ApplyColor ( mitk::BaseRenderer renderer)
protected

Set the color of the image/polydata.

Definition at line 469 of file mitkImageVtkMapper2D.cpp.

References mitk::ImageVtkMapper2D::LocalStorage::m_Actor, and mitk::ImageVtkMapper2D::LocalStorage::m_Actors.

void mitk::ImageVtkMapper2D::ApplyColorTransferFunction ( mitk::BaseRenderer renderer)
protected

This method applies a color transfer function. Internally, a vtkColorTransferFunction is used. This is usefull for coloring continous images (e.g. float)

Warning
To use the color transfer function, the property 'Image Rendering.Transfer Function' must be set and a 'Image Rendering.Mode' which uses the color transfer function must be set.

Definition at line 624 of file mitkImageVtkMapper2D.cpp.

References mitk::ImageVtkMapper2D::LocalStorage::m_LevelWindowFilter, and MITK_ERROR.

void mitk::ImageVtkMapper2D::ApplyLevelWindow ( mitk::BaseRenderer renderer)
protected

ApplyLevelWindow Apply the level window for the given renderer.

Warning
To use the level window, the property 'LevelWindow' must be set and a 'Image Rendering.Mode' which uses the level window must be set.
Parameters
rendererLevel window for which renderer?

Definition at line 445 of file mitkImageVtkMapper2D.cpp.

References mitk::LevelWindow::GetLowerWindowBound(), mitk::LevelWindow::GetUpperWindowBound(), and mitk::ImageVtkMapper2D::LocalStorage::m_LevelWindowFilter.

void mitk::ImageVtkMapper2D::ApplyLookuptable ( mitk::BaseRenderer renderer)
protected

This method applies (or modifies) the lookuptable for all types of images.

Warning
To use the lookup table, the property 'Lookup Table' must be set and a 'Image Rendering.Mode' which uses the lookup table must be set.

Definition at line 601 of file mitkImageVtkMapper2D.cpp.

References mitk::ImageVtkMapper2D::LocalStorage::m_ColorLookupTable, and mitk::ImageVtkMapper2D::LocalStorage::m_LevelWindowFilter.

void mitk::ImageVtkMapper2D::ApplyOpacity ( mitk::BaseRenderer renderer)
protected

Set the opacity of the actor.

Definition at line 532 of file mitkImageVtkMapper2D.cpp.

References mitk::ImageVtkMapper2D::LocalStorage::m_Actor, and mitk::ImageVtkMapper2D::LocalStorage::m_Actors.

void mitk::ImageVtkMapper2D::ApplyRenderingMode ( mitk::BaseRenderer renderer)
float mitk::ImageVtkMapper2D::CalculateLayerDepth ( mitk::BaseRenderer renderer)
protected

This method uses the vtkCamera clipping range and the layer property to calcualte the depth of the object (e.g. image or contour). The depth is used to keep the correct order for the final VTK rendering.

Definition at line 89 of file mitkImageVtkMapper2D.cpp.

References mitk::BaseRenderer::GetVtkRenderer(), and MITK_WARN.

Pointer mitk::ImageVtkMapper2D::Clone ( ) const
template<typename TPixel >
vtkSmartPointer< vtkPolyData > mitk::ImageVtkMapper2D::CreateOutlinePolyData ( mitk::BaseRenderer renderer)
protected

Generates a vtkPolyData object containing the outline of a given binary slice.

Parameters
rendererPointer to the renderer containing the needed information
Note
This code is based on code from the iil library.

Definition at line 873 of file mitkImageVtkMapper2D.cpp.

References line, mitk::ImageVtkMapper2D::LocalStorage::m_mmPerPixel, mitk::ImageVtkMapper2D::LocalStorage::m_ReslicedImage, and mitk::New().

void mitk::ImageVtkMapper2D::GenerateDataForRenderer ( mitk::BaseRenderer renderer)
overrideprotectedvirtual

Does the actual resampling, without rendering the image yet. All the data is generated inside this method. The vtkProp (or Actor) is filled with content (i.e. the resliced image).

After generation, a 4x4 transformation matrix(t) of the current slice is obtained from the vtkResliceImage object via GetReslicesAxis(). This matrix is applied to each textured plane (actor->SetUserTransform(t)) to transform everything to the actual 3D position (cf. the following image).

cameraPositioning3D.png

Reimplemented from mitk::Mapper.

Reimplemented in mitk::TbssImageMapper.

Definition at line 119 of file mitkImageVtkMapper2D.cpp.

References mitk::PlaneClipping::CalculateClippedPlaneBounds(), mitk::DataNode::GetBoolProperty(), mitk::PixelType::GetComponentType(), mitk::BaseRenderer::GetCurrentWorldPlaneGeometry(), mitk::BaseRenderer::GetCurrentWorldPlaneGeometryNode(), mitk::Image::GetDimension(), mitk::DataNode::GetFloatProperty(), mitk::BaseData::GetGeometry(), mitk::TimeGeometry::GetGeometryForTimeStep(), mitk::VtkResliceInterpolationProperty::GetInterpolation(), mitk::DataNode::GetIntProperty(), mitk::PlaneGeometry::GetNormal(), mitk::PixelType::GetNumberOfComponents(), mitk::Image::GetPixelType(), mitk::AbstractTransformGeometry::GetPlane(), mitk::DataNode::GetProperty(), mitk::SlicedData::GetSlicedGeometry(), mitk::BaseData::GetTimeGeometry(), mitk::GenericProperty< T >::GetValue(), mitk::EnumerationProperty::GetValueAsId(), mitk::PlaneGeometry::HasReferenceGeometry(), mitk::BaseData::IsInitialized(), mitk::BaseGeometry::IsValid(), mitk::ImageVtkMapper2D::LocalStorage::m_Actor, mitk::ImageVtkMapper2D::LocalStorage::m_Actors, mitk::ImageVtkMapper2D::LocalStorage::m_EmptyPolyData, mitk::ImageVtkMapper2D::LocalStorage::m_LastUpdateTime, mitk::ImageVtkMapper2D::LocalStorage::m_LevelWindowFilter, mitk::ImageVtkMapper2D::LocalStorage::m_Mapper, mitk::ImageVtkMapper2D::LocalStorage::m_mmPerPixel, mitk::ImageVtkMapper2D::LocalStorage::m_OutlinePolyData, mitk::ImageVtkMapper2D::LocalStorage::m_Plane, mitk::ImageVtkMapper2D::LocalStorage::m_ReslicedImage, mitk::ImageVtkMapper2D::LocalStorage::m_Reslicer, mitk::ImageVtkMapper2D::LocalStorage::m_Texture, mitk::ImageVtkMapper2D::LocalStorage::m_TSFilter, mitk::ImageVtkMapper2D::LocalStorage::m_VectorComponentExtractor, MITK_ERROR, MITK_WARN, mitk::ExtractSliceFilter::RESLICE_CUBIC, mitk::ExtractSliceFilter::RESLICE_LINEAR, and mitk::ExtractSliceFilter::RESLICE_NEAREST.

Referenced by mitk::CompositeMapper::Update().

void mitk::ImageVtkMapper2D::GeneratePlane ( mitk::BaseRenderer renderer,
double  planeBounds[6] 
)
protected

Generates a plane according to the size of the resliced image in milimeters.

texturedPlane.png

In VTK a vtkPlaneSource is defined through three points. The origin and two points defining the axes of the plane (see VTK documentation). The origin is set to (xMin; yMin; Z), where xMin and yMin are the minimal bounds of the resliced image in space. Z is relevant for blending and the layer property. The center of the plane (C) is also the center of the view plane (cf. the image above).

Note
For the standard MITK view with three 2D render windows showing three different slices, three such planes are generated. All these planes are generated in the XY-plane (even if they depict a YZ-slice of the volume).

Definition at line 74 of file mitkImageVtkMapper2D.cpp.

References mitk::ImageVtkMapper2D::LocalStorage::m_Plane.

virtual std::vector<std::string> mitk::ImageVtkMapper2D::GetClassHierarchy ( ) const
inlineoverridevirtual

Reimplemented from mitk::VtkMapper.

Definition at line 124 of file mitkImageVtkMapper2D.h.

virtual const char* mitk::ImageVtkMapper2D::GetClassName ( ) const
virtual

Reimplemented from mitk::VtkMapper.

const mitk::Image * mitk::ImageVtkMapper2D::GetInput ( void  )

Get the Image to map.

Definition at line 108 of file mitkImageVtkMapper2D.cpp.

mitk::ImageVtkMapper2D::LocalStorage * mitk::ImageVtkMapper2D::GetLocalStorage ( mitk::BaseRenderer renderer)

Get the LocalStorage corresponding to the current renderer.

Definition at line 867 of file mitkImageVtkMapper2D.cpp.

Referenced by mitk::PlaneGeometryDataVtkMapper3D::ProcessNode().

static const char* mitk::ImageVtkMapper2D::GetStaticNameOfClass ( )
inlinestatic

Definition at line 124 of file mitkImageVtkMapper2D.h.

vtkProp * mitk::ImageVtkMapper2D::GetVtkProp ( mitk::BaseRenderer renderer)
overridevirtual

Implements mitk::VtkMapper.

Definition at line 113 of file mitkImageVtkMapper2D.cpp.

static Pointer mitk::ImageVtkMapper2D::New ( )
static

Method for creation through the object factory.

Referenced by mitk::QuantificationObjectFactory::CreateMapper(), and mitk::CoreObjectFactory::CreateMapper().

bool mitk::ImageVtkMapper2D::RenderingGeometryIntersectsImage ( const PlaneGeometry renderingGeometry,
SlicedGeometry3D imageGeometry 
)
protected

Calculates whether the given rendering geometry intersects the given SlicedGeometry3D.

This method checks if the given PlaneGeometry intersects the given SlicedGeometry3D. It calculates the distance of the PlaneGeometry to all 8 cornerpoints of the SlicedGeometry3D. If all distances have the same sign (all positive or all negative) there is no intersection. If the distances have different sign, there is an intersection.

Definition at line 1051 of file mitkImageVtkMapper2D.cpp.

References mitk::BaseGeometry::GetCornerPoint(), and mitk::PlaneGeometry::SignedDistance().

void mitk::ImageVtkMapper2D::TransformActor ( mitk::BaseRenderer renderer)
protected

Transforms the actor to the actual position in 3D.

Parameters
rendererThe current renderer corresponding to the render window.

Definition at line 1031 of file mitkImageVtkMapper2D.cpp.

References mitk::ImageVtkMapper2D::LocalStorage::m_Actor, mitk::ImageVtkMapper2D::LocalStorage::m_Actors, mitk::ImageVtkMapper2D::LocalStorage::m_mmPerPixel, mitk::ImageVtkMapper2D::LocalStorage::m_Reslicer, and mitk::New().

Member Data Documentation

mitk::LocalStorageHandler<LocalStorage> mitk::ImageVtkMapper2D::m_LSH

The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows.

Definition at line 200 of file mitkImageVtkMapper2D.h.


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