Forward compatibility: flex
[foam-extend-3.2.git] / applications / utilities / postProcessing / dataConversion / foamToTecplot360 / tecio / tecsrc / DATASET0.h
blob5bae65ce3d27ce5d59276efc0249ca697d72f0ac
1 /*
2 * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM
4 * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide.
6 * Tecplot hereby grants OpenCFD limited authority to distribute without
7 * alteration the source code to the Tecplot Input/Output library, known
8 * as TecIO, as part of its distribution of OpenFOAM and the
9 * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby
10 * granted access to the TecIO source code, and may redistribute it for the
11 * purpose of maintaining the converter. However, no authority is granted
12 * to alter the TecIO source code in any form or manner.
14 * This limited grant of distribution does not supersede Tecplot, Inc.'s
15 * copyright in TecIO. Contact Tecplot, Inc. for further information.
17 * Tecplot, Inc.
18 * 3535 Factoria Blvd, Ste. 550
19 * Bellevue, WA 98006, USA
20 * Phone: +1 425 653 1200
21 * http://www.tecplot.com/
24 #if defined EXTERN
25 #undef EXTERN
26 #endif
27 #if defined DATASET0MODULE
28 #define EXTERN
29 #else
30 #define EXTERN extern
31 #endif
34 ******************************************************************
35 ******************************************************************
36 ******* ********
37 ****** (C) 1988-2008 Tecplot, Inc. *******
38 ******* ********
39 ******************************************************************
40 ******************************************************************
43 namespace tecplot
45 namespace io
47 class File;
51 EXTERN void OutOfMemoryMsg(void);
54 * Turn on DEBUG_FIELDVALUES by default in any build with assertions on
55 * (including checked builds), but allow turning this off with
56 * NO_DEBUG_FIELDVALUES
58 #if !defined NO_ASSERTS && !defined NO_DEBUG_FIELDVALUES && !defined DEBUG_FIELDVALUES
59 #define DEBUG_FIELDVALUES
60 #endif
62 /* FieldData_a is intentionally not defined to further
63 * deter usage of this private structure */
64 struct _FieldData_a
66 void *Data; /* ...placed first in the structure for fastest access */
67 # if defined TECPLOTKERNEL
68 /* CORE SOURCE CODE REMOVED */
69 # else
70 void *GetValueCallback[1]; /* ...this field is for TecIO only */
71 void *SetValueCallback[1]; /* ...this field is for TecIO only */
72 # endif
74 /* PRIVATE */
75 FieldDataType_e Type;
76 ValueLocation_e ValueLocation;
77 LgIndex_t RefCount;
78 LgIndex_t VarShareRefCount;
79 LgIndex_t NumValues;
80 # if defined TECPLOTKERNEL /* TecIO doesn't require these features yet. */
81 /* CORE SOURCE CODE REMOVED */
82 # endif
86 /* *
87 * * NOTE: "FieldData_pa" here is an "abstract type".
88 * * Any routines dealing with the internals workings
89 * * of FieldData_pa must be in the same file as these
90 * * routines
91 * */
93 #if defined USE_MACROS_FOR_FUNCTIONS
94 #define USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
95 #endif
98 * These are low-level (private) FD manipulation functions. In
99 * most cases, you should use some higher-level function. These
100 * macros are supplied for the dataset functions to use.
102 #if defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
103 #define GetFieldDataType GetFieldDataType_MACRO
104 #define GetFieldDataGetFunction GetFieldDataGetFunction_MACRO
105 #define GetFieldDataSetFunction GetFieldDataSetFunction_MACRO
106 #define GetFieldDataNumValues GetFieldDataNumValues_MACRO
107 #define GetFieldDataValueLocation GetFieldDataValueLocation_MACRO
108 #define IsFieldDataDirectAccessAllowed IsFieldDataDirectAccessAllowed_MACRO
109 #else
110 #define GetFieldDataType GetFieldDataType_FUNC
111 #define GetFieldDataGetFunction GetFieldDataGetFunction_FUNC
112 #define GetFieldDataSetFunction GetFieldDataSetFunction_FUNC
113 #define GetFieldDataNumValues GetFieldDataNumValues_FUNC
114 #define GetFieldDataValueLocation GetFieldDataValueLocation_FUNC
115 #define IsFieldDataDirectAccessAllowed IsFieldDataDirectAccessAllowed_FUNC
116 #endif
118 #define GetFieldDataType_MACRO(FieldData) ((FieldData)->Type)
119 #if defined TECPLOTKERNEL
120 /* CORE SOURCE CODE REMOVED */
121 #else /* ...for TecIO only */
122 #define GetFieldDataGetFunction_MACRO(FieldData) ((FieldValueGetFunction_pf)(FieldData)->GetValueCallback[0])
123 #define GetFieldDataSetFunction_MACRO(FieldData) ((FieldValueSetFunction_pf)(FieldData)->SetValueCallback[0])
124 #endif
125 #define GetFieldDataNumValues_MACRO(FieldData) ((FieldData)->NumValues)
126 #define GetFieldDataValueLocation_MACRO(FieldData) ((FieldData)->ValueLocation)
128 EXTERN double STDCALL GetFieldValueForFloat(const FieldData_pa fd, LgIndex_t pt);
129 EXTERN double STDCALL GetFieldValueForDouble(const FieldData_pa fd, LgIndex_t pt);
130 EXTERN double STDCALL GetFieldValueForInt32(const FieldData_pa fd, LgIndex_t pt);
131 EXTERN double STDCALL GetFieldValueForInt16(const FieldData_pa fd, LgIndex_t pt);
132 EXTERN double STDCALL GetFieldValueForByte(const FieldData_pa fd, LgIndex_t pt);
133 EXTERN double STDCALL GetFieldValueForBit(const FieldData_pa fd, LgIndex_t pt);
135 #if defined TECPLOTKERNEL
136 /* CORE SOURCE CODE REMOVED */
137 #else
138 #define IsFieldDataDirectAccessAllowed_MACRO(FieldData) ((FieldData)->Data != NULL)
139 #endif
141 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
142 EXTERN FieldDataType_e GetFieldDataType_FUNC(FieldData_pa FieldData);
143 EXTERN FieldValueGetFunction_pf GetFieldDataGetFunction_FUNC(FieldData_pa FieldData);
144 EXTERN FieldValueSetFunction_pf GetFieldDataSetFunction_FUNC(FieldData_pa FieldData);
145 EXTERN LgIndex_t GetFieldDataNumValues_FUNC(FieldData_pa FieldData);
146 EXTERN ValueLocation_e GetFieldDataValueLocation_FUNC(FieldData_pa FieldData);
147 EXTERN Boolean_t IsFieldDataDirectAccessAllowed_FUNC(FieldData_pa FieldData);
148 #endif
152 * Use separate types for reversed byte data than unreversed data so we
153 * have better compiler checking.
155 typedef UInt32_t FloatRev_t;
156 typedef UInt64_t DoubleRev_t;
157 typedef UInt16_t Int16Rev_t;
158 typedef UInt32_t Int32Rev_t;
159 typedef UInt64_t Int64Rev_t;
163 * Note: there are so many GetFieldData*Ptr functions because we
164 * want a bunch of error checking. The Type and TypeRev check
165 * for that type. The Byte, 2Byte, etc. just make sure it is
166 * that type.
167 * GetFieldDataVoidPtr checks nothing, and thus should only be
168 * used with extreme caution (that is, checking the alignment
169 * and byte order by hand).
171 #if defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
172 #define GetFieldDataFloatPtr GetFieldDataFloatPtr_MACRO
173 #define GetFieldDataFloatRevPtr GetFieldDataFloatRevPtr_MACRO
174 #define GetFieldDataDoublePtr GetFieldDataDoublePtr_MACRO
175 #define GetFieldDataDoubleRevPtr GetFieldDataDoubleRevPtr_MACRO
176 #define GetFieldDataInt64Ptr GetFieldDataInt64Ptr_MACRO
177 #define GetFieldDataInt64RevPtr GetFieldDataInt64RevPtr_MACRO
178 #define GetFieldDataInt32Ptr GetFieldDataInt32Ptr_MACRO
179 #define GetFieldDataInt32RevPtr GetFieldDataInt32RevPtr_MACRO
180 #define GetFieldDataInt16Ptr GetFieldDataInt16Ptr_MACRO
181 #define GetFieldDataInt16RevPtr GetFieldDataInt16RevPtr_MACRO
182 #define GetFieldDataBytePtr GetFieldDataBytePtr_MACRO
183 #define GetFieldData2BytePtr GetFieldData2BytePtr_MACRO
184 #define GetFieldData4BytePtr GetFieldData4BytePtr_MACRO
185 #define GetFieldData8BytePtr GetFieldData8BytePtr_MACRO
186 #define GetFieldDataVoidPtr GetFieldDataVoidPtr_MACRO /*danger:see above*/
187 #else
188 #define GetFieldDataFloatPtr GetFieldDataFloatPtr_FUNC
189 #define GetFieldDataFloatRevPtr GetFieldDataFloatRevPtr_FUNC
190 #define GetFieldDataDoublePtr GetFieldDataDoublePtr_FUNC
191 #define GetFieldDataDoubleRevPtr GetFieldDataDoubleRevPtr_FUNC
192 #define GetFieldDataInt64Ptr GetFieldDataInt64Ptr_FUNC
193 #define GetFieldDataInt64RevPtr GetFieldDataInt64RevPtr_FUNC
194 #define GetFieldDataInt32Ptr GetFieldDataInt32Ptr_FUNC
195 #define GetFieldDataInt32RevPtr GetFieldDataInt32RevPtr_FUNC
196 #define GetFieldDataInt16Ptr GetFieldDataInt16Ptr_FUNC
197 #define GetFieldDataInt16RevPtr GetFieldDataInt16RevPtr_FUNC
198 #define GetFieldDataBytePtr GetFieldDataBytePtr_FUNC
199 #define GetFieldData2BytePtr GetFieldData2BytePtr_FUNC
200 #define GetFieldData4BytePtr GetFieldData4BytePtr_FUNC
201 #define GetFieldData8BytePtr GetFieldData8BytePtr_FUNC
202 #define GetFieldDataVoidPtr GetFieldDataVoidPtr_FUNC /*danger:see above*/
203 #endif
205 #define GetFieldDataFloatPtr_MACRO(FieldData) ((float *)((FieldData)->Data))
206 #define GetFieldDataFloatRevPtr_MACRO(FieldData) ((FloatRev_t *)((FieldData)->Data))
207 #define GetFieldDataDoublePtr_MACRO(FieldData) ((double *)((FieldData)->Data))
208 #define GetFieldDataDoubleRevPtr_MACRO(FieldData) ((DoubleRev_t *)((FieldData)->Data))
209 #define GetFieldDataInt64Ptr_MACRO(FieldData) ((Int64_t *)((FieldData)->Data))
210 #define GetFieldDataInt64RevPtr_MACRO(FieldData) ((Int64Rev_t *)((FieldData)->Data))
211 #define GetFieldDataInt32Ptr_MACRO(FieldData) ((Int32_t *)((FieldData)->Data))
212 #define GetFieldDataInt32RevPtr_MACRO(FieldData) ((Int32Rev_t *)((FieldData)->Data))
213 #define GetFieldDataInt16Ptr_MACRO(FieldData) ((Int16_t *)((FieldData)->Data))
214 #define GetFieldDataInt16RevPtr_MACRO(FieldData) ((Int16Rev_t *)((FieldData)->Data))
215 #define GetFieldDataBytePtr_MACRO(FieldData) ((Byte_t *)((FieldData)->Data))
216 #define GetFieldData2BytePtr_MACRO(FieldData) ((UInt16_t *)((FieldData)->Data))
217 #define GetFieldData4BytePtr_MACRO(FieldData) ((UInt32_t *)((FieldData)->Data))
218 #define GetFieldData8BytePtr_MACRO(FieldData) ((UInt64_t *)((FieldData)->Data))
219 #define GetFieldDataVoidPtr_MACRO(FieldData) ((void *)((FieldData)->Data)) /*danger:see above*/
221 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
222 EXTERN float *GetFieldDataFloatPtr_FUNC(FieldData_pa fd);
223 EXTERN FloatRev_t *GetFieldDataFloatRevPtr_FUNC(FieldData_pa fd);
224 EXTERN double *GetFieldDataDoublePtr_FUNC(FieldData_pa fd);
225 EXTERN DoubleRev_t *GetFieldDataDoubleRevPtr_FUNC(FieldData_pa fd);
226 EXTERN Int64_t *GetFieldDataInt64Ptr_FUNC(FieldData_pa fd);
227 EXTERN Int64Rev_t *GetFieldDataInt64RevPtr_FUNC(FieldData_pa fd);
228 EXTERN Int32_t *GetFieldDataInt32Ptr_FUNC(FieldData_pa fd);
229 EXTERN Int32Rev_t *GetFieldDataInt32RevPtr_FUNC(FieldData_pa fd);
230 EXTERN Int16_t *GetFieldDataInt16Ptr_FUNC(FieldData_pa fd);
231 EXTERN Int16Rev_t *GetFieldDataInt16RevPtr_FUNC(FieldData_pa fd);
232 EXTERN Byte_t *GetFieldDataBytePtr_FUNC(FieldData_pa fd);
233 EXTERN UInt16_t *GetFieldData2BytePtr_FUNC(FieldData_pa fd);
234 EXTERN UInt32_t *GetFieldData4BytePtr_FUNC(FieldData_pa fd);
235 EXTERN UInt64_t *GetFieldData8BytePtr_FUNC(FieldData_pa fd);
236 EXTERN void *GetFieldDataVoidPtr_FUNC(FieldData_pa fd); /*danger:see above*/
237 #endif
241 EXTERN FieldData_pa AllocScratchNodalFieldDataPtr(LgIndex_t NumValues,
242 FieldDataType_e Type,
243 Boolean_t ShowErrMsg);
247 EXTERN void DeallocScratchNodalFieldDataPtr(FieldData_pa *ScratchFieldData);
250 * Assume that indexrange has already been converted to the actual indices.
252 EXTERN void CalcFieldDataMinMaxUsingRange(FieldData_pa field_data,
253 double *min_ptr,
254 double *max_ptr,
255 LgIndex_t startindex,
256 IndexRange_s *indexrange);
258 #if defined TECPLOTKERNEL
259 /* CORE SOURCE CODE REMOVED */
260 #endif
262 #if defined TECPLOTKERNEL
263 /* CORE SOURCE CODE REMOVED */
264 #endif
266 #if defined TECPLOTKERNEL
267 /* CORE SOURCE CODE REMOVED */
268 #endif
270 #if defined TECPLOTKERNEL
271 /* CORE SOURCE CODE REMOVED */
272 #endif
276 EXTERN void CopyTypedValueArray(FieldDataType_e ValueType,
277 void *DstArray,
278 LgIndex_t DstStart,
279 void *SrcArray,
280 LgIndex_t SrcStart,
281 LgIndex_t SrcEnd);
283 EXTERN void SwapBytesInTypedValueArray(FieldDataType_e ValueType,
284 void *SrcArray,
285 LgIndex_t SrcStart,
286 LgIndex_t SrcEnd,
287 LgIndex_t SrcSkip);
289 EXTERN void SwapBytesInUnalignedTypedValueArray(FieldDataType_e ValueType,
290 void *SrcArray,
291 LgIndex_t SrcStart,
292 LgIndex_t SrcEnd,
293 LgIndex_t SrcSkip);
297 * Copies values from "src" to "dst". "src" or "dst" may
298 * be differing types. Either or both may be V3D data pointers.
300 EXTERN void CopyFieldDataRange(FieldData_pa dst,
301 LgIndex_t dst_start,
302 FieldData_pa src,
303 LgIndex_t src_start,
304 LgIndex_t src_end); /* -1 means last point */
307 * Copy all values in field data
309 EXTERN void CopyFieldData(FieldData_pa dst,
310 FieldData_pa src);
313 * Like CopyFieldData except for single value.
315 EXTERN void CopyFieldValue(FieldData_pa dst,
316 LgIndex_t dstindex,
317 FieldData_pa src,
318 LgIndex_t srcindex);
321 #if defined TECPLOTKERNEL
322 /* CORE SOURCE CODE REMOVED */
323 #endif
325 #if defined TECPLOTKERNEL
326 /* CORE SOURCE CODE REMOVED */
327 #endif
329 #if defined TECPLOTKERNEL
330 /* CORE SOURCE CODE REMOVED */
331 #endif
333 #if defined TECPLOTKERNEL
334 /* CORE SOURCE CODE REMOVED */
335 #endif
338 * Sets all values in the field data pointer "field_data"
339 * to zero.
341 EXTERN void SetFieldDataPtrToAllZeros(FieldData_pa field_data);
344 * GetFieldValue macro
346 #if !defined GET_FIELD_VALUE_BY_VIRTUAL_FUNCTION && \
347 !defined GET_FIELD_VALUE_BY_FLOAT_ONLY_MACRO && \
348 !defined GET_FIELD_VALUE_BY_DOUBLE_ONLY_MACRO && \
349 !defined GET_FIELD_VALUE_BY_FLOAT_AND_DOUBLE_MACRO
350 #if !defined NO_ASSERTS || defined DEBUG_FIELDVALUES
351 #define GET_FIELD_VALUE_BY_VIRTUAL_FUNCTION
352 #else
353 #define GET_FIELD_VALUE_BY_FLOAT_AND_DOUBLE_MACRO
354 #endif
355 #endif
357 #if defined GET_FIELD_VALUE_BY_VIRTUAL_FUNCTION
358 #define GetFieldValue(fd,pt) ((GetFieldDataGetFunction(fd))((fd),(pt)))
359 #elif defined GET_FIELD_VALUE_BY_FLOAT_ONLY_MACRO
360 #define GetFieldValue(fd,pt) (GetFieldDataGetFunction(fd)==GetFieldValueForFloat \
361 ?GetFieldDataFloatPtr(fd)[(pt)] \
362 :(GetFieldDataGetFunction(fd))((fd),(pt)))
363 #elif defined GET_FIELD_VALUE_BY_DOUBLE_ONLY_MACRO
364 #define GetFieldValue(fd,pt) (GetFieldDataGetFunction(fd)==GetFieldValueForDouble \
365 ?GetFieldDataDoublePtr(fd)[(pt)] \
366 :(GetFieldDataGetFunction(fd))((fd),(pt)))
367 #elif defined GET_FIELD_VALUE_BY_FLOAT_AND_DOUBLE_MACRO
368 #define GetFieldValue(fd,pt) (GetFieldDataGetFunction(fd)==GetFieldValueForFloat \
369 ?GetFieldDataFloatPtr(fd)[(pt)] \
370 :GetFieldDataGetFunction(fd)==GetFieldValueForDouble \
371 ?GetFieldDataDoublePtr(fd)[(pt)] \
372 :(GetFieldDataGetFunction(fd))((fd),(pt)))
373 #else
374 #error "Need to define one of FIELD_VALUE_MACRO constants"
375 #endif
379 * SetFieldValue macro
381 #define SetFieldValue(fd,pt,val) ((GetFieldDataSetFunction(fd))((fd),(pt),(val)))
384 #if defined TECPLOTKERNEL
385 /* CORE SOURCE CODE REMOVED */
386 #endif /* TECPLOTKERNEL */
388 #if defined _DEBUG
389 #define USEFUNCTIONSFORNODEVALUES
390 #endif
392 #if defined TECPLOTKERNEL
393 /* CORE SOURCE CODE REMOVED */
394 #if !defined NO_ASSERTS
395 #endif
396 #endif /* TECPLOTKERNEL */
398 #if defined TECPLOTKERNEL
399 /* CORE SOURCE CODE REMOVED */
400 #endif /* TECPLOTKERNEL */
402 #if defined TECPLOTKERNEL
403 /* CORE SOURCE CODE REMOVED */
404 #endif