Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::ImageDataItem Class Reference

Internal container for image data used by mitk::Image. More...

#include <mitkImageDataItem.h>

Inheritance diagram for mitk::ImageDataItem:
Collaboration diagram for mitk::ImageDataItem:

Public Types

typedef itk::SmartPointer< mitk::Image > ImagePointer
 Smart pointer to Image. More...
 
typedef itk::SmartPointer< const mitk::Image > ImageConstPointer
 Smart pointer to const Image. More...
 

Public Member Functions

 mitkClassMacroItkParent (ImageDataItem, itk::LightObject)
 
 ImageDataItem (const ImageDataItem &aParent, const mitk::ImageDescriptor::Pointer desc, int timestep, unsigned int dimension, void *data=nullptr, bool manageMemory=false, size_t offset=0)
 Construct a sub-image data item as a child of an existing item. More...
 
 ~ImageDataItem () override
 Destructor. Frees managed memory and VTK resources. More...
 
 ImageDataItem (const mitk::ImageDescriptor::Pointer desc, int timestep, void *data, bool manageMemory)
 Construct a top-level data item from an image descriptor. More...
 
 ImageDataItem (const mitk::PixelType &type, int timestep, unsigned int dimension, unsigned int *dimensions, void *data, bool manageMemory)
 Construct a data item from explicit pixel type and dimension information. More...
 
 ImageDataItem (const ImageDataItem &other)=delete
 
ImageDataItem & operator= (const ImageDataItem &other)=delete
 
bool IsComplete () const
 Check whether all sub-items of this data item have been filled. More...
 
void SetComplete (bool complete)
 Set the completion status of this data item. More...
 
int GetOffset () const
 Get the byte offset of this item within its parent's buffer. More...
 
PixelType GetPixelType () const
 Get the pixel type of this data item. More...
 
void SetTimestep (int t)
 Set the time step index for this data item. More...
 
void SetManageMemory (bool b)
 Set whether this item owns (and will delete) its data buffer. More...
 
int GetDimension () const
 Get the number of spatial dimensions. More...
 
int GetDimension (int i) const
 Get the size along a specific dimension. More...
 
ImageDataItem::ConstPointer GetParent () const
 Get the parent data item, if any. More...
 
ImageVtkReadAccessor * GetVtkImageAccessor (ImageConstPointer iP) const
 Get or create a VTK read accessor for this data item. More...
 
ImageVtkWriteAccessor * GetVtkImageAccessor (ImagePointer iP)
 Get or create a VTK write accessor for this data item. More...
 
bool GetManageMemory () const
 Query whether this item will delete its data buffer on destruction. More...
 
virtual void ConstructVtkImageData (ImageConstPointer iP) const
 Build a vtkImageData representation from the raw pixel buffer. More...
 
size_t GetSize () const
 Get the total size of this data item in bytes. More...
 
virtual void Modified () const
 Mark the internal vtkImageData as modified. More...
 

Protected Member Functions

void * GetData () const
 

Protected Attributes

unsigned char * m_Data
 
PixelType * m_PixelType
 
bool m_ManageMemory
 
vtkImageData * m_VtkImageData
 
ImageVtkReadAccessor * m_VtkImageReadAccessor
 
ImageVtkWriteAccessor * m_VtkImageWriteAccessor
 
int m_Offset
 
bool m_IsComplete
 
size_t m_Size
 

Detailed Description

Internal container for image data used by mitk::Image.

ImageDataItem manages raw pixel buffers and bridges between MITK's Image representation and VTK's vtkImageData. It is primarily used to represent sub-images (e.g. individual slices or volumes of a time series) inside mitk::Image.

This class is an implementation detail; it should not be used directly outside of mitk::Image and its accessor classes.

See also
Image, ImageReadAccessor, ImageWriteAccessor, ImageVtkReadAccessor

Definition at line 44 of file mitkImageDataItem.h.

Member Typedef Documentation

◆ ImageConstPointer

Smart pointer to const Image.

Definition at line 60 of file mitkImageDataItem.h.

◆ ImagePointer

Smart pointer to Image.

Definition at line 59 of file mitkImageDataItem.h.

Constructor & Destructor Documentation

◆ ImageDataItem() [1/4]

mitk::ImageDataItem::ImageDataItem ( const ImageDataItem &  aParent,
const mitk::ImageDescriptor::Pointer  desc,
int  timestep,
unsigned int  dimension,
void *  data = nullptr,
bool  manageMemory = false,
size_t  offset = 0 
)

