1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkImageSetGet.h,v $
6 Date: $Date: 2002/02/01 06:30:41 $
7 Version: $Revision: 1.1.1.1 $
8 Thanks: Thanks to C. Charles Law who developed this file.
10 Copyright (c) 1993-1995 Ken Martin, Will Schroeder, Bill Lorensen.
12 This software is copyrighted by Ken Martin, Will Schroeder and Bill Lorensen.
13 The following terms apply to all files associated with the software unless
14 explicitly disclaimed in individual files. This copyright specifically does
15 not apply to the related textbook "The Visualization Toolkit" ISBN
16 013199837-4 published by Prentice Hall which is covered by its own copyright.
18 The authors hereby grant permission to use, copy, and distribute this
19 software and its documentation for any purpose, provided that existing
20 copyright notices are retained in all copies and that this notice is included
21 verbatim in any distributions. Additionally, the authors grant permission to
22 modify this software and its documentation for any purpose, provided that
23 such modifications are not distributed without the explicit consent of the
24 authors and that existing copyright notices are retained in all copies. Some
25 of the algorithms implemented by this software are patented, observe all
26 applicable patent law.
28 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
29 DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
30 OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
31 EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
34 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35 PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
36 "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
37 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
40 =========================================================================*/
41 // ImageSetGet provides macros which expand the number of ways a method
45 #ifndef __vtkImageSetGet_h
46 #define __vtkImageSetGet_h
50 // These macro are for creating the many convenience functions used
51 // for accessing instance variables. They could simplify this class.
52 #define vtkImageSetAxesMacro(name,type) \
53 virtual void SetAxes##name (int *_axes, type _name0, type _name1, \
54 type _name2, type _name3, type _name4)\
57 _tmp[0] = _name0; _tmp[1] = _name1; _tmp[2] = _name2; \
58 _tmp[3] = _name3; _tmp[4] = _name4; \
59 this->SetAxes##name (5,_axes,_tmp); \
61 virtual void SetAxes##name (int *_axes, type _name0, type _name1, \
62 type _name2, type _name3) \
65 _tmp[0] = _name0; _tmp[1] = _name1; \
66 _tmp[2] = _name2; _tmp[3] = _name3; \
67 this->SetAxes##name (4,_axes,_tmp); \
69 virtual void SetAxes##name (int *_axes, type _name0,type _name1,type _name2) \
72 _tmp[0] = _name0; _tmp[1] = _name1; _tmp[2] = _name2; \
73 this->SetAxes##name (3,_axes,_tmp); \
75 virtual void SetAxes##name (int *_axes, type _name0, type _name1) \
78 _tmp[0] = _name0; _tmp[1] = _name1; \
79 this->SetAxes##name (2,_axes,_tmp); \
81 virtual void SetAxis##name (int _axis, type _name0) \
83 this->SetAxes##name (1,&_axis,&_name0); \
86 #define vtkImageGetAxesMacro(name,type) \
87 virtual void GetAxes##name (int *_axes, type &_name0, type &_name1, \
88 type &_name2, type &_name3, type &_name4) \
91 this->GetAxes##name (5,_axes,_tmp); \
92 _name0 = _tmp[0]; _name1 = _tmp[1]; _name2 = _tmp[2]; \
93 _name3 = _tmp[3]; _name4 = _tmp[4]; \
95 virtual void GetAxes##name (int *_axes, type &_name0, type &_name1, \
96 type &_name2, type &_name3) \
99 this->GetAxes##name (4,_axes,_tmp); \
100 _name0 = _tmp[0]; _name1 = _tmp[1]; _name2 = _tmp[2]; _name3 = _tmp[3]; \
102 virtual void GetAxes##name (int *_axes, type &_name0, type &_name1, \
106 this->GetAxes##name (3,_axes,_tmp); \
107 _name0 = _tmp[0]; _name1 = _tmp[1]; _name2 = _tmp[2]; \
109 virtual void GetAxes##name (int *_axes, type &_name0, type &_name1) \
112 this->GetAxes##name (2,_axes,_tmp); \
113 _name0 = _tmp[0]; _name1 = _tmp[1]; \
115 virtual void GetAxis##name (int _axis, type &_name0) \
117 this->GetAxes##name (1,&_axis,&_name0); \
122 #define vtkImageSetExtentAxesMacro(name,type) \
123 virtual void SetAxes##name (int *_axes, type _min0,type _max0, \
124 type _min1,type _max1, type _min2,type _max2, \
125 type _min3,type _max3, type _min4,type _max4) \
128 _tmp[0] = _min0; _tmp[1] = _max0; \
129 _tmp[2] = _min1; _tmp[3] = _max1; \
130 _tmp[4] = _min2; _tmp[5] = _max2; \
131 _tmp[6] = _min3; _tmp[7] = _max3; \
132 _tmp[8] = _min4; _tmp[9] = _max4; \
133 this->SetAxes##name (5,_axes,_tmp); \
135 virtual void SetAxes##name (int *_axes, type _min0,type _max0, \
136 type _min1,type _max1, type _min2,type _max2, \
137 type _min3,type _max3) \
140 _tmp[0] = _min0; _tmp[1] = _max0; \
141 _tmp[2] = _min1; _tmp[3] = _max1; \
142 _tmp[4] = _min2; _tmp[5] = _max2; \
143 _tmp[6] = _min3; _tmp[7] = _max3; \
144 this->SetAxes##name (4,_axes,_tmp); \
146 virtual void SetAxes##name (int *_axes, type _min0,type _max0, \
147 type _min1,type _max1, type _min2,type _max2) \
150 _tmp[0] = _min0; _tmp[1] = _max0; \
151 _tmp[2] = _min1; _tmp[3] = _max1; \
152 _tmp[4] = _min2; _tmp[5] = _max2; \
153 this->SetAxes##name (3,_axes,_tmp); \
155 virtual void SetAxes##name (int *_axes, type _min0,type _max0, \
156 type _min1,type _max1) \
159 _tmp[0] = _min0; _tmp[1] = _max0; \
160 _tmp[2] = _min1; _tmp[3] = _max1; \
161 this->SetAxes##name (2,_axes,_tmp); \
163 virtual void SetAxis##name (int _axis, type _min0,type _max0) \
166 _tmp[0] = _min0; _tmp[1] = _max0; \
167 this->SetAxes##name (1,&_axis,_tmp); \
170 #define vtkImageGetExtentAxesMacro(name,type) \
171 virtual void GetAxes##name (int *_axes, type &_min0,type &_max0, \
172 type &_min1,type &_max1, type &_min2,type &_max2, \
173 type &_min3,type &_max3, type &_min4,type &_max4) \
176 this->GetAxes##name (5,_axes,_tmp); \
177 _min0 = _tmp[0]; _max0 = _tmp[1]; \
178 _min1 = _tmp[2]; _max1 = _tmp[3]; \
179 _min2 = _tmp[4]; _max2 = _tmp[5]; \
180 _min3 = _tmp[6]; _max3 = _tmp[7]; \
181 _min4 = _tmp[8]; _max4 = _tmp[9]; \
183 virtual void GetAxes##name (int *_axes, type &_min0,type &_max0, \
184 type &_min1,type &_max1, type &_min2,type &_max2, \
185 type &_min3,type &_max3) \
188 this->GetAxes##name (4,_axes,_tmp); \
189 _min0 = _tmp[0]; _max0 = _tmp[1]; \
190 _min1 = _tmp[2]; _max1 = _tmp[3]; \
191 _min2 = _tmp[4]; _max2 = _tmp[5]; \
192 _min3 = _tmp[6]; _max3 = _tmp[7]; \
194 virtual void GetAxes##name (int *_axes, type &_min0,type &_max0, \
195 type &_min1,type &_max1, type &_min2,type &_max2) \
198 this->GetAxes##name (3,_axes,_tmp); \
199 _min0 = _tmp[0]; _max0 = _tmp[1]; \
200 _min1 = _tmp[2]; _max1 = _tmp[3]; \
201 _min2 = _tmp[4]; _max2 = _tmp[5]; \
203 virtual void GetAxes##name (int *_axes, type &_min0,type &_max0, \
204 type &_min1,type &_max1) \
207 this->GetAxes##name (2,_axes,_tmp); \
208 _min0 = _tmp[0]; _max0 = _tmp[1]; \
209 _min1 = _tmp[2]; _max1 = _tmp[3]; \
211 virtual void GetAxis##name (int _axis,type &_min0,type &_max0) \
214 this->GetAxes##name (1,&_axis,_tmp); \
215 _min0 = _tmp[0]; _max0 = _tmp[1]; \
219 // These macro are for creating the many convenience functions used
220 // for accessing instance variables. They could simplify this class.
221 #define vtkImageSetMacro(name,type) \
222 virtual void Set##name (type *_tmp) { this->Set##name (5, _tmp);} \
223 virtual void Set##name (type _name0,type _name1,type _name2, type _name3, \
227 _tmp[0] = _name0; _tmp[1] = _name1; _tmp[2] = _name2; \
228 _tmp[3] = _name3; _tmp[4] = _name4; \
229 this->Set##name (5,_tmp); \
231 virtual void Set##name (type _name0,type _name1,type _name2, type _name3) \
234 _tmp[0] = _name0; _tmp[1] = _name1; \
235 _tmp[2] = _name2; _tmp[3] = _name3; \
236 this->Set##name (4,_tmp); \
238 virtual void Set##name (type _name0,type _name1,type _name2) \
241 _tmp[0] = _name0; _tmp[1] = _name1; _tmp[2] = _name2; \
242 this->Set##name (3,_tmp); \
244 virtual void Set##name (type _name0,type _name1) \
247 _tmp[0] = _name0; _tmp[1] = _name1; \
248 this->Set##name (2,_tmp); \
250 virtual void Set##name (type _name0) \
254 this->Set##name (1,_tmp); \
257 #define vtkImageGetMacro(name,type) \
258 virtual void Get##name (type _tmp[5]) { this->Get##name (5,_tmp);} \
259 virtual void Get##name (type &_name0,type &_name1,type &_name2,type &_name3, \
263 this->Get##name (5,_tmp); \
264 _name0 = _tmp[0]; _name1 = _tmp[1]; _name2 = _tmp[2]; \
265 _name3 = _tmp[3]; _name4 = _tmp[4]; \
267 virtual void Get##name (type &_name0,type &_name1,type &_name2,type &_name3) \
270 this->Get##name (4,_tmp); \
271 _name0 = _tmp[0]; _name1 = _tmp[1]; _name2 = _tmp[2]; _name3 = _tmp[3]; \
273 virtual void Get##name (type &_name0,type &_name1,type &_name2) \
276 this->Get##name (3,_tmp); \
277 _name0 = _tmp[0]; _name1 = _tmp[1]; _name2 = _tmp[2]; \
279 virtual void Get##name (type &_name0,type &_name1) \
282 this->Get##name (2,_tmp); \
283 _name0 = _tmp[0]; _name1 = _tmp[1]; \
285 virtual void Get##name (type &_name0) \
288 this->Get##name (1,_tmp); \
294 #define vtkImageSetExtentMacro(name) \
295 virtual void Set##name (int _tmp[10]) { this->Set##name (5,_tmp);} \
296 virtual void Set##name (int _min0,int _max0,int _min1,int _max1, \
297 int _min2,int _max2,int _min3,int _max3, \
298 int _min4,int _max4) \
301 _tmp[0] = _min0; _tmp[1] = _max0; \
302 _tmp[2] = _min1; _tmp[3] = _max1; \
303 _tmp[4] = _min2; _tmp[5] = _max2; \
304 _tmp[6] = _min3; _tmp[7] = _max3; \
305 _tmp[8] = _min4; _tmp[9] = _max4; \
306 this->Set##name (5,_tmp); \
308 virtual void Set##name (int _min0,int _max0,int _min1,int _max1, \
309 int _min2,int _max2,int _min3,int _max3) \
312 _tmp[0] = _min0; _tmp[1] = _max0; \
313 _tmp[2] = _min1; _tmp[3] = _max1; \
314 _tmp[4] = _min2; _tmp[5] = _max2; \
315 _tmp[6] = _min3; _tmp[7] = _max3; \
316 this->Set##name (4,_tmp); \
318 virtual void Set##name (int _min0,int _max0,int _min1,int _max1, \
319 int _min2,int _max2) \
322 _tmp[0] = _min0; _tmp[1] = _max0; \
323 _tmp[2] = _min1; _tmp[3] = _max1; \
324 _tmp[4] = _min2; _tmp[5] = _max2; \
325 this->Set##name (3,_tmp); \
327 virtual void Set##name (int _min0,int _max0,int _min1,int _max1) \
330 _tmp[0] = _min0; _tmp[1] = _max0; \
331 _tmp[2] = _min1; _tmp[3] = _max1; \
332 this->Set##name (2,_tmp); \
334 virtual void Set##name (int _min0,int _max0) \
337 _tmp[0] = _min0; _tmp[1] = _max0; \
338 this->Set##name (1,_tmp); \
340 #define vtkImageGetExtentMacro(name) \
341 int *Get##name () { return this->name ;} \
342 virtual void Get##name (int _tmp[10]) { this->Get##name (5,_tmp);} \
343 virtual void Get##name (int &_min0,int &_max0,int &_min1,int &_max1, \
344 int &_min2,int &_max2,int &_min3,int &_max3, \
345 int &_min4,int &_max4) \
348 this->Get##name (5,_tmp); \
349 _min0 = _tmp[0]; _max0 = _tmp[1]; \
350 _min1 = _tmp[2]; _max1 = _tmp[3]; \
351 _min2 = _tmp[4]; _max2 = _tmp[5]; \
352 _min3 = _tmp[6]; _max3 = _tmp[7]; \
353 _min4 = _tmp[8]; _max4 = _tmp[9]; \
355 virtual void Get##name (int &_min0,int &_max0,int &_min1,int &_max1, \
356 int &_min2,int &_max2,int &_min3,int &_max3) \
359 this->Get##name (4,_tmp); \
360 _min0 = _tmp[0]; _max0 = _tmp[1]; \
361 _min1 = _tmp[2]; _max1 = _tmp[3]; \
362 _min2 = _tmp[4]; _max2 = _tmp[5]; \
363 _min3 = _tmp[6]; _max3 = _tmp[7]; \
365 virtual void Get##name (int &_min0,int &_max0,int &_min1,int &_max1, \
366 int &_min2,int &_max2) \
369 this->Get##name (3,_tmp); \
370 _min0 = _tmp[0]; _max0 = _tmp[1]; \
371 _min1 = _tmp[2]; _max1 = _tmp[3]; \
372 _min2 = _tmp[4]; _max2 = _tmp[5]; \
374 virtual void Get##name (int &_min0,int &_max0,int &_min1,int &_max1) \
377 this->Get##name (2,_tmp); \
378 _min0 = _tmp[0]; _max0 = _tmp[1]; \
379 _min1 = _tmp[2]; _max1 = _tmp[3]; \
381 virtual void Get##name (int &_min0,int &_max0) \
384 this->Get##name (1,_tmp); \
385 _min0 = _tmp[0]; _max0 = _tmp[1]; \
389 #define vtkImageGetPointerMacro(name,type) \
390 type *Get##name##Pointer(int coords[5]) \
392 return this->Get##name##Pointer(5, coords); \
394 type *Get##name##Pointer(int _c0, int _c1, int _c2, int _c3, int _c4) \
402 return this->Get##name##Pointer (5,_tmp); \
404 type *Get##name##Pointer(int _c0, int _c1, int _c2, int _c3) \
411 return this->Get##name##Pointer (4,_tmp); \
413 type *Get##name##Pointer(int _c0, int _c1, int _c2) \
419 return this->Get##name##Pointer (3,_tmp); \
421 type *Get##name##Pointer(int _c0, int _c1) \
426 return this->Get##name##Pointer (2,_tmp); \
428 type *Get##name##Pointer(int _c0) \
432 return this->Get##name##Pointer (1,_tmp); \
434 type *Get##name##Pointer() \
436 return this->Get##name##Pointer (0, (int *)(NULL)); \