X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FProcessObject.hxx;h=10b4dbe99fcc7a66fb02a42d978523e57b3e5c61;hb=f654620df52b811be7bd263a1775c93d29c69a65;hp=f84d4a6301e202cf44bfbb95fb8b0e4b9b7a4bb2;hpb=62d056ccb528d63392d197552830460e980a5aba;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/ProcessObject.hxx b/lib/cpPlugins/Interface/ProcessObject.hxx index f84d4a6..10b4dbe 100644 --- a/lib/cpPlugins/Interface/ProcessObject.hxx +++ b/lib/cpPlugins/Interface/ProcessObject.hxx @@ -4,10 +4,43 @@ // ------------------------------------------------------------------------- template< class T > T* cpPlugins::Interface::ProcessObject:: -GetInput( unsigned int idx ) +GetITK( ) { - if( idx < this->m_Inputs.size( ) ) - return( dynamic_cast< T* >( this->m_Inputs[ idx ].GetPointer( ) ) ); + return( dynamic_cast< T* >( this->m_ITKObject.GetPointer( ) ) ); +} + +// ------------------------------------------------------------------------- +template< class T > +const T* cpPlugins::Interface::ProcessObject:: +GetITK( ) const +{ + return( dynamic_cast< const T* >( this->m_ITKObject.GetPointer( ) ) ); +} + +// ------------------------------------------------------------------------- +template< class T > +T* cpPlugins::Interface::ProcessObject:: +GetVTK( ) +{ + return( dynamic_cast< T* >( this->m_VTKObject.GetPointer( ) ) ); +} + +// ------------------------------------------------------------------------- +template< class T > +const T* cpPlugins::Interface::ProcessObject:: +GetVTK( ) const +{ + return( dynamic_cast< const T* >( this->m_VTKObject.GetPointer( ) ) ); +} + +// ------------------------------------------------------------------------- +template< class T > +T* cpPlugins::Interface::ProcessObject:: +GetInput( const std::string& id ) +{ + _TDataContainer::iterator i = this->m_Inputs.find( id ); + if( i != this->m_Inputs.end( ) ) + return( dynamic_cast< T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -15,12 +48,11 @@ GetInput( unsigned int idx ) // ------------------------------------------------------------------------- template< class T > const T* cpPlugins::Interface::ProcessObject:: -GetInput( unsigned int idx ) const +GetInput( const std::string& id ) const { - if( idx < this->m_Inputs.size( ) ) - return( - dynamic_cast< const T* >( this->m_Inputs[ idx ].GetPointer( ) ) - ); + _TDataContainer::const_iterator 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 +60,11 @@ GetInput( unsigned int idx ) const // ------------------------------------------------------------------------- template< class T > T* cpPlugins::Interface::ProcessObject:: -GetOutput( unsigned int idx ) +GetOutput( const std::string& id ) { - if( idx < this->m_Outputs.size( ) ) - return( dynamic_cast< T* >( this->m_Outputs[ idx ].GetPointer( ) ) ); + _TDataContainer::iterator i = this->m_Outputs.find( id ); + if( i != this->m_Outputs.end( ) ) + return( dynamic_cast< T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -39,25 +72,56 @@ GetOutput( unsigned int idx ) // ------------------------------------------------------------------------- template< class T > const T* cpPlugins::Interface::ProcessObject:: -GetOutput( unsigned int idx ) const +GetOutput( const std::string& id ) const { - if( idx < this->m_Outputs.size( ) ) - return( - dynamic_cast< const T* >( this->m_Outputs[ idx ].GetPointer( ) ) - ); + _TDataContainer::const_iterator i = this->m_Outputs.find( id ); + if( i != this->m_Outputs.end( ) ) + return( dynamic_cast< const T* >( i->second.GetPointer( ) ) ); else return( NULL ); } +// ------------------------------------------------------------------------- +template< class F > +F* cpPlugins::Interface::ProcessObject:: +_CreateITK( ) +{ + F* filter = dynamic_cast< F* >( this->m_ITKObject.GetPointer( ) ); + if( filter == NULL ) + { + typename F::Pointer ptr = F::New( ); + this->m_ITKObject = ptr; + filter = ptr.GetPointer( ); + this->m_VTKObject = NULL; + + } // fi + return( filter ); +} + +// ------------------------------------------------------------------------- +template< class F > +F* cpPlugins::Interface::ProcessObject:: +_CreateVTK( ) +{ + F* filter = dynamic_cast< F* >( this->m_VTKObject.GetPointer( ) ); + if( filter == NULL ) + { + filter = F::New( ); + this->m_VTKObject = filter; + this->m_ITKObject = NULL; + + } // fi + return( filter ); +} + // ------------------------------------------------------------------------- template< class O > void cpPlugins::Interface::ProcessObject:: -_MakeOutput( unsigned int idx ) +_MakeOutput( const std::string& id ) { - if( idx >= this->m_Outputs.size( ) ) - return; - this->m_Outputs[ idx ] = O::New( ); - this->m_Outputs[ idx ]->SetSource( this ); + this->m_Outputs[ id ] = O::New( ); + this->m_Outputs[ id ]->SetSource( this ); + this->Modified( ); } #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__