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