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