]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.cxx
Generic gaussian model estimator added
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
index cd88ea67ba637162b0938bd3474eb5a37cc9294b..61eaf96e661763080ed48470bfabf069bca4e8b5 100644 (file)
@@ -1,28 +1,22 @@
 #include <cpPlugins/Interface/ProcessObject.h>
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObject::
-ProcessObject( )
-  : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObject::
-~ProcessObject( )
+std::string cpPlugins::Interface::ProcessObject::
+GetClassName( ) const
 {
+  return( "cpPlugins::Interface::ProcessObject" );
 }
 
 // -------------------------------------------------------------------------
 std::string cpPlugins::Interface::ProcessObject::
-GetClassName( ) const
+GetClassType( ) const
 {
-  return( "cpPlugins::Interface::ProcessObject" );
+  return( "ProcessObject" );
 }
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::ProcessObject::
-TParameters& cpPlugins::Interface::ProcessObject::
+const cpPlugins::Interface::Parameters&
+cpPlugins::Interface::ProcessObject::
 GetDefaultParameters( ) const
 {
   return( this->m_DefaultParameters );
@@ -30,9 +24,10 @@ GetDefaultParameters( ) const
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
-SetParameters( const TParameters& params )
+SetParameters( const cpPlugins::Interface::Parameters& params )
 {
   this->m_Parameters = params;
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
@@ -51,17 +46,37 @@ GetNumberOfOutputs( ) const
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
-SetInput(
-  unsigned int idx, const cpPlugins::Interface::DataObject* dobj
-  )
+SetNumberOfInputs( unsigned int n )
+{
+  this->m_Inputs.clear( );
+  this->m_Inputs.resize( n );
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+SetNumberOfOutputs( unsigned int n )
+{
+  this->m_Outputs.clear( );
+  this->m_Outputs.resize( n );
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+SetInput( unsigned int idx, cpPlugins::Interface::DataObject* dobj )
 {
   if( idx < this->m_Inputs.size( ) )
+  {
     this->m_Inputs[ idx ] = dobj;
+    this->Modified( );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::DataObject* cpPlugins::Interface::ProcessObject::
-GetOutput( unsigned int idx ) const
+GetOutput( unsigned int idx )
 {
   if( idx < this->m_Outputs.size( ) )
     return( this->m_Outputs[ idx ] );
@@ -73,19 +88,64 @@ GetOutput( unsigned int idx ) const
 std::string cpPlugins::Interface::ProcessObject::
 Update( )
 {
+  std::string r = "";
+
   // Force upstream updates
-  for( unsigned int idx = 0; idx < this->m_Inputs.size( ); ++idx )
-    this->m_Inputs->GetSource( )->Update( );
+  for( unsigned int i = 0; i < this->m_Inputs.size( ) && r == ""; ++i )
+  {
+    Self* src = dynamic_cast< Self* >( this->m_Inputs[ i ]->GetSource( ) );
+    if( src != NULL )
+      r = src->Update( );
+
+  } // rof
 
   // Current update
-  std::string ret = this->_GenerateData( );
+  if( r == "" )
+    r = this->_GenerateData( );
 
-  // Sync outputs
-  for( unsigned int odx = 0; odx < this->m_Outputs.size( ); ++odx )
-    this->m_Outputs->SetSource( this );
+  // Return error description, if any
+  return( r );
+}
 
-  return( ret );
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+DisconnectOutputs( )
+{
+  for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx )
+    if( this->m_Outputs[ idx ].IsNotNull( ) )
+      this->m_Outputs[ idx ]->DisconnectPipeline( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObject::
+ProcessObject( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObject::
+~ProcessObject( )
+{
+}
+
+// -------------------------------------------------------------------------
+itk::DataObject* cpPlugins::Interface::ProcessObject::
+_GetInput( unsigned int idx )
+{
+  if( idx < this->m_Inputs.size( ) )
+    return( this->m_Inputs[ idx ]->GetRealDataObject( ) );
+  else
+    return( NULL );
 }
 
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+_SetOutput( unsigned int idx, itk::DataObject* dobj )
+{
+  if( idx < this->m_Outputs.size( ) )
+    if( this->m_Outputs[ idx ].IsNotNull( ) )
+      this->m_Outputs[ idx ]->SetRealDataObject( dobj );
+}
 
 // eof - $RCSfile$