Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef IMAGEDATAITEM_H
18 #define IMAGEDATAITEM_H
19 
20 #include "mitkCommon.h"
21 #include <MitkCoreExports.h>
22 //#include <mitkIpPic.h>
23 //#include "mitkPixelType.h"
24 #include "mitkImageDescriptor.h"
25 //#include "mitkImageVtkAccessor.h"
26 
27 class vtkImageData;
28 
29 namespace mitk
30 {
31  class PixelType;
32  class ImageVtkReadAccessor;
33  class ImageVtkWriteAccessor;
34 
35  class Image;
36 
37  //##Documentation
38  //## @brief Internal class for managing references on sub-images
39  //##
40  //## ImageDataItem is a container for image data which is used internal in
41  //## mitk::Image to handle the communication between the different data types for images
42  //## used in MITK (ipPicDescriptor, mitk::Image, vtkImageData). Common for these image data
43  //## types is the actual image data, but they differ in representation of pixel type etc.
44  //## The class is also used to convert ipPic images to vtkImageData.
45  //##
46  //## The class is mainly used to extract sub-images inside of mitk::Image, like single slices etc.
47  //## It should not be used outside of this.
48  //##
49  //## @param manageMemory Determines if image data is removed while destruction of ImageDataItem or not.
50  //## @ingroup Data
51  class MITKCORE_EXPORT ImageDataItem : public itk::LightObject
52  {
53  friend class ImageAccessorBase;
54  friend class ImageWriteAccessor;
55  friend class ImageReadAccessor;
56 
57  template <class TPixel, unsigned int VDimension>
58  friend class ImagePixelAccessor;
59 
60  friend class Image;
61 
62  // template<class TOutputImage>
63  // friend class ImageToItk;
64 
65  public:
68 
70 
71  itkCloneMacro(ImageDataItem);
72  virtual itk::LightObject::Pointer InternalClone() const override;
73 
74  ImageDataItem(const ImageDataItem &aParent,
76  int timestep,
77  unsigned int dimension,
78  void *data = nullptr,
79  bool manageMemory = false,
80  size_t offset = 0);
81 
82  ~ImageDataItem();
83 
84  ImageDataItem(const mitk::ImageDescriptor::Pointer desc, int timestep, void *data, bool manageMemory);
85 
86  ImageDataItem(const mitk::PixelType &type,
87  int timestep,
88  unsigned int dimension,
89  unsigned int *dimensions,
90  void *data,
91  bool manageMemory);
92 
93  ImageDataItem(const ImageDataItem &other);
94 
98  DEPRECATED(void *GetData() const) { return m_Data; }
99  bool IsComplete() const { return m_IsComplete; }
100  void SetComplete(bool complete) { m_IsComplete = complete; }
101  int GetOffset() const { return m_Offset; }
102  PixelType GetPixelType() const { return *m_PixelType; }
103  void SetTimestep(int t) { m_Timestep = t; }
104  void SetManageMemory(bool b) { m_ManageMemory = b; }
105  int GetDimension() const { return m_Dimension; }
106  int GetDimension(int i) const
107  {
108  int returnValue = 0;
109 
110  // return the true size if dimension available
111  if (i < (int)m_Dimension)
112  returnValue = m_Dimensions[i];
113 
114  return returnValue;
115  }
116 
117  ImageDataItem::ConstPointer GetParent() const { return m_Parent; }
127  ImageVtkReadAccessor *GetVtkImageAccessor(ImageConstPointer) const;
128  ImageVtkWriteAccessor *GetVtkImageAccessor(ImagePointer);
129 
130  // Returns if image data should be deleted on destruction of ImageDataItem.
131  bool GetManageMemory() const { return m_ManageMemory; }
132  virtual void ConstructVtkImageData(ImageConstPointer) const;
133 
134  unsigned long GetSize() const { return m_Size; }
135  virtual void Modified() const;
136 
137  protected:
138  unsigned char *m_Data;
139 
141 
143 
144  mutable vtkImageData *m_VtkImageData;
147  int m_Offset;
148 
150 
151  unsigned long m_Size;
152 
153  private:
154  void ComputeItemSize(const unsigned int *dimensions, unsigned int dimension);
155 
157 
158  unsigned int m_Dimension;
159 
160  unsigned int m_Dimensions[MAX_IMAGE_DIMENSIONS];
161 
162  int m_Timestep;
163  };
164 
165 } // namespace mitk
166 
167 #endif /* IMAGEDATAITEM_H */
itk::SmartPointer< Self > Pointer
#define MITKCORE_EXPORT
int GetDimension(int i) const
void SetComplete(bool complete)
void SetManageMemory(bool b)
Provides templated image access for all inheriting classes.
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< const mitk::Image > ImageConstPointer
#define DEPRECATED(func)
Definition: mitkCommon.h:183
static Vector3D offset
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 taken from ipPicDescriptor. ...
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
void * GetData() const
Image class for storing images.
Definition: mitkImage.h:76
bool IsComplete() const
ImageDataItem::ConstPointer GetParent() const
ImageVtkReadAccessor class provides any image read access which is required by Vtk methods...
ImageVtkWriteAccessor * m_VtkImageWriteAccessor
PixelType GetPixelType() const
unsigned short PixelType
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...
bool GetManageMemory() const
unsigned long GetSize() const
Class for defining the data type of pixels.
Definition: mitkPixelType.h:55
vtkImageData * m_VtkImageData