X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FProcessObject.hxx;h=54c2f37bb8ede077d0f7238dbf760f5ac3382ec3;hb=6ffc11d77924d6ab7e94db95d41105982ac73e00;hp=a3362fc5b8ce25de6305aa15d636456cb575c7cc;hpb=1b600247da314fe62d007ca8a0ce24d0006931f4;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/ProcessObject.hxx b/lib/cpPlugins/Interface/ProcessObject.hxx index a3362fc..54c2f37 100644 --- a/lib/cpPlugins/Interface/ProcessObject.hxx +++ b/lib/cpPlugins/Interface/ProcessObject.hxx @@ -6,9 +6,9 @@ template< class T > T* cpPlugins::Interface::ProcessObject:: GetInputData( const std::string& id ) { - _TDataContainer::iterator i = this->m_Inputs.find( id ); + auto i = this->m_Inputs.find( id ); if( i != this->m_Inputs.end( ) ) - return( dynamic_cast< T* >( i->second->GetPointer( ) ) ); + return( dynamic_cast< T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -18,9 +18,9 @@ template< class T > const T* cpPlugins::Interface::ProcessObject:: GetInputData( const std::string& id ) const { - _TDataContainer::const_iterator i = this->m_Inputs.find( id ); + auto i = this->m_Inputs.find( id ); if( i != this->m_Inputs.end( ) ) - return( dynamic_cast< const T* >( i->second->GetPointer( ) ) ); + return( dynamic_cast< const T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -30,9 +30,9 @@ template< class T > T* cpPlugins::Interface::ProcessObject:: GetOutputData( const std::string& id ) { - _TDataContainer::iterator i = this->m_Outputs.find( id ); + auto i = this->m_Outputs.find( id ); if( i != this->m_Outputs.end( ) ) - return( dynamic_cast< T* >( i->second->GetPointer( ) ) ); + return( dynamic_cast< T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -42,9 +42,9 @@ template< class T > const T* cpPlugins::Interface::ProcessObject:: GetOutputData( const std::string& id ) const { - _TDataContainer::const_iterator i = this->m_Outputs.find( id ); + auto i = this->m_Outputs.find( id ); if( i != this->m_Outputs.end( ) ) - return( dynamic_cast< const T* >( i->second->GetPointer( ) ) ); + return( dynamic_cast< const T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -52,18 +52,17 @@ GetOutputData( const std::string& id ) const // ------------------------------------------------------------------------- template< class O > void cpPlugins::Interface::ProcessObject:: -_AddOutput( const std::string& id ) +_AddOutput( const std::string& name ) { - auto oIt = this->m_Outputs.find( id ); - if( oIt == this->m_Outputs.end( ) ) + auto i = this->m_Outputs.find( name ); + if( i == this->m_Outputs.end( ) ) { - this->m_Outputs[ id ] = new DataObject::Pointer( ); - oIt = this->m_Outputs.find( id ); + typename O::Pointer o = O::New( ); + o->SetSource( this ); + this->m_Outputs[ name ] = o; + this->Modified( ); } // fi - *( oIt->second ) = O::New( ); - ( *( oIt->second ) )->SetSource( this ); - this->Modified( ); } // ------------------------------------------------------------------------- @@ -71,13 +70,14 @@ template< class F > F* cpPlugins::Interface::ProcessObject:: _CreateITK( ) { - F* filter = dynamic_cast< F* >( this->m_ITKObject.GetPointer( ) ); + F* filter = this->GetITK< F >( ); if( filter == NULL ) { - typename F::Pointer ptr = F::New( ); - this->m_ITKObject = ptr; - filter = ptr.GetPointer( ); + 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 ); @@ -88,12 +88,14 @@ template< class F > F* cpPlugins::Interface::ProcessObject:: _CreateVTK( ) { - F* filter = dynamic_cast< F* >( this->m_VTKObject.GetPointer( ) ); + F* filter = this->GetVTK< F >( ); if( filter == NULL ) { - filter = F::New( ); - this->m_VTKObject = filter; + 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 );