#ifndef __FPA__VTK__UNIQUEVERTICESTOPOLYDATAFILTER__HXX__ #define __FPA__VTK__UNIQUEVERTICESTOPOLYDATAFILTER__HXX__ #include #include // ------------------------------------------------------------------------- template< class U, class I > typename fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >:: Self* fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >:: New( ) { return( new Self( ) ); } // ------------------------------------------------------------------------- template< class U, class I > const U* fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >:: GetInput( ) const { return( this->m_Container ); } // ------------------------------------------------------------------------- template< class U, class I > void fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >:: SetInput( const U* c ) { if( this->m_Container.GetPointer( ) != c ) { this->m_Container = c; this->m_LastContainerModifiedTime = this->m_Container->GetMTime( ); this->Modified( ); } // fi } // ------------------------------------------------------------------------- template< class U, class I > const I* fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >:: GetImage( ) const { return( this->m_Image ); } // ------------------------------------------------------------------------- template< class U, class I > void fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >:: SetImage( const I* i ) { if( this->m_Image.GetPointer( ) != i ) { this->m_Image = i; this->Modified( ); } // fi } // ------------------------------------------------------------------------- template< class U, class I > unsigned long fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >:: GetMTime( ) { unsigned long ctime = this->m_Container->GetMTime( ); if( ctime > this->m_LastContainerModifiedTime ) { this->m_LastContainerModifiedTime = ctime; this->Modified( ); } // fi return( this->Superclass::GetMTime( ) ); } // ------------------------------------------------------------------------- template< class U, class I > fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >:: UniqueVerticesToPolyDataFilter( ) : vtkPolyDataAlgorithm( ) { this->SetNumberOfInputPorts( 0 ); } // ------------------------------------------------------------------------- template< class U, class I > fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >:: ~UniqueVerticesToPolyDataFilter( ) { } // ------------------------------------------------------------------------- template< class U, class I > int fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >:: RequestData( vtkInformation* information, vtkInformationVector** input, vtkInformationVector* output ) { if( this->m_Container.IsNull( ) || this->m_Image.IsNull( ) ) return( 0 ); // Get output vtkInformation* info = output->GetInformationObject( 0 ); vtkPolyData* out = vtkPolyData::SafeDownCast( info->Get( vtkDataObject::DATA_OBJECT( ) ) ); // Prepare points vtkPoints* points = out->GetPoints( ); if( points == NULL ) { points = vtkPoints::New( ); out->SetPoints( points ); points->Delete( ); } // fi points->SetNumberOfPoints( this->m_Container->Size( ) ); // Prepare cells vtkSmartPointer< vtkCellArray > cells = vtkSmartPointer< vtkCellArray >::New( ); unsigned int pId = 0; for( typename U::ConstIterator it = this->m_Container->Begin( ); it != this->m_Container->End( ); ++it, ++pId ) { typename I::PointType pnt; this->m_Image->TransformIndexToPhysicalPoint( *it, pnt ); if( I::ImageDimension == 1 ) points->SetPoint( pId, pnt[ 0 ], 0, 0 ); else if( I::ImageDimension == 2 ) points->SetPoint( pId, pnt[ 0 ], pnt[ 1 ], 0 ); else points->SetPoint( pId, pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); cells->InsertNextCell( 1 ); cells->InsertCellPoint( pId ); } // rof out->SetPoints( points ); out->SetVerts( cells ); return( 1 ); } // ------------------------------------------------------------------------- template< class U, class I > int fpa::VTK::UniqueVerticesToPolyDataFilter< U, I >:: RequestInformation( vtkInformation* information, vtkInformationVector** input, vtkInformationVector* output ) { vtkInformation* info = output->GetInformationObject( 0 ); /* TODO info->Set( vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES( ), -1 ); */ if( this->m_Container.IsNotNull( ) && this->m_Image.IsNotNull( ) ) { /* TODO typename C::TScalar len = this->m_RGC->GetTotalLength( ); typename C::TScalar s0 = this->m_RGC->Gets0( ); typename C::TPoint p0 = this->m_RGC->Axis( s0 ); typename C::TPoint p1 = this->m_RGC->Axis( s0 + len ); info->Set( vtkStreamingDemandDrivenPipeline::WHOLE_BOUNDING_BOX( ), double( p0[ 0 ] ), double( p1[ 0 ] ), double( p0[ 1 ] ), double( p1[ 1 ] ), double( p0[ 2 ] ), double( p1[ 2 ] ) ); */ } // fi return( 1 ); } #endif // __FPA__VTK__UNIQUEVERTICESTOPOLYDATAFILTER__HXX__ // eof - $RCSfile$