VTK
vtkSetGet.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSetGet.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
26 #ifndef vtkSetGet_h
27 #define vtkSetGet_h
28 
29 #include "vtkCommonCoreModule.h" // For export macro
30 #include "vtkSystemIncludes.h"
31 #include <math.h>
32 
33 //----------------------------------------------------------------------------
34 // Check for unsupported old compilers.
35 #if defined(_MSC_VER) && _MSC_VER <= 1400
36 # error VTK requires MSVC++ 9.0 aka Visual Studio 2008 or newer
37 #endif
38 
39 #if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1))
40 # error VTK requires gcc 4.1 or newer
41 #endif
42 
43 // Convert a macro representing a value to a string.
44 //
45 // Example: vtkQuoteMacro(__LINE__) will expand to "1234" whereas
46 // vtkInternalQuoteMacro(__LINE__) will expand to "__LINE__"
47 #define vtkInternalQuoteMacro(x) #x
48 #define vtkQuoteMacro(x) vtkInternalQuoteMacro(x)
49 
50 // A macro to get the name of a type
51 #define vtkImageScalarTypeNameMacro(type) \
52 (((type) == VTK_VOID) ? "void" : \
53 (((type) == VTK_BIT) ? "bit" : \
54 (((type) == VTK_CHAR) ? "char" : \
55 (((type) == VTK_SIGNED_CHAR) ? "signed char" : \
56 (((type) == VTK_UNSIGNED_CHAR) ? "unsigned char" : \
57 (((type) == VTK_SHORT) ? "short" : \
58 (((type) == VTK_UNSIGNED_SHORT) ? "unsigned short" : \
59 (((type) == VTK_INT) ? "int" : \
60 (((type) == VTK_UNSIGNED_INT) ? "unsigned int" : \
61 (((type) == VTK_LONG) ? "long" : \
62 (((type) == VTK_UNSIGNED_LONG) ? "unsigned long" : \
63 (((type) == VTK_LONG_LONG) ? "long long" : \
64 (((type) == VTK_UNSIGNED_LONG_LONG) ? "unsigned long long" : \
65 (((type) == VTK___INT64) ? "__int64" : \
66 (((type) == VTK_UNSIGNED___INT64) ? "unsigned __int64" : \
67 (((type) == VTK_FLOAT) ? "float" : \
68 (((type) == VTK_DOUBLE) ? "double" : \
69 (((type) == VTK_ID_TYPE) ? "idtype" : \
70 (((type) == VTK_STRING) ? "string" : \
71 (((type) == VTK_UNICODE_STRING) ? "unicode string" : \
72 (((type) == VTK_VARIANT) ? "variant" : \
73 (((type) == VTK_OBJECT) ? "object" : \
74 "Undefined"))))))))))))))))))))))
75 
76 //
77 // Set built-in type. Creates member Set"name"() (e.g., SetVisibility());
78 //
79 #define vtkSetMacro(name,type) \
80 virtual void Set##name (type _arg) \
81  { \
82  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " #name " to " << _arg); \
83  if (this->name != _arg) \
84  { \
85  this->name = _arg; \
86  this->Modified(); \
87  } \
88  }
89 
90 //
91 // Get built-in type. Creates member Get"name"() (e.g., GetVisibility());
92 //
93 #define vtkGetMacro(name,type) \
94 virtual type Get##name () { \
95  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " of " << this->name ); \
96  return this->name; \
97  }
98 
99 
100 //
101 // Set character string. Creates member Set"name"()
102 // (e.g., SetFilename(char *));
103 //
104 #define vtkSetStringMacro(name) \
105 virtual void Set##name (const char* _arg) \
106  { \
107  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to " << (_arg?_arg:"(null)") ); \
108  if ( this->name == NULL && _arg == NULL) { return;} \
109  if ( this->name && _arg && (!strcmp(this->name,_arg))) { return;} \
110  delete [] this->name; \
111  if (_arg) \
112  { \
113  size_t n = strlen(_arg) + 1; \
114  char *cp1 = new char[n]; \
115  const char *cp2 = (_arg); \
116  this->name = cp1; \
117  do { *cp1++ = *cp2++; } while ( --n ); \
118  } \
119  else \
120  { \
121  this->name = NULL; \
122  } \
123  this->Modified(); \
124  }
125 
126 //
127 // Get character string. Creates member Get"name"()
128 // (e.g., char *GetFilename());
129 //
130 #define vtkGetStringMacro(name) \
131 virtual char* Get##name () { \
132  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " of " << (this->name?this->name:"(null)")); \
133  return this->name; \
134  }
135 
136 //
137 // Set built-in type where value is constrained between min/max limits.
138 // Create member Set"name"() (eg., SetRadius()). #defines are
139 // convenience for clamping open-ended values.
140 // The Get"name"MinValue() and Get"name"MaxValue() members return the
141 // min and max limits.
142 //
143 #define vtkSetClampMacro(name,type,min,max) \
144 virtual void Set##name (type _arg) \
145  { \
146  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to " << _arg ); \
147  if (this->name != (_arg<min?min:(_arg>max?max:_arg))) \
148  { \
149  this->name = (_arg<min?min:(_arg>max?max:_arg)); \
150  this->Modified(); \
151  } \
152  } \
153 virtual type Get##name##MinValue () \
154  { \
155  return min; \
156  } \
157 virtual type Get##name##MaxValue () \
158  { \
159  return max; \
160  }
161 
162 //
163 // This macro defines a body of set object macro. It can be used either in
164 // the header file vtkSetObjectMacro or in the implementation one
165 // vtkSetObjectMacro. It sets the pointer to object; uses vtkObject
166 // reference counting methodology. Creates method
167 // Set"name"() (e.g., SetPoints()).
168 //
169 #define vtkSetObjectBodyMacro(name,type,args) \
170  { \
171  vtkDebugMacro(<< this->GetClassName() << " (" << this \
172  << "): setting " << #name " to " << args ); \
173  if (this->name != args) \
174  { \
175  type* tempSGMacroVar = this->name; \
176  this->name = args; \
177  if (this->name != NULL) { this->name->Register(this); } \
178  if (tempSGMacroVar != NULL) \
179  { \
180  tempSGMacroVar->UnRegister(this); \
181  } \
182  this->Modified(); \
183  } \
184  }
185 
186 //
187 // Set pointer to object; uses vtkObject reference counting methodology.
188 // Creates method Set"name"() (e.g., SetPoints()). This macro should
189 // be used in the header file.
190 //
191 #define vtkSetObjectMacro(name,type) \
192 virtual void Set##name (type* _arg) \
193  { \
194  vtkSetObjectBodyMacro(name,type,_arg); \
195  }
196 
197 //
198 // Set pointer to object; uses vtkObject reference counting methodology.
199 // Creates method Set"name"() (e.g., SetPoints()). This macro should
200 // be used in the implementation file. You will also have to write
201 // prototype in the header file. The prototype should look like this:
202 // virtual void Set"name"("type" *);
203 //
204 // Please use vtkCxxSetObjectMacro not vtkSetObjectImplementationMacro.
205 // The first one is just for people who already used it.
206 #define vtkSetObjectImplementationMacro(class,name,type) \
207  vtkCxxSetObjectMacro(class,name,type)
208 
209 #define vtkCxxSetObjectMacro(class,name,type) \
210 void class::Set##name (type* _arg) \
211  { \
212  vtkSetObjectBodyMacro(name,type,_arg); \
213  }
214 
215 //
216 // Get pointer to object wrapped in vtkNew. Creates member Get"name"
217 // (e.g., GetPoints()). This macro should be used in the header file.
218 //
219 #define vtkGetNewMacro(name,type) \
220 virtual type *Get##name () \
221  { \
222  vtkDebugMacro(<< this->GetClassName() << " (" << this \
223  << "): returning " #name " address " \
224  << this->name.GetPointer() ); \
225  return this->name.GetPointer(); \
226  }
227 
228 //
229 // Get pointer to object. Creates member Get"name" (e.g., GetPoints()).
230 // This macro should be used in the header file.
231 //
232 #define vtkGetObjectMacro(name,type) \
233 virtual type *Get##name () \
234  { \
235  vtkDebugMacro(<< this->GetClassName() << " (" << this \
236  << "): returning " #name " address " << this->name ); \
237  return this->name; \
238  }
239 
240 //
241 // Create members "name"On() and "name"Off() (e.g., DebugOn() DebugOff()).
242 // Set method must be defined to use this macro.
243 //
244 #define vtkBooleanMacro(name,type) \
245  virtual void name##On () { this->Set##name(static_cast<type>(1));} \
246  virtual void name##Off () { this->Set##name(static_cast<type>(0));}
247 
248 //
249 // Following set macros for vectors define two members for each macro. The first
250 // allows setting of individual components (e.g, SetColor(float,float,float)),
251 // the second allows setting from an array (e.g., SetColor(float* rgb[3])).
252 // The macros vary in the size of the vector they deal with.
253 //
254 #define vtkSetVector2Macro(name,type) \
255 virtual void Set##name (type _arg1, type _arg2) \
256  { \
257  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to (" << _arg1 << "," << _arg2 << ")"); \
258  if ((this->name[0] != _arg1)||(this->name[1] != _arg2)) \
259  { \
260  this->name[0] = _arg1; \
261  this->name[1] = _arg2; \
262  this->Modified(); \
263  } \
264  } \
265 void Set##name (type _arg[2]) \
266  { \
267  this->Set##name (_arg[0], _arg[1]); \
268  }
269 
270 #define vtkGetVector2Macro(name,type) \
271 virtual type *Get##name () \
272 { \
273  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
274  return this->name; \
275 } \
276 virtual void Get##name (type &_arg1, type &_arg2) \
277  { \
278  _arg1 = this->name[0]; \
279  _arg2 = this->name[1]; \
280  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " = (" << _arg1 << "," << _arg2 << ")"); \
281  } \
282 virtual void Get##name (type _arg[2]) \
283  { \
284  this->Get##name (_arg[0], _arg[1]);\
285  }
286 
287 #define vtkSetVector3Macro(name,type) \
288 virtual void Set##name (type _arg1, type _arg2, type _arg3) \
289  { \
290  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to (" << _arg1 << "," << _arg2 << "," << _arg3 << ")"); \
291  if ((this->name[0] != _arg1)||(this->name[1] != _arg2)||(this->name[2] != _arg3)) \
292  { \
293  this->name[0] = _arg1; \
294  this->name[1] = _arg2; \
295  this->name[2] = _arg3; \
296  this->Modified(); \
297  } \
298  } \
299 virtual void Set##name (type _arg[3]) \
300  { \
301  this->Set##name (_arg[0], _arg[1], _arg[2]);\
302  }
303 
304 #define vtkGetVector3Macro(name,type) \
305 virtual type *Get##name () \
306 { \
307  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
308  return this->name; \
309 } \
310 virtual void Get##name (type &_arg1, type &_arg2, type &_arg3) \
311  { \
312  _arg1 = this->name[0]; \
313  _arg2 = this->name[1]; \
314  _arg3 = this->name[2]; \
315  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " = (" << _arg1 << "," << _arg2 << "," << _arg3 << ")"); \
316  } \
317 virtual void Get##name (type _arg[3]) \
318  { \
319  this->Get##name (_arg[0], _arg[1], _arg[2]);\
320  }
321 
322 #define vtkSetVector4Macro(name,type) \
323 virtual void Set##name (type _arg1, type _arg2, type _arg3, type _arg4) \
324  { \
325  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to (" << _arg1 << "," << _arg2 << "," << _arg3 << "," << _arg4 << ")"); \
326  if ((this->name[0] != _arg1)||(this->name[1] != _arg2)||(this->name[2] != _arg3)||(this->name[3] != _arg4)) \
327  { \
328  this->name[0] = _arg1; \
329  this->name[1] = _arg2; \
330  this->name[2] = _arg3; \
331  this->name[3] = _arg4; \
332  this->Modified(); \
333  } \
334  } \
335 virtual void Set##name (type _arg[4]) \
336  { \
337  this->Set##name (_arg[0], _arg[1], _arg[2], _arg[3]);\
338  }
339 
340 
341 #define vtkGetVector4Macro(name,type) \
342 virtual type *Get##name () \
343 { \
344  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
345  return this->name; \
346 } \
347 virtual void Get##name (type &_arg1, type &_arg2, type &_arg3, type &_arg4) \
348  { \
349  _arg1 = this->name[0]; \
350  _arg2 = this->name[1]; \
351  _arg3 = this->name[2]; \
352  _arg4 = this->name[3]; \
353  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " = (" << _arg1 << "," << _arg2 << "," << _arg3 << "," << _arg4 << ")"); \
354  } \
355 virtual void Get##name (type _arg[4]) \
356  { \
357  this->Get##name (_arg[0], _arg[1], _arg[2], _arg[3]);\
358  }
359 
360 #define vtkSetVector6Macro(name,type) \
361 virtual void Set##name (type _arg1, type _arg2, type _arg3, type _arg4, type _arg5, type _arg6) \
362  { \
363  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to (" << _arg1 << "," << _arg2 << "," << _arg3 << "," << _arg4 << "," << _arg5 << "," << _arg6 << ")"); \
364  if ((this->name[0] != _arg1)||(this->name[1] != _arg2)||(this->name[2] != _arg3)||(this->name[3] != _arg4)||(this->name[4] != _arg5)||(this->name[5] != _arg6)) \
365  { \
366  this->name[0] = _arg1; \
367  this->name[1] = _arg2; \
368  this->name[2] = _arg3; \
369  this->name[3] = _arg4; \
370  this->name[4] = _arg5; \
371  this->name[5] = _arg6; \
372  this->Modified(); \
373  } \
374  } \
375 virtual void Set##name (type _arg[6]) \
376  { \
377  this->Set##name (_arg[0], _arg[1], _arg[2], _arg[3], _arg[4], _arg[5]);\
378  }
379 
380 #define vtkGetVector6Macro(name,type) \
381 virtual type *Get##name () \
382 { \
383  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
384  return this->name; \
385 } \
386 virtual void Get##name (type &_arg1, type &_arg2, type &_arg3, type &_arg4, type &_arg5, type &_arg6) \
387  { \
388  _arg1 = this->name[0]; \
389  _arg2 = this->name[1]; \
390  _arg3 = this->name[2]; \
391  _arg4 = this->name[3]; \
392  _arg5 = this->name[4]; \
393  _arg6 = this->name[5]; \
394  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " = (" << _arg1 << "," << _arg2 << "," << _arg3 << "," << _arg4 << "," << _arg5 <<"," << _arg6 << ")"); \
395  } \
396 virtual void Get##name (type _arg[6]) \
397  { \
398  this->Get##name (_arg[0], _arg[1], _arg[2], _arg[3], _arg[4], _arg[5]);\
399  }
400 
401 //
402 // General set vector macro creates a single method that copies specified
403 // number of values into object.
404 // Examples: void SetColor(c,3)
405 //
406 #define vtkSetVectorMacro(name,type,count) \
407 virtual void Set##name(type data[]) \
408 { \
409  int i; \
410  for (i=0; i<count; i++) { if ( data[i] != this->name[i] ) { break; }} \
411  if ( i < count ) \
412  { \
413  for (i=0; i<count; i++) { this->name[i] = data[i]; }\
414  this->Modified(); \
415  } \
416 }
417 
418 //
419 // Get vector macro defines two methods. One returns pointer to type
420 // (i.e., array of type). This is for efficiency. The second copies data
421 // into user provided array. This is more object-oriented.
422 // Examples: float *GetColor() and void GetColor(float c[count]).
423 //
424 #define vtkGetVectorMacro(name,type,count) \
425 virtual type *Get##name () \
426 { \
427  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
428  return this->name; \
429 } \
430 virtual void Get##name (type data[count]) \
431 { \
432  for (int i=0; i<count; i++) { data[i] = this->name[i]; }\
433 }
434 
435 // Use a global function which actually calls:
436 // vtkOutputWindow::GetInstance()->DisplayText();
437 // This is to avoid vtkObject #include of vtkOutputWindow
438 // while vtkOutputWindow #includes vtkObject
439 
440 extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayText(const char*);
445 
446 //
447 // This macro is used for any output that may not be in an instance method
448 // vtkGenericWarningMacro(<< "this is debug info" << this->SomeVariable);
449 //
450 #define vtkGenericWarningMacro(x) \
451 { if (vtkObject::GetGlobalWarningDisplay()) { \
452  vtkOStreamWrapper::EndlType endl; \
453  vtkOStreamWrapper::UseEndl(endl); \
454  vtkOStrStreamWrapper vtkmsg; \
455  vtkmsg << "Generic Warning: In " __FILE__ ", line " << __LINE__ << "\n" x \
456  << "\n\n"; \
457  vtkOutputWindowDisplayGenericWarningText(vtkmsg.str());\
458  vtkmsg.rdbuf()->freeze(0);}}
459 
460 //
461 // This macro is used for debug statements in instance methods
462 // vtkDebugMacro(<< "this is debug info" << this->SomeVariable);
463 //
464 #define vtkDebugMacro(x) \
465  vtkDebugWithObjectMacro(this,x)
466 
467 //
468 // This macro is used to print out warning messages.
469 // vtkWarningMacro(<< "Warning message" << variable);
470 //
471 #define vtkWarningMacro(x) \
472  vtkWarningWithObjectMacro(this,x)
473 
474 //
475 // This macro is used to print out errors
476 // vtkErrorMacro(<< "Error message" << variable);
477 //
478 #define vtkErrorMacro(x) \
479  vtkErrorWithObjectMacro(this,x)
480 
481 //
482 // This macro is used to print out errors
483 // vtkErrorWithObjectMacro(self, << "Error message" << variable);
484 //
485 #define vtkErrorWithObjectMacro(self, x) \
486  { \
487  if (vtkObject::GetGlobalWarningDisplay()) \
488  { \
489  vtkOStreamWrapper::EndlType endl; \
490  vtkOStreamWrapper::UseEndl(endl); \
491  vtkOStrStreamWrapper vtkmsg; \
492  vtkmsg << "ERROR: In " __FILE__ ", line " << __LINE__ \
493  << "\n" << self->GetClassName() << " (" << self \
494  << "): " x << "\n\n"; \
495  if ( self->HasObserver("ErrorEvent") ) \
496  { \
497  self->InvokeEvent("ErrorEvent", vtkmsg.str()); \
498  } \
499  else \
500  { \
501  vtkOutputWindowDisplayErrorText(vtkmsg.str()); \
502  } \
503  vtkmsg.rdbuf()->freeze(0); vtkObject::BreakOnError(); \
504  } \
505  }
506 
507 //
508 // This macro is used to print out warnings
509 // vtkWarningWithObjectMacro(self, "Warning message" << variable);
510 //
511 #define vtkWarningWithObjectMacro(self, x) \
512  { \
513  if (vtkObject::GetGlobalWarningDisplay()) \
514  { \
515  vtkOStreamWrapper::EndlType endl; \
516  vtkOStreamWrapper::UseEndl(endl); \
517  vtkOStrStreamWrapper vtkmsg; \
518  vtkmsg << "Warning: In " __FILE__ ", line " << __LINE__ \
519  << "\n" << self->GetClassName() << " (" << self \
520  << "): " x << "\n\n"; \
521  if ( self->HasObserver("WarningEvent") ) \
522  { \
523  self->InvokeEvent("WarningEvent", vtkmsg.str()); \
524  } \
525  else \
526  { \
527  vtkOutputWindowDisplayWarningText(vtkmsg.str()); \
528  } \
529  vtkmsg.rdbuf()->freeze(0); \
530  } \
531  }
532 
533 #ifdef NDEBUG
534 # define vtkDebugWithObjectMacro(self, x)
535 #else
536 # define vtkDebugWithObjectMacro(self, x) \
537  { \
538  if (self->GetDebug() && vtkObject::GetGlobalWarningDisplay()) \
539  { \
540  vtkOStreamWrapper::EndlType endl; \
541  vtkOStreamWrapper::UseEndl(endl); \
542  vtkOStrStreamWrapper vtkmsg; \
543  vtkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \
544  << self->GetClassName() << " (" << self << "): " x << "\n\n"; \
545  vtkOutputWindowDisplayDebugText(vtkmsg.str()); \
546  vtkmsg.rdbuf()->freeze(0); \
547  } \
548  }
549 #endif
550 
551 //
552 // This macro is used to quiet compiler warnings about unused parameters
553 // to methods. Only use it when the parameter really shouldn't be used.
554 // Don't use it as a way to shut up the compiler while you take your
555 // sweet time getting around to implementing the method.
556 //
557 #define vtkNotUsed(x)
558 
559 //
560 // This macro is used for functions which may not be used in a translation unit
561 // due to different paths taken based on template types. Please give a reason
562 // why the function may be considered unused (within a translation unit). For
563 // example, a template specialization might not be used in compiles of sources
564 // which use different template types.
565 //
566 #ifdef __GNUC__
567 #define vtkMaybeUnused(reason) __attribute__((unused))
568 #else
569 #define vtkMaybeUnused(reason)
570 #endif
571 
572 #define vtkWorldCoordinateMacro(name) \
573 virtual vtkCoordinate *Get##name##Coordinate () \
574 { \
575  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " #name "Coordinate address " << this->name##Coordinate ); \
576  return this->name##Coordinate; \
577 } \
578 virtual void Set##name(double x[3]) {this->Set##name(x[0],x[1],x[2]);} \
579 virtual void Set##name(double x, double y, double z) \
580 { \
581  this->name##Coordinate->SetValue(x,y,z); \
582 } \
583 virtual double *Get##name() \
584 { \
585  return this->name##Coordinate->GetValue(); \
586 }
587 
588 #define vtkViewportCoordinateMacro(name) \
589 virtual vtkCoordinate *Get##name##Coordinate () \
590 { \
591  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " #name "Coordinate address " << this->name##Coordinate ); \
592  return this->name##Coordinate; \
593 } \
594 virtual void Set##name(double x[2]) {this->Set##name(x[0],x[1]);} \
595 virtual void Set##name(double x, double y) \
596 { \
597  this->name##Coordinate->SetValue(x,y); \
598 } \
599 virtual double *Get##name() \
600 { \
601  return this->name##Coordinate->GetValue(); \
602 }
603 
604 // Allows definition of vtkObject API such that NewInstance may return a
605 // superclass of thisClass.
606 #define vtkAbstractTypeMacroWithNewInstanceType(thisClass,superclass,instanceType) \
607  typedef superclass Superclass; \
608  private: \
609  virtual const char* GetClassNameInternal() const { return #thisClass; } \
610  public: \
611  static int IsTypeOf(const char *type) \
612  { \
613  if ( !strcmp(#thisClass,type) ) \
614  { \
615  return 1; \
616  } \
617  return superclass::IsTypeOf(type); \
618  } \
619  virtual int IsA(const char *type) \
620  { \
621  return this->thisClass::IsTypeOf(type); \
622  } \
623  static thisClass* SafeDownCast(vtkObjectBase *o) \
624  { \
625  if ( o && o->IsA(#thisClass) ) \
626  { \
627  return static_cast<thisClass *>(o); \
628  } \
629  return NULL;\
630  } \
631  instanceType *NewInstance() const \
632  { \
633  return instanceType::SafeDownCast(this->NewInstanceInternal()); \
634  }
635 
636 // Same as vtkTypeMacro, but adapted for cases where thisClass is abstact.
637 #define vtkAbstractTypeMacro(thisClass,superclass) \
638  vtkAbstractTypeMacroWithNewInstanceType(thisClass, superclass, thisClass)
639 
640 // Macro used to determine whether a class is the same class or
641 // a subclass of the named class.
642 #define vtkTypeMacro(thisClass,superclass) \
643  vtkAbstractTypeMacro(thisClass, superclass) \
644  protected: \
645  virtual vtkObjectBase *NewInstanceInternal() const \
646  { \
647  return thisClass::New(); \
648  } \
649  public:
650 
651 // Macro to implement the instantiator's wrapper around the New()
652 // method. Use this macro if and only if vtkStandardNewMacro or
653 // vtkObjectFactoryNewMacro is not used by the class.
654 #define vtkInstantiatorNewMacro(thisClass) \
655  extern vtkObject* vtkInstantiator##thisClass##New(); \
656  vtkObject* vtkInstantiator##thisClass##New() \
657  { \
658  return thisClass::New(); \
659  }
660 
661 // The vtkTemplateMacro is used to centralize the set of types
662 // supported by Execute methods. It also avoids duplication of long
663 // switch statement case lists.
664 //
665 // This version of the macro allows the template to take any number of
666 // arguments. Example usage:
667 // switch(array->GetDataType())
668 // {
669 // vtkTemplateMacro(myFunc(static_cast<VTK_TT*>(data), arg2));
670 // }
671 #define vtkTemplateMacroCase(typeN, type, call) \
672  case typeN: { typedef type VTK_TT; call; }; break
673 #define vtkTemplateMacro(call) \
674  vtkTemplateMacroCase(VTK_DOUBLE, double, call); \
675  vtkTemplateMacroCase(VTK_FLOAT, float, call); \
676  vtkTemplateMacroCase_ll(VTK_LONG_LONG, long long, call) \
677  vtkTemplateMacroCase_ll(VTK_UNSIGNED_LONG_LONG, unsigned long long, call) \
678  vtkTemplateMacroCase_si64(VTK___INT64, __int64, call) \
679  vtkTemplateMacroCase_ui64(VTK_UNSIGNED___INT64, unsigned __int64, call) \
680  vtkTemplateMacroCase(VTK_ID_TYPE, vtkIdType, call); \
681  vtkTemplateMacroCase(VTK_LONG, long, call); \
682  vtkTemplateMacroCase(VTK_UNSIGNED_LONG, unsigned long, call); \
683  vtkTemplateMacroCase(VTK_INT, int, call); \
684  vtkTemplateMacroCase(VTK_UNSIGNED_INT, unsigned int, call); \
685  vtkTemplateMacroCase(VTK_SHORT, short, call); \
686  vtkTemplateMacroCase(VTK_UNSIGNED_SHORT, unsigned short, call); \
687  vtkTemplateMacroCase(VTK_CHAR, char, call); \
688  vtkTemplateMacroCase(VTK_SIGNED_CHAR, signed char, call); \
689  vtkTemplateMacroCase(VTK_UNSIGNED_CHAR, unsigned char, call)
690 
691 // This is same as Template macro with additional case for VTK_STRING.
692 #define vtkExtendedTemplateMacro(call) \
693  vtkTemplateMacro(call); \
694  vtkTemplateMacroCase(VTK_STRING, vtkStdString, call)
695 
696 // The vtkArrayIteratorTemplateMacro is used to centralize the set of types
697 // supported by Execute methods. It also avoids duplication of long
698 // switch statement case lists.
699 //
700 // This version of the macro allows the template to take any number of
701 // arguments.
702 //
703 // Note that in this macro VTK_TT is defined to be the type of the iterator
704 // for the given type of array. One must include the
705 // vtkArrayIteratorIncludes.h header file to provide for extending of this macro
706 // by addition of new iterators.
707 //
708 // Example usage:
709 // vtkArrayIter* iter = array->NewIterator();
710 // switch(array->GetDataType())
711 // {
712 // vtkArrayIteratorTemplateMacro(myFunc(static_cast<VTK_TT*>(iter), arg2));
713 // }
714 // iter->Delete();
715 //
716 #define vtkArrayIteratorTemplateMacroCase(typeN, type, call) \
717  vtkTemplateMacroCase(typeN, vtkArrayIteratorTemplate<type>, call)
718 #define vtkArrayIteratorTemplateMacro(call) \
719  vtkArrayIteratorTemplateMacroCase(VTK_DOUBLE, double, call); \
720  vtkArrayIteratorTemplateMacroCase(VTK_FLOAT, float, call); \
721  vtkArrayIteratorTemplateMacroCase_ll(VTK_LONG_LONG, long long, call); \
722  vtkArrayIteratorTemplateMacroCase_ll(VTK_UNSIGNED_LONG_LONG, unsigned long long, call);\
723  vtkArrayIteratorTemplateMacroCase_si64(VTK___INT64, __int64, call); \
724  vtkArrayIteratorTemplateMacroCase_ui64(VTK_UNSIGNED___INT64, unsigned __int64, call); \
725  vtkArrayIteratorTemplateMacroCase(VTK_ID_TYPE, vtkIdType, call); \
726  vtkArrayIteratorTemplateMacroCase(VTK_LONG, long, call); \
727  vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_LONG, unsigned long, call); \
728  vtkArrayIteratorTemplateMacroCase(VTK_INT, int, call); \
729  vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_INT, unsigned int, call); \
730  vtkArrayIteratorTemplateMacroCase(VTK_SHORT, short, call); \
731  vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_SHORT, unsigned short, call); \
732  vtkArrayIteratorTemplateMacroCase(VTK_CHAR, char, call); \
733  vtkArrayIteratorTemplateMacroCase(VTK_SIGNED_CHAR, signed char, call); \
734  vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_CHAR, unsigned char, call); \
735  vtkArrayIteratorTemplateMacroCase(VTK_STRING, vtkStdString, call); \
736  vtkTemplateMacroCase(VTK_BIT, vtkBitArrayIterator, call);
737 
738 // Add "long long" to the template macro if it is enabled.
739 #if defined(VTK_TYPE_USE_LONG_LONG)
740 # define vtkTemplateMacroCase_ll(typeN, type, call) \
741  vtkTemplateMacroCase(typeN, type, call);
742 # define vtkArrayIteratorTemplateMacroCase_ll(typeN, type, call) \
743  vtkArrayIteratorTemplateMacroCase(typeN, type, call)
744 #else
745 # define vtkTemplateMacroCase_ll(typeN, type, call)
746 # define vtkArrayIteratorTemplateMacroCase_ll(typeN, type, call)
747 #endif
748 
749 // Add "__int64" to the template macro if it is enabled.
750 #if defined(VTK_TYPE_USE___INT64)
751 # define vtkTemplateMacroCase_si64(typeN, type, call) \
752  vtkTemplateMacroCase(typeN, type, call);
753 # define vtkArrayIteratorTemplateMacroCase_si64(typeN, type, call) \
754  vtkArrayIteratorTemplateMacroCase(typeN, type, call)
755 #else
756 # define vtkTemplateMacroCase_si64(typeN, type, call)
757 # define vtkArrayIteratorTemplateMacroCase_si64(typeN, type, call)
758 #endif
759 
760 // Add "unsigned __int64" to the template macro if it is enabled and
761 // can be converted to double.
762 #if defined(VTK_TYPE_USE___INT64) && defined(VTK_TYPE_CONVERT_UI64_TO_DOUBLE)
763 # define vtkTemplateMacroCase_ui64(typeN, type, call) \
764  vtkTemplateMacroCase(typeN, type, call);
765 # define vtkArrayIteratorTemplateMacroCase_ui64(typeN, type, call) \
766  vtkArrayIteratorTemplateMacroCase(typeN, type, call);
767 #else
768 # define vtkTemplateMacroCase_ui64(typeN, type, call)
769 # define vtkArrayIteratorTemplateMacroCase_ui64(typeN, type, call)
770 #endif
771 
772 //----------------------------------------------------------------------------
773 // Setup legacy code policy.
774 
775 // Define VTK_LEGACY macro to mark legacy methods where they are
776 // declared in their class. Example usage:
777 //
778 // // @deprecated Replaced by MyOtherMethod() as of VTK 5.0.
779 // VTK_LEGACY(void MyMethod());
780 #if defined(VTK_LEGACY_REMOVE)
781  // Remove legacy methods completely. Put a bogus declaration in
782  // place to avoid stray semicolons because this is an error for some
783  // compilers. Using a class forward declaration allows any number
784  // of repeats in any context without generating unique names.
785 
786 # define VTK_LEGACY(method) VTK_LEGACY__0(method,__LINE__)
787 # define VTK_LEGACY__0(method,line) VTK_LEGACY__1(method,line)
788 # define VTK_LEGACY__1(method,line) class vtkLegacyMethodRemoved##line
789 
790 #elif defined(VTK_LEGACY_SILENT) || defined(VTK_WRAPPING_CXX)
791  // Provide legacy methods with no warnings.
792 # define VTK_LEGACY(method) method
793 #else
794  // Setup compile-time warnings for uses of deprecated methods if
795  // possible on this compiler.
796 # if defined(__GNUC__) && !defined(__INTEL_COMPILER)
797 # define VTK_LEGACY(method) method __attribute__((deprecated))
798 # elif defined(_MSC_VER)
799 # define VTK_LEGACY(method) __declspec(deprecated) method
800 # else
801 # define VTK_LEGACY(method) method
802 # endif
803 #endif
804 
805 // Macros to create runtime deprecation warning messages in function
806 // bodies. Example usage:
807 //
808 // #if !defined(VTK_LEGACY_REMOVE)
809 // void vtkMyClass::MyOldMethod()
810 // {
811 // VTK_LEGACY_BODY(vtkMyClass::MyOldMethod, "VTK 5.0");
812 // }
813 // #endif
814 //
815 // #if !defined(VTK_LEGACY_REMOVE)
816 // void vtkMyClass::MyMethod()
817 // {
818 // VTK_LEGACY_REPLACED_BODY(vtkMyClass::MyMethod, "VTK 5.0",
819 // vtkMyClass::MyOtherMethod);
820 // }
821 // #endif
822 #if defined(VTK_LEGACY_REMOVE) || defined(VTK_LEGACY_SILENT)
823 # define VTK_LEGACY_BODY(method, version)
824 # define VTK_LEGACY_REPLACED_BODY(method, version, replace)
825 #else
826 # define VTK_LEGACY_BODY(method, version) \
827  vtkGenericWarningMacro(#method " was deprecated for " version " and will be removed in a future version.")
828 # define VTK_LEGACY_REPLACED_BODY(method, version, replace) \
829  vtkGenericWarningMacro(#method " was deprecated for " version " and will be removed in a future version. Use " #replace " instead.")
830 #endif
831 
832 // Qualifiers used for function arguments and return types indicating that the
833 // class is wrapped externally.
834 #define VTK_WRAP_EXTERN
835 
836 //----------------------------------------------------------------------------
837 // Switch case fall-through policy.
838 
839 // Use "VTK_FALLTHROUGH;" to annotate deliberate fall-through in switches,
840 // use it analogously to "break;". The trailing semi-colon is required.
841 #if __cplusplus >= 201103L && defined(__has_warning)
842 # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
843 # define VTK_FALLTHROUGH [[clang::fallthrough]]
844 # endif
845 #endif
846 
847 #ifndef VTK_FALLTHROUGH
848 # define VTK_FALLTHROUGH ((void)0)
849 #endif
850 
851 #endif
852 // VTK-HeaderTest-Exclude: vtkSetGet.h
VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayGenericWarningText(const char *)
VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayErrorText(const char *)
#define VTKCOMMONCORE_EXPORT
VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayDebugText(const char *)
VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayText(const char *)
VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayWarningText(const char *)