Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkTbssImage.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 
17 #ifndef __mitkTbssImage__cpp
18 #define __mitkTbssImage__cpp
19 
20 
21 #include "mitkTbssImage.h"
22 #include "itkImageRegionIterator.h"
23 #include "itkImageRegionConstIterator.h"
24 #include "mitkImageCast.h"
25 
26 
27 
28 
30 {
31 
32 }
33 
34 
36 {
37  if(!m_Image)
38  {
39  MITK_INFO << "TBSS Image could not be initialized. Set all members first!" << std::endl;
40  return;
41  }
42 
43 
44  typedef itk::Image<float,3> ImgType;
46  img->SetSpacing( m_Image->GetSpacing() ); // Set the image spacing
47  img->SetOrigin( m_Image->GetOrigin() ); // Set the image origin
48  img->SetDirection( m_Image->GetDirection() ); // Set the image direction
49  img->SetLargestPossibleRegion( m_Image->GetLargestPossibleRegion());
50  img->SetBufferedRegion( m_Image->GetLargestPossibleRegion() );
51  img->Allocate();
52 
53  int vecLength = m_Image->GetVectorLength();
54  InitializeByItk( img.GetPointer(), 1, vecLength );
55 
56  //for(int i=0; i<vecLength; i++)
57  //{TbssImage();
58 
59 
60  itk::ImageRegionIterator<ImgType> itw (img, img->GetLargestPossibleRegion() );
61  itw.GoToBegin();
62 
63  itk::ImageRegionConstIterator<ImageType> itr (m_Image, m_Image->GetLargestPossibleRegion() );
64  itr.GoToBegin();
65 
66  while(!itr.IsAtEnd())
67  {
68  itw.Set(itr.Get().GetElement(0));
69  ++itr;
70  ++itw;
71  }
72 
73  // init
74  SetImportVolume(img->GetBufferPointer());//, 0, 0, CopyMemory);
75  //SetVolume( img->GetBufferPointer(), i );
76  //}::
77 
78  m_DisplayIndex = 0;
79  MITK_INFO << "Tbss-Image successfully initialized.";
80 
81 }
82 
84 {
85  MITK_INFO << "displayindex: " << displayIndex;
86  int index = displayIndex;
87  int vecLength = m_Image->GetVectorLength();
88  index = index > vecLength-1 ? vecLength-1 : index;
89  if( m_DisplayIndex != index )
90  {
91  typedef itk::Image<float,3> ImgType;
93  CastToItkImage(this, img);
94 
95  itk::ImageRegionIterator<ImgType> itw (img, img->GetLargestPossibleRegion() );
96  itw.GoToBegin();
97 
98  itk::ImageRegionConstIterator<ImageType> itr (m_Image, m_Image->GetLargestPossibleRegion() );
99  itr.GoToBegin();
100 
101  while(!itr.IsAtEnd())
102  {
103  itw.Set(itr.Get().GetElement(index));
104  ++itr;
105  ++itw;
106  }
107  }
108 
109  m_DisplayIndex = index;
110 }
111 
112 
113 
114 #endif /* __mitkTbssImage__cpp */
void SetDisplayIndexForRendering(int displayIndex)
itk::SmartPointer< Self > Pointer
#define MITK_INFO
Definition: mitkLogMacros.h:22
void InitializeFromVectorImage()
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.