Medical Imaging Interaction Toolkit  2021.10.99-1c4db16f
Medical Imaging Interaction Toolkit
mitkImageDataItem.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef IMAGEDATAITEM_H
14 #define IMAGEDATAITEM_H
15 
16 #include "mitkCommon.h"
17 #include <MitkCoreExports.h>
18 #include "mitkImageDescriptor.h"
19 
20 class vtkImageData;
21 
22 namespace mitk
23 {
24  class PixelType;
25  class ImageVtkReadAccessor;
26  class ImageVtkWriteAccessor;
27 
28  class Image;
29 
30  //##Documentation
31  //## @brief Internal class for managing references on sub-images
32  //##
33  //## ImageDataItem is a container for image data which is used internal in
34  //## mitk::Image to handle the communication between the different data types for images
35  //## used in MITK (mitk::Image, vtkImageData). Common for these image data
36  //## types is the actual image data, but they differ in representation of pixel type etc.
37  //##
38  //## The class is mainly used to extract sub-images inside of mitk::Image, like single slices etc.
39  //## It should not be used outside of this.
40  //##
41  //## @param manageMemory Determines if image data is removed while destruction of ImageDataItem or not.
42  //## @ingroup Data
43  class MITKCORE_EXPORT ImageDataItem : public itk::LightObject
44  {
45  friend class ImageAccessorBase;
46  friend class ImageWriteAccessor;
47  friend class ImageReadAccessor;
48 
49  template <class TPixel, unsigned int VDimension>
50  friend class ImagePixelAccessor;
51 
52  friend class Image;
53 
54  // template<class TOutputImage>
55  // friend class ImageToItk;
56 
57  public:
60 
62 
63  itkCloneMacro(ImageDataItem);
64  itk::LightObject::Pointer InternalClone() const override;
65 
66  ImageDataItem(const ImageDataItem &aParent,
68  int timestep,
69  unsigned int dimension,
70  void *data = nullptr,
71  bool manageMemory = false,
72  size_t offset = 0);
73 
74  ~ImageDataItem() override;
75 
76  ImageDataItem(const mitk::ImageDescriptor::Pointer desc, int timestep, void *data, bool manageMemory);
77 
78  ImageDataItem(const mitk::PixelType &type,
79  int timestep,
80  unsigned int dimension,
81  unsigned int *dimensions,
82  void *data,
83  bool manageMemory);
84 
85  ImageDataItem(const ImageDataItem &other);
86 
87  bool IsComplete() const { return m_IsComplete; }
88  void SetComplete(bool complete) { m_IsComplete = complete; }
89  int GetOffset() const { return m_Offset; }
90  PixelType GetPixelType() const { return *m_PixelType; }
91  void SetTimestep(int t) { m_Timestep = t; }
92  void SetManageMemory(bool b) { m_ManageMemory = b; }
93  int GetDimension() const { return m_Dimension; }
94  int GetDimension(int i) const
95  {
96  int returnValue = 0;
97 
98  // return the true size if dimension available
99  if (i < (int)m_Dimension)
100  returnValue = m_Dimensions[i];
101 
102  return returnValue;
103  }
104 
105  ImageDataItem::ConstPointer GetParent() const { return m_Parent; }
115  ImageVtkReadAccessor *GetVtkImageAccessor(ImageConstPointer) const;
116  ImageVtkWriteAccessor *GetVtkImageAccessor(ImagePointer);
117 
118  // Returns if image data should be deleted on destruction of ImageDataItem.
119  bool GetManageMemory() const { return m_ManageMemory; }
120  virtual void ConstructVtkImageData(ImageConstPointer) const;
121 
122  size_t GetSize() const { return m_Size; }
123  virtual void Modified() const;
124 
125  protected:
126 
131  void* GetData() const { return m_Data; }
132 
133  unsigned char *m_Data;
134 
136 
138 
139  mutable vtkImageData *m_VtkImageData;
142  int m_Offset;
143 
145 
146  size_t m_Size;
147 
148  private:
149  void ComputeItemSize(const unsigned int *dimensions, unsigned int dimension);
150 
152 
153  unsigned int m_Dimension;
154 
155  unsigned int m_Dimensions[MAX_IMAGE_DIMENSIONS];
156 
157  int m_Timestep;
158  };
159 
160 } // namespace mitk
161 
162 #endif /* IMAGEDATAITEM_H */
int GetDimension(int i) const
#define MITKCORE_EXPORT
void SetComplete(bool complete)
void SetManageMemory(bool b)
Provides templated image access for all inheriting classes.
PixelType GetPixelType() const
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< const mitk::Image > ImageConstPointer
bool GetManageMemory() const
ImageDataItem::ConstPointer GetParent() const
void * GetData() const
class ITK_EXPORT Image
unsigned char * m_Data
itk::SmartPointer< mitk::Image > ImagePointer
#define MAX_IMAGE_DIMENSIONS
Defines the maximum of 8 dimensions per image channel.
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
Image class for storing images.
Definition: mitkImage.h:69
vcl_size_t GetSize() const
ImageVtkReadAccessor class provides any image read access which is required by Vtk methods...
ImageVtkWriteAccessor * m_VtkImageWriteAccessor
ImageWriteAccessor class to get locked write-access for a particular image part.
ImageVtkReadAccessor * m_VtkImageReadAccessor
Internal class for managing references on sub-images.
ImageReadAccessor class to get locked read access for a particular image part.
ImageVtkWriteAccessor class provides any image write access which is required by Vtk methods...
Class for defining the data type of pixels.
Definition: mitkPixelType.h:51
vtkImageData * m_VtkImageData