1 #ifndef __FPA__VTK__UNIQUEVERTICESTOPOLYDATAFILTER__HXX__
2 #define __FPA__VTK__UNIQUEVERTICESTOPOLYDATAFILTER__HXX__
4 #include <vtkInformation.h>
5 #include <vtkInformationVector.h>
7 // -------------------------------------------------------------------------
8 template< class U, class I >
9 typename fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >::
10 Self* fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >::
13 return( new Self( ) );
16 // -------------------------------------------------------------------------
17 template< class U, class I >
18 const U* fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >::
21 return( this->m_Container );
24 // -------------------------------------------------------------------------
25 template< class U, class I >
26 void fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >::
27 SetInput( const U* c )
29 if( this->m_Container.GetPointer( ) != c )
31 this->m_Container = c;
32 this->m_LastContainerModifiedTime = this->m_Container->GetMTime( );
38 // -------------------------------------------------------------------------
39 template< class U, class I >
40 const I* fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >::
43 return( this->m_Image );
46 // -------------------------------------------------------------------------
47 template< class U, class I >
48 void fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >::
49 SetImage( const I* i )
51 if( this->m_Image.GetPointer( ) != i )
59 // -------------------------------------------------------------------------
60 template< class U, class I >
61 unsigned long fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >::
64 unsigned long ctime = this->m_Container->GetMTime( );
65 if( ctime > this->m_LastContainerModifiedTime )
67 this->m_LastContainerModifiedTime = ctime;
71 return( this->Superclass::GetMTime( ) );
74 // -------------------------------------------------------------------------
75 template< class U, class I >
76 fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >::
77 UniqueVerticesToPolyDataFilter( )
78 : vtkPolyDataAlgorithm( )
80 this->SetNumberOfInputPorts( 0 );
83 // -------------------------------------------------------------------------
84 template< class U, class I >
85 fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >::
86 ~UniqueVerticesToPolyDataFilter( )
90 // -------------------------------------------------------------------------
91 template< class U, class I >
92 int fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >::
94 vtkInformation* information,
95 vtkInformationVector** input,
96 vtkInformationVector* output
99 if( this->m_Container.IsNull( ) || this->m_Image.IsNull( ) )
103 vtkInformation* info = output->GetInformationObject( 0 );
104 vtkPolyData* out = vtkPolyData::SafeDownCast(
105 info->Get( vtkDataObject::DATA_OBJECT( ) )
109 vtkPoints* points = out->GetPoints( );
112 points = vtkPoints::New( );
113 out->SetPoints( points );
117 points->SetNumberOfPoints( this->m_Container->Size( ) );
120 vtkSmartPointer< vtkCellArray > cells =
121 vtkSmartPointer< vtkCellArray >::New( );
123 unsigned int pId = 0;
125 typename U::ConstIterator it = this->m_Container->Begin( );
126 it != this->m_Container->End( );
130 typename I::PointType pnt;
131 this->m_Image->TransformIndexToPhysicalPoint( *it, pnt );
132 if( I::ImageDimension == 1 )
133 points->SetPoint( pId, pnt[ 0 ], 0, 0 );
134 else if( I::ImageDimension == 2 )
135 points->SetPoint( pId, pnt[ 0 ], pnt[ 1 ], 0 );
137 points->SetPoint( pId, pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
139 cells->InsertNextCell( 1 );
140 cells->InsertCellPoint( pId );
143 out->SetPoints( points );
144 out->SetVerts( cells );
148 // -------------------------------------------------------------------------
149 template< class U, class I >
150 int fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >::
152 vtkInformation* information,
153 vtkInformationVector** input,
154 vtkInformationVector* output
157 vtkInformation* info = output->GetInformationObject( 0 );
160 vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES( ), -1
164 if( this->m_Container.IsNotNull( ) && this->m_Image.IsNotNull( ) )
167 typename C::TScalar len = this->m_RGC->GetTotalLength( );
168 typename C::TScalar s0 = this->m_RGC->Gets0( );
169 typename C::TPoint p0 = this->m_RGC->Axis( s0 );
170 typename C::TPoint p1 = this->m_RGC->Axis( s0 + len );
173 vtkStreamingDemandDrivenPipeline::WHOLE_BOUNDING_BOX( ),
174 double( p0[ 0 ] ), double( p1[ 0 ] ),
175 double( p0[ 1 ] ), double( p1[ 1 ] ),
176 double( p0[ 2 ] ), double( p1[ 2 ] )
184 #endif // __FPA__VTK__UNIQUEVERTICESTOPOLYDATAFILTER__HXX__