1 #ifndef __CPPLUGINS__INTERFACE__IMAGE__HXX__
2 #define __CPPLUGINS__INTERFACE__IMAGE__HXX__
7 #include <itkVectorImage.h>
8 #include <itkImageToVTKImageFilter.h>
10 #include <itkCovariantVector.h>
11 #include <itkDiffusionTensor3D.h>
13 #include <itkRGBPixel.h>
14 #include <itkRGBAPixel.h>
15 #include <itkSymmetricSecondRankTensor.h>
16 #include <itkVector.h>
18 // -------------------------------------------------------------------------
19 #define cpPlugins_VTKImage_Demangle( TI, T, D, o ) \
20 if( typeid( TI ) == typeid( itk::Image< T, D > ) ) \
21 this->_ITK_2_VTK< T, D >( o )
23 // -------------------------------------------------------------------------
24 #define cpPlugins_VTKImageArray_Demangle( TI, T, P, DP, DI, o ) \
25 if( typeid( TI ) == typeid( itk::Image< T< P, DP >, DI > ) ) \
26 this->_ITK_2_VTK< T< P, DP >, DI >( o )
28 // -------------------------------------------------------------------------
29 #define cpPlugins_VTKImage_Demangle_AllDims( TI, T, o ) \
30 cpPlugins_VTKImage_Demangle( TI, T, 2, o ); \
31 else cpPlugins_VTKImage_Demangle( TI, T, 3, o )
33 // -------------------------------------------------------------------------
34 #define cpPlugins_VTKImageArray_Demangle_AllDims( TI, T, P, o ) \
35 cpPlugins_VTKImageArray_Demangle( TI, T, P, 2, 2, o ); \
36 else cpPlugins_VTKImageArray_Demangle( TI, T, P, 3, 3, o )
38 // -------------------------------------------------------------------------
40 void cpPlugins::Interface::Image::
41 SetITK( itk::Object* object )
43 // Check if input object has the desired type
44 I* image = dynamic_cast< I* >( object );
47 this->m_ITKObject = NULL;
48 this->m_VTKObject = NULL;
49 this->m_ITKvVTKConnection = NULL;
54 // --------- TODO ---------------
55 typename I::DirectionType norm_dir;
56 norm_dir.SetIdentity( );
57 image->SetDirection( norm_dir );
58 // --------- TODO ---------------
61 cpPlugins_VTKImage_Demangle_AllDims( I, char, image );
62 else cpPlugins_VTKImage_Demangle_AllDims( I, short, image );
63 else cpPlugins_VTKImage_Demangle_AllDims( I, int, image );
64 else cpPlugins_VTKImage_Demangle_AllDims( I, long, image );
65 else cpPlugins_VTKImage_Demangle_AllDims( I, unsigned char, image );
66 else cpPlugins_VTKImage_Demangle_AllDims( I, unsigned short, image );
67 else cpPlugins_VTKImage_Demangle_AllDims( I, unsigned int, image );
68 else cpPlugins_VTKImage_Demangle_AllDims( I, unsigned long, image );
69 else cpPlugins_VTKImage_Demangle_AllDims( I, float, image );
70 else cpPlugins_VTKImage_Demangle_AllDims( I, double, image );
71 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< char >, image );
72 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< short >, image );
73 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< int >, image );
74 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< long >, image );
75 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< unsigned char >, image );
76 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< unsigned short >, image );
77 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< unsigned int >, image );
78 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< unsigned long >, image );
79 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< float >, image );
80 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< double >, image );
81 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< char >, image );
82 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< short >, image );
83 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< int >, image );
84 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< long >, image );
85 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< unsigned char >, image );
86 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< unsigned short >, image );
87 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< unsigned int >, image );
88 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< unsigned long >, image );
89 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< float >, image );
90 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< double >, image );
91 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::DiffusionTensor3D< float >, image );
92 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::DiffusionTensor3D< double >, image );
93 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::Vector, float, image );
94 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::Vector, double, image );
95 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::CovariantVector, float, image );
96 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::CovariantVector, double, image );
97 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::Point, float, image );
98 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::Point, double, image );
99 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::SymmetricSecondRankTensor, float, image );
100 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::SymmetricSecondRankTensor, double, image );
103 this->m_VTKObject = NULL;
104 this->m_ITKvVTKConnection = NULL;
109 this->m_ITKObject = object;
113 // -------------------------------------------------------------------------
114 template< class P, unsigned int D >
115 void cpPlugins::Interface::Image::
116 _ITK_2_VTK( itk::Object* object )
118 typedef itk::Image< P, D > _I;
120 // Check if input object has the desired type
121 _I* image = dynamic_cast< _I* >( object );
126 typename itk::ImageToVTKImageFilter< _I >::Pointer f =
127 itk::ImageToVTKImageFilter< _I >::New( );
128 f->SetInput( image );
132 this->m_VTKObject = f->GetOutput( );
133 this->m_ITKvVTKConnection = f;
136 #ifndef cpPlugins_Interface_EXPORTS
138 // =========================================================================
139 // ========== Declare import itk::Image types ==========
140 // =========================================================================
142 // -------------------------------------------------------------------------
143 #define cpPlugins_ITKImage_Import( T, D ) \
144 cpPlugins_TEMPLATE_IMPORT( \
145 2(class cpPlugins_Interface_EXPORT itk::Image< T, D >) \
148 // -------------------------------------------------------------------------
149 #define cpPlugins_ITKArrayImage_Import( A, T, DA, DI ) \
150 cpPlugins_TEMPLATE_IMPORT( \
151 3(class cpPlugins_Interface_EXPORT itk::Image< A< T, DA >, DI >) \
154 // -------------------------------------------------------------------------
155 #define cpPlugins_ITKImage_AllDims_Import( T ) \
156 cpPlugins_ITKImage_Import( T, 2 ); \
157 cpPlugins_ITKImage_Import( T, 3 ); \
158 cpPlugins_ITKImage_Import( T, 4 )
160 // -------------------------------------------------------------------------
161 #define cpPlugins_ITKArrayImage_AllDims_Import( A, T ) \
162 cpPlugins_ITKArrayImage_Import( A, T, 2, 2 ); \
163 cpPlugins_ITKArrayImage_Import( A, T, 3, 3 ); \
164 cpPlugins_ITKArrayImage_Import( A, T, 4, 4 )
166 // -------------------------------------------------------------------------
167 #define cpPlugins_VTKImage_Import( T, D ) \
168 cpPlugins_TEMPLATE_IMPORT( \
170 class cpPlugins_Interface_EXPORT \
171 itk::ImageToVTKImageFilter< itk::Image< T, D > > \
175 // -------------------------------------------------------------------------
176 #define cpPlugins_VTKArrayImage_Import( A, T, DA, DI ) \
177 cpPlugins_TEMPLATE_IMPORT( \
179 cpPlugins_Interface_EXPORT \
180 itk::ImageToVTKImageFilter< itk::Image< A< T, DA >, DI > >) \
183 // -------------------------------------------------------------------------
184 #define cpPlugins_VTKImage_AllDims_Import( T ) \
185 cpPlugins_VTKImage_Import( T, 2 ); \
186 cpPlugins_VTKImage_Import( T, 3 )
188 // -------------------------------------------------------------------------
189 #define cpPlugins_VTKArrayImage_AllDims_Import( A, T ) \
190 cpPlugins_VTKArrayImage_Import( A, T, 2, 2 ); \
191 cpPlugins_VTKArrayImage_Import( A, T, 3, 3 )
193 // -------------------------------------------------------------------------
194 #define cpPlugins_Image_Import( T, D ) \
195 cpPlugins_ITKImage_Import( T, D ); \
196 cpPlugins_VTKImage_Import( T, D ) \
198 // -------------------------------------------------------------------------
199 #define cpPlugins_Image_AllDims_Import( T ) \
200 cpPlugins_ITKImage_AllDims_Import( T ); \
201 cpPlugins_VTKImage_AllDims_Import( T ) \
203 // -------------------------------------------------------------------------
204 #define cpPlugins_ArrayImage_AllDims_Import( A, T ) \
205 cpPlugins_ITKArrayImage_AllDims_Import( A, T ); \
206 cpPlugins_VTKArrayImage_AllDims_Import( A, T ) \
208 // -------------------------------------------------------------------------
209 // ITK-VTK base clases
210 // -------------------------------------------------------------------------
212 cpPlugins_Image_AllDims_Import( char );
213 cpPlugins_Image_AllDims_Import( short );
214 cpPlugins_Image_AllDims_Import( int );
215 cpPlugins_Image_AllDims_Import( long );
216 cpPlugins_Image_AllDims_Import( unsigned char );
217 cpPlugins_Image_AllDims_Import( unsigned short );
218 cpPlugins_Image_AllDims_Import( unsigned int );
219 cpPlugins_Image_AllDims_Import( unsigned long );
220 cpPlugins_Image_AllDims_Import( float );
221 cpPlugins_Image_AllDims_Import( double );
223 cpPlugins_Image_AllDims_Import( itk::RGBPixel< char > );
224 cpPlugins_Image_AllDims_Import( itk::RGBPixel< short > );
225 cpPlugins_Image_AllDims_Import( itk::RGBPixel< int > );
226 cpPlugins_Image_AllDims_Import( itk::RGBPixel< long > );
227 cpPlugins_Image_AllDims_Import( itk::RGBPixel< unsigned char > );
228 cpPlugins_Image_AllDims_Import( itk::RGBPixel< unsigned short > );
229 cpPlugins_Image_AllDims_Import( itk::RGBPixel< unsigned int > );
230 cpPlugins_Image_AllDims_Import( itk::RGBPixel< unsigned long > );
231 cpPlugins_Image_AllDims_Import( itk::RGBPixel< float > );
232 cpPlugins_Image_AllDims_Import( itk::RGBPixel< double > );
234 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< char > );
235 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< short > );
236 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< int > );
237 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< long > );
238 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< unsigned char > );
239 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< unsigned short > );
240 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< unsigned int > );
241 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< unsigned long > );
242 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< float > );
243 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< double > );
245 cpPlugins_Image_AllDims_Import( itk::DiffusionTensor3D< float > );
246 cpPlugins_Image_AllDims_Import( itk::DiffusionTensor3D< double > );
248 cpPlugins_ArrayImage_AllDims_Import( itk::Vector, float );
249 cpPlugins_ArrayImage_AllDims_Import( itk::Vector, double );
251 cpPlugins_ArrayImage_AllDims_Import( itk::CovariantVector, float );
252 cpPlugins_ArrayImage_AllDims_Import( itk::CovariantVector, double );
254 cpPlugins_ArrayImage_AllDims_Import( itk::Point, float );
255 cpPlugins_ArrayImage_AllDims_Import( itk::Point, double );
257 cpPlugins_ArrayImage_AllDims_Import( itk::SymmetricSecondRankTensor, float );
258 cpPlugins_ArrayImage_AllDims_Import( itk::SymmetricSecondRankTensor, double );
260 // -------------------------------------------------------------------------
261 // ITK-only base clases
262 // -------------------------------------------------------------------------
264 cpPlugins_ITKImage_AllDims_Import( std::complex< float > );
265 cpPlugins_ITKImage_AllDims_Import( std::complex< double > );
267 cpPlugins_ITKImage_Import( itk::Offset< 2 >, 2 );
268 cpPlugins_ITKImage_Import( itk::Offset< 3 >, 3 );
269 cpPlugins_ITKImage_Import( itk::Offset< 4 >, 4 );
271 // =========================================================================
272 // ========== Declare import itk::VectorImage types ==========
273 // =========================================================================
275 // -------------------------------------------------------------------------
276 #define cpPlugins_VectorImage_Import( T, D ) \
277 cpPlugins_TEMPLATE_IMPORT( \
278 2(class cpPlugins_Interface_EXPORT itk::VectorImage< T, D >) \
281 // -------------------------------------------------------------------------
282 #define cpPlugins_ArrayVectorImage_Import( A, T, DA, DI ) \
283 cpPlugins_TEMPLATE_IMPORT( \
285 cpPlugins_Interface_EXPORT \
286 itk::VectorImage< A< T, DA >, DI >) \
289 // -------------------------------------------------------------------------
290 #define cpPlugins_VectorImage_AllDims_Import( T ) \
291 cpPlugins_VectorImage_Import( T, 2 ); \
292 cpPlugins_VectorImage_Import( T, 3 ); \
293 cpPlugins_VectorImage_Import( T, 4 )
295 // -------------------------------------------------------------------------
296 #define cpPlugins_ArrayVectorImage_AllDims_Import( A, T ) \
297 cpPlugins_ArrayVectorImage_Import( A, T, 2, 2 ); \
298 cpPlugins_ArrayVectorImage_Import( A, T, 3, 3 ); \
299 cpPlugins_ArrayVectorImage_Import( A, T, 4, 4 )
301 // -------------------------------------------------------------------------
302 // ITK-VTK base clases
303 // -------------------------------------------------------------------------
305 cpPlugins_VectorImage_AllDims_Import( char );
306 cpPlugins_VectorImage_AllDims_Import( short );
307 cpPlugins_VectorImage_AllDims_Import( int );
308 cpPlugins_VectorImage_AllDims_Import( long );
309 cpPlugins_VectorImage_AllDims_Import( unsigned char );
310 cpPlugins_VectorImage_AllDims_Import( unsigned short );
311 cpPlugins_VectorImage_AllDims_Import( unsigned int );
312 cpPlugins_VectorImage_AllDims_Import( unsigned long );
313 cpPlugins_VectorImage_AllDims_Import( float );
314 cpPlugins_VectorImage_AllDims_Import( double );
316 cpPlugins_VectorImage_AllDims_Import( std::complex< float > );
317 cpPlugins_VectorImage_AllDims_Import( std::complex< double > );
319 cpPlugins_VectorImage_Import( itk::Offset< 2 >, 2 );
320 cpPlugins_VectorImage_Import( itk::Offset< 3 >, 3 );
321 cpPlugins_VectorImage_Import( itk::Offset< 4 >, 4 );
323 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< char > );
324 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< short > );
325 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< int > );
326 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< long > );
327 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< unsigned char > );
328 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< unsigned short > );
329 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< unsigned int > );
330 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< unsigned long > );
331 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< float > );
332 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< double > );
334 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< char > );
335 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< short > );
336 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< int > );
337 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< long > );
338 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< unsigned char > );
339 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< unsigned short > );
340 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< unsigned int > );
341 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< unsigned long > );
342 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< float > );
343 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< double > );
345 cpPlugins_VectorImage_AllDims_Import( itk::DiffusionTensor3D< float > );
346 cpPlugins_VectorImage_AllDims_Import( itk::DiffusionTensor3D< double > );
348 cpPlugins_ArrayVectorImage_AllDims_Import( itk::Vector, float );
349 cpPlugins_ArrayVectorImage_AllDims_Import( itk::Vector, double );
351 cpPlugins_ArrayVectorImage_AllDims_Import( itk::CovariantVector, float );
352 cpPlugins_ArrayVectorImage_AllDims_Import( itk::CovariantVector, double );
354 cpPlugins_ArrayVectorImage_AllDims_Import( itk::Point, float );
355 cpPlugins_ArrayVectorImage_AllDims_Import( itk::Point, double );
357 cpPlugins_ArrayVectorImage_AllDims_Import(
358 itk::SymmetricSecondRankTensor, float
360 cpPlugins_ArrayVectorImage_AllDims_Import(
361 itk::SymmetricSecondRankTensor, double
364 #endif // cpPlugins_Interface_EXPORTS
366 #endif // __CPPLUGINS__INTERFACE__IMAGE__HXX__