]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.hxx
50c03ce82cdfc0fb4c7a13fc2bd1f30424a56b5d
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.hxx
1 #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
2 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
3
4 // -------------------------------------------------------------------------
5 template< class T >
6 T* cpPlugins::Interface::ProcessObject::
7 GetITK( )
8 {
9   return( dynamic_cast< T* >( this->m_ITKObject.GetPointer( ) ) );
10 }
11
12 // -------------------------------------------------------------------------
13 template< class T >
14 const T* cpPlugins::Interface::ProcessObject::
15 GetITK( ) const
16 {
17   return( dynamic_cast< const T* >( this->m_ITKObject.GetPointer( ) ) );
18 }
19
20 // -------------------------------------------------------------------------
21 template< class T >
22 T* cpPlugins::Interface::ProcessObject::
23 GetVTK( )
24 {
25   return( dynamic_cast< T* >( this->m_VTKObject.GetPointer( ) ) );
26 }
27
28 // -------------------------------------------------------------------------
29 template< class T >
30 const T* cpPlugins::Interface::ProcessObject::
31 GetVTK( ) const
32 {
33   return( dynamic_cast< const T* >( this->m_VTKObject.GetPointer( ) ) );
34 }
35
36 // -------------------------------------------------------------------------
37 template< class T >
38 T* cpPlugins::Interface::ProcessObject::
39 GetInput( unsigned int idx )
40 {
41   if( idx < this->m_Inputs.size( ) )
42     return( dynamic_cast< T* >( this->m_Inputs[ idx ].GetPointer( ) ) );
43   else
44     return( NULL );
45 }
46
47 // -------------------------------------------------------------------------
48 template< class T >
49 const T* cpPlugins::Interface::ProcessObject::
50 GetInput( unsigned int idx ) const
51 {
52   if( idx < this->m_Inputs.size( ) )
53     return(
54       dynamic_cast< const T* >( this->m_Inputs[ idx ].GetPointer( ) )
55       );
56   else
57     return( NULL );
58 }
59
60 // -------------------------------------------------------------------------
61 template< class T >
62 T* cpPlugins::Interface::ProcessObject::
63 GetOutput( unsigned int idx )
64 {
65   if( idx < this->m_Outputs.size( ) )
66     return( dynamic_cast< T* >( this->m_Outputs[ idx ].GetPointer( ) ) );
67   else
68     return( NULL );
69 }
70
71 // -------------------------------------------------------------------------
72 template< class T >
73 const T* cpPlugins::Interface::ProcessObject::
74 GetOutput( unsigned int idx ) const
75 {
76   if( idx < this->m_Outputs.size( ) )
77     return(
78       dynamic_cast< const T* >( this->m_Outputs[ idx ].GetPointer( ) )
79       );
80   else
81     return( NULL );
82 }
83
84 // -------------------------------------------------------------------------
85 template< class F >
86 F* cpPlugins::Interface::ProcessObject::
87 _CreateITK( )
88 {
89   F* filter = dynamic_cast< F* >( this->m_ITKObject.GetPointer( ) );
90   if( filter == NULL )
91   {
92     typename F::Pointer ptr = F::New( );
93     this->m_ITKObject = ptr;
94     filter = ptr.GetPointer( );
95     this->m_VTKObject = NULL;
96
97   } // fi
98   return( filter );
99 }
100
101 // -------------------------------------------------------------------------
102 template< class F >
103 F* cpPlugins::Interface::ProcessObject::
104 _CreateVTK( )
105 {
106   F* filter = dynamic_cast< F* >( this->m_VTKObject.GetPointer( ) );
107   if( filter == NULL )
108   {
109     filter = F::New( );
110     this->m_VTKObject = filter;
111     this->m_ITKObject = NULL;
112
113   } // fi
114   return( filter );
115 }
116
117 // -------------------------------------------------------------------------
118 template< class O >
119 void cpPlugins::Interface::ProcessObject::
120 _MakeOutput( unsigned int idx )
121 {
122   if( idx >= this->m_Outputs.size( ) )
123     return;
124   this->m_Outputs[ idx ] = O::New( );
125   this->m_Outputs[ idx ]->SetSource( this );
126 }
127
128 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
129
130 // eof - $RCSfile$