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 
20 /*--------------------------------------------------------------------------*/
21 /* Define a unique integer identifier for each native scalar type. */
22 
23 /* These types are returned by GetDataType to indicate pixel type. */
24 #define VTK_VOID 0
25 #define VTK_BIT 1
26 #define VTK_CHAR 2
27 #define VTK_SIGNED_CHAR 15
28 #define VTK_UNSIGNED_CHAR 3
29 #define VTK_SHORT 4
30 #define VTK_UNSIGNED_SHORT 5
31 #define VTK_INT 6
32 #define VTK_UNSIGNED_INT 7
33 #define VTK_LONG 8
34 #define VTK_UNSIGNED_LONG 9
35 #define VTK_FLOAT 10
36 #define VTK_DOUBLE 11
37 #define VTK_ID_TYPE 12
38 
39 /* These types are not currently supported by GetDataType, but are for
40  completeness. */
41 #define VTK_STRING 13
42 #define VTK_OPAQUE 14
43 
44 #define VTK_LONG_LONG 16
45 #define VTK_UNSIGNED_LONG_LONG 17
46 
47 /* Legacy. This type is never enabled. */
48 #define VTK___INT64 18
49 
50 /* Legacy. This type is never enabled. */
51 #define VTK_UNSIGNED___INT64 19
52 
53 /* These types are required by vtkVariant and vtkVariantArray */
54 #define VTK_VARIANT 20
55 #define VTK_OBJECT 21
56 
57 /* Storage for Unicode strings */
58 #define VTK_UNICODE_STRING 22
59 
60 /*--------------------------------------------------------------------------*/
61 /* Define a unique integer identifier for each vtkDataObject type. */
62 /* When adding a new data type here, make sure to update */
63 /* vtkDataObjectTypes as well. */
64 #define VTK_POLY_DATA 0
65 #define VTK_STRUCTURED_POINTS 1
66 #define VTK_STRUCTURED_GRID 2
67 #define VTK_RECTILINEAR_GRID 3
68 #define VTK_UNSTRUCTURED_GRID 4
69 #define VTK_PIECEWISE_FUNCTION 5
70 #define VTK_IMAGE_DATA 6
71 #define VTK_DATA_OBJECT 7
72 #define VTK_DATA_SET 8
73 #define VTK_POINT_SET 9
74 #define VTK_UNIFORM_GRID 10
75 #define VTK_COMPOSITE_DATA_SET 11
76 #define VTK_MULTIGROUP_DATA_SET 12
77 #define VTK_MULTIBLOCK_DATA_SET 13
78 #define VTK_HIERARCHICAL_DATA_SET 14
79 #define VTK_HIERARCHICAL_BOX_DATA_SET 15
80 #define VTK_GENERIC_DATA_SET 16
81 #define VTK_HYPER_OCTREE 17
82 #define VTK_TEMPORAL_DATA_SET 18
83 #define VTK_TABLE 19
84 #define VTK_GRAPH 20
85 #define VTK_TREE 21
86 #define VTK_SELECTION 22
87 #define VTK_DIRECTED_GRAPH 23
88 #define VTK_UNDIRECTED_GRAPH 24
89 #define VTK_MULTIPIECE_DATA_SET 25
90 #define VTK_DIRECTED_ACYCLIC_GRAPH 26
91 #define VTK_ARRAY_DATA 27
92 #define VTK_REEB_GRAPH 28
93 #define VTK_UNIFORM_GRID_AMR 29
94 #define VTK_NON_OVERLAPPING_AMR 30
95 #define VTK_OVERLAPPING_AMR 31
96 #define VTK_HYPER_TREE_GRID 32
97 #define VTK_MOLECULE 33
98 #define VTK_PISTON_DATA_OBJECT 34
99 #define VTK_PATH 35
100 #define VTK_UNSTRUCTURED_GRID_BASE 36
101 
102 /*--------------------------------------------------------------------------*/
103 /* Define a casting macro for use by the constants below. */
104 #if defined(__cplusplus)
105 # define VTK_TYPE_CAST(T, V) static_cast< T >(V)
106 #else
107 # define VTK_TYPE_CAST(T, V) ((T)(V))
108 #endif
109 
110 /*--------------------------------------------------------------------------*/
111 /* Define min/max constants for each type. */
112 #define VTK_BIT_MIN 0
113 #define VTK_BIT_MAX 1
114 #if VTK_TYPE_CHAR_IS_SIGNED
115 # define VTK_CHAR_MIN VTK_TYPE_CAST(char, 0x80)
116 # define VTK_CHAR_MAX VTK_TYPE_CAST(char, 0x7f)
117 #else
118 # define VTK_CHAR_MIN VTK_TYPE_CAST(char, 0u)
119 # define VTK_CHAR_MAX VTK_TYPE_CAST(char, 0xffu)
120 #endif
121 #define VTK_SIGNED_CHAR_MIN VTK_TYPE_CAST(signed char, 0x80)
122 #define VTK_SIGNED_CHAR_MAX VTK_TYPE_CAST(signed char, 0x7f)
123 #define VTK_UNSIGNED_CHAR_MIN VTK_TYPE_CAST(unsigned char, 0u)
124 #define VTK_UNSIGNED_CHAR_MAX VTK_TYPE_CAST(unsigned char, 0xffu)
125 #define VTK_SHORT_MIN VTK_TYPE_CAST(short, 0x8000)
126 #define VTK_SHORT_MAX VTK_TYPE_CAST(short, 0x7fff)
127 #define VTK_UNSIGNED_SHORT_MIN VTK_TYPE_CAST(unsigned short, 0u)
128 #define VTK_UNSIGNED_SHORT_MAX VTK_TYPE_CAST(unsigned short, 0xffffu)
129 #define VTK_INT_MIN VTK_TYPE_CAST(int, ~(~0u >> 1))
130 #define VTK_INT_MAX VTK_TYPE_CAST(int, ~0u >> 1)
131 #define VTK_UNSIGNED_INT_MIN VTK_TYPE_CAST(unsigned int, 0)
132 #define VTK_UNSIGNED_INT_MAX VTK_TYPE_CAST(unsigned int, ~0u)
133 #define VTK_LONG_MIN VTK_TYPE_CAST(long, ~(~0ul >> 1))
134 #define VTK_LONG_MAX VTK_TYPE_CAST(long, ~0ul >> 1)
135 #define VTK_UNSIGNED_LONG_MIN VTK_TYPE_CAST(unsigned long, 0ul)
136 #define VTK_UNSIGNED_LONG_MAX VTK_TYPE_CAST(unsigned long, ~0ul)
137 #define VTK_FLOAT_MIN VTK_TYPE_CAST(float, -1.0e+38f)
138 #define VTK_FLOAT_MAX VTK_TYPE_CAST(float, 1.0e+38f)
139 #define VTK_DOUBLE_MIN VTK_TYPE_CAST(double, -1.0e+299)
140 #define VTK_DOUBLE_MAX VTK_TYPE_CAST(double, 1.0e+299)
141 #if defined(VTK_SIZEOF_LONG_LONG)
142 # define VTK_LONG_LONG_MIN VTK_TYPE_CAST(long long, ~(~0ull >> 1))
143 # define VTK_LONG_LONG_MAX VTK_TYPE_CAST(long long, ~0ull >> 1)
144 # define VTK_UNSIGNED_LONG_LONG_MIN VTK_TYPE_CAST(unsigned long long, 0ull)
145 # define VTK_UNSIGNED_LONG_LONG_MAX VTK_TYPE_CAST(unsigned long long, ~0ull)
146 #endif
147 
148 /*--------------------------------------------------------------------------*/
149 /* Define named types and constants corresponding to specific integer
150  and floating-point sizes and signedness. */
151 
152 /* Select an 8-bit integer type. */
153 #if VTK_SIZEOF_CHAR == 1
154 typedef unsigned char vtkTypeUInt8;
155 typedef signed char vtkTypeInt8;
156 # define VTK_TYPE_UINT8 VTK_UNSIGNED_CHAR
157 # if VTK_TYPE_CHAR_IS_SIGNED
158 # define VTK_TYPE_INT8 VTK_CHAR
159 # else
160 # define VTK_TYPE_INT8 VTK_SIGNED_CHAR
161 # endif
162 #else
163 # error "No native data type can represent an 8-bit integer."
164 #endif
165 
166 /* Select a 16-bit integer type. */
167 #if VTK_SIZEOF_SHORT == 2
168 typedef unsigned short vtkTypeUInt16;
169 typedef signed short vtkTypeInt16;
170 # define VTK_TYPE_UINT16 VTK_UNSIGNED_SHORT
171 # define VTK_TYPE_INT16 VTK_SHORT
172 #elif VTK_SIZEOF_INT == 2
173 typedef unsigned int vtkTypeUInt16;
174 typedef signed int vtkTypeInt16;
175 # define VTK_TYPE_UINT16 VTK_UNSIGNED_INT
176 # define VTK_TYPE_INT16 VTK_INT
177 #else
178 # error "No native data type can represent a 16-bit integer."
179 #endif
180 
181 /* Select a 32-bit integer type. */
182 #if VTK_SIZEOF_INT == 4
183 typedef unsigned int vtkTypeUInt32;
184 typedef signed int vtkTypeInt32;
185 # define VTK_TYPE_UINT32 VTK_UNSIGNED_INT
186 # define VTK_TYPE_INT32 VTK_INT
187 #elif VTK_SIZEOF_LONG == 4
188 typedef unsigned long vtkTypeUInt32;
189 typedef signed long vtkTypeInt32;
190 # define VTK_TYPE_UINT32 VTK_UNSIGNED_LONG
191 # define VTK_TYPE_INT32 VTK_LONG
192 #else
193 # error "No native data type can represent a 32-bit integer."
194 #endif
195 
196 /* Select a 64-bit integer type. */
197 #if VTK_SIZEOF_LONG_LONG == 8
198 typedef unsigned long long vtkTypeUInt64;
199 typedef signed long long vtkTypeInt64;
200 # define VTK_TYPE_UINT64 VTK_UNSIGNED_LONG_LONG
201 # define VTK_TYPE_INT64 VTK_LONG_LONG
202 #elif VTK_SIZEOF_LONG == 8
203 typedef unsigned long vtkTypeUInt64;
204 typedef signed long vtkTypeInt64;
205 # define VTK_TYPE_UINT64 VTK_UNSIGNED_LONG
206 # define VTK_TYPE_INT64 VTK_LONG
207 #else
208 # error "No native data type can represent a 64-bit integer."
209 #endif
210 
211 /* Select a 32-bit floating point type. */
212 #if VTK_SIZEOF_FLOAT == 4
213 typedef float vtkTypeFloat32;
214 # define VTK_TYPE_FLOAT32 VTK_FLOAT
215 #else
216 # error "No native data type can represent a 32-bit floating point value."
217 #endif
218 
219 /* Select a 64-bit floating point type. */
220 #if VTK_SIZEOF_DOUBLE == 8
221 typedef double vtkTypeFloat64;
222 # define VTK_TYPE_FLOAT64 VTK_DOUBLE
223 #else
224 # error "No native data type can represent a 64-bit floating point value."
225 #endif
226 
227 /*--------------------------------------------------------------------------*/
228 /* Choose an implementation for vtkIdType. */
229 #define VTK_HAS_ID_TYPE
230 #ifdef VTK_USE_64BIT_IDS
231 # if VTK_SIZEOF_LONG_LONG == 8
232 typedef long long vtkIdType;
233 # define VTK_ID_TYPE_IMPL VTK_LONG_LONG
234 # define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_LONG_LONG
235 # define VTK_ID_MIN VTK_LONG_LONG_MIN
236 # define VTK_ID_MAX VTK_LONG_LONG_MAX
237 # elif VTK_SIZEOF_LONG == 8
238 typedef long vtkIdType;
239 # define VTK_ID_TYPE_IMPL VTK_LONG
240 # define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_LONG
241 # define VTK_ID_MIN VTK_LONG_MIN
242 # define VTK_ID_MAX VTK_LONG_MAX
243 # else
244 # error "VTK_USE_64BIT_IDS is ON but no 64-bit integer type is available."
245 # endif
246 #else
247 typedef int vtkIdType;
248 # define VTK_ID_TYPE_IMPL VTK_INT
249 # define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_INT
250 # define VTK_ID_MIN VTK_INT_MIN
251 # define VTK_ID_MAX VTK_INT_MAX
252 #endif
253 
254 #if defined(__cplusplus)
255 /* Description:
256  * Returns true if data type tags a and b point to the same data type. This
257  * is intended to handle vtkIdType, which does not have the same tag as its
258  * underlying data type.
259  * @note This method is only available when included from a C++ source file. */
260 inline int vtkDataTypesCompare(int a, int b)
261 {
262  return (a == b ||
263  ((a == VTK_ID_TYPE || a == VTK_ID_TYPE_IMPL) &&
264  (b == VTK_ID_TYPE || b == VTK_ID_TYPE_IMPL)));
265 }
266 #endif
267 
268 #endif
269 // VTK-HeaderTest-Exclude: vtkType.h
int vtkIdType
Definition: vtkType.h:247
#define VTK_ID_TYPE_IMPL
Definition: vtkType.h:248
#define VTK_ID_TYPE
Definition: vtkType.h:37