Construct a sub-image data item as a child of an existing item.

The child shares the parent's data buffer at the given offset.

Parameters
[in]aParentThe parent ImageDataItem whose buffer is shared.
[in]descImage descriptor providing dimension information.
[in]timestepTime step index associated with this item.
[in]dimensionNumber of dimensions for this sub-image.
[in]dataOptional external data pointer. If non-null and different from the computed parent offset, data is memcpy'd.
[in]manageMemoryIf true and data is provided, the external buffer is deleted after copying.
[in]offsetByte offset into the parent's data buffer.

◆ ~ImageDataItem()

mitk::ImageDataItem::~ImageDataItem ( )
override

Destructor. Frees managed memory and VTK resources.

◆ ImageDataItem() [2/4]

mitk::ImageDataItem::ImageDataItem ( const mitk::ImageDescriptor::Pointer  desc,
int  timestep,
void *  data,
bool  manageMemory 
)

Construct a top-level data item from an image descriptor.

Allocates a new data buffer if data is nullptr.

Parameters
[in]descImage descriptor providing pixel type and dimensions.
[in]timestepTime step index associated with this item.
[in]dataOptional external data buffer.
[in]manageMemoryIf true, the provided buffer will be deleted on destruction.

◆ ImageDataItem() [3/4]

mitk::ImageDataItem::ImageDataItem ( const mitk::PixelType &  type,
int  timestep,
unsigned int  dimension,
unsigned int *  dimensions,
void *  data,
bool  manageMemory 
)

Construct a data item from explicit pixel type and dimension information.

Allocates a new data buffer if data is nullptr.

Parameters
[in]typeThe pixel type.
[in]timestepTime step index.
[in]dimensionNumber of spatial dimensions.
[in]dimensionsArray of dimension sizes (must have at least dimension elements).
[in]dataOptional external data buffer.
[in]manageMemoryIf true, the provided buffer will be deleted on destruction.

◆ ImageDataItem() [4/4]

mitk::ImageDataItem::ImageDataItem ( const ImageDataItem &  other)
delete

Member Function Documentation

◆ ConstructVtkImageData()

virtual void mitk::ImageDataItem::ConstructVtkImageData ( ImageConstPointer  iP) const
virtual

Build a vtkImageData representation from the raw pixel buffer.

Sets up dimensions, spacing, origin, and scalar arrays matching the pixel type and dimension information of this item.

Parameters
[in]iPSmart pointer to the owning Image (used for spacing).

◆ GetData()

void* mitk::ImageDataItem::GetData ( ) const
inlineprotected

Helper function to allow friend classes to access m_Data without changing their code. Moved to protected visibility because only friends are allowed to access m_Data directly. Other classes should used ImageWriteAccessor::GetData() or ImageReadAccessor::GetData() to get access.

Definition at line 242 of file mitkImageDataItem.h.

◆ GetDimension() [1/2]

int mitk::ImageDataItem::GetDimension ( ) const
inline

Get the number of spatial dimensions.

Returns
The dimension count.

Definition at line 164 of file mitkImageDataItem.h.

Referenced by mitk::ImagePixelAccessor< TPixel, VDimension >::CheckData(), and mitk::ImagePixelAccessor< TPixel, VDimension >::GetDimension().

◆ GetDimension() [2/2]

int mitk::ImageDataItem::GetDimension ( int  i) const
inline

Get the size along a specific dimension.

Parameters
[in]iThe dimension index (0-based).
Returns
The size along dimension i, or 0 if i >= GetDimension().

Definition at line 171 of file mitkImageDataItem.h.

◆ GetManageMemory()

bool mitk::ImageDataItem::GetManageMemory ( ) const
inline

Query whether this item will delete its data buffer on destruction.

Returns
True if memory is managed by this item.

Definition at line 211 of file mitkImageDataItem.h.

◆ GetOffset()

int mitk::ImageDataItem::GetOffset ( ) const
inline

Get the byte offset of this item within its parent's buffer.

Returns
The offset in bytes, or 0 for top-level items.

Definition at line 140 of file mitkImageDataItem.h.

◆ GetParent()

ImageDataItem::ConstPointer mitk::ImageDataItem::GetParent ( ) const
inline

Get the parent data item, if any.

Returns
Smart pointer to the parent, or null for top-level items.

Definition at line 186 of file mitkImageDataItem.h.

