]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.hxx
MAC compilation issues solved... Now some tests please
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.hxx
index a3362fc5b8ce25de6305aa15d636456cb575c7cc..54c2f37bb8ede077d0f7238dbf760f5ac3382ec3 100644 (file)
@@ -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 );