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 
129 /*--------------------------------------------------------------------------*/
130 /* Define a casting macro for use by the constants below. */
131 #if defined(__cplusplus)
132 # define VTK_TYPE_CAST(T, V) static_cast< T >(V)
133 #else
134 # define VTK_TYPE_CAST(T, V) ((T)(V))
135 #endif
136 
137 /*--------------------------------------------------------------------------*/
138 /* Define min/max constants for each type. */
139 #define VTK_BIT_MIN 0
140 #define VTK_BIT_MAX 1
141 #if VTK_TYPE_CHAR_IS_SIGNED
142 # define VTK_CHAR_MIN VTK_TYPE_CAST(char, 0x80)
143 # define VTK_CHAR_MAX VTK_TYPE_CAST(char, 0x7f)
144 #else
145 # define VTK_CHAR_MIN VTK_TYPE_CAST(char, 0u)
146 # define VTK_CHAR_MAX VTK_TYPE_CAST(char, 0xffu)
147 #endif
148 #define VTK_SIGNED_CHAR_MIN VTK_TYPE_CAST(signed char, 0x80)
149 #define VTK_SIGNED_CHAR_MAX VTK_TYPE_CAST(signed char, 0x7f)
150 #define VTK_UNSIGNED_CHAR_MIN VTK_TYPE_CAST(unsigned char, 0u)
151 #define VTK_UNSIGNED_CHAR_MAX VTK_TYPE_CAST(unsigned char, 0xffu)
152 #define VTK_SHORT_MIN VTK_TYPE_CAST(short, 0x8000)
153 #define VTK_SHORT_MAX VTK_TYPE_CAST(short, 0x7fff)
154 #define VTK_UNSIGNED_SHORT_MIN VTK_TYPE_CAST(unsigned short, 0u)
155 #define VTK_UNSIGNED_SHORT_MAX VTK_TYPE_CAST(unsigned short, 0xffffu)
156 #define VTK_INT_MIN VTK_TYPE_CAST(int, ~(~0u >> 1))
157 #define VTK_INT_MAX VTK_TYPE_CAST(int, ~0u >> 1)
158 #define VTK_UNSIGNED_INT_MIN VTK_TYPE_CAST(unsigned int, 0)
159 #define VTK_UNSIGNED_INT_MAX VTK_TYPE_CAST(unsigned int, ~0u)
160 #define VTK_LONG_MIN VTK_TYPE_CAST(long, ~(~0ul >> 1))
161 #define VTK_LONG_MAX VTK_TYPE_CAST(long, ~0ul >> 1)
162 #define VTK_UNSIGNED_LONG_MIN VTK_TYPE_CAST(unsigned long, 0ul)
163 #define VTK_UNSIGNED_LONG_MAX VTK_TYPE_CAST(unsigned long, ~0ul)
164 #define VTK_FLOAT_MIN VTK_TYPE_CAST(float, -1.0e+38f)
165 #define VTK_FLOAT_MAX VTK_TYPE_CAST(float, 1.0e+38f)
166 #define VTK_DOUBLE_MIN VTK_TYPE_CAST(double, -1.0e+299)
167 #define VTK_DOUBLE_MAX VTK_TYPE_CAST(double, 1.0e+299)
168 #define VTK_LONG_LONG_MIN VTK_TYPE_CAST(long long, ~(~0ull >> 1))
169 #define VTK_LONG_LONG_MAX VTK_TYPE_CAST(long long, ~0ull >> 1)
170 #define VTK_UNSIGNED_LONG_LONG_MIN VTK_TYPE_CAST(unsigned long long, 0ull)
171 #define VTK_UNSIGNED_LONG_LONG_MAX VTK_TYPE_CAST(unsigned long long, ~0ull)
172 
173 /*--------------------------------------------------------------------------*/
174 /* Define named types and constants corresponding to specific integer
175  and floating-point sizes and signedness. */
176 
177 /* Select an 8-bit integer type. */
178 #if VTK_SIZEOF_CHAR == 1
179 typedef unsigned char vtkTypeUInt8;
180 typedef signed char vtkTypeInt8;
181 # define VTK_TYPE_UINT8 VTK_UNSIGNED_CHAR
182 # define VTK_TYPE_UINT8_MIN VTK_UNSIGNED_CHAR_MIN
183 # define VTK_TYPE_UINT8_MAX VTK_UNSIGNED_CHAR_MAX
184 # if VTK_TYPE_CHAR_IS_SIGNED
185 # define VTK_TYPE_INT8 VTK_CHAR
186 # define VTK_TYPE_INT8_MIN VTK_CHAR_MIN
187 # define VTK_TYPE_INT8_MAX VTK_CHAR_MAX
188 # else
189 # define VTK_TYPE_INT8 VTK_SIGNED_CHAR
190 # define VTK_TYPE_INT8_MIN VTK_SIGNED_CHAR_MIN
191 # define VTK_TYPE_INT8_MAX VTK_SIGNED_CHAR_MAX
192 # endif
193 #else
194 # error "No native data type can represent an 8-bit integer."
195 #endif
196 
197 /* Select a 16-bit integer type. */
198 #if VTK_SIZEOF_SHORT == 2
199 typedef unsigned short vtkTypeUInt16;
200 typedef signed short vtkTypeInt16;
201 # define VTK_TYPE_UINT16 VTK_UNSIGNED_SHORT
202 # define VTK_TYPE_UINT16_MIN VTK_UNSIGNED_SHORT_MIN
203 # define VTK_TYPE_UINT16_MAX VTK_UNSIGNED_SHORT_MAX
204 # define VTK_TYPE_INT16 VTK_SHORT
205 # define VTK_TYPE_INT16_MIN VTK_SHORT_MIN
206 # define VTK_TYPE_INT16_MAX VTK_SHORT_MAX
207 #elif VTK_SIZEOF_INT == 2
208 typedef unsigned int vtkTypeUInt16;
209 typedef signed int vtkTypeInt16;
210 # define VTK_TYPE_UINT16 VTK_UNSIGNED_INT
211 # define VTK_TYPE_UINT16_MIN VTK_UNSIGNED_INT_MIN
212 # define VTK_TYPE_UINT16_MAX VTK_UNSIGNED_INT_MAX
213 # define VTK_TYPE_INT16 VTK_INT
214 # define VTK_TYPE_INT16_MIN VTK_INT_MIN
215 # define VTK_TYPE_INT16_MAX VTK_INT_MAX
216 #else
217 # error "No native data type can represent a 16-bit integer."
218 #endif
219 
220 /* Select a 32-bit integer type. */
221 #if VTK_SIZEOF_INT == 4
222 typedef unsigned int vtkTypeUInt32;
223 typedef signed int vtkTypeInt32;
224 # define VTK_TYPE_UINT32 VTK_UNSIGNED_INT
225 # define VTK_TYPE_UINT32_MIN VTK_UNSIGNED_INT_MIN
226 # define VTK_TYPE_UINT32_MAX VTK_UNSIGNED_INT_MAX
227 # define VTK_TYPE_INT32 VTK_INT
228 # define VTK_TYPE_INT32_MIN VTK_INT_MIN
229 # define VTK_TYPE_INT32_MAX VTK_INT_MAX
230 #elif VTK_SIZEOF_LONG == 4
231 typedef unsigned long vtkTypeUInt32;
232 typedef signed long vtkTypeInt32;
233 # define VTK_TYPE_UINT32 VTK_UNSIGNED_LONG
234 # define VTK_TYPE_UINT32_MIN VTK_UNSIGNED_LONG_MIN
235 # define VTK_TYPE_UINT32_MAX VTK_UNSIGNED_LONG_MAX
236 # define VTK_TYPE_INT32 VTK_LONG
237 # define VTK_TYPE_INT32_MIN VTK_LONG_MIN
238 # define VTK_TYPE_INT32_MAX VTK_LONG_MAX
239 #else
240 # error "No native data type can represent a 32-bit integer."
241 #endif
242 
243 /* Select a 64-bit integer type. */
244 #if VTK_SIZEOF_LONG_LONG == 8
245 typedef unsigned long long vtkTypeUInt64;
246 typedef signed long long vtkTypeInt64;
247 # define VTK_TYPE_UINT64 VTK_UNSIGNED_LONG_LONG
248 # define VTK_TYPE_UINT64_MIN VTK_UNSIGNED_LONG_LONG_MIN
249 # define VTK_TYPE_UINT64_MAX VTK_UNSIGNED_LONG_LONG_MAX
250 # define VTK_TYPE_INT64 VTK_LONG_LONG
251 # define VTK_TYPE_INT64_MIN VTK_LONG_LONG_MIN
252 # define VTK_TYPE_INT64_MAX VTK_LONG_LONG_MAX
253 #elif VTK_SIZEOF_LONG == 8
254 typedef unsigned long vtkTypeUInt64;
255 typedef signed long vtkTypeInt64;
256 # define VTK_TYPE_UINT64 VTK_UNSIGNED_LONG
257 # define VTK_TYPE_UINT64_MIN VTK_UNSIGNED_LONG_MIN
258 # define VTK_TYPE_UINT64_MAX VTK_UNSIGNED_LONG_MAX
259 # define VTK_TYPE_INT64 VTK_LONG
260 # define VTK_TYPE_INT64_MIN VTK_LONG_MIN
261 # define VTK_TYPE_INT64_MAX VTK_LONG_MAX
262 #else
263 # error "No native data type can represent a 64-bit integer."
264 #endif
265 
266 // Provide this define to facilitate apps that need to support older
267 // versions that do not have vtkMTimeType
268 // #ifndef VTK_HAS_MTIME_TYPE
269 // #if VTK_SIZEOF_LONG == 8
270 // typedef unsigned long vtkMTimeType;
271 // #else
272 // typedef vtkTypeUInt64 vtkMTimeType;
273 // #endif
274 // #endif
275 #define VTK_HAS_MTIME_TYPE
276 
277 // If this is a 64-bit platform, or the user has indicated that 64-bit
278 // timestamps should be used, select an unsigned 64-bit integer type
279 // for use in MTime values. If possible, use 'unsigned long' as we have
280 // historically.
281 #if defined(VTK_USE_64BIT_TIMESTAMPS) || VTK_SIZEOF_VOID_P == 8
282 # if VTK_SIZEOF_LONG == 8
283 typedef unsigned long vtkMTimeType;
284 # define VTK_MTIME_TYPE_IMPL VTK_UNSIGNED_LONG
285 # define VTK_MTIME_MIN VTK_UNSIGNED_LONG_MIN
286 # define VTK_MTIME_MAX VTK_UNSIGNED_LONG_MAX
287 # else
288 typedef vtkTypeUInt64 vtkMTimeType;
289 # define VTK_MTIME_TYPE_IMPL VTK_TYPE_UINT64
290 # define VTK_MTIME_MIN VTK_TYPE_UINT64_MIN
291 # define VTK_MTIME_MAX VTK_TYPE_UINT64_MAX
292 # endif
293 #else
294 # if VTK_SIZEOF_LONG == 4
295 typedef unsigned long vtkMTimeType;
296 # define VTK_MTIME_TYPE_IMPL VTK_UNSIGNED_LONG
297 # define VTK_MTIME_MIN VTK_UNSIGNED_LONG_MIN
298 # define VTK_MTIME_MAX VTK_UNSIGNED_LONG_MAX
299 # else
300 typedef vtkTypeUInt32 vtkMTimeType;
301 # define VTK_MTIME_TYPE_IMPL VTK_TYPE_UINT32
302 # define VTK_MTIME_MIN VTK_TYPE_UINT32_MIN
303 # define VTK_MTIME_MAX VTK_TYPE_UINT32_MAX
304 # endif
305 #endif
306 
307 /* Select a 32-bit floating point type. */
308 #if VTK_SIZEOF_FLOAT == 4
309 typedef float vtkTypeFloat32;
310 # define VTK_TYPE_FLOAT32 VTK_FLOAT
311 #else
312 # error "No native data type can represent a 32-bit floating point value."
313 #endif
314 
315 /* Select a 64-bit floating point type. */
316 #if VTK_SIZEOF_DOUBLE == 8
317 typedef double vtkTypeFloat64;
318 # define VTK_TYPE_FLOAT64 VTK_DOUBLE
319 #else
320 # error "No native data type can represent a 64-bit floating point value."
321 #endif
322 
323 /*--------------------------------------------------------------------------*/
324 /* Choose an implementation for vtkIdType. */
325 #define VTK_HAS_ID_TYPE
326 #ifdef VTK_USE_64BIT_IDS
327 # if VTK_SIZEOF_LONG_LONG == 8
328 typedef long long vtkIdType;
329 # define VTK_ID_TYPE_IMPL VTK_LONG_LONG
330 # define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_LONG_LONG
331 # define VTK_ID_MIN VTK_LONG_LONG_MIN
332 # define VTK_ID_MAX VTK_LONG_LONG_MAX
333 # define VTK_ID_TYPE_PRId "lld"
334 # elif VTK_SIZEOF_LONG == 8
335 typedef long vtkIdType;
336 # define VTK_ID_TYPE_IMPL VTK_LONG
337 # define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_LONG
338 # define VTK_ID_MIN VTK_LONG_MIN
339 # define VTK_ID_MAX VTK_LONG_MAX
340 # define VTK_ID_TYPE_PRId "ld"
341 # else
342 # error "VTK_USE_64BIT_IDS is ON but no 64-bit integer type is available."
343 # endif
344 #else
345 typedef int vtkIdType;
346 # define VTK_ID_TYPE_IMPL VTK_INT
347 # define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_INT
348 # define VTK_ID_MIN VTK_INT_MIN
349 # define VTK_ID_MAX VTK_INT_MAX
350 # define VTK_ID_TYPE_PRId "d"
351 #endif
352 
353 #ifndef __cplusplus
354  // Make sure that when VTK headers are used by the C compiler we make
355  // sure to define the bool type. This is possible when using IO features
356  // like vtkXMLWriterC.h
357  #include "stdbool.h"
358 #endif
359 
360 /*--------------------------------------------------------------------------*/
361 /* If not already defined, define vtkTypeBool. When VTK was started, some */
362 /* compilers did not yet support the bool type, and so VTK often used int, */
363 /* or more rarely unsigned int, where it should have used bool. */
364 /* Eventually vtkTypeBool will switch to real bool. */
365 #ifndef VTK_TYPE_BOOL_TYPEDEFED
366 # define VTK_TYPE_BOOL_TYPEDEFED
367 # if 1
368  typedef int vtkTypeBool;
369  typedef unsigned int vtkTypeUBool;
370 # else
371  typedef bool vtkTypeBool;
372  typedef bool vtkTypeUBool;
373 # endif
374 #endif
375 
376 
377 #if defined(__cplusplus)
378 /* Description:
379  * Returns true if data type tags a and b point to the same data type. This
380  * is intended to handle vtkIdType, which does not have the same tag as its
381  * underlying data type.
382  * @note This method is only available when included from a C++ source file. */
383 inline vtkTypeBool vtkDataTypesCompare(int a, int b)
384 {
385  return (a == b ||
386  ((a == VTK_ID_TYPE || a == VTK_ID_TYPE_IMPL) &&
387  (b == VTK_ID_TYPE || b == VTK_ID_TYPE_IMPL)));
388 }
389 #endif
390 
391 /*--------------------------------------------------------------------------*/
393 #define vtkInstantiateTemplateMacro(decl) \
394  decl<float>; \
395  decl<double>; \
396  decl<char>; \
397  decl<signed char>; \
398  decl<unsigned char>; \
399  decl<short>; \
400  decl<unsigned short>; \
401  decl<int>; \
402  decl<unsigned int>; \
403  decl<long>; \
404  decl<unsigned long>; \
405  decl<long long>; \
406  decl<unsigned long long>;
407 
409 #ifdef VTK_USE_EXTERN_TEMPLATE
410 #define vtkExternTemplateMacro(decl) \
411  vtkInstantiateTemplateMacro(decl)
412 #else
413 #define vtkExternTemplateMacro(decl)
414 #endif
415 
416 #endif
417 // VTK-HeaderTest-Exclude: vtkType.h
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
unsigned int vtkTypeUBool
Definition: vtkType.h:369
int vtkIdType
Definition: vtkType.h:345
int vtkTypeBool
Definition: vtkABI.h:69
int vtkTypeBool
Definition: vtkType.h:368
#define VTK_ID_TYPE_IMPL
Definition: vtkType.h:346
#define VTK_ID_TYPE
Definition: vtkType.h:60