X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FProcessObject.hxx;h=54c2f37bb8ede077d0f7238dbf760f5ac3382ec3;hb=6ffc11d77924d6ab7e94db95d41105982ac73e00;hp=f84d4a6301e202cf44bfbb95fb8b0e4b9b7a4bb2;hpb=62d056ccb528d63392d197552830460e980a5aba;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/ProcessObject.hxx b/lib/cpPlugins/Interface/ProcessObject.hxx index f84d4a6..54c2f37 100644 --- a/lib/cpPlugins/Interface/ProcessObject.hxx +++ b/lib/cpPlugins/Interface/ProcessObject.hxx @@ -4,10 +4,11 @@ // ------------------------------------------------------------------------- template< class T > T* cpPlugins::Interface::ProcessObject:: -GetInput( unsigned int idx ) +GetInputData( const std::string& id ) { - if( idx < this->m_Inputs.size( ) ) - return( dynamic_cast< T* >( this->m_Inputs[ idx ].GetPointer( ) ) ); + auto i = this->m_Inputs.find( id ); + if( i != this->m_Inputs.end( ) ) + return( dynamic_cast< T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -15,12 +16,11 @@ GetInput( unsigned int idx ) // ------------------------------------------------------------------------- template< class T > const T* cpPlugins::Interface::ProcessObject:: -GetInput( unsigned int idx ) const +GetInputData( const std::string& id ) const { - if( idx < this->m_Inputs.size( ) ) - return( - dynamic_cast< const T* >( this->m_Inputs[ idx ].GetPointer( ) ) - ); + auto i = this->m_Inputs.find( id ); + if( i != this->m_Inputs.end( ) ) + return( dynamic_cast< const T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -28,10 +28,11 @@ GetInput( unsigned int idx ) const // ------------------------------------------------------------------------- template< class T > T* cpPlugins::Interface::ProcessObject:: -GetOutput( unsigned int idx ) +GetOutputData( const std::string& id ) { - if( idx < this->m_Outputs.size( ) ) - return( dynamic_cast< T* >( this->m_Outputs[ idx ].GetPointer( ) ) ); + auto i = this->m_Outputs.find( id ); + if( i != this->m_Outputs.end( ) ) + return( dynamic_cast< T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -39,12 +40,11 @@ GetOutput( unsigned int idx ) // ------------------------------------------------------------------------- template< class T > const T* cpPlugins::Interface::ProcessObject:: -GetOutput( unsigned int idx ) const +GetOutputData( const std::string& id ) const { - if( idx < this->m_Outputs.size( ) ) - return( - dynamic_cast< const T* >( this->m_Outputs[ idx ].GetPointer( ) ) - ); + auto i = this->m_Outputs.find( id ); + if( i != this->m_Outputs.end( ) ) + return( dynamic_cast< const T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -52,12 +52,53 @@ GetOutput( unsigned int idx ) const // ------------------------------------------------------------------------- template< class O > void cpPlugins::Interface::ProcessObject:: -_MakeOutput( unsigned int idx ) +_AddOutput( const std::string& name ) { - if( idx >= this->m_Outputs.size( ) ) - return; - this->m_Outputs[ idx ] = O::New( ); - this->m_Outputs[ idx ]->SetSource( this ); + auto i = this->m_Outputs.find( name ); + if( i == this->m_Outputs.end( ) ) + { + typename O::Pointer o = O::New( ); + o->SetSource( this ); + this->m_Outputs[ name ] = o; + this->Modified( ); + + } // fi +} + +// ------------------------------------------------------------------------- +template< class F > +F* cpPlugins::Interface::ProcessObject:: +_CreateITK( ) +{ + F* filter = this->GetITK< F >( ); + if( filter == NULL ) + { + typename F::Pointer filter_ptr = F::New( ); + this->m_ITKObject = filter_ptr; + this->m_VTKObject = NULL; + filter = filter_ptr.GetPointer( ); + this->Modified( ); + + } // fi + return( filter ); +} + +// ------------------------------------------------------------------------- +template< class F > +F* cpPlugins::Interface::ProcessObject:: +_CreateVTK( ) +{ + F* filter = this->GetVTK< F >( ); + if( filter == NULL ) + { + vtkSmartPointer< F > filter_ptr = vtkSmartPointer< F >::New( ); + this->m_ITKObject = NULL; + this->m_VTKObject = filter_ptr; + filter = filter_ptr.GetPointer( ); + this->Modified( ); + + } // fi + return( filter ); } #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__