Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
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 <mitkIpPic.h>
19 //#include "mitkPixelType.h"
20 #include "mitkImageDescriptor.h"
21 //#include "mitkImageVtkAccessor.h"
22 
23 class vtkImageData;
24 
25 namespace mitk
26 {
27  class PixelType;
28  class ImageVtkReadAccessor;
29  class ImageVtkWriteAccessor;
30 
31  class Image;
32 
33  //##Documentation
34  //## @brief Internal class for managing references on sub-images
35  //##
36  //## ImageDataItem is a container for image data which is used internal in
37  //## mitk::Image to handle the communication between the different data types for images
38  //## used in MITK (ipPicDescriptor, mitk::Image, vtkImageData). Common for these image data
39  //## types is the actual image data, but they differ in representation of pixel type etc.
40  //## The class is also used to convert ipPic images to vtkImageData.
41  //##
42  //## The class is mainly used to extract sub-images inside of mitk::Image, like single slices etc.
43  //## It should not be used outside of this.
44  //##
45  //## @param manageMemory Determines if image data is removed while destruction of ImageDataItem or not.
46  //## @ingroup Data
47  class MITKCORE_EXPORT ImageDataItem : public itk::LightObject
48  {
49  friend class ImageAccessorBase;
50  friend class ImageWriteAccessor;
51  friend class ImageReadAccessor;
52 
53  template <class TPixel, unsigned int VDimension>
54  friend class ImagePixelAccessor;
55 
56  friend class Image;
57 
58  // template<class TOutputImage>
59  // friend class ImageToItk;
60 
61  public:
64 
66 
67  itkCloneMacro(ImageDataItem);
68  itk::LightObject::Pointer InternalClone() const override;
69 
70  ImageDataItem(const ImageDataItem &aParent,
72  int timestep,
73  unsigned int dimension,
74  void *data = nullptr,
75  bool manageMemory = false,
76  size_t offset = 0);
77 
78  ~ImageDataItem() override;
79 
80  ImageDataItem(const mitk::ImageDescriptor::Pointer desc, int timestep, void *data, bool manageMemory);
81 
82  ImageDataItem(const mitk::PixelType &type,
83  int timestep,
84  unsigned int dimension,
85  unsigned int *dimensions,
86  void *data,
87  bool manageMemory);
88 
89  ImageDataItem(const ImageDataItem &other);
90 
94  DEPRECATED(void *GetData() const) { return m_Data; }
95  bool IsComplete() const { return m_IsComplete; }
96  void SetComplete(bool complete) { m_IsComplete = complete; }
97  int GetOffset() const { return m_Offset; }
98  PixelType GetPixelType() const { return *m_PixelType; }
99  void SetTimestep(int t) { m_Timestep = t; }
100  void SetManageMemory(bool b) { m_ManageMemory = b; }
101  int GetDimension() const { return m_Dimension; }
102  int GetDimension(int i) const
103  {
104  int returnValue = 0;
105 
106  // return the true size if dimension available
107  if (i < (int)m_Dimension)
108  returnValue = m_Dimensions[i];
109 
110  return returnValue;
111  }
112 
113  ImageDataItem::ConstPointer GetParent() const { return m_Parent; }
123  ImageVtkReadAccessor *GetVtkImageAccessor(ImageConstPointer) const;
124  ImageVtkWriteAccessor *GetVtkImageAccessor(ImagePointer);
125 
126  // Returns if image data should be deleted on destruction of ImageDataItem.
127  bool GetManageMemory() const { return m_ManageMemory; }
128  virtual void ConstructVtkImageData(ImageConstPointer) const;
129 
130  size_t GetSize() const { return m_Size; }
131  virtual void Modified() const;
132 
133  protected:
134  unsigned char *m_Data;
135 
137 
139 
140  mutable vtkImageData *m_VtkImageData;
143  int m_Offset;
144 
146 
147  size_t m_Size;
148 
149  private:
150  void ComputeItemSize(const unsigned int *dimensions, unsigned int dimension);
151 
153 
154  unsigned int m_Dimension;
155 
156  unsigned int m_Dimensions[MAX_IMAGE_DIMENSIONS];
157 
158  int m_Timestep;
159  };
160 
161 } // namespace mitk
162 
163 #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
#define DEPRECATED(func)
Definition: mitkCommon.h:179
static Vector3D offset
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 taken from ipPicDescriptor. ...
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:49
Image class for storing images.
Definition: mitkImage.h:72
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