VMTK
Loading...
Searching...
No Matches
vtkvmtkCollidingFrontsImageFilter.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3Program: VMTK
4Module: $RCSfile: vtkvmtkCollidingFrontsImageFilter.cxx,v $
5Language: C++
6Date: $Date: 2006/04/06 16:48:25 $
7Version: $Revision: 1.1 $
8
9 Copyright (c) Luca Antiga, David Steinman. All rights reserved.
10 See LICENSE file for details.
11
12 Portions of this code are covered under the VTK copyright.
13 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm
14 for details.
15
16 Portions of this code are covered under the ITK copyright.
17 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm
18 for details.
19
20 This software is distributed WITHOUT ANY WARRANTY; without even
21 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
22 PURPOSE. See the above copyright notices for more information.
23
24=========================================================================*/
25
28#include "vtkObjectFactory.h"
29
30#include "itkCollidingFrontsImageFilter.h"
31
32// TODO Remove
33#include "vtkPointData.h"
34#include "vtkDataArray.h"
35
37
39{
40 this->Seeds1 = NULL;
41 this->Seeds2 = NULL;
42
43 this->ApplyConnectivity = 0;
44 this->NegativeEpsilon = -1E-6;
45 this->StopOnTargets = 0;
46}
47
49{
50 if (this->Seeds1)
51 {
52 this->Seeds1->Delete();
53 this->Seeds1 = NULL;
54 }
55
56 if (this->Seeds2)
57 {
58 this->Seeds2->Delete();
59 this->Seeds2 = NULL;
60 }
61}
62
63void vtkvmtkCollidingFrontsImageFilter::SimpleExecute(vtkImageData* input, vtkImageData* output)
64{
65 std::cout<<input->GetScalarType()<<std::endl;
66 typedef itk::Image<float,3> ImageType;
67
68 ImageType::Pointer inImage = ImageType::New();
69
71
72 typedef itk::CollidingFrontsImageFilter<ImageType, ImageType> CollidingFrontsFilterType;
73 CollidingFrontsFilterType::Pointer collidingFrontsFilter = CollidingFrontsFilterType::New();
74 collidingFrontsFilter->SetInput(inImage);
75
76 CollidingFrontsFilterType::NodeContainerPointer seeds1 = CollidingFrontsFilterType::NodeContainer::New();
77 int i;
78 for (i=0; i<this->Seeds1->GetNumberOfIds(); i++)
79 {
80 // TODO: here we get the point. We should get the cell center instead.
81 ImageType::PointType seedPoint(input->GetPoint(this->Seeds1->GetId(i)));
82 CollidingFrontsFilterType::NodeType::IndexType seedIndex;
83 inImage->TransformPhysicalPointToIndex(seedPoint,seedIndex);
84 CollidingFrontsFilterType::PixelType seedValue = itk::NumericTraits<CollidingFrontsFilterType::PixelType>::Zero;
85 CollidingFrontsFilterType::NodeType seed;
86 seed.SetValue(seedValue);
87 seed.SetIndex(seedIndex);
88 seeds1->InsertElement(i,seed);
89 }
90 collidingFrontsFilter->SetSeedPoints1(seeds1);
91
92 CollidingFrontsFilterType::NodeContainerPointer seeds2 = CollidingFrontsFilterType::NodeContainer::New();
93 for (i=0; i<this->Seeds2->GetNumberOfIds(); i++)
94 {
95 // TODO: here we get the point. We should get the cell center instead.
96 ImageType::PointType seedPoint(input->GetPoint(this->Seeds2->GetId(i)));
97 CollidingFrontsFilterType::NodeType::IndexType seedIndex;
98 inImage->TransformPhysicalPointToIndex(seedPoint,seedIndex);
99 CollidingFrontsFilterType::PixelType seedValue = itk::NumericTraits<CollidingFrontsFilterType::PixelType>::Zero;
100 CollidingFrontsFilterType::NodeType seed;
101 seed.SetValue(seedValue);
102 seed.SetIndex(seedIndex);
103 seeds2->InsertElement(i,seed);
104 }
105 collidingFrontsFilter->SetSeedPoints2(seeds2);
106
107 collidingFrontsFilter->SetApplyConnectivity(this->ApplyConnectivity);
108 collidingFrontsFilter->SetNegativeEpsilon(this->NegativeEpsilon);
109 collidingFrontsFilter->SetStopOnTargets(this->StopOnTargets);
110 collidingFrontsFilter->Update();
111
112 vtkvmtkITKFilterUtilities::ITKToVTKImage<ImageType>(collidingFrontsFilter->GetOutput(),output);
113}
114
Wraps itk::CollidingFrontsImageFilter.
virtual void SimpleExecute(vtkImageData *input, vtkImageData *output) override
static void ITKToVTKImage(typename TImage::Pointer input, vtkImageData *output)
static void VTKToITKImage(vtkImageData *input, typename TImage::Pointer output)
vtkStandardNewMacro(vtkvmtkCollidingFrontsImageFilter)