1 #ifndef __cpPlugins__BaseObjects__ProcessObject__hxx__
2 #define __cpPlugins__BaseObjects__ProcessObject__hxx__
4 // -------------------------------------------------------------------------
5 template< class _TType >
6 _TType* cpPlugins::BaseObjects::ProcessObject::
7 GetInput( const std::string& n, unsigned int i )
9 auto it = this->m_Inputs.find( n );
10 if( it != this->m_Inputs.end( ) )
11 return( dynamic_cast< _TType* >( it->second->Get( i ) ) );
16 // -------------------------------------------------------------------------
17 template< class _TType >
18 const _TType* cpPlugins::BaseObjects::ProcessObject::
19 GetInput( const std::string& n, unsigned int i ) const
21 auto it = this->m_Inputs.find( n );
22 if( it != this->m_Inputs.end( ) )
23 return( dynamic_cast< const _TType* >( it->second->Get( i ) ) );
28 // -------------------------------------------------------------------------
29 template< class _TType >
30 _TType* cpPlugins::BaseObjects::ProcessObject::
31 GetInputData( const std::string& n, unsigned int i )
33 auto d = this->GetInput( n, i );
36 auto oi = d->m_ITK.GetPointer( );
37 auto ov = d->m_VTK.GetPointer( );
38 if( oi != NULL && ov != NULL )
40 auto di = dynamic_cast< _TType* >( oi );
41 auto dv = dynamic_cast< _TType* >( ov );
42 if ( di != NULL ) return( di );
43 else if( dv != NULL ) return( dv );
46 else if( oi != NULL && ov == NULL )
48 auto di = dynamic_cast< _TType* >( oi );
50 return( d->GetVTK< _TType >( ) );
54 else if( oi == NULL && ov != NULL )
56 auto dv = dynamic_cast< _TType* >( ov );
58 return( d->GetITK< _TType >( ) );
69 // -------------------------------------------------------------------------
70 template< class _TType >
71 const _TType* cpPlugins::BaseObjects::ProcessObject::
72 GetInputData( const std::string& n, unsigned int i ) const
74 auto d = this->GetInput( n, i );
77 auto oi = d->m_ITK.GetPointer( );
78 auto ov = d->m_VTK.GetPointer( );
79 if( oi != NULL && ov != NULL )
81 auto di = dynamic_cast< const _TType* >( oi );
82 auto dv = dynamic_cast< const _TType* >( ov );
83 if ( di != NULL ) return( di );
84 else if( dv != NULL ) return( dv );
87 else if( oi != NULL && ov == NULL )
89 auto di = dynamic_cast< const _TType* >( oi );
91 return( d->GetVTK< _TType >( ) );
95 else if( oi == NULL && ov != NULL )
97 auto dv = dynamic_cast< const _TType* >( ov );
99 return( d->GetITK< _TType >( ) );
110 // -------------------------------------------------------------------------
111 template< class _TType >
112 _TType* cpPlugins::BaseObjects::ProcessObject::
113 GetOutput( const std::string& n )
115 auto it = this->m_Outputs.find( n );
116 if( it != this->m_Outputs.end( ) )
117 return( dynamic_cast< _TType* >( it->second->Get( ) ) );
122 // -------------------------------------------------------------------------
123 template< class _TType >
124 const _TType* cpPlugins::BaseObjects::ProcessObject::
125 GetOutput( const std::string& n ) const
127 auto it = this->m_Outputs.find( n );
128 if( it != this->m_Outputs.end( ) )
129 return( dynamic_cast< const _TType* >( it->second->Get( ) ) );
134 // -------------------------------------------------------------------------
135 template< class _TType >
136 _TType* cpPlugins::BaseObjects::ProcessObject::
137 GetOutputData( const std::string& n )
139 auto d = this->GetOutput( n );
142 auto oi = d->m_ITK.GetPointer( );
143 auto ov = d->m_VTK.GetPointer( );
144 if( oi != NULL && ov != NULL )
146 auto di = dynamic_cast< _TType* >( oi );
147 auto dv = dynamic_cast< _TType* >( ov );
148 if ( di != NULL ) return( di );
149 else if( dv != NULL ) return( dv );
152 else if( oi != NULL && ov == NULL )
154 auto di = dynamic_cast< _TType* >( oi );
156 return( d->GetVTK< _TType >( ) );
160 else if( oi == NULL && ov != NULL )
162 auto dv = dynamic_cast< _TType* >( ov );
164 return( d->GetITK< _TType >( ) );
175 // -------------------------------------------------------------------------
176 template< class _TType >
177 const _TType* cpPlugins::BaseObjects::ProcessObject::
178 GetOutputData( const std::string& n ) const
180 auto d = this->GetOutput( n );
183 auto oi = d->m_ITK.GetPointer( );
184 auto ov = d->m_VTK.GetPointer( );
185 if( oi != NULL && ov != NULL )
187 auto di = dynamic_cast< const _TType* >( oi );
188 auto dv = dynamic_cast< const _TType* >( ov );
189 if ( di != NULL ) return( di );
190 else if( dv != NULL ) return( dv );
193 else if( oi != NULL && ov == NULL )
195 auto di = dynamic_cast< const _TType* >( oi );
197 return( d->GetVTK< _TType >( ) );
201 else if( oi == NULL && ov != NULL )
203 auto dv = dynamic_cast< const _TType* >( ov );
205 return( d->GetITK< _TType >( ) );
216 // -------------------------------------------------------------------------
217 template< class _TType >
218 void cpPlugins::BaseObjects::ProcessObject::
219 _ConfigureInput( const std::string& name, bool required, bool multiple )
221 auto it = this->m_Inputs.find( name );
222 if( it == this->m_Inputs.end( ) )
225 if( multiple ) port = new MultipleInputsPort( required );
226 else port = new InputPort( required );
227 port->Configure< _TType >( );
228 this->m_Inputs[ name ] = port;
234 // -------------------------------------------------------------------------
235 template< class _TType >
236 void cpPlugins::BaseObjects::ProcessObject::
237 _ConfigureOutput( const std::string& name )
239 auto it = this->m_Outputs.find( name );
240 if( it == this->m_Outputs.end( ) )
242 Port* port = new OutputPort( true );
243 port->Configure< _TType >( );
244 port->Add( _TType::New( ) );
245 port->Get( )->SetSource( this );
246 this->m_Outputs[ name ] = port;
252 // -------------------------------------------------------------------------
253 template< class _TFilter >
254 _TFilter* cpPlugins::BaseObjects::ProcessObject::
258 _TFilter* filter = this->GetITK< _TFilter >( );
259 why this lead to synch issues???
261 _TFilter* filter = NULL;
264 typename _TFilter::Pointer filter_ptr = _TFilter::New( );
265 this->m_ITK = filter_ptr;
267 filter = filter_ptr.GetPointer( );
274 // -------------------------------------------------------------------------
275 template< class _TFilter >
276 _TFilter* cpPlugins::BaseObjects::ProcessObject::
280 _TFilter* filter = this->GetVTK< _TFilter >( );
281 why this lead to synch issues???
283 _TFilter* filter = NULL;
286 vtkSmartPointer< _TFilter > filter_ptr =
287 vtkSmartPointer< _TFilter >::New( );
289 this->m_VTK = filter_ptr;
290 filter = filter_ptr.GetPointer( );
297 #endif // __cpPlugins__BaseObjects__ProcessObject__hxx__