VMTK
Static Public Member Functions | Protected Member Functions | List of all members
vtkvmtkITKFilterUtilities Class Reference

Abstract class for wrapping ITK filters. More...

#include <vtkvmtkITKFilterUtilities.h>

Static Public Member Functions

template<typename TImage >
static void VTKToITKImage (vtkImageData *input, typename TImage::Pointer output)
 
template<typename TImage >
static void VTKToITKVectorImage (vtkImageData *input, typename TImage::Pointer output)
 
template<typename TImage >
static void ITKToVTKImage (typename TImage::Pointer input, vtkImageData *output)
 
static void ProgressCallback (itk::Object *o, const itk::EventObject &, void *data)
 
static void ConnectProgress (itk::Object *obj, vtkAlgorithm *alg)
 

Protected Member Functions

 vtkvmtkITKFilterUtilities ()
 
 ~vtkvmtkITKFilterUtilities ()
 

Detailed Description

Abstract class for wrapping ITK filters.

Date
2006/04/06 16:48:25
Revision
1.2

vtkvmtkSimpleImageToImageITKFilter

Definition at line 43 of file vtkvmtkITKFilterUtilities.h.

Constructor & Destructor Documentation

◆ vtkvmtkITKFilterUtilities()

vtkvmtkITKFilterUtilities::vtkvmtkITKFilterUtilities ( )
inlineprotected

Definition at line 200 of file vtkvmtkITKFilterUtilities.h.

200 {};

◆ ~vtkvmtkITKFilterUtilities()

vtkvmtkITKFilterUtilities::~vtkvmtkITKFilterUtilities ( )
inlineprotected

Definition at line 201 of file vtkvmtkITKFilterUtilities.h.

201 {};

Member Function Documentation

◆ VTKToITKImage()

template<typename TImage >
static void vtkvmtkITKFilterUtilities::VTKToITKImage ( vtkImageData *  input,
typename TImage::Pointer  output 
)
inlinestatic

Definition at line 49 of file vtkvmtkITKFilterUtilities.h.

49  {
50 
51  typedef TImage ImageType;
52  typedef typename ImageType::Pointer ImagePointer;
53  typedef typename ImageType::PixelType PixelType;
54 
55  int dims[3];
56  input->GetDimensions(dims);
57  double spacing[3];
58  input->GetSpacing(spacing);
59  double origin[3];
60  input->GetOrigin(origin);
61  int extent[6];
62  input->GetExtent(extent);
63 
64  output->GetPixelContainer()->SetImportPointer(static_cast<PixelType*>(input->GetScalarPointer()),dims[0]*dims[1]*dims[2],false);
65  typename ImageType::RegionType region;
66  typename ImageType::IndexType index;
67  typename ImageType::SizeType size;
68  //index[0] = index[1] = index[2] = 0;
69  //size[0] = dims[0];
70  //size[1] = dims[1];
71  //size[2] = dims[2];
72  index[0] = extent[0];
73  index[1] = extent[2];
74  index[2] = extent[4];
75  size[0] = extent[1] - extent[0] + 1;
76  size[1] = extent[3] - extent[2] + 1;
77  size[2] = extent[5] - extent[4] + 1;
78  region.SetIndex(index);
79  region.SetSize(size);
80  output->SetLargestPossibleRegion(region);
81  output->SetBufferedRegion(region);
82  output->SetSpacing(spacing);
83  output->SetOrigin(origin);
84  }

◆ VTKToITKVectorImage()

template<typename TImage >
static void vtkvmtkITKFilterUtilities::VTKToITKVectorImage ( vtkImageData *  input,
typename TImage::Pointer  output 
)
inlinestatic

Definition at line 88 of file vtkvmtkITKFilterUtilities.h.

