Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkImageVtkWriteAccessor.cpp
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 
18 
19 #include "mitkImage.h"
20 
21 #include <vtkImageData.h>
22 
24 {
25  return m_Image;
26 }
27 
29  const mitk::ImageDataItem *iDI,
30  vtkImageData *imageDataVtk)
31  : ImageAccessorBase(nullptr, iDI), m_Image(iP.GetPointer()), m_ImageDataVtk(imageDataVtk)
32 {
33  m_Image->m_VtkReadersLock.Lock();
34 
35  m_Image->m_VtkReaders.push_back(this);
36  // printf("m_VtkReaders.size(): %d\n", (int) m_Image->m_VtkReaders.size());
37 
38  m_Image->m_VtkReadersLock.Unlock();
39 }
40 
42 {
43  m_Image->m_VtkReadersLock.Lock();
44 
45  auto it = std::find(m_Image->m_VtkReaders.begin(), m_Image->m_VtkReaders.end(), this);
46  if (it != m_Image->m_VtkReaders.end())
47  {
48  m_Image->m_VtkReaders.erase(it);
49  }
50  // printf("m_VtkReaders.size(): %d\n", (int) m_Image->m_VtkReaders.size());
51 
52  m_Image->m_VtkReadersLock.Unlock();
53 }
54 
56 {
57  return m_ImageDataVtk;
58 }
vtkImageData * GetVtkImageData() const
ImageVtkWriteAccessor(ImagePointer iP, const ImageDataItem *iDI, vtkImageData *imageDataVtk)
Creates an ImageVtkWriteAccessor for a whole Image.
virtual const Image * GetImage() const override
Image class for storing images.
Definition: mitkImage.h:76
Internal class for managing references on sub-images.