1 #if defined EXTERN
2 #undef EXTERN
3 #endif
4 #if defined DATASET0MODULE
5 #define EXTERN
6 #else
7 #define EXTERN extern
8 #endif
9 
10 /*
11 ******************************************************************
12 ******************************************************************
13 *******                                                   ********
14 ******  (C) 1988-2010 Tecplot, Inc.                        *******
15 *******                                                   ********
16 ******************************************************************
17 ******************************************************************
18 */
19 
20 #if defined TECPLOTKERNEL
21 /* CORE SOURCE CODE REMOVED */
22 #endif
23 
24 namespace tecplot
25 {
26 class File;
27 }
28 
29 EXTERN void OutOfMemoryMsg(void);
30 
31 /*
32  * Turn on DEBUG_FIELDVALUES by default in any build with assertions on
33  * (including checked builds), but allow turning this off with
34  * NO_DEBUG_FIELDVALUES
35  */
36 #if !defined NO_ASSERTS && !defined NO_DEBUG_FIELDVALUES && !defined DEBUG_FIELDVALUES
37 #define DEBUG_FIELDVALUES
38 #endif
39 
40 /* FieldData_a is intentionally not defined to further
41  * deter usage of this private structure */
42 struct _FieldData_a
43 {
44     void               *Data; /* ...placed first in the structure for fastest access */
45     #if defined TECPLOTKERNEL
46 /* CORE SOURCE CODE REMOVED */
47     #else
48     void *GetValueCallback[1]; /* ...this field is for TecIO only */
49     void *SetValueCallback[1]; /* ...this field is for TecIO only */
50     #endif
51 
52     /* PRIVATE */
53     FieldDataType_e     Type;
54     ValueLocation_e     ValueLocation;
55     #if defined TECPLOTKERNEL /* TecIO doesn't require these features yet. */
56 /* CORE SOURCE CODE REMOVED */
57     #endif
58     LgIndex_t           NumValues;
59     #if defined TECPLOTKERNEL /* TecIO doesn't require these features yet. */
60 /* CORE SOURCE CODE REMOVED */
61     #endif
62 };
63 
64 
65 /* *
66  * * NOTE: "FieldData_pa" here is an "abstract type".
67  * * Any routines dealing with the internals workings
68  * * of FieldData_pa must be in the same file as these
69  * * routines
70  * */
71 
72 #if defined  USE_MACROS_FOR_FUNCTIONS
73 #define USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
74 #endif
75 
76 /*
77  * These are low-level (private) FD manipulation functions.  In
78  * most cases, you should use some higher-level function.  These
79  * macros are supplied for the dataset functions to use.
80  */
81 #if defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
82 #define GetFieldDataType               GetFieldDataType_MACRO
83 #define GetFieldDataGetFunction        GetFieldDataGetFunction_MACRO
84 #define GetFieldDataSetFunction        GetFieldDataSetFunction_MACRO
85 #define GetFieldDataNumValues          GetFieldDataNumValues_MACRO
86 #define GetFieldDataValueLocation      GetFieldDataValueLocation_MACRO
87 #define IsFieldDataDirectAccessAllowed IsFieldDataDirectAccessAllowed_MACRO
88 #else
89 #define GetFieldDataType               GetFieldDataType_FUNC
90 #define GetFieldDataGetFunction        GetFieldDataGetFunction_FUNC
91 #define GetFieldDataSetFunction        GetFieldDataSetFunction_FUNC
92 #define GetFieldDataNumValues          GetFieldDataNumValues_FUNC
93 #define GetFieldDataValueLocation      GetFieldDataValueLocation_FUNC
94 #define IsFieldDataDirectAccessAllowed IsFieldDataDirectAccessAllowed_FUNC
95 #endif
96 
97 #define GetFieldDataType_MACRO(FieldData)          ((FieldData)->Type)
98 #if defined TECPLOTKERNEL
99 /* CORE SOURCE CODE REMOVED */
100 #else /* ...for TecIO only */
101 #define GetFieldDataGetFunction_MACRO(FieldData)   ((FieldValueGetFunction_pf)(FieldData)->GetValueCallback[0])
102 #define GetFieldDataSetFunction_MACRO(FieldData)   ((FieldValueSetFunction_pf)(FieldData)->SetValueCallback[0])
103 #endif
104 #define GetFieldDataNumValues_MACRO(FieldData)     ((FieldData)->NumValues)
105 #define GetFieldDataValueLocation_MACRO(FieldData) ((FieldData)->ValueLocation)
106 
107 EXTERN double STDCALL GetFieldValueForFloat(const FieldData_pa fd, LgIndex_t pt);
108 EXTERN double STDCALL GetFieldValueForDouble(const FieldData_pa fd, LgIndex_t pt);
109 EXTERN double STDCALL GetFieldValueForInt32(const FieldData_pa fd, LgIndex_t pt);
110 EXTERN double STDCALL GetFieldValueForInt16(const FieldData_pa fd, LgIndex_t pt);
111 EXTERN double STDCALL GetFieldValueForByte(const FieldData_pa fd, LgIndex_t pt);
112 EXTERN double STDCALL GetFieldValueForBit(const FieldData_pa fd, LgIndex_t pt);
113 
114 #if defined TECPLOTKERNEL
115 /* CORE SOURCE CODE REMOVED */
116 #else
117 #define IsFieldDataDirectAccessAllowed_MACRO(FieldData) ((FieldData)->Data != NULL)
118 #endif
119 
120 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
121 EXTERN FieldDataType_e GetFieldDataType_FUNC(FieldData_pa FieldData);
122 EXTERN FieldValueGetFunction_pf GetFieldDataGetFunction_FUNC(FieldData_pa FieldData);
123 EXTERN FieldValueSetFunction_pf GetFieldDataSetFunction_FUNC(FieldData_pa FieldData);
124 EXTERN LgIndex_t GetFieldDataNumValues_FUNC(FieldData_pa FieldData);
125 EXTERN ValueLocation_e GetFieldDataValueLocation_FUNC(FieldData_pa FieldData);
126 EXTERN Boolean_t IsFieldDataDirectAccessAllowed_FUNC(FieldData_pa FieldData);
127 #endif
128 
129 
130 /*
131  * Use separate types for reversed byte data than unreversed data so we
132  * have better compiler checking.
133  */
134 typedef UInt32_t FloatRev_t;
135 typedef UInt64_t DoubleRev_t;
136 typedef UInt16_t Int16Rev_t;
137 typedef UInt32_t Int32Rev_t;
138 typedef UInt64_t Int64Rev_t;
139 
140 
141 /*
142  * Note: there are so many GetFieldData*Ptr functions because we
143  * want a bunch of error checking.  The Type and TypeRev check
144  * for that type.  The Byte, 2Byte, etc. just make sure it is
145  * that type.
146  * GetFieldDataVoidPtr checks nothing, and thus should only be
147  * used with extreme caution (that is, checking the alignment
148  * and byte order by hand).
149  */
150 #if defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
151 #define GetFieldDataFloatPtr      GetFieldDataFloatPtr_MACRO
152 #define GetFieldDataFloatRevPtr   GetFieldDataFloatRevPtr_MACRO
153 #define GetFieldDataDoublePtr     GetFieldDataDoublePtr_MACRO
154 #define GetFieldDataDoubleRevPtr  GetFieldDataDoubleRevPtr_MACRO
155 #define GetFieldDataInt64Ptr      GetFieldDataInt64Ptr_MACRO
156 #define GetFieldDataInt64RevPtr   GetFieldDataInt64RevPtr_MACRO
157 #define GetFieldDataInt32Ptr      GetFieldDataInt32Ptr_MACRO
158 #define GetFieldDataInt32RevPtr   GetFieldDataInt32RevPtr_MACRO
159 #define GetFieldDataInt16Ptr      GetFieldDataInt16Ptr_MACRO
160 #define GetFieldDataInt16RevPtr   GetFieldDataInt16RevPtr_MACRO
161 #define GetFieldDataBytePtr       GetFieldDataBytePtr_MACRO
162 #define GetFieldData2BytePtr      GetFieldData2BytePtr_MACRO
163 #define GetFieldData4BytePtr      GetFieldData4BytePtr_MACRO
164 #define GetFieldData8BytePtr      GetFieldData8BytePtr_MACRO
165 #define GetFieldDataVoidPtr       GetFieldDataVoidPtr_MACRO /*danger:see above*/
166 #else
167 #define GetFieldDataFloatPtr      GetFieldDataFloatPtr_FUNC
168 #define GetFieldDataFloatRevPtr   GetFieldDataFloatRevPtr_FUNC
169 #define GetFieldDataDoublePtr     GetFieldDataDoublePtr_FUNC
170 #define GetFieldDataDoubleRevPtr  GetFieldDataDoubleRevPtr_FUNC
171 #define GetFieldDataInt64Ptr      GetFieldDataInt64Ptr_FUNC
172 #define GetFieldDataInt64RevPtr   GetFieldDataInt64RevPtr_FUNC
173 #define GetFieldDataInt32Ptr      GetFieldDataInt32Ptr_FUNC
174 #define GetFieldDataInt32RevPtr   GetFieldDataInt32RevPtr_FUNC
175 #define GetFieldDataInt16Ptr      GetFieldDataInt16Ptr_FUNC
176 #define GetFieldDataInt16RevPtr   GetFieldDataInt16RevPtr_FUNC
177 #define GetFieldDataBytePtr       GetFieldDataBytePtr_FUNC
178 #define GetFieldData2BytePtr      GetFieldData2BytePtr_FUNC
179 #define GetFieldData4BytePtr      GetFieldData4BytePtr_FUNC
180 #define GetFieldData8BytePtr      GetFieldData8BytePtr_FUNC
181 #define GetFieldDataVoidPtr       GetFieldDataVoidPtr_FUNC /*danger:see above*/
182 #endif
183 
184 #define GetFieldDataFloatPtr_MACRO(FieldData)     ((float *)((FieldData)->Data))
185 #define GetFieldDataFloatRevPtr_MACRO(FieldData)  ((FloatRev_t *)((FieldData)->Data))
186 #define GetFieldDataDoublePtr_MACRO(FieldData)    ((double *)((FieldData)->Data))
187 #define GetFieldDataDoubleRevPtr_MACRO(FieldData) ((DoubleRev_t *)((FieldData)->Data))
188 #define GetFieldDataInt64Ptr_MACRO(FieldData)     ((Int64_t *)((FieldData)->Data))
189 #define GetFieldDataInt64RevPtr_MACRO(FieldData)  ((Int64Rev_t *)((FieldData)->Data))
190 #define GetFieldDataInt32Ptr_MACRO(FieldData)     ((Int32_t *)((FieldData)->Data))
191 #define GetFieldDataInt32RevPtr_MACRO(FieldData)  ((Int32Rev_t *)((FieldData)->Data))
192 #define GetFieldDataInt16Ptr_MACRO(FieldData)     ((Int16_t *)((FieldData)->Data))
193 #define GetFieldDataInt16RevPtr_MACRO(FieldData)  ((Int16Rev_t *)((FieldData)->Data))
194 #define GetFieldDataBytePtr_MACRO(FieldData)      ((Byte_t *)((FieldData)->Data))
195 #define GetFieldData2BytePtr_MACRO(FieldData)     ((UInt16_t *)((FieldData)->Data))
196 #define GetFieldData4BytePtr_MACRO(FieldData)     ((UInt32_t *)((FieldData)->Data))
197 #define GetFieldData8BytePtr_MACRO(FieldData)     ((UInt64_t *)((FieldData)->Data))
198 #define GetFieldDataVoidPtr_MACRO(FieldData)      ((void *)((FieldData)->Data)) /*danger:see above*/
199 
200 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
201 EXTERN float *GetFieldDataFloatPtr_FUNC(FieldData_pa fd);
202 EXTERN FloatRev_t *GetFieldDataFloatRevPtr_FUNC(FieldData_pa fd);
203 EXTERN double *GetFieldDataDoublePtr_FUNC(FieldData_pa fd);
204 EXTERN DoubleRev_t *GetFieldDataDoubleRevPtr_FUNC(FieldData_pa fd);
205 EXTERN Int64_t *GetFieldDataInt64Ptr_FUNC(FieldData_pa fd);
206 EXTERN Int64Rev_t *GetFieldDataInt64RevPtr_FUNC(FieldData_pa fd);
207 EXTERN Int32_t *GetFieldDataInt32Ptr_FUNC(FieldData_pa fd);
208 EXTERN Int32Rev_t *GetFieldDataInt32RevPtr_FUNC(FieldData_pa fd);
209 EXTERN Int16_t *GetFieldDataInt16Ptr_FUNC(FieldData_pa fd);
210 EXTERN Int16Rev_t *GetFieldDataInt16RevPtr_FUNC(FieldData_pa fd);
211 EXTERN Byte_t *GetFieldDataBytePtr_FUNC(FieldData_pa fd);
212 EXTERN UInt16_t *GetFieldData2BytePtr_FUNC(FieldData_pa fd);
213 EXTERN UInt32_t *GetFieldData4BytePtr_FUNC(FieldData_pa fd);
214 EXTERN UInt64_t *GetFieldData8BytePtr_FUNC(FieldData_pa fd);
215 EXTERN void *GetFieldDataVoidPtr_FUNC(FieldData_pa fd); /*danger:see above*/
216 #endif
217 
218 /**
219  */
220 EXTERN FieldData_pa AllocScratchNodalFieldDataPtr(LgIndex_t       NumValues,
221                                                   FieldDataType_e Type,
222                                                   Boolean_t       ShowErrMsg);
223 
224 /**
225  */
226 EXTERN void DeallocScratchNodalFieldDataPtr(FieldData_pa *ScratchFieldData);
227 
228 /**
229  * Assume that indexrange has already been converted to the actual indices.
230  */
231 EXTERN void CalcFieldDataMinMaxUsingRange(FieldData_pa  field_data,
232                                           double       *min_ptr,
233                                           double       *max_ptr,
234                                           LgIndex_t     startindex,
235                                           IndexRange_s *indexrange);
236 
237 #if defined TECPLOTKERNEL
238 /* CORE SOURCE CODE REMOVED */
239 #endif
240 
241 #if defined TECPLOTKERNEL
242 /* CORE SOURCE CODE REMOVED */
243 #endif
244 
245 #if defined TECPLOTKERNEL
246 /* CORE SOURCE CODE REMOVED */
247 #endif
248 
249 #if defined TECPLOTKERNEL
250 /* CORE SOURCE CODE REMOVED */
251 #endif
252 
253 /**
254  */
255 EXTERN void CopyTypedValueArray(FieldDataType_e  ValueType,
256                                 void            *DstArray,
257                                 LgIndex_t        DstStart,
258                                 void            *SrcArray,
259                                 LgIndex_t        SrcStart,
260                                 LgIndex_t        SrcEnd);
261 
262 EXTERN void SwapBytesInTypedValueArray(FieldDataType_e  ValueType,
263                                        void            *SrcArray,
264                                        LgIndex_t        SrcStart,
265                                        LgIndex_t        SrcEnd,
266                                        LgIndex_t        SrcSkip);
267 
268 EXTERN void SwapBytesInUnalignedTypedValueArray(FieldDataType_e  ValueType,
269                                                 void            *SrcArray,
270                                                 LgIndex_t        SrcStart,
271                                                 LgIndex_t        SrcEnd,
272                                                 LgIndex_t        SrcSkip);
273 
274 
275 /*
276  * Copies values from "src" to "dst".  "src" or "dst" may
277  * be differing types.  Either or both may be V3D data pointers.
278  *
279  * NOTE: We allow src_end to be one less than src_start and is treated as a noop.
280  */
281 EXTERN void CopyFieldDataRange(FieldData_pa dst,
282                                LgIndex_t    dst_start,
283                                FieldData_pa src,
284                                LgIndex_t    src_start,
285                                LgIndex_t    src_end); /* -1 means last point */
286 
287 /*
288  * Copy all values in field data
289  */
290 EXTERN void CopyFieldData(FieldData_pa dst,
291                           FieldData_pa src);
292 
293 /*
294  * Like CopyFieldData except for single value.
295  */
296 EXTERN void CopyFieldValue(FieldData_pa dst,
297                            LgIndex_t    dstindex,
298                            FieldData_pa src,
299                            LgIndex_t    srcindex);
300 
301 #if defined TECPLOTKERNEL
302 /* CORE SOURCE CODE REMOVED */
303 #endif
304 
305 #if defined TECPLOTKERNEL
306 /* CORE SOURCE CODE REMOVED */
307 #endif
308 
309 #if defined TECPLOTKERNEL
310 /* CORE SOURCE CODE REMOVED */
311 #endif
312 
313 #if defined TECPLOTKERNEL
314 /* CORE SOURCE CODE REMOVED */
315 #endif
316 
317 #if defined TECPLOTKERNEL
318 /* CORE SOURCE CODE REMOVED */
319 #endif
320 
321 /*
322  * Sets all values in the field data pointer "field_data"
323  * to zero.
324  */
325 EXTERN void SetFieldDataPtrToAllZeros(FieldData_pa field_data);
326 
327 /*
328  * GetFieldValue macro
329  */
330 #if !defined GET_FIELD_VALUE_BY_VIRTUAL_FUNCTION && \
331     !defined GET_FIELD_VALUE_BY_FLOAT_ONLY_MACRO && \
332     !defined GET_FIELD_VALUE_BY_DOUBLE_ONLY_MACRO && \
333     !defined GET_FIELD_VALUE_BY_FLOAT_AND_DOUBLE_MACRO
334 #if !defined NO_ASSERTS || defined DEBUG_FIELDVALUES
335 #define GET_FIELD_VALUE_BY_VIRTUAL_FUNCTION
336 #else
337 #define GET_FIELD_VALUE_BY_FLOAT_AND_DOUBLE_MACRO
338 #endif
339 #endif
340 
341 #if defined GET_FIELD_VALUE_BY_VIRTUAL_FUNCTION
342 #define GetFieldValue(fd,pt) ((GetFieldDataGetFunction(fd))((fd),(pt)))
343 #elif defined GET_FIELD_VALUE_BY_FLOAT_ONLY_MACRO
344 #define GetFieldValue(fd,pt) (GetFieldDataGetFunction(fd)==GetFieldValueForFloat \
345                                 ?GetFieldDataFloatPtr(fd)[(pt)] \
346                                 :(GetFieldDataGetFunction(fd))((fd),(pt)))
347 #elif defined GET_FIELD_VALUE_BY_DOUBLE_ONLY_MACRO
348 #define GetFieldValue(fd,pt) (GetFieldDataGetFunction(fd)==GetFieldValueForDouble \
349                                 ?GetFieldDataDoublePtr(fd)[(pt)] \
350                                 :(GetFieldDataGetFunction(fd))((fd),(pt)))
351 #elif defined GET_FIELD_VALUE_BY_FLOAT_AND_DOUBLE_MACRO
352 #define GetFieldValue(fd,pt) (GetFieldDataGetFunction(fd)==GetFieldValueForFloat \
353                                 ?GetFieldDataFloatPtr(fd)[(pt)] \
354                                 :GetFieldDataGetFunction(fd)==GetFieldValueForDouble \
355                                 ?GetFieldDataDoublePtr(fd)[(pt)] \
356                                 :(GetFieldDataGetFunction(fd))((fd),(pt)))
357 #else
358 #error "Need to define one of FIELD_VALUE_MACRO constants"
359 #endif
360 
361 
362 /*
363  * SetFieldValue macro
364  */
365 #define SetFieldValue(fd,pt,val) ((GetFieldDataSetFunction(fd))((fd),(pt),(val)))
366 
367 
368 #if defined TECPLOTKERNEL
369 /* CORE SOURCE CODE REMOVED */
370 #endif /* TECPLOTKERNEL */
371 
372 #if defined _DEBUG
373 #define USEFUNCTIONSFORNODEVALUES
374 #endif
375 
376 #if defined TECPLOTKERNEL
377 /* CORE SOURCE CODE REMOVED */
378 #if !defined NO_ASSERTS
379 #endif
380 #endif /* TECPLOTKERNEL */
381 
382 #if defined TECPLOTKERNEL
383 /* CORE SOURCE CODE REMOVED */
384 #endif /* TECPLOTKERNEL */
385 
386 #if defined TECPLOTKERNEL
387 /* CORE SOURCE CODE REMOVED */
388 #endif
389