VTK
vtkType.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkType.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 =========================================================================*/
15 #ifndef vtkType_h
16 #define vtkType_h
17 
18 #include "vtkConfigure.h"
19 #include "vtk_kwiml.h"
20 
21 #define VTK_SIZEOF_CHAR KWIML_ABI_SIZEOF_CHAR
22 #define VTK_SIZEOF_SHORT KWIML_ABI_SIZEOF_SHORT
23 #define VTK_SIZEOF_INT KWIML_ABI_SIZEOF_INT
24 #define VTK_SIZEOF_LONG KWIML_ABI_SIZEOF_LONG
25 #define VTK_SIZEOF_LONG_LONG KWIML_ABI_SIZEOF_LONG_LONG
26 #define VTK_SIZEOF_FLOAT KWIML_ABI_SIZEOF_FLOAT
27 #define VTK_SIZEOF_DOUBLE KWIML_ABI_SIZEOF_DOUBLE
28 #define VTK_SIZEOF_VOID_P KWIML_ABI_SIZEOF_DATA_PTR
29 
30 /* Whether type "long long" is enabled as a unique fundamental type. */
31 #define VTK_TYPE_USE_LONG_LONG
32 #if VTK_SIZEOF_LONG_LONG == 0
33 #error "No 'long long' type available."
34 #endif
35 
36 /* Whether type "char" is signed (it may be signed or unsigned). */
37 #if defined(KWIML_ABI_CHAR_IS_SIGNED)
38 #define VTK_TYPE_CHAR_IS_SIGNED 1
39 #else
40 #define VTK_TYPE_CHAR_IS_SIGNED 0
41 #endif
42 
43 /*--------------------------------------------------------------------------*/
44 /* Define a unique integer identifier for each native scalar type. */
45 
46 /* These types are returned by GetDataType to indicate pixel type. */
47 #define VTK_VOID 0
48 #define VTK_BIT 1
49 #define VTK_CHAR 2
50 #define VTK_SIGNED_CHAR 15
51 #define VTK_UNSIGNED_CHAR 3
52 #define VTK_SHORT 4
53 #define VTK_UNSIGNED_SHORT 5
54 #define VTK_INT 6
55 #define VTK_UNSIGNED_INT 7
56 #define VTK_LONG 8
57 #define VTK_UNSIGNED_LONG 9
58 #define VTK_FLOAT 10
59 #define VTK_DOUBLE 11
60 #define VTK_ID_TYPE 12
61 
62 /* These types are not currently supported by GetDataType, but are for
63  completeness. */
64 #define VTK_STRING 13
65 #define VTK_OPAQUE 14
66 
67 #define VTK_LONG_LONG 16
68 #define VTK_UNSIGNED_LONG_LONG 17
69 
70 #if !defined(VTK_LEGACY_REMOVE)
71 
72 /* Legacy. This type is never enabled. */
73 #define VTK___INT64 18
74 
75 /* Legacy. This type is never enabled. */
76 #define VTK_UNSIGNED___INT64 19
77 
78 #endif
79 
80 /* These types are required by vtkVariant and vtkVariantArray */
81 #define VTK_VARIANT 20
82 #define VTK_OBJECT 21
83 
84 /* Storage for Unicode strings */
85 #define VTK_UNICODE_STRING 22
86 
87 /*--------------------------------------------------------------------------*/
88 /* Define a unique integer identifier for each vtkDataObject type. */
89 /* When adding a new data type here, make sure to update */
90 /* vtkDataObjectTypes as well. */
91 #define VTK_POLY_DATA 0
92 #define VTK_STRUCTURED_POINTS 1
93 #define VTK_STRUCTURED_GRID 2
94 #define VTK_RECTILINEAR_GRID 3
95 #define VTK_UNSTRUCTURED_GRID 4
96 #define VTK_PIECEWISE_FUNCTION 5
97 #define VTK_IMAGE_DATA 6
98 #define VTK_DATA_OBJECT 7
99 #define VTK_DATA_SET 8
100 #define VTK_POINT_SET 9
101 #define VTK_UNIFORM_GRID 10
102 #define VTK_COMPOSITE_DATA_SET 11
103 #define VTK_MULTIGROUP_DATA_SET 12
104 #define VTK_MULTIBLOCK_DATA_SET 13
105 #define VTK_HIERARCHICAL_DATA_SET 14
106 #define VTK_HIERARCHICAL_BOX_DATA_SET 15
107 #define VTK_GENERIC_DATA_SET 16
108 #define VTK_HYPER_OCTREE 17
109 #define VTK_TEMPORAL_DATA_SET 18
110 #define VTK_TABLE 19
111 #define VTK_GRAPH 20
112 #define VTK_TREE 21
113 #define VTK_SELECTION 22
114 #define VTK_DIRECTED_GRAPH 23
115 #define VTK_UNDIRECTED_GRAPH 24
116 #define VTK_MULTIPIECE_DATA_SET 25
117 #define VTK_DIRECTED_ACYCLIC_GRAPH 26
118 #define VTK_ARRAY_DATA 27
119 #define VTK_REEB_GRAPH 28
120 #define VTK_UNIFORM_GRID_AMR 29
121 #define VTK_NON_OVERLAPPING_AMR 30
122 #define VTK_OVERLAPPING_AMR 31
123 #define VTK_HYPER_TREE_GRID 32
124 #define VTK_MOLECULE 33
125 #define VTK_PISTON_DATA_OBJECT 34
126 #define VTK_PATH 35
127 #define VTK_UNSTRUCTURED_GRID_BASE 36
128 #define VTK_PARTITIONED_DATA_SET 37
129 #define VTK_PARTITIONED_DATA_SET_COLLECTION 38
130 #define VTK_UNIFORM_HYPER_TREE_GRID 39
131 #define VTK_EXPLICIT_STRUCTURED_GRID 40
132 
133 /*--------------------------------------------------------------------------*/
134 /* Define a casting macro for use by the constants below. */
135 #if defined(__cplusplus)
136 #define VTK_TYPE_CAST(T, V) static_cast<T>(V)
137 #else
138 #define VTK_TYPE_CAST(T, V) ((T)(V))
139 #endif
140 
141 /*--------------------------------------------------------------------------*/
142 /* Define min/max constants for each type. */
143 #define VTK_BIT_MIN 0
144 #define VTK_BIT_MAX 1
145 #if VTK_TYPE_CHAR_IS_SIGNED
146 #define VTK_CHAR_MIN VTK_TYPE_CAST(char, 0x80)
147 #define VTK_CHAR_MAX VTK_TYPE_CAST(char, 0x7f)
148 #else
149 #define VTK_CHAR_MIN VTK_TYPE_CAST(char, 0u)
150 #define VTK_CHAR_MAX VTK_TYPE_CAST(char, 0xffu)
151 #endif
152 #define VTK_SIGNED_CHAR_MIN VTK_TYPE_CAST(signed char, 0x80)
153 #define VTK_SIGNED_CHAR_MAX VTK_TYPE_CAST(signed char, 0x7f)
154 #define VTK_UNSIGNED_CHAR_MIN VTK_TYPE_CAST(unsigned char, 0u)
155 #define VTK_UNSIGNED_CHAR_MAX VTK_TYPE_CAST(unsigned char, 0xffu)
156 #define VTK_SHORT_MIN VTK_TYPE_CAST(short, 0x8000)
157 #define VTK_SHORT_MAX VTK_TYPE_CAST(short, 0x7fff)
158 #define VTK_UNSIGNED_SHORT_MIN VTK_TYPE_CAST(unsigned short, 0u)
159 #define VTK_UNSIGNED_SHORT_MAX VTK_TYPE_CAST(unsigned short, 0xffffu)
160 #define VTK_INT_MIN VTK_TYPE_CAST(int, ~(~0u >> 1))
161 #define VTK_INT_MAX VTK_TYPE_CAST(int, ~0u >> 1)
162 #define VTK_UNSIGNED_INT_MIN VTK_TYPE_CAST(unsigned int, 0)
163 #define VTK_UNSIGNED_INT_MAX VTK_TYPE_CAST(unsigned int, ~0u)
164 #define VTK_LONG_MIN VTK_TYPE_CAST(long, ~(~0ul >> 1))
165 #define VTK_LONG_MAX VTK_TYPE_CAST(long, ~0ul >> 1)
166 #define VTK_UNSIGNED_LONG_MIN VTK_TYPE_CAST(unsigned long, 0ul)
167 #define VTK_UNSIGNED_LONG_MAX VTK_TYPE_CAST(unsigned long, ~0ul)
168 #define VTK_FLOAT_MIN VTK_TYPE_CAST(float, -1.0e+38f)
169 #define VTK_FLOAT_MAX VTK_TYPE_CAST(float, 1.0e+38f)
170 #define VTK_DOUBLE_MIN VTK_TYPE_CAST(double, -1.0e+299)
171 #define VTK_DOUBLE_MAX VTK_TYPE_CAST(double, 1.0e+299)
172 #define VTK_LONG_LONG_MIN VTK_TYPE_CAST(long long, ~(~0ull >> 1))
173 #define VTK_LONG_LONG_MAX VTK_TYPE_CAST(long long, ~0ull >> 1)
174 #define VTK_UNSIGNED_LONG_LONG_MIN VTK_TYPE_CAST(unsigned long long, 0ull)
175 #define VTK_UNSIGNED_LONG_LONG_MAX VTK_TYPE_CAST(unsigned long long, ~0ull)
176 
177 /*--------------------------------------------------------------------------*/
178 /* Define named types and constants corresponding to specific integer
179  and floating-point sizes and signedness. */
180 
181 /* Select an 8-bit integer type. */
182 #if VTK_SIZEOF_CHAR == 1
183 typedef unsigned char vtkTypeUInt8;
184 typedef signed char vtkTypeInt8;
185 #define VTK_TYPE_UINT8 VTK_UNSIGNED_CHAR
186 #define VTK_TYPE_UINT8_MIN VTK_UNSIGNED_CHAR_MIN
187 #define VTK_TYPE_UINT8_MAX VTK_UNSIGNED_CHAR_MAX
188 #if VTK_TYPE_CHAR_IS_SIGNED
189 #define VTK_TYPE_INT8 VTK_CHAR
190 #define VTK_TYPE_INT8_MIN VTK_CHAR_MIN
191 #define VTK_TYPE_INT8_MAX VTK_CHAR_MAX
192 #else
193 #define VTK_TYPE_INT8 VTK_SIGNED_CHAR
194 #define VTK_TYPE_INT8_MIN VTK_SIGNED_CHAR_MIN
195 #define VTK_TYPE_INT8_MAX VTK_SIGNED_CHAR_MAX
196 #endif
197 #else
198 #error "No native data type can represent an 8-bit integer."
199 #endif
200 
201 /* Select a 16-bit integer type. */
202 #if VTK_SIZEOF_SHORT == 2
203 typedef unsigned short vtkTypeUInt16;
204 typedef signed short vtkTypeInt16;
205 #define VTK_TYPE_UINT16 VTK_UNSIGNED_SHORT
206 #define VTK_TYPE_UINT16_MIN VTK_UNSIGNED_SHORT_MIN
207 #define VTK_TYPE_UINT16_MAX VTK_UNSIGNED_SHORT_MAX
208 #define VTK_TYPE_INT16 VTK_SHORT
209 #define VTK_TYPE_INT16_MIN VTK_SHORT_MIN
210 #define VTK_TYPE_INT16_MAX VTK_SHORT_MAX
211 #elif VTK_SIZEOF_INT == 2
212 typedef unsigned int vtkTypeUInt16;
213 typedef signed int vtkTypeInt16;
214 #define VTK_TYPE_UINT16 VTK_UNSIGNED_INT
215 #define VTK_TYPE_UINT16_MIN VTK_UNSIGNED_INT_MIN
216 #define VTK_TYPE_UINT16_MAX VTK_UNSIGNED_INT_MAX
217 #define VTK_TYPE_INT16 VTK_INT
218 #define VTK_TYPE_INT16_MIN VTK_INT_MIN
219 #define VTK_TYPE_INT16_MAX VTK_INT_MAX
220 #else
221 #error "No native data type can represent a 16-bit integer."
222 #endif
223 
224 /* Select a 32-bit integer type. */
225 #if VTK_SIZEOF_INT == 4
226 typedef unsigned int vtkTypeUInt32;
227 typedef signed int vtkTypeInt32;
228 #define VTK_TYPE_UINT32 VTK_UNSIGNED_INT
229 #define VTK_TYPE_UINT32_MIN VTK_UNSIGNED_INT_MIN
230 #define VTK_TYPE_UINT32_MAX VTK_UNSIGNED_INT_MAX
231 #define VTK_TYPE_INT32 VTK_INT
232 #define VTK_TYPE_INT32_MIN VTK_INT_MIN
233 #define VTK_TYPE_INT32_MAX VTK_INT_MAX
234 #elif VTK_SIZEOF_LONG == 4
235 typedef unsigned long vtkTypeUInt32;
236 typedef signed long vtkTypeInt32;
237 #define VTK_TYPE_UINT32 VTK_UNSIGNED_LONG
238 #define VTK_TYPE_UINT32_MIN VTK_UNSIGNED_LONG_MIN
239 #define VTK_TYPE_UINT32_MAX VTK_UNSIGNED_LONG_MAX
240 #define VTK_TYPE_INT32 VTK_LONG
241 #define VTK_TYPE_INT32_MIN VTK_LONG_MIN
242 #define VTK_TYPE_INT32_MAX VTK_LONG_MAX
243 #else
244 #error "No native data type can represent a 32-bit integer."
245 #endif
246 
247 /* Select a 64-bit integer type. */
248 #if VTK_SIZEOF_LONG_LONG == 8
249 typedef unsigned long long vtkTypeUInt64;
250 typedef signed long long vtkTypeInt64;
251 #define VTK_TYPE_UINT64 VTK_UNSIGNED_LONG_LONG
252 #define VTK_TYPE_UINT64_MIN VTK_UNSIGNED_LONG_LONG_MIN
253 #define VTK_TYPE_UINT64_MAX VTK_UNSIGNED_LONG_LONG_MAX
254 #define VTK_TYPE_INT64 VTK_LONG_LONG
255 #define VTK_TYPE_INT64_MIN VTK_LONG_LONG_MIN
256 #define VTK_TYPE_INT64_MAX VTK_LONG_LONG_MAX
257 #elif VTK_SIZEOF_LONG == 8
258 typedef unsigned long vtkTypeUInt64;
259 typedef signed long vtkTypeInt64;
260 #define VTK_TYPE_UINT64 VTK_UNSIGNED_LONG
261 #define VTK_TYPE_UINT64_MIN VTK_UNSIGNED_LONG_MIN
262 #define VTK_TYPE_UINT64_MAX VTK_UNSIGNED_LONG_MAX
263 #define VTK_TYPE_INT64 VTK_LONG
264 #define VTK_TYPE_INT64_MIN VTK_LONG_MIN
265 #define VTK_TYPE_INT64_MAX VTK_LONG_MAX
266 #else
267 #error "No native data type can represent a 64-bit integer."
268 #endif
269 
270 // Provide this define to facilitate apps that need to support older
271 // versions that do not have vtkMTimeType
272 // #ifndef VTK_HAS_MTIME_TYPE
273 // #if VTK_SIZEOF_LONG == 8
274 // typedef unsigned long vtkMTimeType;
275 // #else
276 // typedef vtkTypeUInt64 vtkMTimeType;
277 // #endif
278 // #endif
279 #define VTK_HAS_MTIME_TYPE
280 
281 // If this is a 64-bit platform, or the user has indicated that 64-bit
282 // timestamps should be used, select an unsigned 64-bit integer type
283 // for use in MTime values. If possible, use 'unsigned long' as we have
284 // historically.
285 #if defined(VTK_USE_64BIT_TIMESTAMPS) || VTK_SIZEOF_VOID_P == 8
286 #if VTK_SIZEOF_LONG == 8
287 typedef unsigned long vtkMTimeType;
288 #define VTK_MTIME_TYPE_IMPL VTK_UNSIGNED_LONG
289 #define VTK_MTIME_MIN VTK_UNSIGNED_LONG_MIN
290 #define VTK_MTIME_MAX VTK_UNSIGNED_LONG_MAX
291 #else
292 typedef vtkTypeUInt64 vtkMTimeType;
293 #define VTK_MTIME_TYPE_IMPL VTK_TYPE_UINT64
294 #define VTK_MTIME_MIN VTK_TYPE_UINT64_MIN
295 #define VTK_MTIME_MAX VTK_TYPE_UINT64_MAX
296 #endif
297 #else
298 #if VTK_SIZEOF_LONG == 4
299 typedef unsigned long vtkMTimeType;
300 #define VTK_MTIME_TYPE_IMPL VTK_UNSIGNED_LONG
301 #define VTK_MTIME_MIN VTK_UNSIGNED_LONG_MIN
302 #define VTK_MTIME_MAX VTK_UNSIGNED_LONG_MAX
303 #else
304 typedef vtkTypeUInt32 vtkMTimeType;
305 #define VTK_MTIME_TYPE_IMPL VTK_TYPE_UINT32
306 #define VTK_MTIME_MIN VTK_TYPE_UINT32_MIN
307 #define VTK_MTIME_MAX VTK_TYPE_UINT32_MAX
308 #endif
309 #endif
310 
311 /* Select a 32-bit floating point type. */
312 #if VTK_SIZEOF_FLOAT == 4
313 typedef float vtkTypeFloat32;
314 #define VTK_TYPE_FLOAT32 VTK_FLOAT
315 #else
316 #error "No native data type can represent a 32-bit floating point value."
317 #endif
318 
319 /* Select a 64-bit floating point type. */
320 #if VTK_SIZEOF_DOUBLE == 8
321 typedef double vtkTypeFloat64;
322 #define VTK_TYPE_FLOAT64 VTK_DOUBLE
323 #else
324 #error "No native data type can represent a 64-bit floating point value."
325 #endif
326 
327 /*--------------------------------------------------------------------------*/
328 /* Choose an implementation for vtkIdType. */
329 #define VTK_HAS_ID_TYPE
330 #ifdef VTK_USE_64BIT_IDS
331 #if VTK_SIZEOF_LONG_LONG == 8
332 typedef long long vtkIdType;
333 #define VTK_ID_TYPE_IMPL VTK_LONG_LONG
334 #define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_LONG_LONG
335 #define VTK_ID_MIN VTK_LONG_LONG_MIN
336 #define VTK_ID_MAX VTK_LONG_LONG_MAX
337 #define VTK_ID_TYPE_PRId "lld"
338 #elif VTK_SIZEOF_LONG == 8
339 typedef long vtkIdType;
340 #define VTK_ID_TYPE_IMPL VTK_LONG
341 #define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_LONG
342 #define VTK_ID_MIN VTK_LONG_MIN
343 #define VTK_ID_MAX VTK_LONG_MAX
344 #define VTK_ID_TYPE_PRId "ld"
345 #else
346 #error "VTK_USE_64BIT_IDS is ON but no 64-bit integer type is available."
347 #endif
348 #else
349 typedef int vtkIdType;
350 #define VTK_ID_TYPE_IMPL VTK_INT
351 #define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_INT
352 #define VTK_ID_MIN VTK_INT_MIN
353 #define VTK_ID_MAX VTK_INT_MAX
354 #define VTK_ID_TYPE_PRId "d"
355 #endif
356 
357 #ifndef __cplusplus
358 // Make sure that when VTK headers are used by the C compiler we make
359 // sure to define the bool type. This is possible when using IO features
360 // like vtkXMLWriterC.h
361 #include "stdbool.h"
362 #endif
363 
364 /*--------------------------------------------------------------------------*/
365 /* If not already defined, define vtkTypeBool. When VTK was started, some */
366 /* compilers did not yet support the bool type, and so VTK often used int, */
367 /* or more rarely unsigned int, where it should have used bool. */
368 /* Eventually vtkTypeBool will switch to real bool. */
369 #ifndef VTK_TYPE_BOOL_TYPEDEFED
370 #define VTK_TYPE_BOOL_TYPEDEFED
371 #if 1
372 typedef int vtkTypeBool;
373 typedef unsigned int vtkTypeUBool;
374 #else
375 typedef bool vtkTypeBool;
376 typedef bool vtkTypeUBool;
377 #endif
378 #endif
379 
380 #if defined(__cplusplus)
381 /* Description:
382  * Returns true if data type tags a and b point to the same data type. This
383  * is intended to handle vtkIdType, which does not have the same tag as its
384  * underlying data type.
385  * @note This method is only available when included from a C++ source file. */
386 inline vtkTypeBool vtkDataTypesCompare(int a, int b)
387 {
388  return (a == b ||
389  ((a == VTK_ID_TYPE || a == VTK_ID_TYPE_IMPL) && (b == VTK_ID_TYPE || b == VTK_ID_TYPE_IMPL)));
390 }
391 #endif
392 
393 /*--------------------------------------------------------------------------*/
395 #define vtkInstantiateTemplateMacro(decl) \
396  decl<float>; \
397  decl<double>; \
398  decl<char>; \
399  decl<signed char>; \
400  decl<unsigned char>; \
401  decl<short>; \
402  decl<unsigned short>; \
403  decl<int>; \
404  decl<unsigned int>; \
405  decl<long>; \
406  decl<unsigned long>; \
407  decl<long long>; \
408  decl<unsigned long long>
409 
411 #ifdef VTK_USE_EXTERN_TEMPLATE
412 #define vtkExternTemplateMacro(decl) vtkInstantiateTemplateMacro(decl)
413 #else
414 #define vtkExternTemplateMacro(decl)
415 #endif
416 
417 #endif
418 // VTK-HeaderTest-Exclude: vtkType.h
vtkIdType
int vtkIdType
Definition: vtkType.h:349
vtkTypeUBool
unsigned int vtkTypeUBool
Definition: vtkType.h:373
VTK_ID_TYPE_IMPL
#define VTK_ID_TYPE_IMPL
Definition: vtkType.h:350
VTK_ID_TYPE
#define VTK_ID_TYPE
Definition: vtkType.h:60
vtkTypeBool
int vtkTypeBool
Definition: vtkType.h:372
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:304