]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.cxx
61eaf96e661763080ed48470bfabf069bca4e8b5
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
1 #include <cpPlugins/Interface/ProcessObject.h>
2
3 // -------------------------------------------------------------------------
4 std::string cpPlugins::Interface::ProcessObject::
5 GetClassName( ) const
6 {
7   return( "cpPlugins::Interface::ProcessObject" );
8 }
9
10 // -------------------------------------------------------------------------
11 std::string cpPlugins::Interface::ProcessObject::
12 GetClassType( ) const
13 {
14   return( "ProcessObject" );
15 }
16
17 // -------------------------------------------------------------------------
18 const cpPlugins::Interface::Parameters&
19 cpPlugins::Interface::ProcessObject::
20 GetDefaultParameters( ) const
21 {
22   return( this->m_DefaultParameters );
23 }
24
25 // -------------------------------------------------------------------------
26 void cpPlugins::Interface::ProcessObject::
27 SetParameters( const cpPlugins::Interface::Parameters& params )
28 {
29   this->m_Parameters = params;
30   this->Modified( );
31 }
32
33 // -------------------------------------------------------------------------
34 unsigned int cpPlugins::Interface::ProcessObject::
35 GetNumberOfInputs( ) const
36 {
37   return( this->m_Inputs.size( ) );
38 }
39
40 // -------------------------------------------------------------------------
41 unsigned int cpPlugins::Interface::ProcessObject::
42 GetNumberOfOutputs( ) const
43 {
44   return( this->m_Outputs.size( ) );
45 }
46
47 // -------------------------------------------------------------------------
48 void cpPlugins::Interface::ProcessObject::
49 SetNumberOfInputs( unsigned int n )
50 {
51   this->m_Inputs.clear( );
52   this->m_Inputs.resize( n );
53   this->Modified( );
54 }
55
56 // -------------------------------------------------------------------------
57 void cpPlugins::Interface::ProcessObject::
58 SetNumberOfOutputs( unsigned int n )
59 {
60   this->m_Outputs.clear( );
61   this->m_Outputs.resize( n );
62   this->Modified( );
63 }
64
65 // -------------------------------------------------------------------------
66 void cpPlugins::Interface::ProcessObject::
67 SetInput( unsigned int idx, cpPlugins::Interface::DataObject* dobj )
68 {
69   if( idx < this->m_Inputs.size( ) )
70   {
71     this->m_Inputs[ idx ] = dobj;
72     this->Modified( );
73
74   } // fi
75 }
76
77 // -------------------------------------------------------------------------
78 cpPlugins::Interface::DataObject* cpPlugins::Interface::ProcessObject::
79 GetOutput( unsigned int idx )
80 {
81   if( idx < this->m_Outputs.size( ) )
82     return( this->m_Outputs[ idx ] );
83   else
84     return( NULL );
85 }
86
87 // -------------------------------------------------------------------------
88 std::string cpPlugins::Interface::ProcessObject::
89 Update( )
90 {
91   std::string r = "";
92
93   // Force upstream updates
94   for( unsigned int i = 0; i < this->m_Inputs.size( ) && r == ""; ++i )
95   {
96     Self* src = dynamic_cast< Self* >( this->m_Inputs[ i ]->GetSource( ) );
97     if( src != NULL )
98       r = src->Update( );
99
100   } // rof
101
102   // Current update
103   if( r == "" )
104     r = this->_GenerateData( );
105
106   // Return error description, if any
107   return( r );
108 }
109
110 // -------------------------------------------------------------------------
111 void cpPlugins::Interface::ProcessObject::
112 DisconnectOutputs( )
113 {
114   for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx )
115     if( this->m_Outputs[ idx ].IsNotNull( ) )
116       this->m_Outputs[ idx ]->DisconnectPipeline( );
117 }
118
119 // -------------------------------------------------------------------------
120 cpPlugins::Interface::ProcessObject::
121 ProcessObject( )
122   : Superclass( )
123 {
124 }
125
126 // -------------------------------------------------------------------------
127 cpPlugins::Interface::ProcessObject::
128 ~ProcessObject( )
129 {
130 }
131
132 // -------------------------------------------------------------------------
133 itk::DataObject* cpPlugins::Interface::ProcessObject::
134 _GetInput( unsigned int idx )
135 {
136   if( idx < this->m_Inputs.size( ) )
137     return( this->m_Inputs[ idx ]->GetRealDataObject( ) );
138   else
139     return( NULL );
140 }
141
142 // -------------------------------------------------------------------------
143 void cpPlugins::Interface::ProcessObject::
144 _SetOutput( unsigned int idx, itk::DataObject* dobj )
145 {
146   if( idx < this->m_Outputs.size( ) )
147     if( this->m_Outputs[ idx ].IsNotNull( ) )
148       this->m_Outputs[ idx ]->SetRealDataObject( dobj );
149 }
150
151 // eof - $RCSfile$