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