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