File: vtkvmtkFastMarchingDirectionalFreezeImageFilter.h

package info (click to toggle)
vmtk 1.0.1-1
  • links: PTS, VCS
  • area: non-free
  • in suites: wheezy
  • size: 8,612 kB
  • sloc: cpp: 79,872; ansic: 31,817; python: 18,860; perl: 381; makefile: 118; sh: 15; tcl: 1
file content (202 lines) | stat: -rw-r--r-- 6,392 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*=========================================================================

Program:   VMTK
Module:    $RCSfile: vtkvmtkFastMarchingDirectionalFreezeImageFilter.h,v $
Language:  C++
Date:      $Date: 2006/04/06 16:48:25 $
Version:   $Revision: 1.4 $

  Copyright (c) Luca Antiga, David Steinman. All rights reserved.
  See LICENCE file for details.

  Portions of this code are covered under the VTK copyright.
  See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm 
  for details.

  Portions of this code are covered under the ITK copyright.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm
  for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

// .NAME vtkvmtkFastMarchingDirectionalFreezeImageFilter - Wrapper class around itk::FastMarchingDirectionalFreezeImageFilter
// .SECTION Description
// vtkvmtkFastMarchingDirectionalFreezeImageFilter


#ifndef __vtkvmtkFastMarchingDirectionalFreezeImageFilter_h
#define __vtkvmtkFastMarchingDirectionalFreezeImageFilter_h

#include "vtkvmtkITKImageToImageFilterFF.h"
#include "itkFastMarchingDirectionalFreezeImageFilter.h"
#include "vtkIdList.h"
#include "vtkvmtkWin32Header.h"

class VTK_VMTK_SEGMENTATION_EXPORT vtkvmtkFastMarchingDirectionalFreezeImageFilter : public vtkvmtkITKImageToImageFilterFF
{
 public:
  static vtkvmtkFastMarchingDirectionalFreezeImageFilter *New();
  vtkTypeRevisionMacro(vtkvmtkFastMarchingDirectionalFreezeImageFilter, vtkvmtkITKImageToImageFilterFF);

//   void SetUseImageSpacing ( int value )
//   {
//     DelegateITKInputMacro ( SetUseImageSpacing, (bool) value );
//   }

//   void UseImageSpacingOn()
//   {
//     this->SetUseImageSpacing (true);
//   }
//   void UseImageSpacingOff()
//   {
//     this->SetUseImageSpacing (false);
//   }
//   int GetUseImageSpacing()
//   { DelegateITKOutputMacro ( GetUseImageSpacing ); }

  void SetGenerateGradientImage ( int value )
  {
    DelegateITKInputMacro ( SetGenerateGradientImage, (bool) value );
  }

  void GenerateGradientImageOn()
  {
    this->SetGenerateGradientImage (true);
  }

  void GenerateGradientImageOff()
  {
    this->SetGenerateGradientImage (false);
  }

  int GetGenerateGradientImage()
  { 
    DelegateITKOutputMacro ( GetGenerateGradientImage ); 
  }

  void SetTargetReachedMode ( int value )
  {
    DelegateITKInputMacro ( SetTargetReachedMode, value );
  }

  int GetTargetReachedMode()
  { 
    DelegateITKOutputMacro ( GetTargetReachedMode ); 
  }

  void SetTargetReachedModeToOneTarget()
  {
    this->SetTargetReachedMode ( ImageFilterType::OneTarget );
  }

  void SetTargetReachedModeToAllTargets()
  {
    this->SetTargetReachedMode ( ImageFilterType::AllTargets );
  }

  double GetTargetValue()
  { 
    DelegateITKOutputMacro ( GetTargetValue ); 
  }

  void SetTargetOffset ( double value )
  {
    DelegateITKInputMacro ( SetTargetOffset, value );
  }

  double GetTargetOffset()
  { 
    DelegateITKOutputMacro ( GetTargetOffset ); 
  }

  vtkSetObjectMacro(Seeds,vtkIdList);
  vtkGetObjectMacro(Seeds,vtkIdList);

  vtkSetObjectMacro(Targets,vtkIdList);
  vtkGetObjectMacro(Targets,vtkIdList);

  void Update()
  {
  //BTX
    this->itkImporter->Update();
    if (this->vtkExporter->GetInput())
    {
    ImageFilterType::NodeContainerPointer seeds = ImageFilterType::NodeContainer::New();
    int i;
    for (i=0; i<this->Seeds->GetNumberOfIds(); i++)
      {
      // TODO: here we get the point. We should get the cell center instead.
      Superclass::InputImageType::PointType seedPoint(this->vtkExporter->GetInput()->GetPoint(this->Seeds->GetId(i)));
      ImageFilterType::NodeType::IndexType seedIndex;
      this->itkImporter->GetOutput()->TransformPhysicalPointToIndex(seedPoint,seedIndex);
      ImageFilterType::PixelType seedValue = itk::NumericTraits<ImageFilterType::PixelType>::Zero;
      ImageFilterType::NodeType seed;
      seed.SetValue(seedValue);
      seed.SetIndex(seedIndex);
      seeds->InsertElement(i,seed);
      }
    this->GetImageFilterPointer()->SetTrialPoints(seeds);

    ImageFilterType::NodeContainerPointer targets = ImageFilterType::NodeContainer::New();
    for (i=0; i<this->Targets->GetNumberOfIds(); i++)
      {
      // TODO: here we get the point. We should get the cell center instead.
      Superclass::InputImageType::PointType seedPoint(this->vtkExporter->GetInput()->GetPoint(this->Targets->GetId(i)));
      ImageFilterType::NodeType::IndexType seedIndex;
      this->itkImporter->GetOutput()->TransformPhysicalPointToIndex(seedPoint,seedIndex);
      ImageFilterType::PixelType seedValue = itk::NumericTraits<ImageFilterType::PixelType>::Zero;
      ImageFilterType::NodeType seed;
      seed.SetValue(seedValue);
      seed.SetIndex(seedIndex);
      targets->InsertElement(i,seed);
      }
    this->GetImageFilterPointer()->SetTargetPoints(targets);
    } 
     
    // Force the internal pipeline to update.
    if (this->GetOutput(0))
      {
      this->GetOutput(0)->Update();
      if ( this->GetOutput(0)->GetSource() )
        {
        //          this->SetErrorCode( this->GetOutput(0)->GetSource()->GetErrorCode() );
        }
      }
  //ETX
  }

protected:
  //BTX
  typedef itk::FastMarchingDirectionalFreezeImageFilter<Superclass::InputImageType, Superclass::OutputImageType> ImageFilterType;
  vtkvmtkFastMarchingDirectionalFreezeImageFilter() : Superclass ( ImageFilterType::New() )
    { 
      this->Seeds = NULL; 
      this->Targets = NULL; 
    }
  ~vtkvmtkFastMarchingDirectionalFreezeImageFilter() 
    { 
      if (this->Seeds) 
        {
        this->Seeds->Delete();
        }
      if (this->Targets) 
        {
        this->Targets->Delete();
        }
    }
  ImageFilterType* GetImageFilterPointer() { return dynamic_cast<ImageFilterType*> ( m_Filter.GetPointer() ); }
  //ETX
  
  vtkIdList* Seeds;
  vtkIdList* Targets;
                                                                            
private:
  vtkvmtkFastMarchingDirectionalFreezeImageFilter(const vtkvmtkFastMarchingDirectionalFreezeImageFilter&);  // Not implemented.
  void operator=(const vtkvmtkFastMarchingDirectionalFreezeImageFilter&);  // Not implemented.
};

#endif