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.
18 * 3535 Factoria Blvd, Ste. 550
19 * Bellevue, WA 98006, USA
20 * Phone: +1 425 653 1200
21 * http://www.tecplot.com/
26 #define TECPLOTENGINEMODULE
29 ******************************************************************
30 ******************************************************************
32 ****** (C) 1988-2008 Tecplot, Inc. *******
34 ******************************************************************
35 ******************************************************************
38 #define DATASET0MODULE
41 #include "Q_UNICODE.h"
47 #include "FILESTREAM.h"
48 #if defined TECPLOTKERNEL
49 /* CORE SOURCE CODE REMOVED */
54 using namespace tecplot::strutil
;
55 #if defined TECPLOTKERNEL
56 /* CORE SOURCE CODE REMOVED */
60 * Low level dataset functions. No references to zones, vars or
61 * the DataSet_s master structure here.
67 void OutOfMemoryMsg(void)
69 ErrMsg(translate("Cannot allocate enough memory for this operation."));
70 } /* OutOfMemoryMsg() */
75 FieldData_pa
FieldDataAlloc(void)
79 Result
= (FieldData_pa
)ALLOC_ITEM(struct _FieldData_a
, "FieldDataPtr");
84 # if defined TECPLOTKERNEL /* TecIO doesn't require these features yet */
85 /* CORE SOURCE CODE REMOVED */
86 # else /* ...for TecIO only */
87 Result
->GetValueCallback
[0] = NULL
;
88 Result
->SetValueCallback
[0] = NULL
;
91 # if defined TECPLOTKERNEL /* TecIO doesn't require these features yet */
92 /* CORE SOURCE CODE REMOVED */
95 Result
->Type
= FieldDataType_Invalid
;
96 Result
->ValueLocation
= ValueLocation_Invalid
;
97 Result
->RefCount
= 1; /* self */
98 Result
->VarShareRefCount
= 1; /* self */
99 Result
->NumValues
= 0;
100 # if defined TECPLOTKERNEL /* TecIO doesn't require these features yet */
101 /* CORE SOURCE CODE REMOVED */
105 ENSURE(VALID_REF(Result
) || Result
== NULL
);
110 * Most clients should not call this function but FieldDataCleanup() instead.
111 * An exception to this would be Tecplot's own storable load-on-demand
114 void FieldDataDeallocData(FieldData_pa FieldData
)
116 REQUIRE(VALID_REF(FieldData
));
118 #if defined TECPLOTKERNEL
119 /* CORE SOURCE CODE REMOVED */
121 if (FieldData
->Data
!= NULL
)
123 /* Hack to remove 'deleting void* is undefined' warning... */
124 char *Tmp
= (char *)FieldData
->Data
;
125 FREE_ARRAY(Tmp
, "FieldData _Data");
126 FieldData
->Data
= NULL
;
129 #if defined TECPLOTKERNEL
130 /* CORE SOURCE CODE REMOVED */
133 ENSURE(FieldData
->Data
== NULL
);
136 #if defined TECPLOTKERNEL
137 /* CORE SOURCE CODE REMOVED */
140 #if defined TECPLOTKERNEL
141 /* CORE SOURCE CODE REMOVED */
144 #if defined TECPLOTKERNEL
145 /* CORE SOURCE CODE REMOVED */
148 #if defined TECPLOTKERNEL
149 /* CORE SOURCE CODE REMOVED */
152 #if defined TECPLOTKERNEL
153 /* CORE SOURCE CODE REMOVED */
156 #if defined TECPLOTKERNEL
157 /* CORE SOURCE CODE REMOVED */
160 #if defined TECPLOTKERNEL
161 /* CORE SOURCE CODE REMOVED */
164 #if defined TECPLOTKERNEL
165 /* CORE SOURCE CODE REMOVED */
168 #if defined TECPLOTKERNEL
169 /* CORE SOURCE CODE REMOVED */
172 #if defined TECPLOTKERNEL
173 /* CORE SOURCE CODE REMOVED */
176 #if defined TECPLOTKERNEL
177 /* CORE SOURCE CODE REMOVED */
180 #if defined TECPLOTKERNEL
181 /* CORE SOURCE CODE REMOVED */
184 #if defined TECPLOTKERNEL
185 /* CORE SOURCE CODE REMOVED */
188 #if defined TECPLOTKERNEL
189 /* CORE SOURCE CODE REMOVED */
192 #if defined TECPLOTKERNEL
193 /* CORE SOURCE CODE REMOVED */
196 #if defined TECPLOTKERNEL
197 /* CORE SOURCE CODE REMOVED */
202 void FieldDataCleanup(FieldData_pa FieldData
)
204 REQUIRE(VALID_REF(FieldData
));
206 # if defined TECPLOTKERNEL
207 /* CORE SOURCE CODE REMOVED */
209 FieldDataDeallocData(FieldData
);
215 void FieldDataDealloc(FieldData_pa
*FieldData
,
216 Boolean_t DoTrackVarSharing
)
218 REQUIRE(VALID_REF(FieldData
));
219 REQUIRE(VALID_REF(*FieldData
) || *FieldData
== NULL
);
220 REQUIRE(IMPLICATION(*FieldData
!= NULL
,
221 IsStructureReferenced(*FieldData
)));
222 REQUIRE(IMPLICATION(*FieldData
!= NULL
&& DoTrackVarSharing
,
223 IsVarStructureReferenced(*FieldData
)));
224 REQUIRE(VALID_BOOLEAN(DoTrackVarSharing
));
225 REQUIRE(IMPLICATION(*FieldData
!= NULL
,
226 (*FieldData
)->RefCount
>= (*FieldData
)->VarShareRefCount
));
228 if (*FieldData
!= NULL
)
230 if (DoTrackVarSharing
)
231 DecVarStructureReference(*FieldData
);
232 DecStructureReference(*FieldData
);
233 if (!IsStructureReferenced(*FieldData
))
235 FieldDataCleanup(*FieldData
);
237 #if defined TECPLOTKERNEL
238 /* CORE SOURCE CODE REMOVED */
241 FREE_ITEM(*FieldData
, "field data");
246 ENSURE(*FieldData
== NULL
);
249 #if defined TECPLOTKERNEL
250 /* CORE SOURCE CODE REMOVED */
251 #if !defined NDEBUG || defined CHECKED_BUILD
255 #if defined TECPLOTKERNEL
256 /* CORE SOURCE CODE REMOVED */
257 #if !defined NDEBUG || defined CHECKED_BUILD
261 #if defined TECPLOTKERNEL
262 /* CORE SOURCE CODE REMOVED */
265 template <typename T
>
266 static void copyTypedValueArray(void* DstArray
,
272 T
* SrcPtr
= ((T
*)SrcArray
) + SrcStart
;
273 T
* DstPtr
= ((T
*)DstArray
) + DstStart
;
274 size_t numBytes
= sizeof(T
) * (SrcEnd
- SrcStart
+ 1);
275 memcpy(DstPtr
, SrcPtr
, numBytes
);
278 * DstArray and SrcArray are aligned on proper word boundaries.
280 void CopyTypedValueArray(FieldDataType_e ValueType
,
287 REQUIRE(VALID_FIELD_DATA_TYPE(ValueType
) &&
288 ValueType
!= FieldDataType_Bit
);
289 REQUIRE(VALID_REF(DstArray
));
290 REQUIRE(DstStart
>= 0);
291 REQUIRE(VALID_REF(SrcArray
));
292 REQUIRE(0 <= SrcStart
&& SrcStart
<= SrcEnd
);
293 REQUIRE(DstArray
!= SrcArray
);
297 case FieldDataType_Int64
: CHECK(FALSE
); /* Future work: remove check */
298 case FieldDataType_Double
:
300 CHECK(sizeof(UInt64_t
) == 8 && sizeof(double) == 8);
301 copyTypedValueArray
<UInt64_t
>(DstArray
,
307 case FieldDataType_Float
:
308 case FieldDataType_Int32
:
310 CHECK(sizeof(UInt32_t
) == 4 && sizeof(float) == 4);
311 copyTypedValueArray
<UInt32_t
>(DstArray
,
317 case FieldDataType_Int16
:
319 CHECK(sizeof(UInt16_t
) == 2);
320 copyTypedValueArray
<UInt16_t
>(DstArray
,
326 case FieldDataType_Byte
:
328 copyTypedValueArray
<Byte_t
>(DstArray
,
334 default : CHECK(FALSE
);
339 * SrcArray is aligned on proper word boundaries.
341 void SwapBytesInTypedValueArray(FieldDataType_e ValueType
,
347 REQUIRE(VALID_FIELD_DATA_TYPE(ValueType
) &&
348 ValueType
!= FieldDataType_Bit
);
349 REQUIRE(VALID_REF(SrcArray
));
350 REQUIRE(0 <= SrcStart
&& SrcStart
<= SrcEnd
);
351 REQUIRE(SrcSkip
> 0);
355 case FieldDataType_Int64
: CHECK(FALSE
); /* Future work: remove CHECK */
356 case FieldDataType_Double
:
358 /* swap 8 bytes blocks */
359 UInt64_t
*SrcPtr
= ((UInt64_t
*)SrcArray
) + SrcStart
;
360 UInt64_t
*SrcPtrEnd
= ((UInt64_t
*)SrcArray
) + SrcEnd
;
361 CHECK(sizeof(UInt64_t
) == 8 && sizeof(double) == 8);
362 while (SrcPtr
<= SrcPtrEnd
)
364 REVERSE_8_BYTES(SrcPtr
);
368 case FieldDataType_Float
:
369 case FieldDataType_Int32
:
371 /* swap 4 bytes blocks */
372 UInt32_t
*SrcPtr
= ((UInt32_t
*)SrcArray
) + SrcStart
;
373 UInt32_t
*SrcPtrEnd
= ((UInt32_t
*)SrcArray
) + SrcEnd
;
374 CHECK(sizeof(UInt32_t
) == 4 && sizeof(float) == 4);
375 while (SrcPtr
<= SrcPtrEnd
)
377 REVERSE_4_BYTES(SrcPtr
);
381 case FieldDataType_Int16
:
383 /* swap 4 bytes blocks */
384 UInt16_t
*SrcPtr
= ((UInt16_t
*)SrcArray
) + SrcStart
;
385 UInt16_t
*SrcPtrEnd
= ((UInt16_t
*)SrcArray
) + SrcEnd
;
386 CHECK(sizeof(UInt16_t
) == 2);
387 while (SrcPtr
<= SrcPtrEnd
)
389 REVERSE_2_BYTES(SrcPtr
);
393 case FieldDataType_Byte
:
394 case FieldDataType_Bit
:
398 default: CHECK(FALSE
);
403 * Same as SwapBytesInTypedValueArray, but does extra work. Doesn't assume
404 * DstArray and SrcArray are aligned on proper word boundaries.
406 void SwapBytesInUnalignedTypedValueArray(FieldDataType_e ValueType
,
412 REQUIRE(VALID_FIELD_DATA_TYPE(ValueType
) &&
413 ValueType
!= FieldDataType_Bit
);
414 REQUIRE(VALID_REF(SrcArray
));
415 REQUIRE(0 <= SrcStart
&& SrcStart
<= SrcEnd
);
416 REQUIRE(SrcSkip
> 0);
420 case FieldDataType_Int64
: CHECK(FALSE
); /* Future work: remove CHECK */
421 case FieldDataType_Double
:
423 /* swap 8-byte blocks */
424 Byte_t
*SrcPtr
= ((Byte_t
*)SrcArray
) + SrcStart
* sizeof(UInt64_t
);
425 Byte_t
*SrcPtrEnd
= ((Byte_t
*)SrcArray
) + SrcEnd
* sizeof(UInt64_t
);
426 size_t byte_skip
= SrcSkip
* sizeof(UInt64_t
);
427 CHECK(sizeof(UInt64_t
) == 8 && sizeof(double) == 8);
428 while (SrcPtr
<= SrcPtrEnd
)
430 REVERSE_8_BYTES_1_AT_A_TIME(SrcPtr
);
434 case FieldDataType_Float
:
435 case FieldDataType_Int32
:
437 /* swap 4-byte blocks */
438 Byte_t
*SrcPtr
= ((Byte_t
*)SrcArray
) + SrcStart
* sizeof(UInt32_t
);
439 Byte_t
*SrcPtrEnd
= ((Byte_t
*)SrcArray
) + SrcEnd
* sizeof(UInt32_t
);
440 size_t byte_skip
= SrcSkip
* sizeof(UInt32_t
);
441 CHECK(sizeof(UInt32_t
) == 4 && sizeof(float) == 4);
442 while (SrcPtr
<= SrcPtrEnd
)
444 REVERSE_4_BYTES_1_AT_A_TIME(SrcPtr
);
448 case FieldDataType_Int16
:
450 /* swap 2-byte blocks */
451 Byte_t
*SrcPtr
= ((Byte_t
*)SrcArray
) + SrcStart
* sizeof(UInt16_t
);
452 Byte_t
*SrcPtrEnd
= ((Byte_t
*)SrcArray
) + SrcEnd
* sizeof(UInt16_t
);
453 size_t byte_skip
= SrcSkip
* sizeof(UInt16_t
);
454 CHECK(sizeof(UInt16_t
) == 2);
455 while (SrcPtr
<= SrcPtrEnd
)
457 REVERSE_2_BYTES_1_AT_A_TIME(SrcPtr
);
461 case FieldDataType_Byte
:
462 case FieldDataType_Bit
:
464 /* No swapping required. */
466 default: CHECK(FALSE
);
471 #if defined TECPLOTKERNEL
472 /* CORE SOURCE CODE REMOVED */
475 #if defined TECPLOTKERNEL
476 /* CORE SOURCE CODE REMOVED */
479 #if defined TECPLOTKERNEL
480 /* CORE SOURCE CODE REMOVED */
483 #if defined TECPLOTKERNEL
484 /* CORE SOURCE CODE REMOVED */
487 #if defined TECPLOTKERNEL
488 /* CORE SOURCE CODE REMOVED */
491 #if defined TECPLOTKERNEL
492 /* CORE SOURCE CODE REMOVED */
495 #if defined TECPLOTKERNEL
496 /* CORE SOURCE CODE REMOVED */
500 #if defined TECPLOTKERNEL
501 /* CORE SOURCE CODE REMOVED */
504 #if defined TECPLOTKERNEL
505 /* CORE SOURCE CODE REMOVED */
508 #if defined TECPLOTKERNEL
509 /* CORE SOURCE CODE REMOVED */
512 #if defined DEBUG_FIELDVALUES
513 # define DEBUG_FIELDVALUES_BAD_VALUE 0x11
514 static unsigned char BadValueStr
[] =
516 DEBUG_FIELDVALUES_BAD_VALUE
,
517 DEBUG_FIELDVALUES_BAD_VALUE
,
518 DEBUG_FIELDVALUES_BAD_VALUE
,
519 DEBUG_FIELDVALUES_BAD_VALUE
,
520 DEBUG_FIELDVALUES_BAD_VALUE
,
521 DEBUG_FIELDVALUES_BAD_VALUE
,
522 DEBUG_FIELDVALUES_BAD_VALUE
,
523 DEBUG_FIELDVALUES_BAD_VALUE
526 * If Tecplot is responsible for managing (allocating and deallocating) the
529 # if defined TECPLOTKERNEL
530 /* CORE SOURCE CODE REMOVED */
532 # define FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, type) \
533 ((sizeof(type) < 4) /* cannot make reliably test with less than four bytes */ || \
534 memcmp(BadValueStr,((char *)((fd)->Data))+sizeof(type)*(pt), sizeof(type)) != 0)
537 # define FIELD_DATA_VALUE_IS_INITIALIZED(fd, pt, type) TRUE
543 * Used in macros, thus not static
545 double STDCALL
GetFieldValueForFloat(const FieldData_pa fd
,
548 REQUIRE(VALID_REF(fd
));
549 # if defined TECPLOTKERNEL
550 /* CORE SOURCE CODE REMOVED */
552 REQUIRE(0 <= pt
&& pt
< GetFieldDataNumValues(fd
));
553 REQUIRE(FIELD_DATA_VALUE_IS_INITIALIZED(fd
, pt
, float));
555 double Result
= (double)GetFieldDataFloatPtr(fd
)[pt
];
561 #if defined TECPLOTKERNEL
562 /* CORE SOURCE CODE REMOVED */
567 * Used in macros, thus not static
569 double STDCALL
GetFieldValueForDouble(const FieldData_pa fd
,
572 REQUIRE(VALID_REF(fd
));
573 # if defined TECPLOTKERNEL
574 /* CORE SOURCE CODE REMOVED */
576 REQUIRE(0 <= pt
&& pt
< GetFieldDataNumValues(fd
));
577 REQUIRE(FIELD_DATA_VALUE_IS_INITIALIZED(fd
, pt
, double));
579 double Result
= GetFieldDataDoublePtr(fd
)[pt
];
585 #if defined TECPLOTKERNEL
586 /* CORE SOURCE CODE REMOVED */
592 double STDCALL
GetFieldValueForInt32(const FieldData_pa fd
,
595 REQUIRE(VALID_REF(fd
));
596 # if defined TECPLOTKERNEL
597 /* CORE SOURCE CODE REMOVED */
599 REQUIRE(0 <= pt
&& pt
< GetFieldDataNumValues(fd
));
600 REQUIRE(FIELD_DATA_VALUE_IS_INITIALIZED(fd
, pt
, Int32_t
));
602 double Result
= (double)GetFieldDataInt32Ptr(fd
)[pt
];
608 #if defined TECPLOTKERNEL
609 /* CORE SOURCE CODE REMOVED */
615 double STDCALL
GetFieldValueForInt16(const FieldData_pa fd
,
618 REQUIRE(VALID_REF(fd
));
619 # if defined TECPLOTKERNEL
620 /* CORE SOURCE CODE REMOVED */
622 REQUIRE(0 <= pt
&& pt
< GetFieldDataNumValues(fd
));
623 REQUIRE(FIELD_DATA_VALUE_IS_INITIALIZED(fd
, pt
, Int16_t
));
625 double Result
= (double)GetFieldDataInt16Ptr(fd
)[pt
];
631 #if defined TECPLOTKERNEL
632 /* CORE SOURCE CODE REMOVED */
638 double STDCALL
GetFieldValueForByte(const FieldData_pa fd
,
641 REQUIRE(VALID_REF(fd
));
642 # if defined TECPLOTKERNEL
643 /* CORE SOURCE CODE REMOVED */
645 REQUIRE(fd
->Type
== FieldDataType_Byte
);
646 REQUIRE(0 <= pt
&& pt
< GetFieldDataNumValues(fd
));
647 REQUIRE(FIELD_DATA_VALUE_IS_INITIALIZED(fd
, pt
, Byte_t
));
649 double Result
= (double)GetFieldDataBytePtr(fd
)[pt
];
655 #if defined TECPLOTKERNEL
656 /* CORE SOURCE CODE REMOVED */
662 double STDCALL
GetFieldValueForBit(const FieldData_pa fd
,
665 REQUIRE(VALID_REF(fd
));
666 # if defined TECPLOTKERNEL
667 /* CORE SOURCE CODE REMOVED */
669 REQUIRE(fd
->Type
== FieldDataType_Bit
);
670 REQUIRE(0 <= pt
&& pt
< GetFieldDataNumValues(fd
));
671 REQUIRE(FIELD_DATA_VALUE_IS_INITIALIZED(fd
, pt
/ 8, Byte_t
));
673 LgIndex_t ByteOffset
= pt
/ 8;
674 Byte_t BitMask
= (01 << (pt
% 8));
676 Byte_t
*byte_array
= GetFieldDataBytePtr(fd
);
677 double Result
= (byte_array
[ByteOffset
] & BitMask
) ? 1.0 : 0.0;
683 #if defined TECPLOTKERNEL
684 /* CORE SOURCE CODE REMOVED */
690 FieldValueGetFunction_pf
DetermineFieldDataGetFunction(FieldDataType_e DataType
,
691 Boolean_t IsFragmented
)
693 FieldValueGetFunction_pf Result
;
695 REQUIRE(VALID_FIELD_DATA_TYPE(DataType
));
696 REQUIRE(VALID_BOOLEAN(IsFragmented
));
698 #if defined TECPLOTKERNEL
699 /* CORE SOURCE CODE REMOVED */
704 case FieldDataType_Float
:
706 Result
= GetFieldValueForFloat
;
708 case FieldDataType_Double
:
710 Result
= GetFieldValueForDouble
;
712 case FieldDataType_Int32
:
714 Result
= GetFieldValueForInt32
;
716 case FieldDataType_Int16
:
718 Result
= GetFieldValueForInt16
;
720 case FieldDataType_Byte
:
722 Result
= GetFieldValueForByte
;
724 case FieldDataType_Bit
:
726 Result
= GetFieldValueForBit
;
731 Result
= NULL
; /* satisfy compiler */
740 static void STDCALL
SetFieldValueForFloat(FieldData_pa fd
,
744 REQUIRE(VALID_REF(fd
));
745 # if defined TECPLOTKERNEL
746 /* CORE SOURCE CODE REMOVED */
748 REQUIRE(0 <= pt
&& pt
< GetFieldDataNumValues(fd
));
749 REQUIRE("val can have any value");
751 GetFieldDataFloatPtr(fd
)[pt
] = CONVERT_DOUBLE_TO_FLOAT(val
);
753 ENSURE(FIELD_DATA_VALUE_IS_INITIALIZED(fd
, pt
, float));
757 #if defined TECPLOTKERNEL
758 /* CORE SOURCE CODE REMOVED */
764 static void STDCALL
SetFieldValueForDouble(FieldData_pa fd
,
768 REQUIRE(VALID_REF(fd
));
769 # if defined TECPLOTKERNEL
770 /* CORE SOURCE CODE REMOVED */
772 REQUIRE(0 <= pt
&& pt
< GetFieldDataNumValues(fd
));
773 REQUIRE("val can have any value");
775 GetFieldDataDoublePtr(fd
)[pt
] = CLAMP_DOUBLE(val
);
777 ENSURE(FIELD_DATA_VALUE_IS_INITIALIZED(fd
, pt
, double));
781 #if defined TECPLOTKERNEL
782 /* CORE SOURCE CODE REMOVED */
788 static void STDCALL
SetFieldValueForInt32(FieldData_pa fd
,
792 REQUIRE(VALID_REF(fd
));
793 # if defined TECPLOTKERNEL
794 /* CORE SOURCE CODE REMOVED */
796 REQUIRE(0 <= pt
&& pt
< GetFieldDataNumValues(fd
));
797 REQUIRE("val can have any value");
799 GetFieldDataInt32Ptr(fd
)[pt
] = CONVERT_DOUBLE_TO_INT32(val
);
801 ENSURE(FIELD_DATA_VALUE_IS_INITIALIZED(fd
, pt
, Int32_t
));
805 #if defined TECPLOTKERNEL
806 /* CORE SOURCE CODE REMOVED */
812 static void STDCALL
SetFieldValueForInt16(FieldData_pa fd
,
816 REQUIRE(VALID_REF(fd
));
817 # if defined TECPLOTKERNEL
818 /* CORE SOURCE CODE REMOVED */
820 REQUIRE(0 <= pt
&& pt
< GetFieldDataNumValues(fd
));
821 REQUIRE("val can have any value");
823 GetFieldDataInt16Ptr(fd
)[pt
] = CONVERT_DOUBLE_TO_INT16(val
);
825 ENSURE(FIELD_DATA_VALUE_IS_INITIALIZED(fd
, pt
, Int16_t
));
829 #if defined TECPLOTKERNEL
830 /* CORE SOURCE CODE REMOVED */
836 static void STDCALL
SetFieldValueForByte(FieldData_pa fd
,
840 REQUIRE(VALID_REF(fd
));
841 # if defined TECPLOTKERNEL
842 /* CORE SOURCE CODE REMOVED */
844 REQUIRE(fd
->Type
== FieldDataType_Byte
);
845 REQUIRE(0 <= pt
&& pt
< GetFieldDataNumValues(fd
));
846 REQUIRE("val can have any value");
849 GetFieldDataBytePtr(fd
)[pt
] = 0;
850 else if (val
> 255.0)
851 GetFieldDataBytePtr(fd
)[pt
] = 255;
853 GetFieldDataBytePtr(fd
)[pt
] = (Byte_t
)val
;
855 ENSURE(FIELD_DATA_VALUE_IS_INITIALIZED(fd
, pt
, Byte_t
));
859 #if defined TECPLOTKERNEL
860 /* CORE SOURCE CODE REMOVED */
866 static void STDCALL
SetFieldValueForBit(FieldData_pa fd
,
870 REQUIRE(VALID_REF(fd
));
871 # if defined TECPLOTKERNEL
872 /* CORE SOURCE CODE REMOVED */
874 REQUIRE(fd
->Type
== FieldDataType_Bit
);
875 REQUIRE(0 <= pt
&& pt
< GetFieldDataNumValues(fd
));
876 REQUIRE("val can have any value");
878 LgIndex_t ByteOffset
= pt
/ 8;
879 Byte_t BitMask
= (01 << (pt
% 8));
882 GetFieldDataBytePtr(fd
)[ByteOffset
] &= ~BitMask
;
884 GetFieldDataBytePtr(fd
)[ByteOffset
] |= BitMask
;
886 ENSURE(FIELD_DATA_VALUE_IS_INITIALIZED(fd
, pt
/ 8, Byte_t
));
890 #if defined TECPLOTKERNEL
891 /* CORE SOURCE CODE REMOVED */
897 FieldValueSetFunction_pf
DetermineFieldDataSetFunction(FieldDataType_e DataType
,
898 Boolean_t IsFragmented
)
900 FieldValueSetFunction_pf Result
;
902 REQUIRE(VALID_FIELD_DATA_TYPE(DataType
));
903 REQUIRE(VALID_BOOLEAN(IsFragmented
));
905 #if defined TECPLOTKERNEL
906 /* CORE SOURCE CODE REMOVED */
911 case FieldDataType_Float
:
913 Result
= SetFieldValueForFloat
;
915 case FieldDataType_Double
:
917 Result
= SetFieldValueForDouble
;
919 case FieldDataType_Int32
:
921 Result
= SetFieldValueForInt32
;
923 case FieldDataType_Int16
:
925 Result
= SetFieldValueForInt16
;
927 case FieldDataType_Byte
:
929 Result
= SetFieldValueForByte
;
931 case FieldDataType_Bit
:
933 Result
= SetFieldValueForBit
;
938 Result
= NULL
; /* satisfy compiler */
948 Int64_t
FieldDataGetBytesNeeded(LgIndex_t NumValues
,
949 FieldDataType_e DataType
)
951 Int64_t Result
= 0; /* ...quite compiler */
953 REQUIRE(NumValues
>= 0);
954 REQUIRE(VALID_FIELD_DATA_TYPE(DataType
));
958 case FieldDataType_Float
: Result
= ((Int64_t
)NumValues
)*sizeof(float); break;
959 case FieldDataType_Double
: Result
= ((Int64_t
)NumValues
)*sizeof(double); break;
960 case FieldDataType_Int32
: Result
= ((Int64_t
)NumValues
)*sizeof(LgIndex_t
); break;
961 case FieldDataType_Int16
: Result
= ((Int64_t
)NumValues
)*sizeof(SmInteger_t
); break;
962 case FieldDataType_Byte
: Result
= ((Int64_t
)NumValues
)*sizeof(Byte_t
); break;
963 case FieldDataType_Bit
: Result
= ((Int64_t
)(NumValues
+7)/8)*sizeof(Byte_t
); break;
964 default: CHECK(FALSE
); break;
972 * On the SGI, HP, and Sun machines 64 bit objects such as doubles must be 8
973 * byte aligned while on all other machines 32 bit alignment suffices. Some
974 * allow 1 byte alignment but we won't bother with that.
976 #if defined IRISX || defined HPUX || defined SUNX
977 # define SIZEOF_LARGEST_OBJECT_TO_ALIGN sizeof(Int64_t)
979 # define SIZEOF_LARGEST_OBJECT_TO_ALIGN sizeof(Int32_t)
984 Boolean_t
IsOffsetAlignedForFieldDataType(FieldDataType_e FieldDataType
,
987 REQUIRE(VALID_FIELD_DATA_TYPE(FieldDataType
));
988 REQUIRE(Offset
>= 0);
990 Int64_t SizeOfType
= FieldDataGetBytesNeeded(1, FieldDataType
);
991 if (SizeOfType
> (Int64_t
)SIZEOF_LARGEST_OBJECT_TO_ALIGN
)
992 SizeOfType
= SIZEOF_LARGEST_OBJECT_TO_ALIGN
;
994 Boolean_t HasValidAlignment
= (Offset
% SizeOfType
== 0);
996 ENSURE(VALID_BOOLEAN(HasValidAlignment
));
997 return HasValidAlignment
;
1002 Int64_t
GetAlignedOffsetForFieldDataType(FieldDataType_e FieldDataType
,
1005 REQUIRE(VALID_FIELD_DATA_TYPE(FieldDataType
));
1006 REQUIRE(Offset
>= 0);
1008 Int64_t SizeOfType
= FieldDataGetBytesNeeded(1, FieldDataType
);
1009 if (SizeOfType
> (Int64_t
)SIZEOF_LARGEST_OBJECT_TO_ALIGN
)
1010 SizeOfType
= SIZEOF_LARGEST_OBJECT_TO_ALIGN
;
1012 Int64_t NumBytesPastAlignment
= (Offset
% SizeOfType
);
1013 Int64_t Result
= Offset
- NumBytesPastAlignment
;
1015 ENSURE(0 <= Result
&& Result
<= Offset
);
1016 ENSURE(IsOffsetAlignedForFieldDataType(FieldDataType
, Result
));
1022 void FieldDataDefineData(FieldData_pa FieldData
,
1023 LgIndex_t NumValues
,
1024 FieldDataType_e DataType
,
1025 ValueLocation_e ValueLocation
)
1027 REQUIRE(VALID_REF(FieldData
));
1028 REQUIRE(NumValues
>= 0);
1029 REQUIRE(VALID_FIELD_DATA_TYPE(DataType
));
1030 REQUIRE(VALID_ENUM(ValueLocation
, ValueLocation_e
));
1033 * Remove any old data (transformed UVW is one example that calls this
1034 * function with a non-null data pointer when switching the value location
1035 * when style changes the value location and therefore the amount of data
1038 FieldDataCleanup(FieldData
);
1041 * The reference count is not modified here. This function only allocates the
1042 * structure and makes adjustments to the some of the members. The reference
1043 * count was initialized when the structure was initially created and the
1044 * structure may be shared before the data portion is even allocated.
1046 FieldData
->NumValues
= NumValues
;
1047 FieldData
->Type
= DataType
;
1048 FieldData
->ValueLocation
= ValueLocation
;
1049 # if defined TECPLOTKERNEL
1050 /* CORE SOURCE CODE REMOVED */
1051 # else /* ...for TecIO only */
1052 FieldData
->GetValueCallback
[0] = (void *)DetermineFieldDataGetFunction(DataType
, FALSE
);
1053 FieldData
->SetValueCallback
[0] = (void *)DetermineFieldDataSetFunction(DataType
, FALSE
);
1056 ENSURE(FieldData
->Data
== NULL
);
1061 Boolean_t
FieldDataAllocData(FieldData_pa FieldData
,
1062 Boolean_t ShowErrMsg
)
1064 REQUIRE(VALID_REF(FieldData
));
1065 REQUIRE(FieldData
->Type
!= FieldDataType_Invalid
); /* ...must call FieldDataDefineData first */
1066 REQUIRE(FieldData
->Data
== NULL
);
1067 REQUIRE(VALID_BOOLEAN(ShowErrMsg
));
1070 * The size of size_t may be smaller than our unsigned 64 bit integer value
1071 * so we might have to squeeze it down possibly loosing precision.
1073 Int64_t ActualBytesNeeded
= FieldDataGetBytesNeeded(FieldData
->NumValues
, FieldData
->Type
);
1074 size_t BytesToAllocate
= (size_t)ActualBytesNeeded
;
1077 * 64 bit architectures are effectively unlimited in their allocation size
1078 * while 32 architectures are limited to 4GB (some may limit further to 2GB
1079 * which will be borne out by the call to malloc).
1081 CHECK(sizeof(size_t) == 4 || sizeof(size_t) == 8);
1082 Boolean_t IsOk
= (FieldData
->NumValues
<= MAXINDEX
&&
1083 IMPLICATION(sizeof(size_t) == 4,
1084 ActualBytesNeeded
<= (Int64_t
)0xffffffff));
1087 if (FieldData
->NumValues
> 0)
1089 FieldData
->Data
= (void *)ALLOC_ARRAY(BytesToAllocate
, char, "FieldData's Data");
1090 #if defined DEBUG_FIELDVALUES
1092 if (FieldData
->Data
!= NULL
)
1093 memset(FieldData
->Data
, DEBUG_FIELDVALUES_BAD_VALUE
, BytesToAllocate
);
1097 * For bit type data zero the last byte in the data array. We do
1098 * this because NumValues is probably not a multiple of 8 bits and
1099 * thus the valid bit values will not occupy all bits of the last
1100 * byte. By zeroing the unused bits at the end of the array we
1101 * produce consistent data files when written to disk.
1103 if (FieldData
->Type
== FieldDataType_Bit
)
1104 ((char*)FieldData
->Data
)[BytesToAllocate
-1] = '\0';
1106 IsOk
= (FieldData
->NumValues
== 0 ||
1107 FieldData
->Data
!= NULL
);
1108 if (!IsOk
&& ShowErrMsg
)
1111 else if (ShowErrMsg
)
1112 ErrMsg(translate("Storage limit (%ld) exceeded for a single variable."), (long)MAXINDEX
);
1114 # if defined TECPLOTKERNEL
1115 /* CORE SOURCE CODE REMOVED */
1118 ENSURE(VALID_REF(FieldData
->Data
) || FieldData
->Data
== NULL
);
1119 ENSURE(VALID_BOOLEAN(IsOk
));
1123 #if defined TECPLOTKERNEL
1124 /* CORE SOURCE CODE REMOVED */
1127 #if defined TECPLOTKERNEL
1128 /* CORE SOURCE CODE REMOVED */
1131 #if defined TECPLOTKERNEL
1132 /* CORE SOURCE CODE REMOVED */
1135 #if defined TECPLOTKERNEL
1136 /* CORE SOURCE CODE REMOVED */
1139 #if defined TECPLOTKERNEL
1140 /* CORE SOURCE CODE REMOVED */
1143 #if defined TECPLOTKERNEL
1144 /* CORE SOURCE CODE REMOVED */
1147 #if defined TECPLOTKERNEL
1148 /* CORE SOURCE CODE REMOVED */
1151 #if !defined NO_ASSERTS
1152 #if defined TECPLOTKERNEL
1153 /* CORE SOURCE CODE REMOVED */
1157 #if defined TECPLOTKERNEL
1158 /* CORE SOURCE CODE REMOVED */
1161 #if defined TECPLOTKERNEL
1162 /* CORE SOURCE CODE REMOVED */
1166 * Allocates a field data pointer with space for "num_pts" of field data type
1167 * "field_data_type" nodal values.
1170 * This field data may NOT be used for zones but only for things like
1171 * geometries or other temporary field data that will never be placed
1172 * into a COB or zone.
1174 FieldData_pa
AllocScratchNodalFieldDataPtr(LgIndex_t NumValues
,
1175 FieldDataType_e Type
,
1176 Boolean_t ShowErrMsg
)
1178 REQUIRE(NumValues
>= 0);
1179 REQUIRE(VALID_FIELD_DATA_TYPE(Type
));
1180 REQUIRE(VALID_BOOLEAN(ShowErrMsg
));
1182 FieldData_pa Result
= FieldDataAlloc();
1185 FieldDataDefineData(Result
, NumValues
, Type
, ValueLocation_Nodal
);
1186 if (!FieldDataAllocData(Result
, ShowErrMsg
))
1187 FieldDataDealloc(&Result
, FALSE
);
1189 else if (ShowErrMsg
)
1192 ENSURE(VALID_REF(Result
) || Result
== NULL
);
1193 # if defined TECPLOTKERNEL
1194 /* CORE SOURCE CODE REMOVED */
1196 ENSURE(IMPLICATION(Result
!= NULL
,
1197 (Result
->NumValues
>= 0 &&
1198 IMPLICATION(Result
->NumValues
!= 0,
1199 VALID_REF(Result
->Data
)) &&
1200 VALID_FIELD_DATA_TYPE(Result
->Type
))));
1207 * Frees memory allocated with AllocScratchNodalFieldDataPtr().
1209 * @param ScratchFieldData
1210 * Scratch field data pointer to deallocate. This should NEVER be a field
1211 * data from a zone or COB. See note in AllocScratchNodalFieldDataPtr().
1213 void DeallocScratchNodalFieldDataPtr(FieldData_pa
*FieldDataRef
)
1215 FieldDataDealloc(FieldDataRef
,
1216 FALSE
); /* DoTrackVarSharing */
1220 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1223 FieldDataType_e
GetFieldDataType_FUNC(FieldData_pa FieldData
)
1225 REQUIRE(VALID_REF(FieldData
));
1227 FieldDataType_e Result
= GetFieldDataType_MACRO(FieldData
);
1229 ENSURE(VALID_FIELD_DATA_TYPE(Result
));
1232 #endif /* !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS */
1235 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1238 FieldValueGetFunction_pf
GetFieldDataGetFunction_FUNC(FieldData_pa FieldData
)
1240 REQUIRE(VALID_REF(FieldData
));
1242 FieldValueGetFunction_pf Result
= GetFieldDataGetFunction_MACRO(FieldData
);
1244 ENSURE(VALID_FN_REF(Result
));
1247 #endif /* !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS */
1250 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1253 FieldValueSetFunction_pf
GetFieldDataSetFunction_FUNC(FieldData_pa FieldData
)
1255 REQUIRE(VALID_REF(FieldData
));
1257 FieldValueSetFunction_pf Result
= GetFieldDataSetFunction_MACRO(FieldData
);
1259 ENSURE(VALID_FN_REF(Result
));
1262 #endif /* !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS */
1265 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1268 LgIndex_t
GetFieldDataNumValues_FUNC(FieldData_pa FieldData
)
1270 REQUIRE(VALID_REF(FieldData
));
1272 LgIndex_t Result
= GetFieldDataNumValues_MACRO(FieldData
);
1274 ENSURE(Result
>= 0);
1277 #endif /* !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS */
1280 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1283 ValueLocation_e
GetFieldDataValueLocation_FUNC(FieldData_pa FieldData
)
1285 REQUIRE(VALID_REF(FieldData
));
1287 ValueLocation_e Result
= GetFieldDataValueLocation_MACRO(FieldData
);
1289 ENSURE(Result
== ValueLocation_Invalid
|| /* i.e. pending assignment */
1290 VALID_ENUM(Result
, ValueLocation_e
));
1293 #endif /* !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS */
1296 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1299 Boolean_t
IsFieldDataDirectAccessAllowed_FUNC(FieldData_pa FieldData
)
1301 REQUIRE(VALID_REF(FieldData
));
1303 Boolean_t Result
= IsFieldDataDirectAccessAllowed_MACRO(FieldData
);
1305 ENSURE(VALID_BOOLEAN(Result
));
1311 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1314 float *GetFieldDataFloatPtr_FUNC(FieldData_pa fd
)
1316 REQUIRE(VALID_REF(fd
));
1318 float *Result
= GetFieldDataFloatPtr_MACRO(fd
);
1320 ENSURE(VALID_REF(Result
));
1326 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1329 double *GetFieldDataDoublePtr_FUNC(FieldData_pa fd
)
1331 REQUIRE(VALID_REF(fd
));
1333 double *Result
= GetFieldDataDoublePtr_MACRO(fd
);
1335 ENSURE(VALID_REF(Result
));
1341 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1344 Int64_t
*GetFieldDataInt64Ptr_FUNC(FieldData_pa fd
)
1346 REQUIRE(VALID_REF(fd
));
1348 Int64_t
*Result
= GetFieldDataInt64Ptr_MACRO(fd
);
1350 ENSURE(VALID_REF(Result
));
1356 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1359 Int32_t
*GetFieldDataInt32Ptr_FUNC(FieldData_pa fd
)
1361 REQUIRE(VALID_REF(fd
));
1363 Int32_t
*Result
= GetFieldDataInt32Ptr_MACRO(fd
);
1365 ENSURE(VALID_REF(Result
));
1371 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1374 Int16_t
*GetFieldDataInt16Ptr_FUNC(FieldData_pa fd
)
1376 REQUIRE(VALID_REF(fd
));
1378 Int16_t
*Result
= GetFieldDataInt16Ptr_MACRO(fd
);
1380 ENSURE(VALID_REF(Result
));
1386 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1388 * No byte ordering or alignment issues with single bytes (which are also used with the "Bit" type)
1390 Byte_t
*GetFieldDataBytePtr_FUNC(FieldData_pa fd
)
1393 * This function gets called for Byte and Bit types, but we cannot REQUIRE
1394 * those types because it is also used for non-aligned values. We can't
1395 * check for non-aligned because we might be copying aligned bytes to a
1396 * non-aligned location.
1398 REQUIRE(VALID_REF(fd
));
1400 Byte_t
*Result
= GetFieldDataBytePtr_MACRO(fd
);
1402 ENSURE(VALID_REF(Result
));
1408 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1410 * Gets a ptr to 2-byte blocks regardless of byte ordering, but still has to
1411 * worry about byte alignment
1413 UInt16_t
*GetFieldData2BytePtr_FUNC(FieldData_pa fd
)
1415 REQUIRE(VALID_REF(fd
));
1416 REQUIRE(fd
->Type
== FieldDataType_Int16
);
1418 UInt16_t
*Result
= GetFieldData2BytePtr_MACRO(fd
);
1420 ENSURE(VALID_REF(Result
));
1426 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1428 * Gets a ptr to 4-byte blocks regardless of byte ordering, but still has to
1429 * worry about byte alignment
1431 UInt32_t
*GetFieldData4BytePtr_FUNC(FieldData_pa fd
)
1433 REQUIRE(VALID_REF(fd
));
1434 REQUIRE(fd
->Type
== FieldDataType_Int32
|| fd
->Type
== FieldDataType_Float
);
1436 UInt32_t
*Result
= GetFieldData4BytePtr_MACRO(fd
);
1438 ENSURE(VALID_REF(Result
));
1444 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1446 * Gets a ptr to 8-byte blocks regardless of byte ordering, but still has to
1447 * worry about byte alignment
1449 UInt64_t
*GetFieldData8BytePtr_FUNC(FieldData_pa fd
)
1451 REQUIRE(VALID_REF(fd
));
1452 REQUIRE(fd
->Type
== FieldDataType_Int64
|| fd
->Type
== FieldDataType_Double
);
1454 UInt64_t
*Result
= GetFieldData8BytePtr_MACRO(fd
);
1456 ENSURE(VALID_REF(Result
));
1462 #if !defined USE_MACROS_FOR_FIELD_DATA_FUNCTIONS
1464 * WARNING: GetFieldDataVoidPtr checks nothing, and thus should only be
1465 * used with extreme caution (that is, checking the alignment
1466 * and byte order by hand).
1468 void *GetFieldDataVoidPtr_FUNC(FieldData_pa fd
)
1470 REQUIRE(VALID_REF(fd
));
1472 void *Result
= GetFieldDataVoidPtr_MACRO(fd
);
1474 ENSURE(VALID_REF(Result
));
1479 #if defined TECPLOTKERNEL
1480 /* CORE SOURCE CODE REMOVED */
1481 #endif /* TECPLOTKERNEL */
1483 #if defined TECPLOTKERNEL
1484 /* CORE SOURCE CODE REMOVED */
1487 #if defined TECPLOTKERNEL
1488 /* CORE SOURCE CODE REMOVED */
1491 #if defined TECPLOTKERNEL
1492 /* CORE SOURCE CODE REMOVED */
1495 #if defined TECPLOTKERNEL
1496 /* CORE SOURCE CODE REMOVED */
1499 #if defined TECPLOTKERNEL
1500 /* CORE SOURCE CODE REMOVED */
1503 #if defined TECPLOTKERNEL
1504 /* CORE SOURCE CODE REMOVED */
1505 #endif /* TECPLOTKERNEL */
1507 #if defined TECPLOTKERNEL
1508 /* CORE SOURCE CODE REMOVED */
1514 void CopyFieldValue(FieldData_pa dst
,
1519 REQUIRE(VALID_REF(dst
));
1520 REQUIRE(VALID_REF(src
));
1521 #if defined TECPLOTKERNEL
1522 /* CORE SOURCE CODE REMOVED */
1523 #endif /* TECPLOTKERNEL */
1524 REQUIRE(dstindex
>= 0 && dstindex
< GetFieldDataNumValues(dst
) &&
1525 srcindex
>= 0 && srcindex
< GetFieldDataNumValues(src
));
1527 Boolean_t DoBruteForceCopy
= TRUE
;
1529 if (IsFieldDataDirectAccessAllowed(src
) &&
1530 IsFieldDataDirectAccessAllowed(dst
) &&
1531 GetFieldDataType(src
) == GetFieldDataType(dst
))
1533 switch (GetFieldDataType(src
))
1535 case FieldDataType_Int64
: CHECK(FALSE
); /* Future work: remove and let fall through */
1536 case FieldDataType_Double
:
1538 CHECK(sizeof(UInt64_t
) == 8 && sizeof(double) == 8);
1539 UInt64_t
*dst_ptr
= GetFieldData8BytePtr(dst
) + dstindex
;
1540 UInt64_t
*src_ptr
= GetFieldData8BytePtr(src
) + srcindex
;
1541 *dst_ptr
= *src_ptr
;
1542 DoBruteForceCopy
= FALSE
;
1544 case FieldDataType_Float
:
1545 case FieldDataType_Int32
:
1547 CHECK(sizeof(UInt32_t
) == 4 && sizeof(float) == 4);
1548 UInt32_t
*dst_ptr
= GetFieldData4BytePtr(dst
) + dstindex
;
1549 UInt32_t
*src_ptr
= GetFieldData4BytePtr(src
) + srcindex
;
1550 *dst_ptr
= *src_ptr
;
1551 DoBruteForceCopy
= FALSE
;
1553 case FieldDataType_Int16
:
1555 CHECK(sizeof(UInt16_t
) == 2);
1556 UInt16_t
*dst_ptr
= GetFieldData2BytePtr(dst
) + dstindex
;
1557 UInt16_t
*src_ptr
= GetFieldData2BytePtr(src
) + srcindex
;
1558 *dst_ptr
= *src_ptr
;
1560 case FieldDataType_Byte
:
1562 GetFieldDataBytePtr(dst
)[dstindex
] = GetFieldDataBytePtr(src
)[srcindex
];
1563 DoBruteForceCopy
= FALSE
;
1565 case FieldDataType_Bit
: break; /* handle below */
1566 default : CHECK(FALSE
); /* Future work: when more complex types are added, remove this CHECK */
1570 if (DoBruteForceCopy
)
1572 double val
= GetFieldValue(src
, srcindex
);
1573 SetFieldValue(dst
, dstindex
, val
);
1575 } /* CopyFieldValue() */
1578 #if defined TECPLOTKERNEL
1579 /* CORE SOURCE CODE REMOVED */
1582 #if defined TECPLOTKERNEL
1583 /* CORE SOURCE CODE REMOVED */
1586 #if defined TECPLOTKERNEL
1587 /* CORE SOURCE CODE REMOVED */
1590 #if defined TECPLOTKERNEL
1591 /* CORE SOURCE CODE REMOVED */
1595 #if defined TECPLOTKERNEL
1596 /* CORE SOURCE CODE REMOVED */
1597 #endif /* TECPLOTKERNEL */
1602 void SetFieldDataPtrToAllZeros(FieldData_pa fd
)
1604 REQUIRE(VALID_REF(fd
));
1605 #if defined TECPLOTKERNEL
1606 /* CORE SOURCE CODE REMOVED */
1607 #endif /* TECPLOTKERNEL */
1609 LgIndex_t NumValues
= GetFieldDataNumValues(fd
);
1612 * memset each byte to 0 works for floats and doubles and works regardless
1613 * of byte ordering or alignment.
1615 size_t NumBytesToMemSet
= 0;
1616 if (IsFieldDataDirectAccessAllowed(fd
))
1618 switch (GetFieldDataType(fd
))
1620 case FieldDataType_Int64
: CHECK(FALSE
); /* Future work: remove CHECK */
1621 case FieldDataType_Double
:
1623 CHECK(sizeof(UInt64_t
) == 8 && sizeof(double) == 8);
1624 NumBytesToMemSet
= NumValues
* sizeof(Int64_t
);
1626 case FieldDataType_Int32
:
1627 case FieldDataType_Float
:
1629 CHECK(sizeof(UInt32_t
) == 4 && sizeof(float) == 4);
1630 NumBytesToMemSet
= NumValues
* sizeof(Int32_t
);
1632 case FieldDataType_Int16
:
1634 CHECK(sizeof(UInt16_t
) == 2);
1635 NumBytesToMemSet
= NumValues
* sizeof(Int16_t
);
1637 case FieldDataType_Byte
:
1639 NumBytesToMemSet
= NumValues
* sizeof(Byte_t
);
1641 case FieldDataType_Bit
:
1643 NumBytesToMemSet
= ((NumValues
+ 7) / 8) * sizeof(Byte_t
);
1652 if (NumBytesToMemSet
> 0)
1654 void *fd_data
= GetFieldDataVoidPtr(fd
);
1655 memset(fd_data
, 0, NumBytesToMemSet
);
1660 for (ii
= 0; ii
< NumValues
; ii
++)
1661 SetFieldValue(fd
, ii
, 0.0);
1664 } /* SetFieldDataPtrToAllZeros() */
1666 #if defined TECPLOTKERNEL
1667 /* CORE SOURCE CODE REMOVED */
1668 #endif /* TECPLOTKERNEL */