1 #include <cpPluginsVisualization/IndexesToPolyData.h>
2 #include <cpPlugins/Image.h>
3 #include <cpPlugins/Mesh.h>
5 #include <cpExtensions/Visualization/IndexesToPolyData.h>
6 #include <cpExtensions/Visualization/IndexesToPolyData.hxx>
8 // -------------------------------------------------------------------------
9 cpPluginsVisualization::IndexesToPolyData::
13 this->_AddInput( "Input" );
14 this->_AddInput( "ReferenceImage", false );
15 this->_AddOutput< cpPlugins::Mesh >( "Output" );
18 // -------------------------------------------------------------------------
19 cpPluginsVisualization::IndexesToPolyData::
24 // -------------------------------------------------------------------------
25 std::string cpPluginsVisualization::IndexesToPolyData::
28 typedef itk::SimpleDataObjectDecorator< std::vector< itk::Index< 2 > > > _2D;
29 typedef itk::SimpleDataObjectDecorator< std::vector< itk::Index< 3 > > > _3D;
31 auto indexes = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
32 auto indexes2D = dynamic_cast< _2D* >( indexes );
33 auto indexes3D = dynamic_cast< _3D* >( indexes );
34 if( indexes2D != NULL )
35 return( this->_GD0( indexes2D ) );
36 else if( indexes3D != NULL )
37 return( this->_GD0( indexes3D ) );
39 return( "cpPluginsVisualization::IndexesToPolyData: no valid input." );
42 // -------------------------------------------------------------------------
43 template< class _TIndexes >
44 std::string cpPluginsVisualization::IndexesToPolyData::
45 _GD0( _TIndexes* indexes )
48 cpExtensions::Visualization::IndexesToPolyData< _TIndexes >
50 typedef typename _TFilter::TImage _TImage;
53 _TFilter* filter = this->_CreateVTK< _TFilter >( );
54 filter->SetInput( indexes );
55 filter->SetReferenceImage(
56 this->GetInputData( "Input" )->GetITK< _TImage >( )
61 this->GetOutputData( "Output" )->SetVTK( filter->GetOutput( ) );