1 #include <cpPlugins/Plugins/PolyDataReader.h>
2 #include <cpPlugins/Interface/PolyData.h>
4 #include <vtkErrorCode.h>
5 #include <vtkPolyDataReader.h>
7 // -------------------------------------------------------------------------
8 std::string cpPlugins::Plugins::PolyDataReader::
11 return( "cpPlugins::Plugins::PolyDataReader" );
14 // -------------------------------------------------------------------------
15 cpPlugins::Plugins::PolyDataReader::
19 this->SetNumberOfOutputs( 1 );
20 this->_MakeOutput< cpPlugins::Interface::PolyData >( 0 );
22 using namespace cpPlugins::Interface;
23 this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
24 this->m_Parameters = this->m_DefaultParameters;
27 // -------------------------------------------------------------------------
28 cpPlugins::Plugins::PolyDataReader::
33 // -------------------------------------------------------------------------
34 std::string cpPlugins::Plugins::PolyDataReader::
38 using namespace cpPlugins::Interface;
39 Parameters::TString fname =
40 this->m_Parameters.GetValueAsString( "FileName" );
42 // Create a possible reader
43 vtkPolyDataReader* reader =
44 dynamic_cast< vtkPolyDataReader* >( this->m_Reader.GetPointer( ) );
47 this->m_Reader = vtkSmartPointer< vtkPolyDataReader >::New( );
49 dynamic_cast< vtkPolyDataReader* >( this->m_Reader.GetPointer( ) );
52 reader->SetFileName( fname.c_str( ) );
54 unsigned long error = reader->GetErrorCode( );
55 if( error == vtkErrorCode::NoError )
57 if( this->m_Outputs[ 0 ].IsNotNull( ) )
59 cpPlugins::Interface::PolyData* pdata =
60 dynamic_cast< cpPlugins::Interface::PolyData* >(
61 this->m_Outputs[ 0 ].GetPointer( )
64 pdata->SetRealDataObject( reader->GetOutput( ) );
70 return( vtkErrorCode::GetStringFromErrorCode( error ) );