1 #include <cpPlugins/Interface/ProcessObject.h>
3 // -------------------------------------------------------------------------
4 cpPlugins::Interface::ProcessObject::
7 m_OutputsDisconnected( false )
11 // -------------------------------------------------------------------------
12 cpPlugins::Interface::ProcessObject::
15 this->_DeleteOutputs( );
18 // -------------------------------------------------------------------------
19 std::string cpPlugins::Interface::ProcessObject::
22 return( "cpPlugins::Interface::ProcessObject" );
25 // -------------------------------------------------------------------------
26 const cpPlugins::Interface::ProcessObject::
27 TParameters& cpPlugins::Interface::ProcessObject::
28 GetDefaultParameters( ) const
30 return( this->m_DefaultParameters );
33 // -------------------------------------------------------------------------
34 void cpPlugins::Interface::ProcessObject::
35 SetParameters( const TParameters& params )
37 this->m_Parameters = params;
40 // -------------------------------------------------------------------------
41 unsigned int cpPlugins::Interface::ProcessObject::
42 GetNumberOfInputs( ) const
44 return( this->m_Inputs.size( ) );
47 // -------------------------------------------------------------------------
48 unsigned int cpPlugins::Interface::ProcessObject::
49 GetNumberOfOutputs( ) const
51 return( this->m_Outputs.size( ) );
54 // -------------------------------------------------------------------------
55 void cpPlugins::Interface::ProcessObject::
56 SetNumberOfInputs( unsigned int n )
58 this->m_Inputs.clear( );
59 this->m_Inputs.resize( n, NULL );
62 // -------------------------------------------------------------------------
63 void cpPlugins::Interface::ProcessObject::
64 SetNumberOfOutputs( unsigned int n )
66 this->_DeleteOutputs( );
67 this->m_Outputs.clear( );
68 this->m_Outputs.resize( n, NULL );
69 this->m_OutputsDisconnected = false;
72 // -------------------------------------------------------------------------
73 void cpPlugins::Interface::ProcessObject::
75 unsigned int idx, const cpPlugins::Interface::DataObject* dobj
78 if( idx < this->m_Inputs.size( ) )
79 this->m_Inputs[ idx ] = dobj;
82 // -------------------------------------------------------------------------
83 cpPlugins::Interface::DataObject* cpPlugins::Interface::ProcessObject::
84 GetOutput( unsigned int idx )
86 if( idx < this->m_Outputs.size( ) )
87 return( this->m_Outputs[ idx ] );
92 // -------------------------------------------------------------------------
93 std::string cpPlugins::Interface::ProcessObject::
96 // Force upstream updates
98 for( unsigned int i = 0; i < this->m_Inputs.size( ) && r == ""; ++i )
99 r = this->m_Inputs[ i ]->GetSource( )->Update( );
104 r = this->_GenerateData( );
105 this->m_OutputsDisconnected = false;
109 // Return error description, if any
113 // -------------------------------------------------------------------------
114 void cpPlugins::Interface::ProcessObject::
117 this->m_OutputsDisconnected = true;
118 for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx )
119 if( this->m_Outputs[ idx ] != NULL )
120 this->m_Outputs[ idx ]->GetDataObject( )->DisconnectPipeline( );
123 // -------------------------------------------------------------------------
124 itk::DataObject* cpPlugins::Interface::ProcessObject::
125 _GetInput( unsigned int idx )
127 if( idx < this->m_Inputs.size( ) )
128 return( this->m_Inputs[ idx ]->GetDataObject( ) );
133 // -------------------------------------------------------------------------
134 void cpPlugins::Interface::ProcessObject::
135 _SetOutput( unsigned int idx, itk::DataObject* dobj )
137 if( idx < this->m_Outputs.size( ) )
138 if( this->m_Outputs[ idx ] != NULL )
139 this->m_Outputs[ idx ]->SetDataObject( dobj );
142 // -------------------------------------------------------------------------
143 void cpPlugins::Interface::ProcessObject::
146 if( !( this->m_OutputsDisconnected ) )
147 for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx )
148 if( this->m_Outputs[ idx ] != NULL )
149 delete this->m_Outputs[ idx ];