]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.hxx
10b4dbe99fcc7a66fb02a42d978523e57b3e5c61
[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( const std::string& id )
40 {
41   _TDataContainer::iterator i = this->m_Inputs.find( id );
42   if( i != this->m_Inputs.end( ) )
43     return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
44   else
45     return( NULL );
46 }
47
48 // -------------------------------------------------------------------------
49 template< class T >
50 const T* cpPlugins::Interface::ProcessObject::
51 GetInput( const std::string& id ) const
52 {
53   _TDataContainer::const_iterator i = this->m_Inputs.find( id );
54   if( i != this->m_Inputs.end( ) )
55     return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
56   else
57     return( NULL );
58 }
59
60 // -------------------------------------------------------------------------
61 template< class T >
62 T* cpPlugins::Interface::ProcessObject::
63 GetOutput( const std::string& id )
64 {
65   _TDataContainer::iterator i = this->m_Outputs.find( id );
66   if( i != this->m_Outputs.end( ) )
67     return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
68   else
69     return( NULL );
70 }
71
72 // -------------------------------------------------------------------------
73 template< class T >
74 const T* cpPlugins::Interface::ProcessObject::
75 GetOutput( const std::string& id ) const
76 {
77   _TDataContainer::const_iterator i = this->m_Outputs.find( id );
78   if( i != this->m_Outputs.end( ) )
79     return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
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( const std::string& id )
121 {
122   this->m_Outputs[ id ] = O::New( );
123   this->m_Outputs[ id ]->SetSource( this );
124   this->Modified( );
125 }
126
127 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
128
129 // eof - $RCSfile$