VTK  9.7.1
vtkType.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 #ifndef vtkType_h
4 #define vtkType_h
5 
6 #include "vtkABINamespace.h"
7 #include "vtkCompiler.h" // for VTK_USE_EXTERN_TEMPLATE
8 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0
9 #include "vtkOptions.h" // for VTK_USE_64BIT_IDS, VTK_USE_64BIT_TIMESTAMPS, VTK_USE_FUTURE_BOOL
10 #include "vtk_kwiml.h"
11 
12 #define VTK_SIZEOF_CHAR KWIML_ABI_SIZEOF_CHAR
13 #define VTK_SIZEOF_SHORT KWIML_ABI_SIZEOF_SHORT
14 #define VTK_SIZEOF_INT KWIML_ABI_SIZEOF_INT
15 #define VTK_SIZEOF_LONG KWIML_ABI_SIZEOF_LONG
16 #define VTK_SIZEOF_LONG_LONG KWIML_ABI_SIZEOF_LONG_LONG
17 #define VTK_SIZEOF_FLOAT KWIML_ABI_SIZEOF_FLOAT
18 #define VTK_SIZEOF_DOUBLE KWIML_ABI_SIZEOF_DOUBLE
19 #define VTK_SIZEOF_VOID_P KWIML_ABI_SIZEOF_DATA_PTR
20 
21 /* Whether type "char" is signed (it may be signed or unsigned). */
22 #if defined(KWIML_ABI_CHAR_IS_SIGNED)
23 #define VTK_TYPE_CHAR_IS_SIGNED 1
24 #else
25 #define VTK_TYPE_CHAR_IS_SIGNED 0
26 #endif
27 
28 /*--------------------------------------------------------------------------*/
29 /* Define a unique integer identifier for each native scalar type. */
30 
31 /* These types are returned by GetDataType to indicate pixel type. */
32 #define VTK_VOID 0
33 #define VTK_BIT 1
34 #define VTK_CHAR 2
35 #define VTK_SIGNED_CHAR 15
36 #define VTK_UNSIGNED_CHAR 3
37 #define VTK_SHORT 4
38 #define VTK_UNSIGNED_SHORT 5
39 #define VTK_INT 6
40 #define VTK_UNSIGNED_INT 7
41 #define VTK_LONG 8
42 #define VTK_UNSIGNED_LONG 9
43 #define VTK_FLOAT 10
44 #define VTK_DOUBLE 11
45 #define VTK_ID_TYPE 12
46 
47 /* These types are not currently supported by GetDataType, but are for
48  completeness. */
49 #define VTK_STRING 13
50 #define VTK_OPAQUE 14
51 
52 #define VTK_LONG_LONG 16
53 #define VTK_UNSIGNED_LONG_LONG 17
54 
55 /* These types are required by vtkVariant and vtkVariantArray */
56 #define VTK_VARIANT 20
57 #define VTK_OBJECT 21
58 
59 // vtkTypes.h can be included in C code directly, which does not support
60 // deprecation of enum values
61 #ifdef __cplusplus
62 #define VTK_DEPRECATED_IN_9_7_0_TYPE(reason) VTK_DEPRECATED_IN_9_7_0(reason)
63 #else
64 #define VTK_DEPRECATED_IN_9_7_0_TYPE(reason)
65 #endif
66 
67 /*--------------------------------------------------------------------------*/
68 /* Define a unique integer identifier for each native array type. */
69 // NOLINTNEXTLINE(readability-enum-initial-value)
71 {
73 
74  // AbstractArray subclasses
78 
79  // DataArray subclasses
81 
82  // GenericDataArray subclasses
85  VTK_SCALED_SOA_DATA_ARRAY VTK_DEPRECATED_IN_9_7_0_TYPE("No longer needed"),
87  VTK_PERIODIC_DATA_ARRAY VTK_DEPRECATED_IN_9_7_0_TYPE("No longer needed"),
89 
90  // ImplicitArray subclasses/typedefs
95  VTK_STD_FUNCTION_ARRAY VTK_DEPRECATED_IN_9_7_0_TYPE("No longer needed"),
98 
100 };
101 
102 /*--------------------------------------------------------------------------*/
103 // Define a unique integer identifier for each vtkDataObject type.
104 // When adding a new data type here, make sure to update vtkDataObjectTypes as well.
105 // In case of deprecation removal, do not fully remove obsolete values between 0 and current max,
106 // but meraly comment it out. New values should be added after the max.
108 {
121  // VTK_MULTIGROUP_DATA_SET = 12 OBSOLETE
123  // VTK_HIERARCHICAL_DATA_SET = 14 OBSOLETE
124  // VTK_HIERARCHICAL_BOX_DATA_SET = 15 OBSOLETE
126  // VTK_HYPER_OCTREE = 17 OBSOLETE
127  // VTK_TEMPORAL_DATA_SET = 18 OBSOLETE
128  VTK_TABLE = 19,
129  VTK_GRAPH = 20,
130  VTK_TREE = 21,
143  // VTK_PISTON_DATA_OBJECT = 34 OBSOLETE
144  VTK_PATH = 35,
162 };
163 
164 /*--------------------------------------------------------------------------*/
165 /* Define a casting macro for use by the constants below. */
166 #if defined(__cplusplus)
167 #define VTK_TYPE_CAST(T, V) static_cast<T>(V)
168 #else
169 #define VTK_TYPE_CAST(T, V) ((T)(V))
170 #endif
171 
172 /*--------------------------------------------------------------------------*/
173 /* Define min/max constants for each type. */
174 #define VTK_BIT_MIN 0
175 #define VTK_BIT_MAX 1
176 #if VTK_TYPE_CHAR_IS_SIGNED
177 #define VTK_CHAR_MIN VTK_TYPE_CAST(char, 0x80)
178 #define VTK_CHAR_MAX VTK_TYPE_CAST(char, 0x7f)
179 #else
180 #define VTK_CHAR_MIN VTK_TYPE_CAST(char, 0u)
181 #define VTK_CHAR_MAX VTK_TYPE_CAST(char, 0xffu)
182 #endif
183 #define VTK_SIGNED_CHAR_MIN VTK_TYPE_CAST(signed char, 0x80)
184 #define VTK_SIGNED_CHAR_MAX VTK_TYPE_CAST(signed char, 0x7f)
185 #define VTK_UNSIGNED_CHAR_MIN VTK_TYPE_CAST(unsigned char, 0u)
186 #define VTK_UNSIGNED_CHAR_MAX VTK_TYPE_CAST(unsigned char, 0xffu)
187 #define VTK_SHORT_MIN VTK_TYPE_CAST(short, 0x8000)
188 #define VTK_SHORT_MAX VTK_TYPE_CAST(short, 0x7fff)
189 #define VTK_UNSIGNED_SHORT_MIN VTK_TYPE_CAST(unsigned short, 0u)
190 #define VTK_UNSIGNED_SHORT_MAX VTK_TYPE_CAST(unsigned short, 0xffffu)
191 #define VTK_INT_MIN VTK_TYPE_CAST(int, ~(~0u >> 1))
192 #define VTK_INT_MAX VTK_TYPE_CAST(int, ~0u >> 1)
193 #define VTK_UNSIGNED_INT_MIN VTK_TYPE_CAST(unsigned int, 0)
194 #define VTK_UNSIGNED_INT_MAX VTK_TYPE_CAST(unsigned int, ~0u)
195 #define VTK_LONG_MIN VTK_TYPE_CAST(long, ~(~0ul >> 1))
196 #define VTK_LONG_MAX VTK_TYPE_CAST(long, ~0ul >> 1)
197 #define VTK_UNSIGNED_LONG_MIN VTK_TYPE_CAST(unsigned long, 0ul)
198 #define VTK_UNSIGNED_LONG_MAX VTK_TYPE_CAST(unsigned long, ~0ul)
199 #define VTK_FLOAT_MIN VTK_TYPE_CAST(float, -1.0e+38f)
200 #define VTK_FLOAT_MAX VTK_TYPE_CAST(float, 1.0e+38f)
201 #define VTK_DOUBLE_MIN VTK_TYPE_CAST(double, -1.0e+299)
202 #define VTK_DOUBLE_MAX VTK_TYPE_CAST(double, 1.0e+299)
203 #define VTK_LONG_LONG_MIN VTK_TYPE_CAST(long long, ~(~0ull >> 1))
204 #define VTK_LONG_LONG_MAX VTK_TYPE_CAST(long long, ~0ull >> 1)
205 #define VTK_UNSIGNED_LONG_LONG_MIN VTK_TYPE_CAST(unsigned long long, 0ull)
206 #define VTK_UNSIGNED_LONG_LONG_MAX VTK_TYPE_CAST(unsigned long long, ~0ull)
207 
208 /*--------------------------------------------------------------------------*/
209 /* Define named types and constants corresponding to specific integer
210  and floating-point sizes and signedness. */
211 
212 /* Select an 8-bit integer type. */
213 #if VTK_SIZEOF_CHAR == 1
214 typedef unsigned char vtkTypeUInt8;
215 typedef signed char vtkTypeInt8;
216 #define VTK_TYPE_UINT8 VTK_UNSIGNED_CHAR
217 #define VTK_TYPE_UINT8_MIN VTK_UNSIGNED_CHAR_MIN
218 #define VTK_TYPE_UINT8_MAX VTK_UNSIGNED_CHAR_MAX
219 #define VTK_TYPE_INT8 VTK_SIGNED_CHAR
220 #define VTK_TYPE_INT8_MIN VTK_SIGNED_CHAR_MIN
221 #define VTK_TYPE_INT8_MAX VTK_SIGNED_CHAR_MAX
222 #else
223 #error "No native data type can represent an 8-bit integer."
224 #endif
225 
226 /* Select a 16-bit integer type. */
227 #if VTK_SIZEOF_SHORT == 2
228 typedef unsigned short vtkTypeUInt16;
229 typedef signed short vtkTypeInt16;
230 #define VTK_TYPE_UINT16 VTK_UNSIGNED_SHORT
231 #define VTK_TYPE_UINT16_MIN VTK_UNSIGNED_SHORT_MIN
232 #define VTK_TYPE_UINT16_MAX VTK_UNSIGNED_SHORT_MAX
233 #define VTK_TYPE_INT16 VTK_SHORT
234 #define VTK_TYPE_INT16_MIN VTK_SHORT_MIN
235 #define VTK_TYPE_INT16_MAX VTK_SHORT_MAX
236 #elif VTK_SIZEOF_INT == 2
237 typedef unsigned int vtkTypeUInt16;
238 typedef signed int vtkTypeInt16;
239 #define VTK_TYPE_UINT16 VTK_UNSIGNED_INT
240 #define VTK_TYPE_UINT16_MIN VTK_UNSIGNED_INT_MIN
241 #define VTK_TYPE_UINT16_MAX VTK_UNSIGNED_INT_MAX
242 #define VTK_TYPE_INT16 VTK_INT
243 #define VTK_TYPE_INT16_MIN VTK_INT_MIN
244 #define VTK_TYPE_INT16_MAX VTK_INT_MAX
245 #else
246 #error "No native data type can represent a 16-bit integer."
247 #endif
248 
249 /* Select a 32-bit integer type. */
250 #if VTK_SIZEOF_INT == 4
251 typedef unsigned int vtkTypeUInt32;
252 typedef signed int vtkTypeInt32;
253 #define VTK_TYPE_UINT32 VTK_UNSIGNED_INT
254 #define VTK_TYPE_UINT32_MIN VTK_UNSIGNED_INT_MIN
255 #define VTK_TYPE_UINT32_MAX VTK_UNSIGNED_INT_MAX
256 #define VTK_TYPE_INT32 VTK_INT
257 #define VTK_TYPE_INT32_MIN VTK_INT_MIN
258 #define VTK_TYPE_INT32_MAX VTK_INT_MAX
259 #elif VTK_SIZEOF_LONG == 4
260 typedef unsigned long vtkTypeUInt32;
261 typedef signed long vtkTypeInt32;
262 #define VTK_TYPE_UINT32 VTK_UNSIGNED_LONG
263 #define VTK_TYPE_UINT32_MIN VTK_UNSIGNED_LONG_MIN
264 #define VTK_TYPE_UINT32_MAX VTK_UNSIGNED_LONG_MAX
265 #define VTK_TYPE_INT32 VTK_LONG
266 #define VTK_TYPE_INT32_MIN VTK_LONG_MIN
267 #define VTK_TYPE_INT32_MAX VTK_LONG_MAX
268 #else
269 #error "No native data type can represent a 32-bit integer."
270 #endif
271 
272 /* Select a 64-bit integer type. */
273 #if VTK_SIZEOF_LONG_LONG == 8
274 typedef unsigned long long vtkTypeUInt64;
275 typedef signed long long vtkTypeInt64;
276 #define VTK_TYPE_UINT64 VTK_UNSIGNED_LONG_LONG
277 #define VTK_TYPE_UINT64_MIN VTK_UNSIGNED_LONG_LONG_MIN
278 #define VTK_TYPE_UINT64_MAX VTK_UNSIGNED_LONG_LONG_MAX
279 #define VTK_TYPE_INT64 VTK_LONG_LONG
280 #define VTK_TYPE_INT64_MIN VTK_LONG_LONG_MIN
281 #define VTK_TYPE_INT64_MAX VTK_LONG_LONG_MAX
282 #elif VTK_SIZEOF_LONG == 8
283 typedef unsigned long vtkTypeUInt64;
284 typedef signed long vtkTypeInt64;
285 #define VTK_TYPE_UINT64 VTK_UNSIGNED_LONG
286 #define VTK_TYPE_UINT64_MIN VTK_UNSIGNED_LONG_MIN
287 #define VTK_TYPE_UINT64_MAX VTK_UNSIGNED_LONG_MAX
288 #define VTK_TYPE_INT64 VTK_LONG
289 #define VTK_TYPE_INT64_MIN VTK_LONG_MIN
290 #define VTK_TYPE_INT64_MAX VTK_LONG_MAX
291 #else
292 #error "No native data type can represent a 64-bit integer."
293 #endif
294 
295 // If this is a 64-bit platform, or the user has indicated that 64-bit
296 // timestamps should be used, select an unsigned 64-bit integer type
297 // for use in MTime values. If possible, use 'unsigned long' as we have
298 // historically.
299 #if defined(VTK_USE_64BIT_TIMESTAMPS) || VTK_SIZEOF_VOID_P == 8
300 #if VTK_SIZEOF_LONG == 8
301 typedef unsigned long vtkMTimeType;
302 #define VTK_MTIME_TYPE_IMPL VTK_UNSIGNED_LONG
303 #define VTK_MTIME_MIN VTK_UNSIGNED_LONG_MIN
304 #define VTK_MTIME_MAX VTK_UNSIGNED_LONG_MAX
305 #else
306 typedef vtkTypeUInt64 vtkMTimeType;
307 #define VTK_MTIME_TYPE_IMPL VTK_TYPE_UINT64
308 #define VTK_MTIME_MIN VTK_TYPE_UINT64_MIN
309 #define VTK_MTIME_MAX VTK_TYPE_UINT64_MAX
310 #endif
311 #else
312 #if VTK_SIZEOF_LONG == 4
313 typedef unsigned long vtkMTimeType;
314 #define VTK_MTIME_TYPE_IMPL VTK_UNSIGNED_LONG
315 #define VTK_MTIME_MIN VTK_UNSIGNED_LONG_MIN
316 #define VTK_MTIME_MAX VTK_UNSIGNED_LONG_MAX
317 #else
318 typedef vtkTypeUInt32 vtkMTimeType;
319 #define VTK_MTIME_TYPE_IMPL VTK_TYPE_UINT32
320 #define VTK_MTIME_MIN VTK_TYPE_UINT32_MIN
321 #define VTK_MTIME_MAX VTK_TYPE_UINT32_MAX
322 #endif
323 #endif
324 
325 /* Select a 32-bit floating point type. */
326 #if VTK_SIZEOF_FLOAT == 4
327 typedef float vtkTypeFloat32;
328 #define VTK_TYPE_FLOAT32 VTK_FLOAT
329 #else
330 #error "No native data type can represent a 32-bit floating point value."
331 #endif
332 
333 /* Select a 64-bit floating point type. */
334 #if VTK_SIZEOF_DOUBLE == 8
335 typedef double vtkTypeFloat64;
336 #define VTK_TYPE_FLOAT64 VTK_DOUBLE
337 #else
338 #error "No native data type can represent a 64-bit floating point value."
339 #endif
340 
341 /*--------------------------------------------------------------------------*/
342 /* Choose an implementation for vtkIdType. */
343 #define VTK_HAS_ID_TYPE
344 #ifdef VTK_USE_64BIT_IDS
345 #if VTK_SIZEOF_LONG_LONG == 8
346 typedef long long vtkIdType;
347 #define VTK_ID_TYPE_IMPL VTK_LONG_LONG
348 #define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_LONG_LONG
349 #define VTK_ID_MIN VTK_LONG_LONG_MIN
350 #define VTK_ID_MAX VTK_LONG_LONG_MAX
351 #define VTK_ID_TYPE_PRId "lld"
352 #elif VTK_SIZEOF_LONG == 8
353 typedef long vtkIdType;
354 #define VTK_ID_TYPE_IMPL VTK_LONG
355 #define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_LONG
356 #define VTK_ID_MIN VTK_LONG_MIN
357 #define VTK_ID_MAX VTK_LONG_MAX
358 #define VTK_ID_TYPE_PRId "ld"
359 #else
360 #error "VTK_USE_64BIT_IDS is ON but no 64-bit integer type is available."
361 #endif
362 #else
363 typedef int vtkIdType;
364 #define VTK_ID_TYPE_IMPL VTK_INT
365 #define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_INT
366 #define VTK_ID_MIN VTK_INT_MIN
367 #define VTK_ID_MAX VTK_INT_MAX
368 #define VTK_ID_TYPE_PRId "d"
369 #endif
370 
371 #ifndef __cplusplus
372 // Make sure that when VTK headers are used by the C compiler we make
373 // sure to define the bool type. This is possible when using IO features
374 // like vtkXMLWriterC.h
375 #include "stdbool.h"
376 #endif
377 
378 /*--------------------------------------------------------------------------*/
379 /* If not already defined, define vtkTypeBool. When VTK was started, some */
380 /* compilers did not yet support the bool type, and so VTK often used int, */
381 /* or more rarely unsigned int, where it should have used bool. */
382 /* Eventually vtkTypeBool will switch to real bool. */
383 #ifndef VTK_TYPE_BOOL_TYPEDEFED
384 #define VTK_TYPE_BOOL_TYPEDEFED
385 #if VTK_USE_FUTURE_BOOL
386 typedef bool vtkTypeBool;
387 typedef bool vtkTypeUBool;
388 #else
389 typedef int vtkTypeBool;
390 typedef unsigned int vtkTypeUBool;
391 #endif
392 #endif
393 
394 #if defined(__cplusplus)
395 /* Description:
396  * Returns true if data type tags a and b point to the same data type. This
397  * is intended to handle vtkIdType, which does not have the same tag as its
398  * underlying data type.
399  * @note This method is only available when included from a C++ source file. */
400 VTK_ABI_NAMESPACE_BEGIN
401 inline vtkTypeBool vtkDataTypesCompare(int a, int b)
402 {
403  return (a == b ||
404  ((a == VTK_ID_TYPE || a == VTK_ID_TYPE_IMPL) && (b == VTK_ID_TYPE || b == VTK_ID_TYPE_IMPL)));
405 }
406 VTK_ABI_NAMESPACE_END
407 #endif
408 
409 /*--------------------------------------------------------------------------*/
411 #define vtkInstantiateTemplateMacro(decl) \
412  decl<float>; \
413  decl<double>; \
414  decl<char>; \
415  decl<signed char>; \
416  decl<unsigned char>; \
417  decl<short>; \
418  decl<unsigned short>; \
419  decl<int>; \
420  decl<unsigned int>; \
421  decl<long>; \
422  decl<unsigned long>; \
423  decl<long long>; \
424  decl<unsigned long long>
425 
426 #define vtkInstantiateSecondOrderTemplateMacro(decl0, decl1) \
427  decl0<decl1<float>>; \
428  decl0<decl1<double>>; \
429  decl0<decl1<char>>; \
430  decl0<decl1<signed char>>; \
431  decl0<decl1<unsigned char>>; \
432  decl0<decl1<short>>; \
433  decl0<decl1<unsigned short>>; \
434  decl0<decl1<int>>; \
435  decl0<decl1<unsigned int>>; \
436  decl0<decl1<long>>; \
437  decl0<decl1<unsigned long>>; \
438  decl0<decl1<long long>>; \
439  decl0<decl1<unsigned long long>>
440 
441 #define vtkInstantiateSecondOrderWithParameterTemplateMacro(decl0, decl1, par) \
442  decl0<decl1<float>, par>; \
443  decl0<decl1<double>, par>; \
444  decl0<decl1<char>, par>; \
445  decl0<decl1<signed char>, par>; \
446  decl0<decl1<unsigned char>, par>; \
447  decl0<decl1<short>, par>; \
448  decl0<decl1<unsigned short>, par>; \
449  decl0<decl1<int>, par>; \
450  decl0<decl1<unsigned int>, par>; \
451  decl0<decl1<long>, par>; \
452  decl0<decl1<unsigned long>, par>; \
453  decl0<decl1<long long>, par>; \
454  decl0<decl1<unsigned long long>, par>
455 
457 #ifdef VTK_USE_EXTERN_TEMPLATE
458 #define vtkExternTemplateMacro(decl) vtkInstantiateTemplateMacro(decl)
459 #define vtkExternSecondOrderTemplateMacro(decl0, decl1) \
460  vtkInstantiateSecondOrderTemplateMacro(decl0, decl1)
461 #define vtkExternSecondOrderWithParameterTemplateMacro(decl0, decl1, par) \
462  vtkInstantiateSecondOrderWithParameterTemplateMacro(decl0, decl1, par)
463 #else
464 #define vtkExternTemplateMacro(decl)
465 #define vtkExternSecondOrderTemplateMacro(decl0, decl1)
466 #define vtkExternSecondOrderWithParameterTemplateMacro(decl0, decl1, par)
467 #endif
468 
469 #endif
470 // VTK-HeaderTest-Exclude: vtkType.h
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
unsigned int vtkTypeUBool
Definition: vtkType.h:390
int vtkIdType
Definition: vtkType.h:363
int vtkTypeBool
Definition: vtkABI.h:64
vtkArrayTypes
Definition: vtkType.h:70
vtkTypesDataObject
Definition: vtkType.h:107
int vtkTypeBool
Definition: vtkType.h:389
#define VTK_DEPRECATED_IN_9_7_0_TYPE(reason)
Definition: vtkType.h:64
#define VTK_ID_TYPE_IMPL
Definition: vtkType.h:364
#define VTK_ID_TYPE
Definition: vtkType.h:45