88  {
89 
90  typedef TImage ImageType;
91  typedef typename ImageType::Pointer ImagePointer;
92  typedef typename ImageType::PixelType PixelType;
93  typedef typename ImageType::InternalPixelType InternalPixelType;
94 
95  int dims[3];
96  input->GetDimensions(dims);
97  double spacing[3];
98  input->GetSpacing(spacing);
99  int components = input->GetNumberOfScalarComponents();
100  double origin[3];
101  input->GetOrigin(origin);
102  int extent[6];
103  input->GetExtent(extent);
104 
105  output->GetPixelContainer()->SetImportPointer(static_cast<InternalPixelType*>(input->GetScalarPointer()),dims[0]*dims[1]*dims[2]*components,false);
106  typename ImageType::RegionType region;
107  typename ImageType::IndexType index;
108  typename ImageType::SizeType size;
109  //index[0] = index[1] = index[2] = 0;
110  //size[0] = dims[0];
111  //size[1] = dims[1];
112  //size[2] = dims[2];
113  index[0] = extent[0];
114  index[1] = extent[2];
115  index[2] = extent[4];
116  size[0] = extent[1] - extent[0] + 1;
117  size[1] = extent[3] - extent[2] + 1;
118  size[2] = extent[5] - extent[4] + 1;
119  region.SetIndex(index);
120  region.SetSize(size);
121  output->SetLargestPossibleRegion(region);
122  output->SetBufferedRegion(region);
123  output->SetSpacing(spacing);
124  output->SetOrigin(origin);
125  output->SetVectorLength(components);
126  }

◆ ITKToVTKImage()

template<typename TImage >
static void vtkvmtkITKFilterUtilities::ITKToVTKImage ( typename TImage::Pointer  input,
vtkImageData *  output 
)
inlinestatic

Definition at line 130 of file vtkvmtkITKFilterUtilities.h.

130  {
131 
132  typedef TImage ImageType;
133  typedef typename ImageType::Pointer ImagePointer;
134  typedef typename ImageType::PixelType PixelType;
135  typedef typename ImageType::PointType PointType;
136  typedef typename ImageType::SpacingType SpacingType;
137  typedef typename ImageType::RegionType RegionType;
138  typedef typename ImageType::IndexType IndexType;
139  typedef typename ImageType::SizeType SizeType;
140 
141  PointType origin = input->GetOrigin();
142  SpacingType spacing = input->GetSpacing();
143 
144  double outputOrigin[3];
145  double outputSpacing[3];
146 
147  outputOrigin[0] = origin[0];
148  outputOrigin[1] = origin[1];
149  outputOrigin[2] = origin[2];
150 
151  outputSpacing[0] = spacing[0];
152  outputSpacing[1] = spacing[1];
153  outputSpacing[2] = spacing[2];
154 
155  output->SetOrigin(outputOrigin);
156  output->SetSpacing(outputSpacing);
157 
158  RegionType region = input->GetBufferedRegion();
159  IndexType index = region.GetIndex();
160  SizeType size = region.GetSize();
161 
162  //int dimensions[3];
163  //dimensions[0] = size[0];
164  //dimensions[1] = size[1];
165  //dimensions[2] = size[2];
166  int extent[6];
167  extent[0] = index[0];
168  extent[1] = index[0] + size[0] - 1;
169  extent[2] = index[1];
170  extent[3] = index[1] + size[1] - 1;
171  extent[4] = index[2];
172  extent[5] = index[2] + size[2] - 1;
173 
174  int components = input->GetNumberOfComponentsPerPixel();
175  int dataType = output->GetScalarType(); // WARNING: we delegate setting type to caller
176 
177  //output->SetDimensions(dimensions);
178  output->SetExtent(extent);
179  output->AllocateScalars(dataType,components);
180 
181  memcpy(static_cast<PixelType*>(output->GetScalarPointer()),input->GetBufferPointer(),input->GetBufferedRegion().GetNumberOfPixels()*sizeof(PixelType));
182  }

◆ ProgressCallback()

static void vtkvmtkITKFilterUtilities::ProgressCallback ( itk::Object *  o,
const itk::EventObject &  ,
void *  data 
)
inlinestatic

Definition at line 185 of file vtkvmtkITKFilterUtilities.h.

186  {
187  ((vtkAlgorithm*)data)->UpdateProgress(dynamic_cast<const itk::ProcessObject*>(o)->GetProgress());
188  }

◆ ConnectProgress()

static void vtkvmtkITKFilterUtilities::ConnectProgress ( itk::Object *  obj,
vtkAlgorithm *  alg 
)
inlinestatic

Definition at line 191 of file vtkvmtkITKFilterUtilities.h.

192  {
193  itk::CStyleCommand::Pointer progressCommand = itk::CStyleCommand::New();
194  progressCommand->SetCallback(vtkvmtkITKFilterUtilities::ProgressCallback);
195  progressCommand->SetClientData(alg);
196  obj->AddObserver(itk::ProgressEvent(),progressCommand);
197  }
static void ProgressCallback(itk::Object *o, const itk::EventObject &, void *data)

The documentation for this class was generated from the following file: