1 #ifndef __CPPLUGINS__INTERFACE__IMAGE__HXX__
2 #define __CPPLUGINS__INTERFACE__IMAGE__HXX__
4 #include <cpPlugins/Interface/Macros.h>
9 #include <itkVectorImage.h>
10 #include <itkImageToVTKImageFilter.h>
12 #include <itkCovariantVector.h>
13 #include <itkDiffusionTensor3D.h>
15 #include <itkRGBPixel.h>
16 #include <itkRGBAPixel.h>
17 #include <itkSymmetricSecondRankTensor.h>
18 #include <itkVector.h>
20 // -------------------------------------------------------------------------
21 #define cpPlugins_VTKImage_Demangle( TI, T, D, o ) \
22 if( typeid( TI ) == typeid( itk::Image< T, D > ) ) \
23 this->_ITK_2_VTK< T, D >( o )
25 // -------------------------------------------------------------------------
26 #define cpPlugins_VTKImageArray_Demangle( TI, T, P, DP, DI, o ) \
27 if( typeid( TI ) == typeid( itk::Image< T< P, DP >, DI > ) ) \
28 this->_ITK_2_VTK< T< P, DP >, DI >( o )
30 // -------------------------------------------------------------------------
31 #define cpPlugins_VTKImage_Demangle_AllDims( TI, T, o ) \
32 cpPlugins_VTKImage_Demangle( TI, T, 2, o ); \
33 else cpPlugins_VTKImage_Demangle( TI, T, 3, o )
35 // -------------------------------------------------------------------------
36 #define cpPlugins_VTKImageArray_Demangle_AllDims( TI, T, P, o ) \
37 cpPlugins_VTKImageArray_Demangle( TI, T, P, 2, 2, o ); \
38 else cpPlugins_VTKImageArray_Demangle( TI, T, P, 3, 3, o )
40 // -------------------------------------------------------------------------
42 void cpPlugins::Interface::Image::
43 SetITK( itk::Object* object )
45 // Check if input object has the desired type
46 I* image = dynamic_cast< I* >( object );
49 this->m_ITKObject = NULL;
50 this->m_VTKObject = NULL;
51 this->m_ITKvVTKConnection = NULL;
57 cpPlugins_VTKImage_Demangle_AllDims( I, char, image );
58 else cpPlugins_VTKImage_Demangle_AllDims( I, short, image );
59 else cpPlugins_VTKImage_Demangle_AllDims( I, int, image );
60 else cpPlugins_VTKImage_Demangle_AllDims( I, long, image );
61 else cpPlugins_VTKImage_Demangle_AllDims( I, unsigned char, image );
62 else cpPlugins_VTKImage_Demangle_AllDims( I, unsigned short, image );
63 else cpPlugins_VTKImage_Demangle_AllDims( I, unsigned int, image );
64 else cpPlugins_VTKImage_Demangle_AllDims( I, unsigned long, image );
65 else cpPlugins_VTKImage_Demangle_AllDims( I, float, image );
66 else cpPlugins_VTKImage_Demangle_AllDims( I, double, image );
67 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< char >, image );
68 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< short >, image );
69 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< int >, image );
70 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< long >, image );
71 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< unsigned char >, image );
72 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< unsigned short >, image );
73 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< unsigned int >, image );
74 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< unsigned long >, image );
75 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< float >, image );
76 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBPixel< double >, image );
77 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< char >, image );
78 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< short >, image );
79 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< int >, image );
80 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< long >, image );
81 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< unsigned char >, image );
82 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< unsigned short >, image );
83 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< unsigned int >, image );
84 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< unsigned long >, image );
85 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< float >, image );
86 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::RGBAPixel< double >, image );
87 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::DiffusionTensor3D< float >, image );
88 else cpPlugins_VTKImage_Demangle_AllDims( I, itk::DiffusionTensor3D< double >, image );
89 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::Vector, float, image );
90 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::Vector, double, image );
91 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::CovariantVector, float, image );
92 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::CovariantVector, double, image );
93 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::Point, float, image );
94 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::Point, double, image );
95 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::SymmetricSecondRankTensor, float, image );
96 else cpPlugins_VTKImageArray_Demangle_AllDims( I, itk::SymmetricSecondRankTensor, double, image );
99 this->m_VTKObject = NULL;
100 this->m_ITKvVTKConnection = NULL;
105 this->m_ITKObject = object;
109 // -------------------------------------------------------------------------
110 template< class P, unsigned int D >
111 void cpPlugins::Interface::Image::
112 _ITK_2_VTK( itk::Object* object )
114 typedef itk::Image< P, D > _I;
116 // Check if input object has the desired type
117 _I* image = dynamic_cast< _I* >( object );
122 typename itk::ImageToVTKImageFilter< _I >::Pointer f =
123 itk::ImageToVTKImageFilter< _I >::New( );
124 f->SetInput( image );
128 this->m_VTKObject = f->GetOutput( );
129 this->m_ITKvVTKConnection = f;
132 #ifndef cpPlugins_Interface_EXPORTS
134 // =========================================================================
135 // ========== Declare import itk::Image types ==========
136 // =========================================================================
138 // -------------------------------------------------------------------------
139 #define cpPlugins_ITKImage_Import( T, D ) \
140 cpPlugins_TEMPLATE_IMPORT( \
141 2(class cpPlugins_Interface_EXPORT itk::Image< T, D >) \
144 // -------------------------------------------------------------------------
145 #define cpPlugins_ITKArrayImage_Import( A, T, DA, DI ) \
146 cpPlugins_TEMPLATE_IMPORT( \
147 3(class cpPlugins_Interface_EXPORT itk::Image< A< T, DA >, DI >) \
150 // -------------------------------------------------------------------------
151 #define cpPlugins_ITKImage_AllDims_Import( T ) \
152 cpPlugins_ITKImage_Import( T, 2 ); \
153 cpPlugins_ITKImage_Import( T, 3 ); \
154 cpPlugins_ITKImage_Import( T, 4 )
156 // -------------------------------------------------------------------------
157 #define cpPlugins_ITKArrayImage_AllDims_Import( A, T ) \
158 cpPlugins_ITKArrayImage_Import( A, T, 2, 2 ); \
159 cpPlugins_ITKArrayImage_Import( A, T, 3, 3 ); \
160 cpPlugins_ITKArrayImage_Import( A, T, 4, 4 )
162 // -------------------------------------------------------------------------
163 #define cpPlugins_VTKImage_Import( T, D ) \
164 cpPlugins_TEMPLATE_IMPORT( \
166 class cpPlugins_Interface_EXPORT \
167 itk::ImageToVTKImageFilter< itk::Image< T, D > > \
171 // -------------------------------------------------------------------------
172 #define cpPlugins_VTKArrayImage_Import( A, T, DA, DI ) \
173 cpPlugins_TEMPLATE_IMPORT( \
175 cpPlugins_Interface_EXPORT \
176 itk::ImageToVTKImageFilter< itk::Image< A< T, DA >, DI > >) \
179 // -------------------------------------------------------------------------
180 #define cpPlugins_VTKImage_AllDims_Import( T ) \
181 cpPlugins_VTKImage_Import( T, 2 ); \
182 cpPlugins_VTKImage_Import( T, 3 )
184 // -------------------------------------------------------------------------
185 #define cpPlugins_VTKArrayImage_AllDims_Import( A, T ) \
186 cpPlugins_VTKArrayImage_Import( A, T, 2, 2 ); \
187 cpPlugins_VTKArrayImage_Import( A, T, 3, 3 )
189 // -------------------------------------------------------------------------
190 #define cpPlugins_Image_Import( T, D ) \
191 cpPlugins_ITKImage_Import( T, D ); \
192 cpPlugins_VTKImage_Import( T, D ) \
194 // -------------------------------------------------------------------------
195 #define cpPlugins_Image_AllDims_Import( T ) \
196 cpPlugins_ITKImage_AllDims_Import( T ); \
197 cpPlugins_VTKImage_AllDims_Import( T ) \
199 // -------------------------------------------------------------------------
200 #define cpPlugins_ArrayImage_AllDims_Import( A, T ) \
201 cpPlugins_ITKArrayImage_AllDims_Import( A, T ); \
202 cpPlugins_VTKArrayImage_AllDims_Import( A, T ) \
204 // -------------------------------------------------------------------------
205 // ITK-VTK base clases
206 // -------------------------------------------------------------------------
208 cpPlugins_Image_AllDims_Import( char );
209 cpPlugins_Image_AllDims_Import( short );
210 cpPlugins_Image_AllDims_Import( int );
211 cpPlugins_Image_AllDims_Import( long );
212 cpPlugins_Image_AllDims_Import( unsigned char );
213 cpPlugins_Image_AllDims_Import( unsigned short );
214 cpPlugins_Image_AllDims_Import( unsigned int );
215 cpPlugins_Image_AllDims_Import( unsigned long );
216 cpPlugins_Image_AllDims_Import( float );
217 cpPlugins_Image_AllDims_Import( double );
219 cpPlugins_Image_AllDims_Import( itk::RGBPixel< char > );
220 cpPlugins_Image_AllDims_Import( itk::RGBPixel< short > );
221 cpPlugins_Image_AllDims_Import( itk::RGBPixel< int > );
222 cpPlugins_Image_AllDims_Import( itk::RGBPixel< long > );
223 cpPlugins_Image_AllDims_Import( itk::RGBPixel< unsigned char > );
224 cpPlugins_Image_AllDims_Import( itk::RGBPixel< unsigned short > );
225 cpPlugins_Image_AllDims_Import( itk::RGBPixel< unsigned int > );
226 cpPlugins_Image_AllDims_Import( itk::RGBPixel< unsigned long > );
227 cpPlugins_Image_AllDims_Import( itk::RGBPixel< float > );
228 cpPlugins_Image_AllDims_Import( itk::RGBPixel< double > );
230 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< char > );
231 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< short > );
232 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< int > );
233 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< long > );
234 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< unsigned char > );
235 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< unsigned short > );
236 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< unsigned int > );
237 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< unsigned long > );
238 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< float > );
239 cpPlugins_Image_AllDims_Import( itk::RGBAPixel< double > );
241 cpPlugins_Image_AllDims_Import( itk::DiffusionTensor3D< float > );
242 cpPlugins_Image_AllDims_Import( itk::DiffusionTensor3D< double > );
244 cpPlugins_ArrayImage_AllDims_Import( itk::Vector, float );
245 cpPlugins_ArrayImage_AllDims_Import( itk::Vector, double );
247 cpPlugins_ArrayImage_AllDims_Import( itk::CovariantVector, float );
248 cpPlugins_ArrayImage_AllDims_Import( itk::CovariantVector, double );
250 cpPlugins_ArrayImage_AllDims_Import( itk::Point, float );
251 cpPlugins_ArrayImage_AllDims_Import( itk::Point, double );
253 cpPlugins_ArrayImage_AllDims_Import( itk::SymmetricSecondRankTensor, float );
254 cpPlugins_ArrayImage_AllDims_Import( itk::SymmetricSecondRankTensor, double );
256 // -------------------------------------------------------------------------
257 // ITK-only base clases
258 // -------------------------------------------------------------------------
260 cpPlugins_ITKImage_AllDims_Import( std::complex< float > );
261 cpPlugins_ITKImage_AllDims_Import( std::complex< double > );
263 cpPlugins_ITKImage_Import( itk::Offset< 2 >, 2 );
264 cpPlugins_ITKImage_Import( itk::Offset< 3 >, 3 );
265 cpPlugins_ITKImage_Import( itk::Offset< 4 >, 4 );
267 // =========================================================================
268 // ========== Declare import itk::VectorImage types ==========
269 // =========================================================================
271 // -------------------------------------------------------------------------
272 #define cpPlugins_VectorImage_Import( T, D ) \
273 cpPlugins_TEMPLATE_IMPORT( \
274 2(class cpPlugins_Interface_EXPORT itk::VectorImage< T, D >) \
277 // -------------------------------------------------------------------------
278 #define cpPlugins_ArrayVectorImage_Import( A, T, DA, DI ) \
279 cpPlugins_TEMPLATE_IMPORT( \
281 cpPlugins_Interface_EXPORT \
282 itk::VectorImage< A< T, DA >, DI >) \
285 // -------------------------------------------------------------------------
286 #define cpPlugins_VectorImage_AllDims_Import( T ) \
287 cpPlugins_VectorImage_Import( T, 2 ); \
288 cpPlugins_VectorImage_Import( T, 3 ); \
289 cpPlugins_VectorImage_Import( T, 4 )
291 // -------------------------------------------------------------------------
292 #define cpPlugins_ArrayVectorImage_AllDims_Import( A, T ) \
293 cpPlugins_ArrayVectorImage_Import( A, T, 2, 2 ); \
294 cpPlugins_ArrayVectorImage_Import( A, T, 3, 3 ); \
295 cpPlugins_ArrayVectorImage_Import( A, T, 4, 4 )
297 // -------------------------------------------------------------------------
298 // ITK-VTK base clases
299 // -------------------------------------------------------------------------
301 cpPlugins_VectorImage_AllDims_Import( char );
302 cpPlugins_VectorImage_AllDims_Import( short );
303 cpPlugins_VectorImage_AllDims_Import( int );
304 cpPlugins_VectorImage_AllDims_Import( long );
305 cpPlugins_VectorImage_AllDims_Import( unsigned char );
306 cpPlugins_VectorImage_AllDims_Import( unsigned short );
307 cpPlugins_VectorImage_AllDims_Import( unsigned int );
308 cpPlugins_VectorImage_AllDims_Import( unsigned long );
309 cpPlugins_VectorImage_AllDims_Import( float );
310 cpPlugins_VectorImage_AllDims_Import( double );
312 cpPlugins_VectorImage_AllDims_Import( std::complex< float > );
313 cpPlugins_VectorImage_AllDims_Import( std::complex< double > );
315 cpPlugins_VectorImage_Import( itk::Offset< 2 >, 2 );
316 cpPlugins_VectorImage_Import( itk::Offset< 3 >, 3 );
317 cpPlugins_VectorImage_Import( itk::Offset< 4 >, 4 );
319 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< char > );
320 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< short > );
321 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< int > );
322 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< long > );
323 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< unsigned char > );
324 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< unsigned short > );
325 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< unsigned int > );
326 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< unsigned long > );
327 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< float > );
328 cpPlugins_VectorImage_AllDims_Import( itk::RGBPixel< double > );
330 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< char > );
331 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< short > );
332 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< int > );
333 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< long > );
334 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< unsigned char > );
335 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< unsigned short > );
336 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< unsigned int > );
337 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< unsigned long > );
338 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< float > );
339 cpPlugins_VectorImage_AllDims_Import( itk::RGBAPixel< double > );
341 cpPlugins_VectorImage_AllDims_Import( itk::DiffusionTensor3D< float > );
342 cpPlugins_VectorImage_AllDims_Import( itk::DiffusionTensor3D< double > );
344 cpPlugins_ArrayVectorImage_AllDims_Import( itk::Vector, float );
345 cpPlugins_ArrayVectorImage_AllDims_Import( itk::Vector, double );
347 cpPlugins_ArrayVectorImage_AllDims_Import( itk::CovariantVector, float );
348 cpPlugins_ArrayVectorImage_AllDims_Import( itk::CovariantVector, double );
350 cpPlugins_ArrayVectorImage_AllDims_Import( itk::Point, float );
351 cpPlugins_ArrayVectorImage_AllDims_Import( itk::Point, double );
353 cpPlugins_ArrayVectorImage_AllDims_Import(
354 itk::SymmetricSecondRankTensor, float
356 cpPlugins_ArrayVectorImage_AllDims_Import(
357 itk::SymmetricSecondRankTensor, double
360 #endif // cpPlugins_Interface_EXPORTS
362 #endif // __CPPLUGINS__INTERFACE__IMAGE__HXX__