◆ GetPixelType()

PixelType mitk::ImageDataItem::GetPixelType ( ) const
inline

Get the pixel type of this data item.

Returns
A copy of the PixelType.

Definition at line 146 of file mitkImageDataItem.h.

◆ GetSize()

size_t mitk::ImageDataItem::GetSize ( ) const
inline

Get the total size of this data item in bytes.

Returns
The byte size (pixel size * number of pixels).

Definition at line 227 of file mitkImageDataItem.h.

◆ GetVtkImageAccessor() [1/2]

ImageVtkReadAccessor* mitk::ImageDataItem::GetVtkImageAccessor ( ImageConstPointer  iP) const

Get or create a VTK read accessor for this data item.

If no vtkImageData has been constructed yet, one is created via ConstructVtkImageData(). For 3D images the VTK origin is set to (0, 0, 0) for historical compatibility (see MITK bug 5050).

Parameters
[in]iPSmart pointer to the owning Image (used for geometry queries).
Returns
Pointer to an ImageVtkReadAccessor wrapping the VTK data.

◆ GetVtkImageAccessor() [2/2]

ImageVtkWriteAccessor* mitk::ImageDataItem::GetVtkImageAccessor ( ImagePointer  iP)

Get or create a VTK write accessor for this data item.

Parameters
[in]iPSmart pointer to the owning Image.
Returns
Pointer to an ImageVtkWriteAccessor wrapping the VTK data.

◆ IsComplete()

bool mitk::ImageDataItem::IsComplete ( ) const
inline

Check whether all sub-items of this data item have been filled.

Returns
True if complete.

Definition at line 128 of file mitkImageDataItem.h.

◆ mitkClassMacroItkParent()

mitk::ImageDataItem::mitkClassMacroItkParent ( ImageDataItem  ,
itk::LightObject   
)

◆ Modified()

virtual void mitk::ImageDataItem::Modified ( ) const
virtual

Mark the internal vtkImageData as modified.

Call this after changing the raw data buffer so that VTK pipelines recognize the update.

◆ operator=()

ImageDataItem& mitk::ImageDataItem::operator= ( const ImageDataItem &  other)
delete

◆ SetComplete()

void mitk::ImageDataItem::SetComplete ( bool  complete)
inline

Set the completion status of this data item.

Parameters
[in]completeTrue if all data has been loaded.

Definition at line 134 of file mitkImageDataItem.h.

◆ SetManageMemory()

void mitk::ImageDataItem::SetManageMemory ( bool  b)
inline

Set whether this item owns (and will delete) its data buffer.

Parameters
[in]bTrue if this item should manage the memory.

Definition at line 158 of file mitkImageDataItem.h.

◆ SetTimestep()

void mitk::ImageDataItem::SetTimestep ( int  t)
inline

Set the time step index for this data item.

Parameters
[in]tThe time step index.

Definition at line 152 of file mitkImageDataItem.h.

Member Data Documentation

◆ m_Data

unsigned char* mitk::ImageDataItem::m_Data
protected

Definition at line 244 of file mitkImageDataItem.h.

◆ m_IsComplete

bool mitk::ImageDataItem::m_IsComplete
protected

Definition at line 255 of file mitkImageDataItem.h.

◆ m_ManageMemory

bool mitk::ImageDataItem::m_ManageMemory
protected

Definition at line 248 of file mitkImageDataItem.h.

◆ m_Offset

int mitk::ImageDataItem::m_Offset
protected

Definition at line 253 of file mitkImageDataItem.h.

◆ m_PixelType

PixelType* mitk::ImageDataItem::m_PixelType
protected

Definition at line 246 of file mitkImageDataItem.h.

◆ m_Size

size_t mitk::ImageDataItem::m_Size
protected

Definition at line 257 of file mitkImageDataItem.h.

◆ m_VtkImageData

vtkImageData* mitk::ImageDataItem::m_VtkImageData
mutableprotected

Definition at line 250 of file mitkImageDataItem.h.

◆ m_VtkImageReadAccessor

ImageVtkReadAccessor* mitk::ImageDataItem::m_VtkImageReadAccessor
mutableprotected

Definition at line 251 of file mitkImageDataItem.h.

◆ m_VtkImageWriteAccessor

ImageVtkWriteAccessor* mitk::ImageDataItem::m_VtkImageWriteAccessor
protected

Definition at line 252 of file mitkImageDataItem.h.


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