Forward compatibility: flex
[foam-extend-3.2.git] / applications / utilities / postProcessing / dataConversion / foamToTecplot360 / tecio / tecsrc / tecxxx.cpp
blobe64504a071864971e495ba46503e96047f5fc437
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 #include "stdafx.h"
25 #include "MASTER.h"
27 #define TECPLOTENGINEMODULE
30 ******************************************************************
31 ******************************************************************
32 ******* ********
33 ****** (C) 1988-2008 Tecplot, Inc. *******
34 ******* ********
35 ******************************************************************
36 ******************************************************************
38 /* Source file revision $Revision: 7627 $ */
40 #include "GLOBAL.h"
41 #include "TASSERT.h"
42 #include "Q_UNICODE.h"
43 #include "SYSTEM.h"
44 #include "FILESTREAM.h"
45 #if defined TECPLOTKERNEL
46 /* CORE SOURCE CODE REMOVED */
47 #endif
48 #include "DATAIO4.h"
49 #include "DATASET0.h"
50 #include "TECXXX.h"
51 #include "DATAUTIL.h"
52 #include "ALLOC.h"
53 #include <vector>
55 #if !defined MAKEARCHIVE
56 #include "AUXDATA.h"
57 #endif /* MAKEARCHIVE */
59 #if defined MSWIN
60 #include <io.h>
61 #endif
63 #if defined UNIXX
64 #include <stdio.h>
65 #include <sys/types.h>
66 #include <sys/stat.h>
67 #endif
69 #if defined TECPLOTKERNEL
70 /* CORE SOURCE CODE REMOVED */
71 #endif
72 using namespace std;
74 #if defined MAKEARCHIVE
75 #if defined MSWIN && defined _DEBUG
76 /* For debug .dll builds, send debug info to debug window. */
77 #define PRINT0(s) do { OutputDebugString(s); } while (0)
78 #define PRINT1(s,a1) do { char buffer[512]; sprintf(buffer,s,a1); OutputDebugString(buffer); } while (0)
79 #define PRINT2(s,a1,a2) do { char buffer[512]; sprintf(buffer,s,a1,a2); OutputDebugString(buffer); } while (0)
80 #else
81 /* For all other builds (including release .dll), send debug info to stdout. */
82 #define PRINT0(s) printf(s)
83 #define PRINT1(s,a1) printf(s,a1)
84 #define PRINT2(s,a1,a2) printf(s,a1,a2)
85 #endif
86 #else
87 #if defined MSWIN
88 /* For nonarchive, Windows, don't send debug info. */
89 #define PRINT0(s) ((void)0)
90 #define PRINT1(s,a1) ((void)0)
91 #define PRINT2(s,a1,a2) ((void)0)
92 #else
93 /* For nonarchive, nonwindows, send debug info to stdout. */
94 #define PRINT0(s) printf(s)
95 #define PRINT1(s,a1) printf(s,a1)
96 #define PRINT2(s,a1,a2) printf(s,a1,a2)
97 #endif
98 #endif
100 typedef char *FNameType;
101 typedef FILE *FilePtr;
103 #define MaxNumFiles 10
104 #define MAX_DUPLIST_VARS 50 /* maybe crank up in the future */
106 #define BYTES_PER_CHUNK 4096
107 #define TECIO_NO_NEIGHBORING_ELEM 0
108 #define TECIO_NO_NEIGHBORING_ZONE 0
110 #if defined MAKEARCHIVE
111 static LgIndex_t DebugLevel[MaxNumFiles] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
112 #endif
113 static INTEGER4 IsOpen[MaxNumFiles] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
114 static INTEGER4 NumErrs[MaxNumFiles] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
115 static INTEGER4 NumVars[MaxNumFiles];
116 static FNameType DestFName[MaxNumFiles] = {NULL, NULL, NULL, NULL, NULL,
117 NULL, NULL, NULL, NULL, NULL
119 static FNameType BlckFName[MaxNumFiles] = {NULL, NULL, NULL, NULL, NULL,
120 NULL, NULL, NULL, NULL, NULL
122 static FileStream_s* BlckFile[MaxNumFiles];
123 static FileStream_s* HeadFile[MaxNumFiles];
124 static vector<FileOffset_t> MinMaxOffset[MaxNumFiles]; /* vector dimensioned by num zones */
125 static vector<double> VarMinValue[MaxNumFiles]; /* vector dimensioned by num vars */
126 static vector<double> VarMaxValue[MaxNumFiles]; /* vector dimensioned by num vars */
127 static INTEGER4 DoWriteForeign = FALSE; /* ...default is to write native */
128 static INTEGER4 IsWritingNative[MaxNumFiles];
129 static INTEGER4 IsBlock[MaxNumFiles];
130 static INTEGER4 ZoneType[MaxNumFiles];
131 static LgIndex_t IMax[MaxNumFiles]; /* ones based indices */
132 static LgIndex_t JMax[MaxNumFiles]; /* ones based indices */
133 static LgIndex_t KMax[MaxNumFiles]; /* ones based indices */
134 static vector<LgIndex_t> TotalNumFaceNodes[MaxNumFiles]; /* vector dimensioned by num zones */
135 static LgIndex_t TotalNumFaceBndryFaces[MaxNumFiles];
136 static LgIndex_t TotalNumFaceBndryConns[MaxNumFiles];
137 static LgIndex_t ICellMax[MaxNumFiles];
138 static LgIndex_t JCellMax[MaxNumFiles];
139 static LgIndex_t KCellMax[MaxNumFiles];
140 static vector<INTEGER4> NumFaceConnections[MaxNumFiles]; /* vector dimensioned by num zones */
141 static INTEGER4 FaceNeighborMode[MaxNumFiles];
142 static vector<INTEGER4> FaceNeighborsOrMapWritten[MaxNumFiles]; /* vector dimensioned by num zones */
143 static INTEGER4 NumIndices[MaxNumFiles];
144 static LgIndex_t NumDataValuesWritten[MaxNumFiles];
145 static LgIndex_t NumOrderedCCDataValuesWritten[MaxNumFiles]; /* CC data only */
146 static LgIndex_t NumDataValuesToWrite[MaxNumFiles];
147 static vector<LgIndex_t> NumRunningVarValues[MaxNumFiles]; /* vector dimensioned by num vars */
148 static vector<Boolean_t> IsSharedVar[MaxNumFiles]; /* vector dimensioned by num vars */
149 static vector<Boolean_t> IsPassiveVar[MaxNumFiles]; /* vector dimensioned by num vars */
150 static INTEGER4 CurZone[MaxNumFiles]; /* zero based zone numbers */
151 static INTEGER4 CurVar[MaxNumFiles]; /* zero based var numbers */
152 static INTEGER4 FieldDataType;
153 static INTEGER4 CurFile = -1;
154 static vector<Boolean_t> IsCellCentered[MaxNumFiles]; /* vector dimensioned by num vars */
155 static Boolean_t HasFECONNECT[MaxNumFiles];
156 static INTEGER4 FileTypes[MaxNumFiles];
157 static vector<INTEGER4> NumConnectivityNodes[MaxNumFiles]; /* vector dimensioned by num zones */
158 static vector<Boolean_t> ConnectivityWritten[MaxNumFiles]; /* vector dimensioned by num zones */
161 * From preplot.cpp:
163 * ZoneType 0=ORDERED,1=FELINESEG,2=FETRIANGLE,
164 * 3=FEQUADRILATERAL,4=FETETRAHEDRON,5=FEBRICK,
165 * 6=FEPOLYGON,7=FEPOLYHEDRON
167 #define ORDERED 0
168 #define FELINESEG 1
169 #define FETRIANGLE 2
170 #define FEQUADRILATERAL 3
171 #define FETETRAHEDRON 4
172 #define FEBRICK 5
173 #define FEPOLYGON 6
174 #define FEPOLYHEDRON 7
176 * FileType 0=FULLFILE,1=GRIDFILE,2=SOLUTIONFILE
178 #define FULLFILE 0
179 #define GRIDFILE 1
180 #define SOLUTIONFILE 2
182 #if defined MAKEARCHIVE
183 static char const* ZoneTypes[] =
185 "ORDERED",
186 "FELINESEG",
187 "FETRIANGLE",
188 "FEQUADRILATERAL",
189 "FETETRAHEDRON",
190 "FEBRICK",
191 "FEPOLYGON",
192 "FEPOLYHEDRON"
194 #endif /* MAKEARCHIVE */
197 static void WriteErr(const char *routine_name)
199 #if defined MAKEARCHIVE
200 PRINT2("Err: (%s) Write failure on file %d.\n", routine_name, CurFile + 1);
201 #endif
202 NumErrs[CurFile]++;
205 static LgIndex_t TecXXXZoneNum = 0;
207 Boolean_t ParseDupList(LgIndex_t **ShareVarFromZone,
208 LgIndex_t *ShareConnectivityFromZone,
209 const char *DupList)
211 Boolean_t IsOk = TRUE;
213 REQUIRE(VALID_REF(ShareVarFromZone) && *ShareVarFromZone == NULL);
214 REQUIRE(VALID_REF(ShareConnectivityFromZone));
215 REQUIRE(VALID_REF(DupList));
217 while (IsOk && *DupList)
219 /* skip leading spaces */
220 while (*DupList && *DupList == ' ')
221 DupList++;
223 /* is this the FECONNECT keyword? */
224 if (*DupList && !strncmp(DupList, "FECONNECT", 9))
225 *ShareConnectivityFromZone = TecXXXZoneNum;
227 else if (*DupList && !isdigit(*DupList))
228 IsOk = FALSE; /* syntax error */
230 else if (*DupList)
232 char *NotUsed = NULL;
233 EntIndex_t WhichVar = strtol(DupList, &NotUsed, 10);
234 EntIndex_t numVarsForFile = NumVars[CurFile];
236 if (0 < WhichVar && WhichVar < numVarsForFile)
238 if (!(*ShareVarFromZone))
240 *ShareVarFromZone = ALLOC_ARRAY(numVarsForFile, LgIndex_t, "Variable sharing list");
241 if (*ShareVarFromZone)
242 memset(*ShareVarFromZone, (char)0, numVarsForFile * sizeof(LgIndex_t));
245 if (*ShareVarFromZone)
246 (*ShareVarFromZone)[WhichVar - 1] = TecXXXZoneNum;
247 else
248 IsOk = FALSE;
250 else
252 /* Invalid var num */
253 IsOk = FALSE;
258 * Skip to the comma. This
259 * will also allow the syntax error
260 * of more than one consecutive comma
263 while (*DupList && *DupList != ',')
264 DupList++;
266 /* skip past the comma (can handle the syntax error of more than 1 comma) */
267 while (*DupList && *DupList == ',')
268 DupList++;
271 return IsOk;
276 static FileStream_s *OpenFileStream(const char *FilePath,
277 const char *AccessMode,
278 Boolean_t IsByteOrderNative)
280 REQUIRE(VALID_REF(FilePath));
281 REQUIRE(VALID_REF(AccessMode));
283 FileStream_s *Result = NULL;
284 FILE *File = TP_FOPEN(FilePath, AccessMode);
285 if (File != NULL)
287 Result = FileStreamAlloc(File, IsByteOrderNative);
288 if (Result == NULL)
289 TP_FCLOSE(File);
292 ENSURE((VALID_REF(Result) && VALID_REF(Result->File)) || Result == NULL);
293 return Result;
298 static void CloseFileStream(FileStream_s **FileStream)
300 REQUIRE(VALID_REF(FileStream));
301 REQUIRE(VALID_REF(*FileStream) || *FileStream == NULL);
303 if (*FileStream != NULL)
305 TP_FCLOSE((*FileStream)->File);
306 FileStreamDealloc(FileStream);
309 ENSURE(*FileStream == NULL);
313 * Get the best terminator (separator) character to use for the string. First
314 * precedence goes to the new line then the command and finally by default the
315 * space. NOTE: We use a do loop to allow it to be used as a single statement.
317 #define GET_BEST_TERMINATOR_CHAR(CompoundStr, TerminatorChar) \
318 do \
320 if (strchr((CompoundStr), '\n') != NULL) \
321 (TerminatorChar) = '\n'; \
322 else if (strchr((CompoundStr), ',') != NULL) \
323 (TerminatorChar) = ','; \
324 else \
325 (TerminatorChar) = ' '; \
326 } while (0)
330 * TECINIXXX
332 INTEGER4 LIBCALL TECINI112(char *Title,
333 char *Variables,
334 char *FName,
335 char *ScratchDir,
336 INTEGER4 *FileType,
337 INTEGER4 *Debug,
338 INTEGER4 *VIsDouble)
340 size_t L;
341 int I;
342 char RName[80];
343 char *CPtr;
344 int NewFile = -1;
347 * Note that users should not mix TECXXX, TEC100XXX, and TEC110XXX calls, but
348 * just in case, initialize the TecXXXZoneNum variable. It may not help, but
349 * it doesn't hurt...
351 TecXXXZoneNum = 0;
353 #if defined MAKEARCHIVE
354 InitInputSpecs();
355 #endif
357 for (I = 0; (I < MaxNumFiles) && (NewFile == -1); I++)
359 if (!IsOpen[I])
360 NewFile = I;
363 if (NewFile == -1)
365 #if defined MAKEARCHIVE
366 PRINT1("Err: (TECINI112) Too many files (%d) opened for printing.\n", NewFile);
367 #endif
368 return (-1);
371 if (CurFile == -1)
372 CurFile = 0;
374 #if defined MAKEARCHIVE
375 DebugLevel[NewFile] = *Debug;
376 #endif
377 /* check sizes for array sized by number of variables */
378 CHECK(VarMinValue[NewFile].empty());
379 CHECK(VarMaxValue[NewFile].empty());
380 CHECK(NumRunningVarValues[NewFile].empty());
381 CHECK(IsSharedVar[NewFile].empty());
382 CHECK(IsPassiveVar[NewFile].empty());
383 CHECK(IsCellCentered[NewFile].empty());
385 /* check sizes for array sized by number of zones */
386 CHECK(MinMaxOffset[NewFile].empty());
387 CHECK(TotalNumFaceNodes[NewFile].empty());
388 CHECK(NumFaceConnections[NewFile].empty());
389 CHECK(FaceNeighborsOrMapWritten[NewFile].empty());
390 CHECK(NumConnectivityNodes[NewFile].empty());
391 CHECK(ConnectivityWritten[NewFile].empty());
393 CurZone[NewFile] = -1;
394 L = 0;
395 if (FName != NULL)
396 L = strlen(FName);
397 if (L == 0)
399 #if defined MAKEARCHIVE
400 PRINT1("Err: (TECINI112) Bad file name for file %d.\n", NewFile);
401 #endif
402 return (-1);
404 DestFName[NewFile] = ALLOC_ARRAY(L + 1, char, "data set fname");
405 strcpy(DestFName[NewFile], FName);
407 #if defined (DOS)
409 sprintf(RName, "BLCKFILE.%03d", (int)(NewFile + 1));
411 #else
413 sprintf(RName, "tp%1dXXXXXX", NewFile + 1);
415 #endif
417 L = strlen(RName);
418 if (ScratchDir != NULL)
419 L += strlen(ScratchDir) + 1; /* +1 for the slash delimeter */
420 BlckFName[NewFile] = ALLOC_ARRAY(L + 1, char, "data set fname");
421 if (ScratchDir != NULL)
423 strcpy(BlckFName[NewFile], ScratchDir);
424 #if defined DOS || defined MSWIN
426 strcat(BlckFName[NewFile], "\\");
428 #else
430 strcat(BlckFName[NewFile], "/");
432 #endif
434 else
435 BlckFName[NewFile][0] = '\0';
437 strcat(BlckFName[NewFile], RName);
438 CHECK(strlen(BlckFName[NewFile]) <= L);
440 #if defined MSWIN
442 _mktemp(BlckFName[NewFile]);
444 #elif defined UNIXX
447 * POSIX compiant behavior is to make
448 * sure umask is set correctly first.
450 mode_t OrigUmask = umask(0022); /* ...should produce rw------- */
451 int FileDesc = mkstemp(BlckFName[NewFile]);
452 if (FileDesc != -1)
453 close(FileDesc);
454 umask(OrigUmask);
456 #endif
458 #if defined MAKEARCHIVE
459 if (DebugLevel[NewFile])
461 PRINT2("Scratch File #%d: %s\n", NewFile + 1, BlckFName[NewFile]);
462 PRINT2("Dest File #%d: %s\n", NewFile + 1, DestFName[NewFile]);
464 #endif
466 IsWritingNative[NewFile] = !DoWriteForeign;
468 #if defined TECPLOTKERNEL
469 /* CORE SOURCE CODE REMOVED */
470 #endif
472 HeadFile[NewFile] = OpenFileStream(DestFName[NewFile], "wb", IsWritingNative[NewFile]);
473 BlckFile[NewFile] = OpenFileStream(BlckFName[NewFile], "wb", IsWritingNative[NewFile]);
475 if (BlckFile[NewFile] == NULL)
477 #if defined MAKEARCHIVE
478 PRINT0("Err: (TECINI112) Cannot open scratch file for output.\n");
479 PRINT0(" Check permissions in scratch directory.\n");
480 #endif
481 NumErrs[NewFile]++;
482 return (-1);
484 if (HeadFile[NewFile] == NULL)
486 #if defined MAKEARCHIVE
487 PRINT0("Err: (TECINI112) Cannot open plot file. Check permissions.\n");
488 #endif
489 NumErrs[NewFile]++;
490 return (-1);
493 writeBinaryVersionNumber(*HeadFile[NewFile],
494 TecplotBinaryFileVersion);
495 WriteBinaryMagic(HeadFile[NewFile]);
497 /* Write file type */
498 if (*FileType >= FULLFILE && *FileType <= SOLUTIONFILE)
499 FileTypes[NewFile] = *FileType;
500 else
502 #if defined MAKEARCHIVE
503 PRINT0("Err: (TECINI112) Bad filetype argument. Check documentation.\n");
504 #endif
505 NumErrs[NewFile]++;
506 return (-1);
509 CHECK(TecplotBinaryFileVersion == 112);
510 if (!WriteBinaryInt32(HeadFile[NewFile], (LgIndex_t)FileTypes[NewFile]))
512 WriteErr("TECINI112");
513 return (-1);
516 if (!DumpDatafileString(HeadFile[NewFile],
517 Title,
518 TRUE))
520 WriteErr("TECINI112");
521 return (-1);
524 NumVars[NewFile] = 0;
525 CPtr = Variables;
529 * Three possible variable name separators are accepted with the following
530 * precidence: newline, comma, and space.
533 char terminator;
535 GET_BEST_TERMINATOR_CHAR(CPtr, terminator);
536 while (*CPtr)
538 /* strip leading spaces */
539 while (*CPtr && *CPtr == ' ')
540 CPtr++;
542 if (*CPtr)
544 NumVars[NewFile]++;
545 /* skip to terminating character */
546 while (*CPtr && *CPtr != terminator)
547 CPtr++;
548 /* skip past terminating character */
549 if (*CPtr)
550 CPtr++;
555 #if 0
556 /* A grid file can have no variables in it as long as there is a connectivity list */
557 if (NumVars[NewFile] == 0 && FileTypes[NewFile] != GRIDFILE)
559 #if defined MAKEARCHIVE
560 PRINT0("Err: (TECINI110) No variable names were defined.\n");
561 #endif
562 NumErrs[NewFile]++;
563 return (-1);
565 #endif
567 #if defined MAKEARCHIVE
568 if (DebugLevel[NewFile])
569 PRINT1("NumVars=%d\n", NumVars[NewFile]);
570 #endif
571 /* make sure var-sized arrays are big enough for all vars */
574 VarMinValue[NewFile].resize(NumVars[NewFile]);
575 VarMaxValue[NewFile].resize(NumVars[NewFile]);
576 NumRunningVarValues[NewFile].resize(NumVars[NewFile]);
577 IsSharedVar[NewFile].resize(NumVars[NewFile]);
578 IsPassiveVar[NewFile].resize(NumVars[NewFile]);
579 IsCellCentered[NewFile].resize(NumVars[NewFile]);
581 catch (std::bad_alloc const&)
583 #if defined MAKEARCHIVE
584 PRINT0("Err: (TECINI112) Memory allocation error.\n");
585 #endif
586 NumErrs[NewFile]++;
587 return (-1);
590 if (!WriteBinaryInt32(HeadFile[NewFile], (LgIndex_t)NumVars[NewFile]))
592 WriteErr("TECINI110");
593 return (-1);
596 CPtr = Variables;
598 char terminator;
599 char TString[MaxChrsVarName+1];
600 int I;
602 GET_BEST_TERMINATOR_CHAR(CPtr, terminator);
603 while (*CPtr)
605 /* skip leading space characters */
606 while (*CPtr && *CPtr == ' ')
607 CPtr++;
608 if (*CPtr)
610 I = 0;
611 /* skip to terminator */
612 while (*CPtr && *CPtr != terminator)
614 TString[I++] = *CPtr++;
616 /* skip past terminator */
617 if (*CPtr)
618 CPtr++;
620 /* strip trailing spaces */
621 I--;
622 while (I >= 0 && TString[I] == ' ')
623 I--;
625 TString[I+1] = '\0';
627 if (!DumpDatafileString(HeadFile[NewFile], TString, TRUE))
629 WriteErr("TECINI110");
630 return (-1);
636 IsOpen[NewFile] = 1;
638 if (*VIsDouble)
639 FieldDataType = FieldDataType_Double;
640 else
641 FieldDataType = FieldDataType_Float;
643 return (0);
646 INTEGER4 LIBCALL TECINI111(char *Title,
647 char *Variables,
648 char *FName,
649 char *ScratchDir,
650 INTEGER4 *FileType,
651 INTEGER4 *Debug,
652 INTEGER4 *VIsDouble)
654 return TECINI112(Title,
655 Variables,
656 FName,
657 ScratchDir,
658 FileType,
659 Debug,
660 VIsDouble);
663 INTEGER4 LIBCALL TECINI110(char *Title,
664 char *Variables,
665 char *FName,
666 char *ScratchDir,
667 INTEGER4 *Debug,
668 INTEGER4 *VIsDouble)
670 INTEGER4 FType = FULLFILE;
672 TecXXXZoneNum = 0;
673 return TECINI112(Title,
674 Variables,
675 FName,
676 ScratchDir,
677 &FType,
678 Debug,
679 VIsDouble);
682 INTEGER4 LIBCALL TECINI100(char *Title,
683 char *Variables,
684 char *FName,
685 char *ScratchDir,
686 INTEGER4 *Debug,
687 INTEGER4 *VIsDouble)
689 INTEGER4 FType = FULLFILE;
691 TecXXXZoneNum = 0;
692 return TECINI112(Title,
693 Variables,
694 FName,
695 ScratchDir,
696 &FType,
697 Debug,
698 VIsDouble);
701 INTEGER4 LIBCALL TECINI(char *Title,
702 char *Variables,
703 char *FName,
704 char *ScratchDir,
705 INTEGER4 *Debug,
706 INTEGER4 *VIsDouble)
708 INTEGER4 FType = FULLFILE;
710 TecXXXZoneNum = 0;
711 return TECINI112(Title,
712 Variables,
713 FName,
714 ScratchDir,
715 &FType,
716 Debug,
717 VIsDouble);
720 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
721 LIBFUNCTION INTEGER4 LIBCALL tecini112_(char *Title,
722 char *Variables,
723 char *FName,
724 char *ScratchDir,
725 INTEGER4 *FileType,
726 INTEGER4 *Debug,
727 INTEGER4 *VIsDouble)
729 return TECINI112(Title, Variables, FName, ScratchDir, FileType, Debug, VIsDouble);
732 LIBFUNCTION INTEGER4 LIBCALL tecini111_(char *Title,
733 char *Variables,
734 char *FName,
735 char *ScratchDir,
736 INTEGER4 *FileType,
737 INTEGER4 *Debug,
738 INTEGER4 *VIsDouble)
740 return TECINI112(Title, Variables, FName, ScratchDir, FileType, Debug, VIsDouble);
743 LIBFUNCTION INTEGER4 LIBCALL tecini110_(char *Title,
744 char *Variables,
745 char *FName,
746 char *ScratchDir,
747 INTEGER4 *Debug,
748 INTEGER4 *VIsDouble)
750 INTEGER4 FType = FULLFILE;
751 return TECINI112(Title, Variables, FName, ScratchDir, &FType, Debug, VIsDouble);
754 LIBFUNCTION INTEGER4 LIBCALL tecini100_(char *Title,
755 char *Variables,
756 char *FName,
757 char *ScratchDir,
758 INTEGER4 *Debug,
759 INTEGER4 *VIsDouble)
761 INTEGER4 FType = FULLFILE;
762 return TECINI112(Title, Variables, FName, ScratchDir, &FType, Debug, VIsDouble);
765 LIBFUNCTION INTEGER4 LIBCALL tecini_(char *Title,
766 char *Variables,
767 char *FName,
768 char *ScratchDir,
769 INTEGER4 *Debug,
770 INTEGER4 *VIsDouble)
772 INTEGER4 FType = FULLFILE;
773 return TECINI112(Title,
774 Variables,
775 FName,
776 ScratchDir,
777 &FType,
778 Debug,
779 VIsDouble);
781 #endif
784 static int CheckData(const char *routine_name)
787 if (NumDataValuesToWrite[CurFile] != NumDataValuesWritten[CurFile])
789 #if defined MAKEARCHIVE
790 PRINT2("Err: (%s) Wrong number of data values in file %d:\n", routine_name, CurFile + 1);
791 PRINT2(" %d data values for Zone %d were processed,\n", NumDataValuesWritten[CurFile], CurZone[CurFile] + 1);
792 PRINT1(" %d data values were expected.\n", NumDataValuesToWrite[CurFile]);
793 #endif
794 NumErrs[CurFile]++;
795 return (-1);
797 return (0);
800 static int CheckFile(const char *routine_name)
802 if ((CurFile == -1) || (!IsOpen[CurFile]))
804 #if defined MAKEARCHIVE
805 PRINT2("Err: (%s) Attempt to use invalid file (%d).\n",
806 routine_name, CurFile + 1);
807 #endif
808 return (-1);
810 return (0);
814 * Advances CurVar[CurFile] to the next non-shared active variable. TECDATXXX
815 * clients should not supply values for shared or passive variables.
817 static void AdvanceToNextVarWithValues(void)
819 /* search for the next variable with values */
822 CurVar[CurFile]++;
824 while (CurVar[CurFile] < NumVars[CurFile] &&
825 (IsSharedVar[CurFile][CurVar[CurFile]] ||
826 IsPassiveVar[CurFile][CurVar[CurFile]]));
830 * TECZNEXXX
832 INTEGER4 LIBCALL TECZNE112(char *ZnTitle,
833 INTEGER4 *ZnType,
834 INTEGER4 *IMxOrNumPts,
835 INTEGER4 *JMxOrNumElements,
836 INTEGER4 *KMxOrNumFaces,
837 INTEGER4 *ICellMx,
838 INTEGER4 *JCellMx,
839 INTEGER4 *KCellMx,
840 double *SolutionTime,
841 INTEGER4 *StrandID,
842 INTEGER4 *ParentZone,
843 INTEGER4 *IsBlk,
844 INTEGER4 *NumFaceConn,
845 INTEGER4 *FNMode,
846 INTEGER4 *NumFaceNodes,
847 INTEGER4 *NumFaceBndryFaces,
848 INTEGER4 *NumFaceBndryConns,
849 INTEGER4 *PassiveVarList,
850 INTEGER4 *ValueLocation,
851 INTEGER4 *ShareVarFromZone,
852 INTEGER4 *ShareConnectivityFromZone)
854 int I;
855 int IsOk = 1;
857 if (CheckFile("TECZNE112") < 0)
858 return (-1);
860 if (CurZone[CurFile] > -1)
862 if (CheckData("TECZNE112") < 0)
863 return (-1);
866 if (NumVars[CurFile] == 0)
868 WriteErr("TECZNE112");
869 #if defined MAKEARCHIVE
870 PRINT1("Err: (TECZNE112) Cannot write out zones if numvars is equal to zero (file %d).\n",
871 CurFile + 1);
872 #endif
873 return (-1);
876 if (CurZone[CurFile] > MaxNumZonesOrVars - 2) /* -1 based */
878 WriteErr("TECZNE112");
879 #if defined MAKEARCHIVE
880 PRINT2("Err: (TECZNE112) Exceeded max number of zones (%d) in file %d.\n",
881 MaxNumZonesOrVars, CurFile + 1);
882 #endif
883 return (-1);
886 if (*StrandID < -1)
888 #if defined MAKEARCHIVE
889 PRINT2("Err: (TECZNE112) Invalid StrandID supplied for file %d, zone %d.\n",
890 CurFile + 1, CurZone[CurFile] + 1 + 1);
891 #endif
892 return (-1);
895 if (*ParentZone < 0)
897 #if defined MAKEARCHIVE
898 PRINT2("Err: (TECZNE112) Invalid ParentZone supplied for file %d, zone %d.\n",
899 CurFile + 1, CurZone[CurFile] + 1 + 1);
900 #endif
901 return (-1);
905 * This is a temporary error. Point format should no longer be written to the file
906 * and should instead be converted to block format before being written. Since the
907 * conversion has not yet been implemented, it is an error to use point data.
908 * TODO (JN): Remove this error when point to block conversion has been implemented.
910 if (*IsBlk != 1)
912 #if defined MAKEARCHIVE
913 PRINT2("Err: (TECZNE112) Point data is not currently allowed. "
914 " Please use block format for file %d, zone %d.\n",
915 CurFile + 1, CurZone[CurFile] + 1 + 1);
916 #endif
917 return (-1);
920 NumDataValuesWritten[CurFile] = 0;
921 NumOrderedCCDataValuesWritten[CurFile] = 0;
922 CurZone[CurFile]++;
924 /* Resize zone-dimensioned arrays (CurZone[] is 0-based) */
927 MinMaxOffset[CurFile].resize(CurZone[CurFile] + 1);
928 TotalNumFaceNodes[CurFile].resize(CurZone[CurFile] + 1);
929 NumFaceConnections[CurFile].resize(CurZone[CurFile] + 1);
930 FaceNeighborsOrMapWritten[CurFile].resize(CurZone[CurFile] + 1);
931 NumConnectivityNodes[CurFile].resize(CurZone[CurFile] + 1);
932 ConnectivityWritten[CurFile].resize(CurZone[CurFile] + 1);
934 catch (std::bad_alloc const&)
936 #if defined MAKEARCHIVE
937 PRINT0("Err: (TECZNE112) Memory allocation error.\n");
938 #endif
939 NumErrs[CurFile]++;
940 return (-1);
943 ZoneType[CurFile] = *ZnType;
944 IMax[CurFile] = *IMxOrNumPts;
945 JMax[CurFile] = *JMxOrNumElements;
946 KMax[CurFile] = *KMxOrNumFaces;
947 ICellMax[CurFile] = *ICellMx;
948 JCellMax[CurFile] = *JCellMx;
949 KCellMax[CurFile] = *KCellMx;
950 /* Set the flags that connectivity, face neighbors or face map hasn't been written for the zone yet. */
951 FaceNeighborsOrMapWritten[CurFile][CurZone[CurFile]] = FALSE;
952 ConnectivityWritten[CurFile][CurZone[CurFile]] = FALSE;
954 if (ZoneType[CurFile] == ZoneType_FEPolygon ||
955 ZoneType[CurFile] == ZoneType_FEPolyhedron)
957 NumFaceConnections[CurFile][CurZone[CurFile]] = 0; /* ...not used for polytope data */
958 FaceNeighborMode[CurFile] = 0; /* ...not used for polytope data */
959 NumConnectivityNodes[CurFile][CurZone[CurFile]] = 0; /* ...not used for polytope data */
961 IsBlock[CurFile] = TRUE; /* ...polytope data is always block */
962 TotalNumFaceNodes[CurFile][CurZone[CurFile]] = *NumFaceNodes;
963 TotalNumFaceBndryFaces[CurFile] = *NumFaceBndryFaces;
964 TotalNumFaceBndryConns[CurFile] = *NumFaceBndryConns;
966 else /* ...classic data */
968 IsBlock[CurFile] = *IsBlk;
969 NumFaceConnections[CurFile][CurZone[CurFile]] = *NumFaceConn;
970 FaceNeighborMode[CurFile] = *FNMode;
972 TotalNumFaceNodes[CurFile][CurZone[CurFile]] = 0; /* ...not used for classic data */
973 TotalNumFaceBndryFaces[CurFile] = 0; /* ...not used for classic data */
974 TotalNumFaceBndryConns[CurFile] = 0; /* ...not used for classic data */
977 WriteBinaryReal(HeadFile[CurFile],
978 (double)ZoneMarker,
979 FieldDataType_Float);
980 if (!DumpDatafileString(HeadFile[CurFile],
981 ZnTitle,
982 TRUE))
984 WriteErr("TECZNE112");
985 return (-1);
988 if ((ShareVarFromZone && *ShareConnectivityFromZone) &&
989 CurZone[CurFile] == 0)
991 /* can't have a duplist if there's nothing to duplicate */
992 IsOk = 0;
995 if (IsOk == 0)
997 #if defined MAKEARCHIVE
998 PRINT1("Err: (TECZNE112) Bad zone format for file %d.\n", CurFile + 1);
999 #endif
1000 NumErrs[CurFile]++;
1001 return (-1);
1004 switch (ZoneType[CurFile])
1006 case ORDERED:
1007 NumIndices[CurFile] = 0;
1008 break;
1009 case FELINESEG:
1010 NumIndices[CurFile] = 2;
1011 break;
1012 case FETRIANGLE:
1013 NumIndices[CurFile] = 3;
1014 break;
1015 case FEQUADRILATERAL:
1016 NumIndices[CurFile] = 4;
1017 break;
1018 case FETETRAHEDRON:
1019 NumIndices[CurFile] = 4;
1020 break;
1021 case FEBRICK:
1022 NumIndices[CurFile] = 8;
1023 break;
1026 /* ...not used for poly or ordered data and don't count sharing or solution files. */
1027 if (ZoneType[CurFile] != ZoneType_FEPolygon &&
1028 ZoneType[CurFile] != ZoneType_FEPolyhedron &&
1029 *ShareConnectivityFromZone == 0 &&
1030 FileTypes[CurFile] != SOLUTIONFILE)
1031 NumConnectivityNodes[CurFile][CurZone[CurFile]] = NumIndices[CurFile] * JMax[CurFile];
1034 * We do not check any return values until the end. If these calls fail,
1035 * WriteFieldDataType below should fail as well.
1037 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)(*ParentZone) - 1); /* ...ParentZone is zero based for binary file */
1038 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)(*StrandID) - 1); /* ...StrandID is zero based for binary file */
1039 WriteBinaryReal(HeadFile[CurFile], *SolutionTime, FieldDataType_Double);
1040 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t) - 1); /* No Zone Color Assignment */
1041 WriteBinaryInt32(HeadFile[CurFile], ZoneType[CurFile]);
1043 NumDataValuesToWrite[CurFile] = 0;
1044 for (I = 0; I < NumVars[CurFile]; I++)
1046 IsSharedVar[CurFile][I] = (ShareVarFromZone != NULL && ShareVarFromZone[I] != 0); /* ...shared? */
1047 IsPassiveVar[CurFile][I] = (PassiveVarList != NULL && PassiveVarList[I] == 1); /* ...passive? */
1050 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)(ValueLocation != NULL ? 1 : 0)); /* ...are var locations specified? */
1051 if (ValueLocation)
1053 for (I = 0; I < NumVars[CurFile]; I++)
1055 int VIndex;
1056 LgIndex_t NumNodes;
1057 LgIndex_t NumCells;
1059 if (ZoneType[CurFile] == ORDERED)
1061 NumNodes = IMax[CurFile] * JMax[CurFile] * KMax[CurFile];
1062 NumCells = (MAX(IMax[CurFile] - 1, 1) *
1063 MAX(JMax[CurFile] - 1, 1) *
1064 MAX(KMax[CurFile] - 1, 1));
1066 else
1068 NumNodes = IMax[CurFile];
1069 NumCells = JMax[CurFile];
1072 if (IsSharedVar[CurFile][I])
1073 VIndex = ShareVarFromZone[I] - 1;
1074 else
1075 VIndex = I;
1077 if (VIndex == 0)
1078 NumRunningVarValues[CurFile][I] = 0;
1079 else
1080 NumRunningVarValues[CurFile][VIndex] = NumRunningVarValues[CurFile][VIndex-1];
1082 IsCellCentered[CurFile][VIndex] = (ValueLocation[I] == ValueLocation_CellCentered);
1083 if (ValueLocation[I] == ValueLocation_CellCentered)
1085 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)1);
1086 if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
1088 NumDataValuesToWrite[CurFile] += NumCells;
1089 NumRunningVarValues[CurFile][VIndex] += NumCells;
1092 else if (ValueLocation[I] == ValueLocation_Nodal)
1094 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0);
1095 if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
1097 NumDataValuesToWrite[CurFile] += NumNodes;
1098 NumRunningVarValues[CurFile][VIndex] += NumNodes;
1101 else
1103 #if defined MAKEARCHIVE
1104 PRINT2("Err: (TECZNE112) Bad zone value location for file %d, variable %d.\n", CurFile + 1, I + 1);
1105 #endif
1106 NumErrs[CurFile]++;
1107 return(-1);
1111 else
1113 LgIndex_t NumNodes;
1114 if (ZoneType[CurFile] == ORDERED)
1116 NumNodes = IMax[CurFile] * JMax[CurFile] * KMax[CurFile];
1118 else
1120 NumNodes = IMax[CurFile];
1123 for (I = 0; I < NumVars[CurFile]; I++)
1125 int VIndex;
1126 if (IsSharedVar[CurFile][I])
1127 VIndex = ShareVarFromZone[I] - 1;
1128 else
1129 VIndex = I;
1131 if (VIndex == 0)
1132 NumRunningVarValues[CurFile][I] = 0;
1133 else
1134 NumRunningVarValues[CurFile][VIndex] = NumRunningVarValues[CurFile][VIndex-1];
1136 IsCellCentered[CurFile][VIndex] = FALSE;
1137 if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
1139 NumDataValuesToWrite[CurFile] += NumNodes;
1140 NumRunningVarValues[CurFile][VIndex] += NumNodes;
1146 * As of binary version 108 Tecplot introduced
1147 * the ability to output its auto-generated face
1148 * neighbor array in its raw form. For now
1149 * TecIO will always decline to perform this
1150 * step and instead fall back to the delivering
1151 * one neighbor at a time.
1153 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0); /* IsRawFNAvailable */
1155 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)NumFaceConnections[CurFile][CurZone[CurFile]]);
1156 if (NumFaceConnections[CurFile][CurZone[CurFile]] > 0)
1158 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)FaceNeighborMode[CurFile]);
1159 if (ZoneType[CurFile] != ORDERED)
1160 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0); /* FEFaceNeighborsComplete */
1163 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)IMax[CurFile]);
1164 if (ZoneType[CurFile] == FEPOLYGON ||
1165 ZoneType[CurFile] == FEPOLYHEDRON)
1167 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)KMax[CurFile]);
1170 * As of binary version 111 these items moved from the data section to
1171 * the header.
1173 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceNodes[CurFile][CurZone[CurFile]]);
1174 if (TotalNumFaceBndryFaces[CurFile] > 0)
1176 /* Each boundary face must have >= 1 boundary connection. */
1177 if (TotalNumFaceBndryConns[CurFile] < TotalNumFaceBndryFaces[CurFile])
1179 #if defined MAKEARCHIVE
1180 PRINT1("Err: (TECZNE112) There must be at least 1 boundary connection for each boundary face in zone %d.\n",
1181 CurZone[CurFile] + 1);
1182 PRINT2(" %d boundary faces and %d boundary connections were specified.\n",
1183 TotalNumFaceBndryFaces[CurFile], TotalNumFaceBndryConns[CurFile]);
1184 #endif
1185 NumErrs[CurFile]++;
1186 return(-1);
1190 * As a convenience for the ASCII format, TecUtil, and TECIO layers if any
1191 * boundary connections exists we automatically add a no-neighboring
1192 * connection as the first item so that they can user 0 for no-neighboring
1193 * element in the element list regardless if they have boundary connections
1194 * or not.
1196 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceBndryFaces[CurFile] + 1); /* ...add a boundary face for no neighboring element as a convenience */
1198 else
1199 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceBndryFaces[CurFile]);
1200 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceBndryConns[CurFile]);
1202 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)JMax[CurFile]);
1204 if (ZoneType[CurFile] == ORDERED)
1206 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)KMax[CurFile]);
1208 else
1210 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)ICellMax[CurFile]);
1211 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)JCellMax[CurFile]);
1212 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)KCellMax[CurFile]);
1216 * Aux data. This has to be over-written by the aux data writing routine.
1217 * Because it currently at the end of the header section we don't need to
1218 * keep track of the position for seeking back to it.
1220 WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0);
1222 WriteBinaryReal(BlckFile[CurFile],
1223 (double)ZoneMarker,
1224 FieldDataType_Float);
1226 for (I = 0; I < NumVars[CurFile]; I++)
1228 if (!WriteFieldDataType(BlckFile[CurFile],
1229 (FieldDataType_e)FieldDataType,
1230 TRUE))
1232 WriteErr("TECZNE112");
1233 return (-1);
1237 /* Passive variable identification */
1238 if (PassiveVarList)
1240 WriteBinaryInt32(BlckFile[CurFile], 1);
1241 for (I = 0; I < NumVars[CurFile]; I++)
1242 WriteBinaryInt32(BlckFile[CurFile], PassiveVarList[I]);
1244 else
1245 WriteBinaryInt32(BlckFile[CurFile], 0);
1247 /* get the CurVar[CurFile] on the first active variable */
1248 CurVar[CurFile] = -1;
1249 AdvanceToNextVarWithValues();
1251 /* Variable & Connectivity Sharing */
1252 if (ShareVarFromZone)
1254 WriteBinaryInt32(BlckFile[CurFile], 1);
1255 for (I = 0; I < NumVars[CurFile]; I++)
1256 WriteBinaryInt32(BlckFile[CurFile], ShareVarFromZone[I] - 1);
1258 else
1259 WriteBinaryInt32(BlckFile[CurFile], 0);
1260 WriteBinaryInt32(BlckFile[CurFile], *ShareConnectivityFromZone - 1);
1263 * Create place holders or the variable min/max value. We will come back
1264 * later after writing the data portion with the real min/max values. In the
1265 * mean time, keep track of the starting point so we can seek back to this
1266 * place.
1268 MinMaxOffset[CurFile][CurZone[CurFile]] = (FileOffset_t)TP_FTELL(BlckFile[CurFile]->File);
1270 for (I = 0; I < NumVars[CurFile]; I++)
1272 /* initialize to unset values */
1273 VarMinValue[CurFile][I] = LARGEDOUBLE;
1274 VarMaxValue[CurFile][I] = -LARGEDOUBLE;
1276 if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
1278 WriteBinaryReal(BlckFile[CurFile], 0.0, FieldDataType_Double);
1279 WriteBinaryReal(BlckFile[CurFile], 0.0, FieldDataType_Double);
1283 #if defined MAKEARCHIVE
1284 if (DebugLevel[CurFile])
1286 PRINT1("Writing Zone %d:\n", CurZone[CurFile] + 1);
1287 PRINT1(" Title = %s\n", ZnTitle);
1288 PRINT1(" Type = %s\n", ZoneTypes[ZoneType[CurFile]]);
1289 PRINT1(" IMax = %d\n", IMax[CurFile]);
1290 PRINT1(" JMax = %d\n", JMax[CurFile]);
1291 PRINT1(" KMax = %d\n", KMax[CurFile]);
1292 if (ShareVarFromZone)
1294 char DupList[1024] = "";
1296 for (I = 0; I < NumVars[CurFile]; I++)
1298 if (I > 0)
1299 strcat(DupList, ",");
1300 sprintf(&DupList[strlen(DupList)], "%d", ShareVarFromZone[I]);
1302 PRINT1(" DupList = %s\n", DupList);
1305 #endif
1307 return (0);
1310 INTEGER4 LIBCALL TECZNE111(char *ZnTitle,
1311 INTEGER4 *ZnType,
1312 INTEGER4 *IMxOrNumPts,
1313 INTEGER4 *JMxOrNumElements,
1314 INTEGER4 *KMxOrNumFaces,
1315 INTEGER4 *ICellMx,
1316 INTEGER4 *JCellMx,
1317 INTEGER4 *KCellMx,
1318 double *SolutionTime,
1319 INTEGER4 *StrandID,
1320 INTEGER4 *ParentZone,
1321 INTEGER4 *IsBlk,
1322 INTEGER4 *NumFaceConn,
1323 INTEGER4 *FNMode,
1324 INTEGER4 *NumFaceNodes,
1325 INTEGER4 *NumFaceBndryFaces,
1326 INTEGER4 *NumFaceBndryConns,
1327 INTEGER4 *PassiveVarList,
1328 INTEGER4 *ValueLocation,
1329 INTEGER4 *ShareVarFromZone,
1330 INTEGER4 *ShareConnectivityFromZone)
1332 return TECZNE112(ZnTitle,
1333 ZnType,
1334 IMxOrNumPts,
1335 JMxOrNumElements,
1336 KMxOrNumFaces,
1337 ICellMx,
1338 JCellMx,
1339 KCellMx,
1340 SolutionTime,
1341 StrandID,
1342 ParentZone,
1343 IsBlk,
1344 NumFaceConn,
1345 FNMode,
1346 NumFaceNodes,
1347 NumFaceBndryFaces,
1348 NumFaceBndryConns,
1349 PassiveVarList,
1350 ValueLocation,
1351 ShareVarFromZone,
1352 ShareConnectivityFromZone);
1355 INTEGER4 LIBCALL TECZNE110(char *ZnTitle,
1356 INTEGER4 *ZnType,
1357 INTEGER4 *IMxOrNumPts,
1358 INTEGER4 *JMxOrNumElements,
1359 INTEGER4 *KMx,
1360 INTEGER4 *ICellMx,
1361 INTEGER4 *JCellMx,
1362 INTEGER4 *KCellMx,
1363 double *SolutionTime,
1364 INTEGER4 *StrandID,
1365 INTEGER4 *ParentZone,
1366 INTEGER4 *IsBlk,
1367 INTEGER4 *NumFaceConn,
1368 INTEGER4 *FNMode,
1369 INTEGER4 *PassiveVarList,
1370 INTEGER4 *ValueLocation,
1371 INTEGER4 *ShareVarFromZone,
1372 INTEGER4 *ShareConnectivityFromZone)
1374 INTEGER4 NumFaceNodes = 0;
1375 INTEGER4 NumFaceBndryFaces = 0;
1376 INTEGER4 NumFaceBndryConns = 0;
1378 return TECZNE112(ZnTitle,
1379 ZnType,
1380 IMxOrNumPts,
1381 JMxOrNumElements,
1382 KMx,
1383 ICellMx,
1384 JCellMx,
1385 KCellMx,
1386 SolutionTime,
1387 StrandID,
1388 ParentZone,
1389 IsBlk,
1390 NumFaceConn,
1391 FNMode,
1392 &NumFaceNodes,
1393 &NumFaceBndryFaces,
1394 &NumFaceBndryConns,
1395 PassiveVarList,
1396 ValueLocation,
1397 ShareVarFromZone,
1398 ShareConnectivityFromZone);
1401 INTEGER4 LIBCALL TECZNE100(char *ZnTitle,
1402 INTEGER4 *ZnType,
1403 INTEGER4 *IMxOrNumPts,
1404 INTEGER4 *JMxOrNumElements,
1405 INTEGER4 *KMx,
1406 INTEGER4 *ICellMx,
1407 INTEGER4 *JCellMx,
1408 INTEGER4 *KCellMx,
1409 INTEGER4 *IsBlk,
1410 INTEGER4 *NumFaceConn,
1411 INTEGER4 *FNMode,
1412 INTEGER4 *ValueLocation,
1413 INTEGER4 *ShareVarFromZone,
1414 INTEGER4 *ShareConnectivityFromZone)
1416 double SolutionTime = 0.0;
1417 INTEGER4 StrandID = STRAND_ID_STATIC + 1; /* TECXXX is ones based for StrandID */
1418 INTEGER4 ParentZone = BAD_SET_VALUE + 1; /* TECXXX is ones based for ParentZone */
1419 INTEGER4 NumFaceNodes = 0;
1420 INTEGER4 NumFaceBndryFaces = 0;
1421 INTEGER4 NumFaceBndryConns = 0;
1423 return TECZNE112(ZnTitle,
1424 ZnType,
1425 IMxOrNumPts,
1426 JMxOrNumElements,
1427 KMx,
1428 ICellMx,
1429 JCellMx,
1430 KCellMx,
1431 &SolutionTime,
1432 &StrandID,
1433 &ParentZone,
1434 IsBlk,
1435 NumFaceConn,
1436 FNMode,
1437 &NumFaceNodes,
1438 &NumFaceBndryFaces,
1439 &NumFaceBndryConns,
1440 NULL, /* PassiveVarList */
1441 ValueLocation,
1442 ShareVarFromZone,
1443 ShareConnectivityFromZone);
1446 #if !defined INDEX_16_BIT // not supported in this test-only mode
1447 INTEGER4 LIBCALL TECZNE(char *ZoneTitle,
1448 INTEGER4 *IMx,
1449 INTEGER4 *JMx,
1450 INTEGER4 *KMx,
1451 char *ZFormat,
1452 char *DupList)
1455 LgIndex_t ZoneType;
1456 LgIndex_t IsBlock;
1457 LgIndex_t *ShareVarFromZone = NULL;
1458 LgIndex_t ShareConnectivityFromZone;
1459 LgIndex_t Result = 0;
1462 if (ZFormat == NULL)
1463 Result = -1;
1464 else if (!strcmp(ZFormat, "BLOCK"))
1466 IsBlock = 1;
1467 ZoneType = ZoneType_Ordered;
1469 else if (!strcmp(ZFormat, "FEBLOCK"))
1471 IsBlock = 1;
1472 switch (*KMx)
1475 * From preplot.c:
1477 * ZoneType 0=ORDERED,1=FELINESEG,2=FETRIANGLE,
1478 * 3=FEQUADRILATERAL,4=FETETRAHEDRON,5=FEBRICK
1480 case 0: /* Triangular. */
1481 ZoneType = 2;
1482 break;
1483 case 1: /* Quadrilateral */
1484 ZoneType = 3;
1485 break;
1486 case 2: /* Tetrahedral */
1487 ZoneType = 4;
1488 break;
1489 case 3: /* Brick. */
1490 ZoneType = 5;
1491 break;
1494 else if (!strcmp(ZFormat, "POINT"))
1496 IsBlock = 0;
1497 ZoneType = ZoneType_Ordered;
1499 else if (!strcmp(ZFormat, "FEPOINT"))
1501 IsBlock = 0;
1502 switch (*KMx)
1504 case 0: /* Triangular. */
1505 ZoneType = 2;
1506 break;
1507 case 1: /* Quadrilateral */
1508 ZoneType = 3;
1509 break;
1510 case 2: /* Tetrahedral */
1511 ZoneType = 4;
1512 break;
1513 case 3: /* Brick. */
1514 ZoneType = 5;
1515 break;
1518 else
1519 Result = -1;
1521 ShareConnectivityFromZone = 0;
1524 if (Result == 0 &&
1525 DupList &&
1526 !ParseDupList(&ShareVarFromZone, &ShareConnectivityFromZone, DupList))
1528 Result = -1;
1531 /*Result = TECZNE((char *)ZoneTitle, IMx, JMx, KMx, (char *)ZFormat,(char*)DupList);*/
1532 if (Result == 0)
1534 INTEGER4 ICellMx = 0;
1535 INTEGER4 JCellMx = 0;
1536 INTEGER4 KCellMx = 0;
1537 INTEGER4 NumFaceConnections = 0;
1538 INTEGER4 FaceNeighborMode = FaceNeighborMode_LocalOneToOne;
1539 double SolutionTime = 0.0;
1540 INTEGER4 StrandID = STRAND_ID_STATIC + 1; /* TECXXX is ones based for StrandID */
1541 INTEGER4 ParentZone = BAD_SET_VALUE + 1; /* TECXXX is ones based for ParentZone */
1542 INTEGER4 NumFaceNodes = 0;
1543 INTEGER4 NumFaceBndryFaces = 0;
1544 INTEGER4 NumFaceBndryConns = 0;
1546 Result = TECZNE112((char *)ZoneTitle,
1547 &ZoneType,
1548 IMx,
1549 JMx,
1550 KMx,
1551 &ICellMx,
1552 &JCellMx,
1553 &KCellMx,
1554 &SolutionTime,
1555 &StrandID,
1556 &ParentZone,
1557 &IsBlock,
1558 &NumFaceConnections,
1559 &FaceNeighborMode,
1560 &NumFaceNodes,
1561 &NumFaceBndryFaces,
1562 &NumFaceBndryConns,
1563 NULL, /* PassiveVarList */
1564 NULL, /* ValueLocation */
1565 DupList ? ShareVarFromZone : NULL,
1566 &ShareConnectivityFromZone);
1567 TecXXXZoneNum++;
1570 if (ShareVarFromZone)
1571 FREE_ARRAY(ShareVarFromZone, "Variable sharing list");
1573 return (INTEGER4) Result;
1575 #endif // INDEX_16_BIT -- not supported in this test-only mode
1577 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
1578 LIBFUNCTION INTEGER4 LIBCALL teczne112_(char *ZoneTitle,
1579 INTEGER4 *ZnType,
1580 INTEGER4 *IMxOrNumPts,
1581 INTEGER4 *JMxOrNumElements,
1582 INTEGER4 *KMx,
1583 INTEGER4 *ICellMx,
1584 INTEGER4 *JCellMx,
1585 INTEGER4 *KCellMx,
1586 double *SolutionTime,
1587 INTEGER4 *StrandID,
1588 INTEGER4 *ParentZone,
1589 INTEGER4 *IsBlk,
1590 INTEGER4 *NumFaceConn,
1591 INTEGER4 *FNMode,
1592 INTEGER4 *NumFaceNodes,
1593 INTEGER4 *NumFaceBndryFaces,
1594 INTEGER4 *NumFaceBndryConns,
1595 INTEGER4 *PassiveVarList,
1596 INTEGER4 *ValueLocation,
1597 INTEGER4 *ShareVarFromZone,
1598 INTEGER4 *ShareConnectivityFromZone)
1600 return TECZNE112(ZoneTitle,
1601 ZnType,
1602 IMxOrNumPts,
1603 JMxOrNumElements,
1604 KMx,
1605 ICellMx,
1606 JCellMx,
1607 KCellMx,
1608 SolutionTime,
1609 StrandID,
1610 ParentZone,
1611 IsBlk,
1612 NumFaceConn,
1613 FNMode,
1614 NumFaceNodes,
1615 NumFaceBndryFaces,
1616 NumFaceBndryConns,
1617 PassiveVarList,
1618 ValueLocation,
1619 ShareVarFromZone,
1620 ShareConnectivityFromZone);
1623 LIBFUNCTION INTEGER4 LIBCALL teczne111_(char *ZoneTitle,
1624 INTEGER4 *ZnType,
1625 INTEGER4 *IMxOrNumPts,
1626 INTEGER4 *JMxOrNumElements,
1627 INTEGER4 *KMx,
1628 INTEGER4 *ICellMx,
1629 INTEGER4 *JCellMx,
1630 INTEGER4 *KCellMx,
1631 double *SolutionTime,
1632 INTEGER4 *StrandID,
1633 INTEGER4 *ParentZone,
1634 INTEGER4 *IsBlk,
1635 INTEGER4 *NumFaceConn,
1636 INTEGER4 *FNMode,
1637 INTEGER4 *NumFaceNodes,
1638 INTEGER4 *NumFaceBndryFaces,
1639 INTEGER4 *NumFaceBndryConns,
1640 INTEGER4 *PassiveVarList,
1641 INTEGER4 *ValueLocation,
1642 INTEGER4 *ShareVarFromZone,
1643 INTEGER4 *ShareConnectivityFromZone)
1645 return TECZNE112(ZoneTitle,
1646 ZnType,
1647 IMxOrNumPts,
1648 JMxOrNumElements,
1649 KMx,
1650 ICellMx,
1651 JCellMx,
1652 KCellMx,
1653 SolutionTime,
1654 StrandID,
1655 ParentZone,
1656 IsBlk,
1657 NumFaceConn,
1658 FNMode,
1659 NumFaceNodes,
1660 NumFaceBndryFaces,
1661 NumFaceBndryConns,
1662 PassiveVarList,
1663 ValueLocation,
1664 ShareVarFromZone,
1665 ShareConnectivityFromZone);
1668 LIBFUNCTION INTEGER4 LIBCALL teczne110_(char *ZoneTitle,
1669 INTEGER4 *ZnType,
1670 INTEGER4 *IMxOrNumPts,
1671 INTEGER4 *JMxOrNumElements,
1672 INTEGER4 *KMx,
1673 INTEGER4 *ICellMx,
1674 INTEGER4 *JCellMx,
1675 INTEGER4 *KCellMx,
1676 double *SolutionTime,
1677 INTEGER4 *StrandID,
1678 INTEGER4 *ParentZone,
1679 INTEGER4 *IsBlk,
1680 INTEGER4 *NumFaceConn,
1681 INTEGER4 *FNMode,
1682 INTEGER4 *PassiveVarList,
1683 INTEGER4 *ValueLocation,
1684 INTEGER4 *ShareVarFromZone,
1685 INTEGER4 *ShareConnectivityFromZone)
1687 INTEGER4 NumFaceNodes = 0;
1688 INTEGER4 NumFaceBndryFaces = 0;
1689 INTEGER4 NumFaceBndryConns = 0;
1691 return TECZNE112(ZoneTitle,
1692 ZnType,
1693 IMxOrNumPts,
1694 JMxOrNumElements,
1695 KMx,
1696 ICellMx,
1697 JCellMx,
1698 KCellMx,
1699 SolutionTime,
1700 StrandID,
1701 ParentZone,
1702 IsBlk,
1703 NumFaceConn,
1704 FNMode,
1705 &NumFaceNodes,
1706 &NumFaceBndryFaces,
1707 &NumFaceBndryConns,
1708 PassiveVarList,
1709 ValueLocation,
1710 ShareVarFromZone,
1711 ShareConnectivityFromZone);
1714 LIBFUNCTION INTEGER4 LIBCALL teczne100_(char *ZoneTitle,
1715 INTEGER4 *ZnType,
1716 INTEGER4 *IMxOrNumPts,
1717 INTEGER4 *JMxOrNumElements,
1718 INTEGER4 *KMx,
1719 INTEGER4 *ICellMx,
1720 INTEGER4 *JCellMx,
1721 INTEGER4 *KCellMx,
1722 INTEGER4 *IsBlk,
1723 INTEGER4 *NumFaceConn,
1724 INTEGER4 *FNMode,
1725 INTEGER4 *ValueLocation,
1726 INTEGER4 *ShareVarFromZone,
1727 INTEGER4 *ShareConnectivityFromZone)
1729 return TECZNE100(ZoneTitle,
1730 ZnType,
1731 IMxOrNumPts,
1732 JMxOrNumElements,
1733 KMx,
1734 ICellMx,
1735 JCellMx,
1736 KCellMx,
1737 IsBlk,
1738 NumFaceConn,
1739 FNMode,
1740 ValueLocation,
1741 ShareVarFromZone,
1742 ShareConnectivityFromZone);
1745 LIBFUNCTION INTEGER4 LIBCALL teczne_(char *ZoneTitle,
1746 INTEGER4 *IMx,
1747 INTEGER4 *JMx,
1748 INTEGER4 *KMx,
1749 char *ZFormat,
1750 char *DupList)
1752 return TECZNE(ZoneTitle,
1753 IMx,
1754 JMx,
1755 KMx,
1756 ZFormat,
1757 DupList);
1759 #endif
1762 * Rewrite the var min/max place holders which currently have zero in them.
1764 static void RewritePendingMinMaxValues(void)
1766 FileOffset_t CurrentOffset = (FileOffset_t)TP_FTELL(BlckFile[CurFile]->File);
1768 TP_FSEEK(BlckFile[CurFile]->File, MinMaxOffset[CurFile][CurZone[CurFile]], SEEK_SET);
1769 int I;
1770 for (I = 0; I < NumVars[CurFile]; I++)
1772 if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
1774 WriteBinaryReal(BlckFile[CurFile], VarMinValue[CurFile][I], FieldDataType_Double);
1775 WriteBinaryReal(BlckFile[CurFile], VarMaxValue[CurFile][I], FieldDataType_Double);
1779 /* return the original position */
1780 TP_FSEEK(BlckFile[CurFile]->File, CurrentOffset, SEEK_SET);
1784 * TECDATXXX
1786 INTEGER4 LIBCALL TECDAT112(INTEGER4 *N,
1787 void *Data,
1788 INTEGER4 *IsDouble)
1790 LgIndex_t I;
1791 double *dptr = (double *)Data;
1792 float *fptr = (float *)Data;
1794 if (CheckFile("TECDAT112") < 0)
1795 return (-1);
1797 #if defined MAKEARCHIVE
1798 if (DebugLevel[CurFile] && (*N > 1))
1799 PRINT2("Writing %d values to file %d.\n", *N, CurFile + 1);
1800 #endif
1802 for (I = 0; I < *N; I++)
1804 double Value = (*IsDouble == 1 ? dptr[I] : fptr[I]);
1806 /* keep track of var min/max */
1807 if (Value < VarMinValue[CurFile][CurVar[CurFile]])
1808 VarMinValue[CurFile][CurVar[CurFile]] = Value;
1809 if (Value > VarMaxValue[CurFile][CurVar[CurFile]])
1810 VarMaxValue[CurFile][CurVar[CurFile]] = Value;
1812 if (!WriteBinaryReal(BlckFile[CurFile], Value, (FieldDataType_e)FieldDataType))
1814 WriteErr("TECDAT112");
1815 return (-1);
1819 * As of version 103 Tecplot writes binary data files so that the ordered
1820 * cell centered field data includes the ghost cells. This makes it much
1821 * easier for Tecplot to map the data when reading by simply writing out
1822 * field data's as a block. As of version 104 the ghost cells of the
1823 * slowest moving index are not included.
1825 if (IsCellCentered[CurFile][CurVar[CurFile]] && ZoneType[CurFile] == ORDERED)
1827 CHECK(IsBlock[CurFile]); /* ...ordered CC data must be block format */
1828 LgIndex_t PIndex = (NumOrderedCCDataValuesWritten[CurFile]);
1829 LgIndex_t FinalIMax = MAX(IMax[CurFile] - 1, 1);
1830 LgIndex_t FinalJMax = MAX(JMax[CurFile] - 1, 1);
1831 LgIndex_t FinalKMax = MAX(KMax[CurFile] - 1, 1);
1832 LgIndex_t IIndex = (PIndex % IMax[CurFile]);
1833 LgIndex_t JIndex = ((PIndex % (IMax[CurFile] * JMax[CurFile])) / IMax[CurFile]);
1834 LgIndex_t KIndex = (PIndex / (IMax[CurFile] * JMax[CurFile]));
1835 LgIndex_t IMaxAdjust = 0;
1836 LgIndex_t JMaxAdjust = 0;
1837 LgIndex_t KMaxAdjust = 0;
1838 if (KMax[CurFile] > 1)
1839 KMaxAdjust = 1; /* ...K is slowest */
1840 else if (JMax[CurFile] > 1)
1841 JMaxAdjust = 1; /* ...J is slowest */
1842 else if (IMax[CurFile] > 1)
1843 IMaxAdjust = 1; /* ...I is slowest */
1845 if (IIndex + 1 == FinalIMax && FinalIMax < IMax[CurFile] - IMaxAdjust)
1847 NumOrderedCCDataValuesWritten[CurFile]++;
1848 if (!WriteBinaryReal(BlckFile[CurFile], 0.0, (FieldDataType_e)FieldDataType))
1850 WriteErr("TECDAT112");
1851 return (-1);
1854 if (IIndex + 1 == FinalIMax &&
1855 (JIndex + 1 == FinalJMax && FinalJMax < JMax[CurFile] - JMaxAdjust))
1857 LgIndex_t II;
1858 for (II = 1; II <= IMax[CurFile] - IMaxAdjust; II++)
1860 NumOrderedCCDataValuesWritten[CurFile]++;
1861 if (!WriteBinaryReal(BlckFile[CurFile], 0.0, (FieldDataType_e)FieldDataType))
1863 WriteErr("TECDAT112");
1864 return (-1);
1868 if (IIndex + 1 == FinalIMax &&
1869 JIndex + 1 == FinalJMax &&
1870 (KIndex + 1 == FinalKMax && FinalKMax < KMax[CurFile] - KMaxAdjust))
1872 LgIndex_t JJ, II;
1873 for (JJ = 1; JJ <= JMax[CurFile] - JMaxAdjust; JJ++)
1874 for (II = 1; II <= IMax[CurFile] - IMaxAdjust; II++)
1876 NumOrderedCCDataValuesWritten[CurFile]++;
1877 if (!WriteBinaryReal(BlckFile[CurFile], 0.0, (FieldDataType_e)FieldDataType))
1879 WriteErr("TECDAT112");
1880 return (-1);
1885 /* increment for the original cell value */
1886 NumOrderedCCDataValuesWritten[CurFile]++;
1889 /* update the number of data points written */
1890 NumDataValuesWritten[CurFile]++;
1892 if (IsBlock[CurFile])
1894 /* for block format update the variable when all values have been given */
1895 if (NumRunningVarValues[CurFile][CurVar[CurFile]] == NumDataValuesWritten[CurFile])
1897 AdvanceToNextVarWithValues(); /* ...move on to the next variable */
1898 if (CurVar[CurFile] < NumVars[CurFile] &&
1899 IsCellCentered[CurFile][CurVar[CurFile]] &&
1900 ZoneType[CurFile] == ORDERED)
1901 NumOrderedCCDataValuesWritten[CurFile] = 0; /* reset for next CC variable */
1904 else
1906 /* for point format update the variable after each value */
1907 AdvanceToNextVarWithValues();
1908 if (CurVar[CurFile] >= NumVars[CurFile])
1910 /* reset to the first active variable */
1911 CurVar[CurFile] = -1;
1912 AdvanceToNextVarWithValues();
1916 #if defined MAKEARCHIVE
1917 if (DebugLevel[CurFile] > 1)
1918 PRINT2("%d %G\n", NumDataValuesWritten[CurFile] + I + 1, Value);
1919 #endif
1923 * If this is the last call to TECDAT112,
1924 * then we may have to set the 'repeat adjacency list'
1925 * flag in the file.
1927 if (HasFECONNECT[CurFile] &&
1929 /* (essentialy this is CheckData() but we don't want to print
1930 an error message) */
1931 (NumDataValuesToWrite[CurFile] == NumDataValuesWritten[CurFile]))
1933 if (!WriteBinaryInt32(BlckFile[CurFile], (LgIndex_t)1))
1935 WriteErr("TECDAT112");
1936 return (-1);
1940 /* re-write min/max values when all data has been delivered */
1941 if (NumDataValuesToWrite[CurFile] == NumDataValuesWritten[CurFile])
1942 RewritePendingMinMaxValues();
1944 return (0);
1947 INTEGER4 LIBCALL TECDAT111(INTEGER4 *N,
1948 void *Data,
1949 INTEGER4 *IsDouble)
1951 return TECDAT112(N,
1952 Data,
1953 IsDouble);
1956 INTEGER4 LIBCALL TECDAT110(INTEGER4 *N,
1957 void *FieldData,
1958 INTEGER4 *IsDouble)
1960 return TECDAT112(N,
1961 FieldData,
1962 IsDouble);
1965 INTEGER4 LIBCALL TECDAT100(INTEGER4 *N,
1966 void *FieldData,
1967 INTEGER4 *IsDouble)
1969 return TECDAT112(N,
1970 FieldData,
1971 IsDouble);
1974 INTEGER4 LIBCALL TECDAT(INTEGER4 *N,
1975 void *FieldData,
1976 INTEGER4 *IsDouble)
1978 return TECDAT112(N,
1979 FieldData,
1980 IsDouble);
1983 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
1984 LIBFUNCTION INTEGER4 LIBCALL tecdat112_(INTEGER4 *N,
1985 void *Data,
1986 INTEGER4 *IsDouble)
1988 return TECDAT112(N, Data, IsDouble);
1991 LIBFUNCTION INTEGER4 LIBCALL tecdat111_(INTEGER4 *N,
1992 void *Data,
1993 INTEGER4 *IsDouble)
1995 return TECDAT112(N, Data, IsDouble);
1998 LIBFUNCTION INTEGER4 LIBCALL tecdat110_(INTEGER4 *N,
1999 void *Data,
2000 INTEGER4 *IsDouble)
2002 return TECDAT112(N, Data, IsDouble);
2005 LIBFUNCTION INTEGER4 LIBCALL tecdat100_(INTEGER4 *N,
2006 void *Data,
2007 INTEGER4 *IsDouble)
2009 return TECDAT112(N, Data, IsDouble);
2012 LIBFUNCTION INTEGER4 LIBCALL tecdat_(INTEGER4 *N,
2013 void *FieldData,
2014 INTEGER4 *IsDouble)
2016 return TECDAT112(N,
2017 FieldData,
2018 IsDouble);
2020 #endif
2023 * TECNODXXX
2025 INTEGER4 LIBCALL TECNOD112(INTEGER4 *NData)
2027 LgIndex_t L = NumConnectivityNodes[CurFile][CurZone[CurFile]];
2028 LgIndex_t I;
2030 ConnectivityWritten[CurFile][CurZone[CurFile]] = TRUE;
2032 if (CheckFile("TECNOD112") < 0)
2033 return (-1);
2035 if (ZoneType[CurFile] == FEPOLYGON ||
2036 ZoneType[CurFile] == FEPOLYHEDRON)
2038 /* Wrong way to specify connectivity for polygons and polyhedrons */
2039 #if defined MAKEARCHIVE
2040 PRINT0("Err: (TECNOD112) Cannot call TECNOD112 for polygonal or polyhedral zones.\n");
2041 #endif
2042 NumErrs[CurFile]++;
2043 return (-1);
2046 if (HasFECONNECT[CurFile])
2049 * The connectivity list is duplicated,
2050 * so we shouldn't be calling TECNOD112()
2052 return (-1);
2055 if (FileTypes[CurFile] == SOLUTIONFILE)
2057 #if defined MAKEARCHIVE
2058 PRINT0("Err: (TECNOD112) Cannot call TECNOD112 if file type is SOLUTIONFILE.\n");
2059 #endif
2060 NumErrs[CurFile]++;
2061 return (-1);
2064 if (ZoneType[CurFile] == ORDERED)
2066 #if defined MAKEARCHIVE
2067 PRINT0("Err: (TECNOD112) Cannot call TECNOD110 if zone type is ORDERED.\n");
2068 #endif
2069 NumErrs[CurFile]++;
2070 return (-1);
2073 if (CheckData("TECNOD112") < 0)
2074 return (-1);
2076 for (I = 0; I < L; I++)
2078 if ((NData[I] > IMax[CurFile]) ||
2079 (NData[I] < 1))
2081 #if defined MAKEARCHIVE
2082 PRINT1("Err: (TECNOD112) Invalid node map value at position %d:\n", I);
2083 PRINT2(" node map value = %d, max value = %d.\n", NData[I], IMax[CurFile]);
2084 #endif
2085 NumErrs[CurFile]++;
2086 return (-1);
2089 * As of version 103 Tecplot assumes that node maps are zero based
2090 * instead of ones based. Since we have to maintain the contract we
2091 * subtract 1 for the caller.
2093 if (!WriteBinaryInt32(BlckFile[CurFile], NData[I] - 1)) /* zero based */
2095 WriteErr("TECNOD112");
2096 return (-1);
2099 return (0);
2102 INTEGER4 LIBCALL TECNOD111(INTEGER4 *NData)
2104 return TECNOD112(NData);
2107 INTEGER4 LIBCALL TECNOD110(INTEGER4 *NData)
2109 return TECNOD112(NData);
2112 INTEGER4 LIBCALL TECNOD100(INTEGER4 *NData)
2114 return TECNOD112(NData);
2117 INTEGER4 LIBCALL TECNOD(INTEGER4 *NData)
2119 return TECNOD112(NData);
2122 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
2123 LIBFUNCTION INTEGER4 LIBCALL tecnod112_(INTEGER4 *NData)
2125 return TECNOD112(NData);
2128 LIBFUNCTION INTEGER4 LIBCALL tecnod111_(INTEGER4 *NData)
2130 return TECNOD112(NData);
2133 LIBFUNCTION INTEGER4 LIBCALL tecnod110_(INTEGER4 *NData)
2135 return TECNOD112(NData);
2138 LIBFUNCTION INTEGER4 LIBCALL tecnod100_(INTEGER4 *NData)
2140 return TECNOD112(NData);
2143 LIBFUNCTION INTEGER4 LIBCALL tecnod_(INTEGER4 *NData)
2145 return TECNOD112(NData);
2147 #endif
2150 * TECENDXXX
2152 INTEGER4 LIBCALL TECEND112(void)
2154 int RetVal = 0;
2157 * Validate that all zone data was given for the file since there are no
2158 * more chances to give it. Note that solution files don't define the
2159 * connectivity again.
2161 if (FileTypes[CurFile] != SOLUTIONFILE)
2163 for (int ZoneIndex = 0; (RetVal == 0) && (ZoneIndex <= CurZone[CurFile]); ZoneIndex++)
2165 if (((NumConnectivityNodes[CurFile][ZoneIndex] > 0) &&
2166 (ConnectivityWritten[CurFile][ZoneIndex] == FALSE)))
2168 #if defined MAKEARCHIVE
2169 PRINT1("Err: (TECEND112) File %d is being closed without writing connectivity data.\n", CurFile + 1);
2170 PRINT1(" Zone %d was defined with a Classic FE zone type but TECNOD112() was not called.\n", ZoneIndex + 1);
2171 #endif
2172 NumErrs[CurFile]++;
2173 RetVal = -1;
2175 if (((NumFaceConnections[CurFile][ZoneIndex] > 0) &&
2176 (FaceNeighborsOrMapWritten[CurFile][ZoneIndex] == FALSE)))
2178 #if defined MAKEARCHIVE
2179 PRINT1("Err: (TECEND112) File %d is being closed without writing face neighbor data.\n", CurFile + 1);
2180 PRINT2(" %d connections were specified for zone %d but TECFACE112() was not called.\n",
2181 NumFaceConnections[CurFile][ZoneIndex], ZoneIndex + 1);
2182 #endif
2183 NumErrs[CurFile]++;
2184 RetVal = -1;
2186 else if (((TotalNumFaceNodes[CurFile][ZoneIndex] > 0) &&
2187 (FaceNeighborsOrMapWritten[CurFile][ZoneIndex] == FALSE)))
2189 #if defined MAKEARCHIVE
2190 PRINT1("Err: (TECEND112) File %d is being closed without writing face map data.\n", CurFile + 1);
2191 PRINT2(" %d face nodes were specified for zone %d but TECPOLY112() was not called.\n",
2192 TotalNumFaceNodes[CurFile][ZoneIndex], ZoneIndex + 1);
2193 #endif
2194 NumErrs[CurFile]++;
2195 RetVal = -1;
2200 if (RetVal == 0)
2202 if (CheckFile("TECEND112") < 0)
2203 RetVal = -1;
2206 if (RetVal == 0)
2208 if (CheckData("TECEND112") < 0)
2209 RetVal = -1;
2212 if (RetVal == 0)
2213 if (!WriteBinaryReal(HeadFile[CurFile], EndHeaderMarker, FieldDataType_Float))
2215 WriteErr("TECEND112");
2216 RetVal = -1;
2219 CloseFileStream(&BlckFile[CurFile]);
2221 if (RetVal == 0)
2223 BlckFile[CurFile] = OpenFileStream(BlckFName[CurFile], "rb", IsWritingNative[CurFile]);
2225 /* Append data from BlckFile to HeadFile... */
2226 char buffer[BYTES_PER_CHUNK];
2227 size_t bytesRead = 0;
2228 while ((RetVal == 0) &&
2229 (feof(BlckFile[CurFile]->File) == 0))
2231 bytesRead = fread((void*)buffer, 1, BYTES_PER_CHUNK, BlckFile[CurFile]->File);
2232 if (ferror(BlckFile[CurFile]->File) == 0)
2234 if (bytesRead != fwrite((void*)buffer, 1, bytesRead, HeadFile[CurFile]->File))
2236 /* do not call WriteErr, use custom message instead */
2237 #if defined MAKEARCHIVE
2238 PRINT1("Err: (TECEND112) Write failure during repack on file %d.\n", CurFile + 1);
2239 #endif
2240 NumErrs[CurFile]++;
2241 RetVal = -1;
2244 else
2246 /* do not call WriteErr, use custom message instead */
2247 #if defined MAKEARCHIVE
2248 PRINT1("Err: (TECEND112) Write failure during repack on file %d.\n", CurFile + 1);
2249 #endif
2250 NumErrs[CurFile]++;
2251 RetVal = -1;
2254 CloseFileStream(&BlckFile[CurFile]);
2257 TP_UNLINK(BlckFName[CurFile]);
2259 CloseFileStream(&HeadFile[CurFile]);
2261 #if defined MAKEARCHIVE
2262 if (DebugLevel[CurFile])
2264 PRINT1("File %d closed.\n", CurFile + 1);
2265 if (NumErrs[CurFile])
2267 PRINT0("********************************************\n");
2268 PRINT1(" %d Errors occurred on this file\n", NumErrs[CurFile]);
2269 PRINT0("********************************************\n");
2272 #endif
2274 NumErrs[CurFile] = 0;
2275 IsOpen[CurFile] = 0;
2276 if (DestFName[CurFile])
2277 FREE_ARRAY(DestFName[CurFile], "data set fname");
2278 if (BlckFName[CurFile])
2279 FREE_ARRAY(BlckFName[CurFile], "data set fname");
2280 BlckFName[CurFile] = NULL;
2281 DestFName[CurFile] = NULL;
2283 /* reset arrays sized by number of variables */
2284 VarMinValue[CurFile].clear();
2285 VarMaxValue[CurFile].clear();
2286 NumRunningVarValues[CurFile].clear();
2287 IsSharedVar[CurFile].clear();
2288 IsPassiveVar[CurFile].clear();
2289 IsCellCentered[CurFile].clear();
2291 /* reset arrays sized by number of zones */
2292 MinMaxOffset[CurFile].clear();
2293 TotalNumFaceNodes[CurFile].clear();
2294 NumFaceConnections[CurFile].clear();
2295 FaceNeighborsOrMapWritten[CurFile].clear();
2296 NumConnectivityNodes[CurFile].clear();
2297 ConnectivityWritten[CurFile].clear();
2299 CurFile = 0;
2300 while ((CurFile < MaxNumFiles) && !IsOpen[CurFile])
2301 CurFile++;
2303 if (CurFile == MaxNumFiles)
2304 CurFile = -1;
2306 return RetVal;
2309 INTEGER4 LIBCALL TECEND111(void)
2311 return TECEND112();
2314 INTEGER4 LIBCALL TECEND110(void)
2316 return TECEND112();
2319 INTEGER4 LIBCALL TECEND100(void)
2321 return TECEND112();
2324 INTEGER4 LIBCALL TECEND(void)
2326 return TECEND112();
2329 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
2330 LIBFUNCTION INTEGER4 LIBCALL tecend112_(void)
2332 return TECEND112();
2335 LIBFUNCTION INTEGER4 LIBCALL tecend111_(void)
2337 return TECEND112();
2340 LIBFUNCTION INTEGER4 LIBCALL tecend110_(void)
2342 return TECEND112();
2345 LIBFUNCTION INTEGER4 LIBCALL tecend100_(void)
2347 return TECEND112();
2350 LIBFUNCTION INTEGER4 LIBCALL tecend_(void)
2352 return TECEND112();
2354 #endif
2359 static void GetNextLabel(const char **CPtr,
2360 char *NextLabel)
2362 int N = 0;
2363 char *NPtr = NextLabel;
2364 *NPtr = '\0';
2365 /* Find label start */
2366 while ((**CPtr) && (**CPtr != '"'))
2367 (*CPtr)++;
2368 if (**CPtr)
2369 (*CPtr)++;
2370 while ((N < 60) && (**CPtr) && (**CPtr != '"'))
2372 if (**CPtr == '\\')
2374 (*CPtr)++;
2376 *NPtr++ = **CPtr;
2377 N++;
2378 (*CPtr)++;
2380 if (**CPtr)
2381 (*CPtr)++;
2382 *NPtr = '\0';
2387 * TECLABXXX
2389 INTEGER4 LIBCALL TECLAB112(char *S)
2391 const char *CPtr = (const char *)S;
2392 LgIndex_t N = 0;
2393 char Label[60];
2395 if (CheckFile("TECLAB112") < 0)
2396 return (-1);
2398 #if defined MAKEARCHIVE
2399 if (DebugLevel[CurFile])
2400 PRINT0("\nInserting Custom Labels:\n");
2401 #endif
2405 GetNextLabel(&CPtr, Label);
2406 if (*Label)
2407 N++;
2409 while (*Label);
2411 if (N == 0)
2413 #if defined MAKEARCHIVE
2414 PRINT1("Err: (TECLAB112) Invalid custom label string: %s\n",
2415 (S ? S : " "));
2416 #endif
2417 NumErrs[CurFile]++;
2418 return (-1);
2421 WriteBinaryReal(HeadFile[CurFile], CustomLabelMarker, FieldDataType_Float);
2422 if (!WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)N))
2424 WriteErr("TECLAB112");
2425 return (-1);
2428 CPtr = (const char *)S;
2431 GetNextLabel(&CPtr, Label);
2432 if (*Label)
2434 if (!DumpDatafileString(HeadFile[CurFile], Label, TRUE))
2436 WriteErr("TECLAB112");
2437 return (-1);
2439 #if defined MAKEARCHIVE
2440 if (DebugLevel[CurFile])
2441 printf(" %s\n", Label);
2442 #endif
2445 while (*Label);
2447 return (0);
2450 INTEGER4 LIBCALL TECLAB111(char *S)
2452 return TECLAB112(S);
2455 INTEGER4 LIBCALL TECLAB110(char *S)
2457 return TECLAB112(S);
2460 INTEGER4 LIBCALL TECLAB100(char *S)
2462 return TECLAB112(S);
2465 INTEGER4 LIBCALL TECLAB(char *S)
2467 return TECLAB112(S);
2470 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
2471 LIBFUNCTION INTEGER4 LIBCALL teclab112_(char *S)
2473 return TECLAB112(S);
2476 LIBFUNCTION INTEGER4 LIBCALL teclab111_(char *S)
2478 return TECLAB112(S);
2481 LIBFUNCTION INTEGER4 LIBCALL teclab110_(char *S)
2483 return TECLAB112(S);
2486 LIBFUNCTION INTEGER4 LIBCALL teclab100_(char *S)
2488 return TECLAB112(S);
2491 LIBFUNCTION INTEGER4 LIBCALL teclab_(char *S)
2493 return TECLAB112(S);
2495 #endif
2499 * TECUSRXXX
2501 INTEGER4 LIBCALL TECUSR112(char *S)
2503 if (CheckFile("TECUSR112") < 0)
2504 return (-1);
2506 #if defined MAKEARCHIVE
2507 if (DebugLevel[CurFile])
2508 PRINT1("\nInserting UserRec: %s\n", S);
2509 #endif
2511 if ((S == NULL) || (*S == '\0'))
2513 #if defined MAKEARCHIVE
2514 PRINT0("Err: (TECUSR112) Invalid TECUSR110 string\n");
2515 #endif
2516 NumErrs[CurFile]++;
2517 return (-1);
2520 WriteBinaryReal(HeadFile[CurFile], UserRecMarker, FieldDataType_Float);
2521 if (!DumpDatafileString(HeadFile[CurFile], S, TRUE))
2523 #if defined MAKEARCHIVE
2524 if (DebugLevel[CurFile])
2525 printf("Err: (TECUSR112) Write failure for file %d\n", CurFile + 1);
2526 #endif
2527 NumErrs[CurFile]++;
2528 return (-1);
2530 return (0);
2533 INTEGER4 LIBCALL TECUSR111(char *S)
2535 return TECUSR112(S);
2538 INTEGER4 LIBCALL TECUSR110(char *S)
2540 return TECUSR112(S);
2543 INTEGER4 LIBCALL TECUSR100(char *S)
2545 return TECUSR112(S);
2548 INTEGER4 LIBCALL TECUSR(char *S)
2550 return TECUSR112(S);
2553 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
2554 LIBFUNCTION INTEGER4 LIBCALL tecusr112_(char *S)
2556 return TECUSR112(S);
2559 LIBFUNCTION INTEGER4 LIBCALL tecusr111_(char *S)
2561 return TECUSR112(S);
2564 LIBFUNCTION INTEGER4 LIBCALL tecusr110_(char *S)
2566 return TECUSR112(S);
2569 LIBFUNCTION INTEGER4 LIBCALL tecusr100_(char *S)
2571 return TECUSR112(S);
2574 LIBFUNCTION INTEGER4 LIBCALL tecusr_(char *S)
2576 return TECUSR112(S);
2578 #endif
2580 #if 0 // NOT_CURRENTLY_USED
2581 static int WriteGeomDataBlock(float *Data,
2582 LgIndex_t NumPts)
2584 LgIndex_t I;
2586 for (I = 0; I < NumPts; I++)
2588 if (!WriteBinaryReal(HeadFile[CurFile], Data[I], FieldDataType_Float))
2590 return (-1);
2593 return (0);
2597 static void ShowDebugColor(LgIndex_t Color)
2599 #if defined MAKEARCHIVE
2600 switch (Color)
2602 case 0 : PRINT0("BLACK\n"); break;
2603 case 1 : PRINT0("RED\n"); break;
2604 case 2 : PRINT0("GREEN\n"); break;
2605 case 3 : PRINT0("BLUE\n"); break;
2606 case 4 : PRINT0("CYAN\n"); break;
2607 case 5 : PRINT0("YELLOW\n"); break;
2608 case 6 : PRINT0("PURPLE\n"); break;
2609 case 7 : PRINT0("WHITE\n"); break;
2610 case 8 :
2611 case 9 :
2612 case 10:
2613 case 11:
2614 case 12:
2615 case 13:
2616 case 14:
2617 case 15: PRINT1("CUSTOM%1d\n", Color-7); break;
2618 default : PRINT0("INVALID\n");
2620 #endif
2622 #endif /* NOT_CURRENTLY_USED */
2626 * TECGEOXXX
2628 INTEGER4 LIBCALL TECGEO112(double *XOrThetaPos,
2629 double *YOrRPos,
2630 double *ZPos,
2631 INTEGER4 *PosCoordMode, /* 0=Grid, 1=Frame, 3=Grid3D */
2632 INTEGER4 *AttachToZone,
2633 INTEGER4 *Zone,
2634 INTEGER4 *Color,
2635 INTEGER4 *FillColor,
2636 INTEGER4 *IsFilled,
2637 INTEGER4 *GeomType,
2638 INTEGER4 *LinePattern,
2639 double *PatternLength,
2640 double *LineThickness,
2641 INTEGER4 *NumEllipsePts,
2642 INTEGER4 *ArrowheadStyle,
2643 INTEGER4 *ArrowheadAttachment,
2644 double *ArrowheadSize,
2645 double *ArrowheadAngle,
2646 INTEGER4 *Scope,
2647 INTEGER4 *Clipping,
2648 INTEGER4 *NumSegments,
2649 INTEGER4 *NumSegPts,
2650 float *XOrThetaGeomData,
2651 float *YOrRGeomData,
2652 float *ZGeomData,
2653 char *mfc)
2655 int I, RetVal;
2656 int RawDataSize = 0;
2657 double Fract;
2659 Geom_s Geom;
2661 if (CheckFile("TECGEO112") < 0)
2662 return (-1);
2664 Geom.PositionCoordSys = (CoordSys_e) * PosCoordMode;
2665 if (Geom.PositionCoordSys == CoordSys_Frame)
2666 Fract = 0.01;
2667 else
2668 Fract = 1.0;
2670 Geom.AnchorPos.Generic.V1 = (*XOrThetaPos) * Fract;
2671 Geom.AnchorPos.Generic.V2 = (*YOrRPos) * Fract;
2672 Geom.AnchorPos.Generic.V3 = (*ZPos) * Fract;
2673 Geom.AttachToZone = *AttachToZone != 0;
2674 Geom.Zone = *Zone - 1;
2675 Geom.BColor = (ColorIndex_t) * Color;
2676 Geom.FillBColor = (ColorIndex_t) * FillColor;
2677 Geom.IsFilled = *IsFilled;
2678 Geom.GeomType = (GeomType_e) * GeomType;
2679 Geom.LinePattern = (LinePattern_e) * LinePattern;
2680 Geom.PatternLength = *PatternLength / 100.0;
2681 Geom.LineThickness = *LineThickness / 100.0;
2682 Geom.NumEllipsePts = *NumEllipsePts;
2683 Geom.ArrowheadStyle = (ArrowheadStyle_e) * ArrowheadStyle;
2684 Geom.ArrowheadAttachment = (ArrowheadAttachment_e) * ArrowheadAttachment;
2685 Geom.ArrowheadSize = *ArrowheadSize / 100.0;
2686 Geom.ArrowheadAngle = *ArrowheadAngle / DEGPERRADIANS;
2687 Geom.Scope = (Scope_e) * Scope;
2688 Geom.DrawOrder = DrawOrder_AfterData;
2689 Geom.Clipping = (Clipping_e) * Clipping;
2690 Geom.NumSegments = *NumSegments;
2691 Geom.MacroFunctionCommand = mfc;
2692 Geom.ImageFileName = NULL;
2693 Geom.ImageNumber = 0;
2694 Geom.MaintainAspectRatio = TRUE;
2695 Geom.PixelAspectRatio = 1.0;
2696 Geom.ImageResizeFilter = ImageResizeFilter_Texture;
2698 if (Geom.GeomType == GeomType_LineSegs3D)
2700 Geom.GeomType = GeomType_LineSegs;
2701 Geom.PositionCoordSys = CoordSys_Grid3D;
2704 #if defined MAKEARCHIVE
2705 if (DebugLevel[CurFile])
2706 PRINT0("\nInserting Geometry\n");
2707 #endif
2709 switch (Geom.GeomType)
2711 case GeomType_LineSegs :
2713 int I;
2714 RawDataSize = 0;
2715 for (I = 0; I < *NumSegments; I++)
2717 Geom.NumSegPts[I] = NumSegPts[I];
2718 RawDataSize += NumSegPts[I];
2720 } break;
2721 case GeomType_Rectangle :
2722 case GeomType_Square :
2723 case GeomType_Circle :
2724 case GeomType_Ellipse :
2726 RawDataSize = 1;
2727 } break;
2728 case GeomType_Image :
2730 CHECK(FALSE); /* Images not allowed in data files. */
2731 } break;
2732 default :
2734 CHECK(FALSE);
2735 } break;
2738 Geom.DataType = FieldDataType_Float;
2739 Geom.GeomData.Generic.V1Base = AllocScratchNodalFieldDataPtr(RawDataSize, FieldDataType_Float, TRUE);
2740 Geom.GeomData.Generic.V2Base = AllocScratchNodalFieldDataPtr(RawDataSize, FieldDataType_Float, TRUE);
2741 Geom.GeomData.Generic.V3Base = AllocScratchNodalFieldDataPtr(RawDataSize, FieldDataType_Float, TRUE);
2743 for (I = 0; I < RawDataSize; I++)
2745 SetFieldValue(Geom.GeomData.Generic.V1Base, I, (double)XOrThetaGeomData[I]*Fract);
2746 SetFieldValue(Geom.GeomData.Generic.V2Base, I, (double)YOrRGeomData[I]*Fract);
2747 SetFieldValue(Geom.GeomData.Generic.V3Base, I, (double)ZGeomData[I]*Fract);
2750 if (DumpGeometry(HeadFile[CurFile], &Geom, TRUE, FALSE))
2751 RetVal = 0;
2752 else
2753 RetVal = -1;
2755 DeallocScratchNodalFieldDataPtr(&Geom.GeomData.Generic.V1Base);
2756 DeallocScratchNodalFieldDataPtr(&Geom.GeomData.Generic.V2Base);
2757 DeallocScratchNodalFieldDataPtr(&Geom.GeomData.Generic.V3Base);
2759 return RetVal;
2762 INTEGER4 LIBCALL TECGEO111(double *XOrThetaPos,
2763 double *YOrRPos,
2764 double *ZPos,
2765 INTEGER4 *PosCoordMode, /* 0=Grid, 1=Frame, 3=Grid3D */
2766 INTEGER4 *AttachToZone,
2767 INTEGER4 *Zone,
2768 INTEGER4 *Color,
2769 INTEGER4 *FillColor,
2770 INTEGER4 *IsFilled,
2771 INTEGER4 *GeomType,
2772 INTEGER4 *LinePattern,
2773 double *PatternLength,
2774 double *LineThickness,
2775 INTEGER4 *NumEllipsePts,
2776 INTEGER4 *ArrowheadStyle,
2777 INTEGER4 *ArrowheadAttachment,
2778 double *ArrowheadSize,
2779 double *ArrowheadAngle,
2780 INTEGER4 *Scope,
2781 INTEGER4 *Clipping,
2782 INTEGER4 *NumSegments,
2783 INTEGER4 *NumSegPts,
2784 float *XOrThetaGeomData,
2785 float *YOrRGeomData,
2786 float *ZGeomData,
2787 char *mfc)
2789 return TECGEO112(XOrThetaPos,
2790 YOrRPos,
2791 ZPos,
2792 PosCoordMode,
2793 AttachToZone,
2794 Zone,
2795 Color,
2796 FillColor,
2797 IsFilled,
2798 GeomType,
2799 LinePattern,
2800 PatternLength,
2801 LineThickness,
2802 NumEllipsePts,
2803 ArrowheadStyle,
2804 ArrowheadAttachment,
2805 ArrowheadSize,
2806 ArrowheadAngle,
2807 Scope,
2808 Clipping,
2809 NumSegments,
2810 NumSegPts,
2811 XOrThetaGeomData,
2812 YOrRGeomData,
2813 ZGeomData,
2814 mfc);
2817 INTEGER4 LIBCALL TECGEO110(double *XOrThetaPos,
2818 double *YOrRPos,
2819 double *ZPos,
2820 INTEGER4 *PosCoordMode, /* 0=Grid, 1=Frame, 3=Grid3D */
2821 INTEGER4 *AttachToZone,
2822 INTEGER4 *Zone,
2823 INTEGER4 *Color,
2824 INTEGER4 *FillColor,
2825 INTEGER4 *IsFilled,
2826 INTEGER4 *GeomType,
2827 INTEGER4 *LinePattern,
2828 double *PatternLength,
2829 double *LineThickness,
2830 INTEGER4 *NumEllipsePts,
2831 INTEGER4 *ArrowheadStyle,
2832 INTEGER4 *ArrowheadAttachment,
2833 double *ArrowheadSize,
2834 double *ArrowheadAngle,
2835 INTEGER4 *Scope,
2836 INTEGER4 *Clipping,
2837 INTEGER4 *NumSegments,
2838 INTEGER4 *NumSegPts,
2839 float *XOrThetaGeomData,
2840 float *YOrRGeomData,
2841 float *ZGeomData,
2842 char *mfc)
2844 return TECGEO112(XOrThetaPos,
2845 YOrRPos,
2846 ZPos,
2847 PosCoordMode,
2848 AttachToZone,
2849 Zone,
2850 Color,
2851 FillColor,
2852 IsFilled,
2853 GeomType,
2854 LinePattern,
2855 PatternLength,
2856 LineThickness,
2857 NumEllipsePts,
2858 ArrowheadStyle,
2859 ArrowheadAttachment,
2860 ArrowheadSize,
2861 ArrowheadAngle,
2862 Scope,
2863 Clipping,
2864 NumSegments,
2865 NumSegPts,
2866 XOrThetaGeomData,
2867 YOrRGeomData,
2868 ZGeomData,
2869 mfc);
2872 INTEGER4 LIBCALL TECGEO100(double *XOrThetaPos,
2873 double *YOrRPos,
2874 double *ZPos,
2875 INTEGER4 *PosCoordMode, /* 0=Grid, 1=Frame, 3=Grid3D */
2876 INTEGER4 *AttachToZone,
2877 INTEGER4 *Zone,
2878 INTEGER4 *Color,
2879 INTEGER4 *FillColor,
2880 INTEGER4 *IsFilled,
2881 INTEGER4 *GeomType,
2882 INTEGER4 *LinePattern,
2883 double *PatternLength,
2884 double *LineThickness,
2885 INTEGER4 *NumEllipsePts,
2886 INTEGER4 *ArrowheadStyle,
2887 INTEGER4 *ArrowheadAttachment,
2888 double *ArrowheadSize,
2889 double *ArrowheadAngle,
2890 INTEGER4 *Scope,
2891 INTEGER4 *Clipping,
2892 INTEGER4 *NumSegments,
2893 INTEGER4 *NumSegPts,
2894 float *XOrThetaGeomData,
2895 float *YOrRGeomData,
2896 float *ZGeomData,
2897 char *mfc)
2899 return TECGEO112(XOrThetaPos,
2900 YOrRPos,
2901 ZPos,
2902 PosCoordMode,
2903 AttachToZone,
2904 Zone,
2905 Color,
2906 FillColor,
2907 IsFilled,
2908 GeomType,
2909 LinePattern,
2910 PatternLength,
2911 LineThickness,
2912 NumEllipsePts,
2913 ArrowheadStyle,
2914 ArrowheadAttachment,
2915 ArrowheadSize,
2916 ArrowheadAngle,
2917 Scope,
2918 Clipping,
2919 NumSegments,
2920 NumSegPts,
2921 XOrThetaGeomData,
2922 YOrRGeomData,
2923 ZGeomData,
2924 mfc);
2927 INTEGER4 LIBCALL TECGEO(double *XPos,
2928 double *YPos,
2929 double *ZPos,
2930 INTEGER4 *PosCoordMode,
2931 INTEGER4 *AttachToZone,
2932 INTEGER4 *Zone,
2933 INTEGER4 *Color,
2934 INTEGER4 *FillColor,
2935 INTEGER4 *IsFilled,
2936 INTEGER4 *GeomType,
2937 INTEGER4 *LinePattern,
2938 double *PatternLength,
2939 double *LineThickness,
2940 INTEGER4 *NumEllipsePts,
2941 INTEGER4 *ArrowheadStyle,
2942 INTEGER4 *ArrowheadAttachment,
2943 double *ArrowheadSize,
2944 double *ArrowheadAngle,
2945 INTEGER4 *Scope,
2946 INTEGER4 *NumSegments,
2947 INTEGER4 *NumSegPts,
2948 float *XGeomData,
2949 float *YGeomData,
2950 float *ZGeomData,
2951 char *mfc)
2953 int Clipping = (int)Clipping_ClipToViewport;
2954 return TECGEO112(XPos,
2955 YPos,
2956 ZPos,
2957 PosCoordMode,
2958 AttachToZone,
2959 Zone,
2960 Color,
2961 FillColor,
2962 IsFilled,
2963 GeomType,
2964 LinePattern,
2965 PatternLength,
2966 LineThickness,
2967 NumEllipsePts,
2968 ArrowheadStyle,
2969 ArrowheadAttachment,
2970 ArrowheadSize,
2971 ArrowheadAngle,
2972 Scope,
2973 &Clipping,
2974 NumSegments,
2975 NumSegPts,
2976 XGeomData,
2977 YGeomData,
2978 ZGeomData,
2979 mfc);
2982 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
2983 LIBFUNCTION INTEGER4 LIBCALL tecgeo112_(double *XPos,
2984 double *YPos,
2985 double *ZPos,
2986 INTEGER4 *PosCoordMode,
2987 INTEGER4 *AttachToZone,
2988 INTEGER4 *Zone,
2989 INTEGER4 *Color,
2990 INTEGER4 *FillColor,
2991 INTEGER4 *IsFilled,
2992 INTEGER4 *GeomType,
2993 INTEGER4 *LinePattern,
2994 double *PatternLength,
2995 double *LineThickness,
2996 INTEGER4 *NumEllipsePts,
2997 INTEGER4 *ArrowheadStyle,
2998 INTEGER4 *ArrowheadAttachment,
2999 double *ArrowheadSize,
3000 double *ArrowheadAngle,
3001 INTEGER4 *Scope,
3002 INTEGER4 *Clipping,
3003 INTEGER4 *NumSegments,
3004 INTEGER4 *NumSegPts,
3005 float *XGeomData,
3006 float *YGeomData,
3007 float *ZGeomData,
3008 char *mfc)
3010 return TECGEO112(XPos,
3011 YPos,
3012 ZPos,
3013 PosCoordMode,
3014 AttachToZone,
3015 Zone,
3016 Color,
3017 FillColor,
3018 IsFilled,
3019 GeomType,
3020 LinePattern,
3021 PatternLength,
3022 LineThickness,
3023 NumEllipsePts,
3024 ArrowheadStyle,
3025 ArrowheadAttachment,
3026 ArrowheadSize,
3027 ArrowheadAngle,
3028 Scope,
3029 Clipping,
3030 NumSegments,
3031 NumSegPts,
3032 XGeomData,
3033 YGeomData,
3034 ZGeomData,
3035 mfc);
3038 LIBFUNCTION INTEGER4 LIBCALL tecgeo111_(double *XPos,
3039 double *YPos,
3040 double *ZPos,
3041 INTEGER4 *PosCoordMode,
3042 INTEGER4 *AttachToZone,
3043 INTEGER4 *Zone,
3044 INTEGER4 *Color,
3045 INTEGER4 *FillColor,
3046 INTEGER4 *IsFilled,
3047 INTEGER4 *GeomType,
3048 INTEGER4 *LinePattern,
3049 double *PatternLength,
3050 double *LineThickness,
3051 INTEGER4 *NumEllipsePts,
3052 INTEGER4 *ArrowheadStyle,
3053 INTEGER4 *ArrowheadAttachment,
3054 double *ArrowheadSize,
3055 double *ArrowheadAngle,
3056 INTEGER4 *Scope,
3057 INTEGER4 *Clipping,
3058 INTEGER4 *NumSegments,
3059 INTEGER4 *NumSegPts,
3060 float *XGeomData,
3061 float *YGeomData,
3062 float *ZGeomData,
3063 char *mfc)
3065 return TECGEO112(XPos,
3066 YPos,
3067 ZPos,
3068 PosCoordMode,
3069 AttachToZone,
3070 Zone,
3071 Color,
3072 FillColor,
3073 IsFilled,
3074 GeomType,
3075 LinePattern,
3076 PatternLength,
3077 LineThickness,
3078 NumEllipsePts,
3079 ArrowheadStyle,
3080 ArrowheadAttachment,
3081 ArrowheadSize,
3082 ArrowheadAngle,
3083 Scope,
3084 Clipping,
3085 NumSegments,
3086 NumSegPts,
3087 XGeomData,
3088 YGeomData,
3089 ZGeomData,
3090 mfc);
3093 LIBFUNCTION INTEGER4 LIBCALL tecgeo110_(double *XPos,
3094 double *YPos,
3095 double *ZPos,
3096 INTEGER4 *PosCoordMode,
3097 INTEGER4 *AttachToZone,
3098 INTEGER4 *Zone,
3099 INTEGER4 *Color,
3100 INTEGER4 *FillColor,
3101 INTEGER4 *IsFilled,
3102 INTEGER4 *GeomType,
3103 INTEGER4 *LinePattern,
3104 double *PatternLength,
3105 double *LineThickness,
3106 INTEGER4 *NumEllipsePts,
3107 INTEGER4 *ArrowheadStyle,
3108 INTEGER4 *ArrowheadAttachment,
3109 double *ArrowheadSize,
3110 double *ArrowheadAngle,
3111 INTEGER4 *Scope,
3112 INTEGER4 *Clipping,
3113 INTEGER4 *NumSegments,
3114 INTEGER4 *NumSegPts,
3115 float *XGeomData,
3116 float *YGeomData,
3117 float *ZGeomData,
3118 char *mfc)
3120 return TECGEO112(XPos,
3121 YPos,
3122 ZPos,
3123 PosCoordMode,
3124 AttachToZone,
3125 Zone,
3126 Color,
3127 FillColor,
3128 IsFilled,
3129 GeomType,
3130 LinePattern,
3131 PatternLength,
3132 LineThickness,
3133 NumEllipsePts,
3134 ArrowheadStyle,
3135 ArrowheadAttachment,
3136 ArrowheadSize,
3137 ArrowheadAngle,
3138 Scope,
3139 Clipping,
3140 NumSegments,
3141 NumSegPts,
3142 XGeomData,
3143 YGeomData,
3144 ZGeomData,
3145 mfc);
3148 LIBFUNCTION INTEGER4 LIBCALL tecgeo100_(double *XPos,
3149 double *YPos,
3150 double *ZPos,
3151 INTEGER4 *PosCoordMode,
3152 INTEGER4 *AttachToZone,
3153 INTEGER4 *Zone,
3154 INTEGER4 *Color,
3155 INTEGER4 *FillColor,
3156 INTEGER4 *IsFilled,
3157 INTEGER4 *GeomType,
3158 INTEGER4 *LinePattern,
3159 double *PatternLength,
3160 double *LineThickness,
3161 INTEGER4 *NumEllipsePts,
3162 INTEGER4 *ArrowheadStyle,
3163 INTEGER4 *ArrowheadAttachment,
3164 double *ArrowheadSize,
3165 double *ArrowheadAngle,
3166 INTEGER4 *Scope,
3167 INTEGER4 *Clipping,
3168 INTEGER4 *NumSegments,
3169 INTEGER4 *NumSegPts,
3170 float *XGeomData,
3171 float *YGeomData,
3172 float *ZGeomData,
3173 char *mfc)
3175 return TECGEO112(XPos,
3176 YPos,
3177 ZPos,
3178 PosCoordMode,
3179 AttachToZone,
3180 Zone,
3181 Color,
3182 FillColor,
3183 IsFilled,
3184 GeomType,
3185 LinePattern,
3186 PatternLength,
3187 LineThickness,
3188 NumEllipsePts,
3189 ArrowheadStyle,
3190 ArrowheadAttachment,
3191 ArrowheadSize,
3192 ArrowheadAngle,
3193 Scope,
3194 Clipping,
3195 NumSegments,
3196 NumSegPts,
3197 XGeomData,
3198 YGeomData,
3199 ZGeomData,
3200 mfc);
3203 LIBFUNCTION INTEGER4 LIBCALL tecgeo_(double *XPos,
3204 double *YPos,
3205 double *ZPos,
3206 INTEGER4 *PosCoordMode,
3207 INTEGER4 *AttachToZone,
3208 INTEGER4 *Zone,
3209 INTEGER4 *Color,
3210 INTEGER4 *FillColor,
3211 INTEGER4 *IsFilled,
3212 INTEGER4 *GeomType,
3213 INTEGER4 *LinePattern,
3214 double *PatternLength,
3215 double *LineThickness,
3216 INTEGER4 *NumEllipsePts,
3217 INTEGER4 *ArrowheadStyle,
3218 INTEGER4 *ArrowheadAttachment,
3219 double *ArrowheadSize,
3220 double *ArrowheadAngle,
3221 INTEGER4 *Scope,
3222 INTEGER4 *NumSegments,
3223 INTEGER4 *NumSegPts,
3224 float *XGeomData,
3225 float *YGeomData,
3226 float *ZGeomData,
3227 char *mfc)
3229 return TECGEO(XPos,
3230 YPos,
3231 ZPos,
3232 PosCoordMode,
3233 AttachToZone,
3234 Zone,
3235 Color,
3236 FillColor,
3237 IsFilled,
3238 GeomType,
3239 LinePattern,
3240 PatternLength,
3241 LineThickness,
3242 NumEllipsePts,
3243 ArrowheadStyle,
3244 ArrowheadAttachment,
3245 ArrowheadSize,
3246 ArrowheadAngle,
3247 Scope,
3248 NumSegments,
3249 NumSegPts,
3250 XGeomData,
3251 YGeomData,
3252 ZGeomData,
3253 mfc);
3255 #endif
3258 * TECTXTXXX
3260 INTEGER4 LIBCALL TECTXT112(double *XOrThetaPos,
3261 double *YOrRPos,
3262 double *ZOrUnusedPos,
3263 INTEGER4 *PosCoordMode,
3264 INTEGER4 *AttachToZone,
3265 INTEGER4 *Zone,
3266 INTEGER4 *BFont,
3267 INTEGER4 *FontHeightUnits,
3268 double *FontHeight,
3269 INTEGER4 *BoxType,
3270 double *BoxMargin,
3271 double *BoxLineThickness,
3272 INTEGER4 *BoxColor,
3273 INTEGER4 *BoxFillColor,
3274 double *Angle,
3275 INTEGER4 *Anchor,
3276 double *LineSpacing,
3277 INTEGER4 *TextColor,
3278 INTEGER4 *Scope,
3279 INTEGER4 *Clipping,
3280 char *String,
3281 char *mfc)
3283 int RetVal;
3284 Text_s Text;
3285 double Fract;
3286 if (CheckFile("TECTXT112") < 0)
3287 return (-1);
3289 Text.PositionCoordSys = (CoordSys_e) * PosCoordMode;
3290 if (Text.PositionCoordSys == CoordSys_Frame)
3291 Fract = 0.01;
3292 else
3293 Fract = 1.0;
3295 Text.AnchorPos.Generic.V1 = (*XOrThetaPos) * Fract;
3296 Text.AnchorPos.Generic.V2 = (*YOrRPos) * Fract;
3297 Text.AnchorPos.Generic.V3 = (*ZOrUnusedPos) * Fract;
3298 Text.AttachToZone = *AttachToZone != 0;
3299 Text.Zone = *Zone - 1;
3300 Text.BColor = (ColorIndex_t) * TextColor;
3301 Text.TextShape.Font = (Font_e) * BFont;
3302 Text.TextShape.SizeUnits = (Units_e) * FontHeightUnits;
3303 if (Text.TextShape.SizeUnits == Units_Frame)
3304 Text.TextShape.Height = (*FontHeight) / 100.0;
3305 else
3306 Text.TextShape.Height = *FontHeight;
3307 Text.Box.BoxType = (TextBox_e) * BoxType;
3308 Text.Box.Margin = *BoxMargin / 100.0;
3309 Text.Box.LineThickness = *BoxLineThickness / 100.0;
3310 Text.Box.BColor = (ColorIndex_t) * BoxColor;
3311 Text.Box.FillBColor = (ColorIndex_t) * BoxFillColor;
3312 Text.Anchor = (TextAnchor_e) * Anchor;
3313 Text.LineSpacing = *LineSpacing;
3314 Text.Angle = *Angle / DEGPERRADIANS;
3315 Text.Scope = (Scope_e) * Scope;
3316 Text.Text = String;
3317 Text.MacroFunctionCommand = mfc;
3318 Text.Clipping = (Clipping_e) * Clipping;
3320 #if defined MAKEARCHIVE
3321 if (DebugLevel[CurFile])
3322 PRINT1("\nInserting Text: %s\n", String);
3323 #endif
3325 if (DumpText(HeadFile[CurFile], &Text, TRUE, FALSE))
3326 RetVal = 0;
3327 else
3328 RetVal = -1;
3330 return RetVal;
3333 INTEGER4 LIBCALL TECTXT111(double *XOrThetaPos,
3334 double *YOrRPos,
3335 double *ZOrUnusedPos,
3336 INTEGER4 *PosCoordMode,
3337 INTEGER4 *AttachToZone,
3338 INTEGER4 *Zone,
3339 INTEGER4 *BFont,
3340 INTEGER4 *FontHeightUnits,
3341 double *FontHeight,
3342 INTEGER4 *BoxType,
3343 double *BoxMargin,
3344 double *BoxLineThickness,
3345 INTEGER4 *BoxColor,
3346 INTEGER4 *BoxFillColor,
3347 double *Angle,
3348 INTEGER4 *Anchor,
3349 double *LineSpacing,
3350 INTEGER4 *TextColor,
3351 INTEGER4 *Scope,
3352 INTEGER4 *Clipping,
3353 char *String,
3354 char *mfc)
3356 return TECTXT112(XOrThetaPos,
3357 YOrRPos,
3358 ZOrUnusedPos,
3359 PosCoordMode,
3360 AttachToZone,
3361 Zone,
3362 BFont,
3363 FontHeightUnits,
3364 FontHeight,
3365 BoxType,
3366 BoxMargin,
3367 BoxLineThickness,
3368 BoxColor,
3369 BoxFillColor,
3370 Angle,
3371 Anchor,
3372 LineSpacing,
3373 TextColor,
3374 Scope,
3375 Clipping,
3376 String,
3377 mfc);
3380 INTEGER4 LIBCALL TECTXT110(double *XOrThetaPos,
3381 double *YOrRPos,
3382 double *ZOrUnusedPos,
3383 INTEGER4 *PosCoordMode,
3384 INTEGER4 *AttachToZone,
3385 INTEGER4 *Zone,
3386 INTEGER4 *BFont,
3387 INTEGER4 *FontHeightUnits,
3388 double *FontHeight,
3389 INTEGER4 *BoxType,
3390 double *BoxMargin,
3391 double *BoxLineThickness,
3392 INTEGER4 *BoxColor,
3393 INTEGER4 *BoxFillColor,
3394 double *Angle,
3395 INTEGER4 *Anchor,
3396 double *LineSpacing,
3397 INTEGER4 *TextColor,
3398 INTEGER4 *Scope,
3399 INTEGER4 *Clipping,
3400 char *String,
3401 char *mfc)
3403 return TECTXT112(XOrThetaPos,
3404 YOrRPos,
3405 ZOrUnusedPos,
3406 PosCoordMode,
3407 AttachToZone,
3408 Zone,
3409 BFont,
3410 FontHeightUnits,
3411 FontHeight,
3412 BoxType,
3413 BoxMargin,
3414 BoxLineThickness,
3415 BoxColor,
3416 BoxFillColor,
3417 Angle,
3418 Anchor,
3419 LineSpacing,
3420 TextColor,
3421 Scope,
3422 Clipping,
3423 String,
3424 mfc);
3427 INTEGER4 LIBCALL TECTXT100(double *XOrThetaPos,
3428 double *YOrRPos,
3429 double *ZOrUnusedPos,
3430 INTEGER4 *PosCoordMode,
3431 INTEGER4 *AttachToZone,
3432 INTEGER4 *Zone,
3433 INTEGER4 *BFont,
3434 INTEGER4 *FontHeightUnits,
3435 double *FontHeight,
3436 INTEGER4 *BoxType,
3437 double *BoxMargin,
3438 double *BoxLineThickness,
3439 INTEGER4 *BoxColor,
3440 INTEGER4 *BoxFillColor,
3441 double *Angle,
3442 INTEGER4 *Anchor,
3443 double *LineSpacing,
3444 INTEGER4 *TextColor,
3445 INTEGER4 *Scope,
3446 INTEGER4 *Clipping,
3447 char *String,
3448 char *mfc)
3450 return TECTXT112(XOrThetaPos,
3451 YOrRPos,
3452 ZOrUnusedPos,
3453 PosCoordMode,
3454 AttachToZone,
3455 Zone,
3456 BFont,
3457 FontHeightUnits,
3458 FontHeight,
3459 BoxType,
3460 BoxMargin,
3461 BoxLineThickness,
3462 BoxColor,
3463 BoxFillColor,
3464 Angle,
3465 Anchor,
3466 LineSpacing,
3467 TextColor,
3468 Scope,
3469 Clipping,
3470 String,
3471 mfc);
3474 INTEGER4 LIBCALL TECTXT(double *XPos,
3475 double *YPos,
3476 INTEGER4 *PosCoordMode,
3477 INTEGER4 *AttachToZone,
3478 INTEGER4 *Zone,
3479 INTEGER4 *BFont,
3480 INTEGER4 *FontHeightUnits,
3481 double *FontHeight,
3482 INTEGER4 *BoxType,
3483 double *BoxMargin,
3484 double *BoxLineThickness,
3485 INTEGER4 *BoxColor,
3486 INTEGER4 *BoxFillColor,
3487 double *Angle,
3488 INTEGER4 *Anchor,
3489 double *LineSpacing,
3490 INTEGER4 *TextColor,
3491 INTEGER4 *Scope,
3492 char *Text,
3493 char *mfc)
3495 double ZPos = 0.0;
3496 int Clipping = (int)Clipping_ClipToViewport;
3497 return TECTXT112(XPos,
3498 YPos,
3499 &ZPos,
3500 PosCoordMode,
3501 AttachToZone,
3502 Zone,
3503 BFont,
3504 FontHeightUnits,
3505 FontHeight,
3506 BoxType,
3507 BoxMargin,
3508 BoxLineThickness,
3509 BoxColor,
3510 BoxFillColor,
3511 Angle,
3512 Anchor,
3513 LineSpacing,
3514 TextColor,
3515 Scope,
3516 &Clipping,
3517 Text,
3518 mfc);
3521 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
3522 LIBFUNCTION INTEGER4 LIBCALL tectxt112_(double *XOrThetaPos,
3523 double *YOrRPos,
3524 double *ZOrUnusedPos,
3525 INTEGER4 *PosCoordMode,
3526 INTEGER4 *AttachToZone,
3527 INTEGER4 *Zone,
3528 INTEGER4 *BFont,
3529 INTEGER4 *FontHeightUnits,
3530 double *FontHeight,
3531 INTEGER4 *BoxType,
3532 double *BoxMargin,
3533 double *BoxLineThickness,
3534 INTEGER4 *BoxColor,
3535 INTEGER4 *BoxFillColor,
3536 double *Angle,
3537 INTEGER4 *Anchor,
3538 double *LineSpacing,
3539 INTEGER4 *TextColor,
3540 INTEGER4 *Scope,
3541 INTEGER4 *Clipping,
3542 char *String,
3543 char *mfc)
3545 return TECTXT112(XOrThetaPos,
3546 YOrRPos,
3547 ZOrUnusedPos,
3548 PosCoordMode,
3549 AttachToZone,
3550 Zone,
3551 BFont,
3552 FontHeightUnits,
3553 FontHeight,
3554 BoxType,
3555 BoxMargin,
3556 BoxLineThickness,
3557 BoxColor,
3558 BoxFillColor,
3559 Angle,
3560 Anchor,
3561 LineSpacing,
3562 TextColor,
3563 Scope,
3564 Clipping,
3565 String,
3566 mfc);
3569 LIBFUNCTION INTEGER4 LIBCALL tectxt111_(double *XOrThetaPos,
3570 double *YOrRPos,
3571 double *ZOrUnusedPos,
3572 INTEGER4 *PosCoordMode,
3573 INTEGER4 *AttachToZone,
3574 INTEGER4 *Zone,
3575 INTEGER4 *BFont,
3576 INTEGER4 *FontHeightUnits,
3577 double *FontHeight,
3578 INTEGER4 *BoxType,
3579 double *BoxMargin,
3580 double *BoxLineThickness,
3581 INTEGER4 *BoxColor,
3582 INTEGER4 *BoxFillColor,
3583 double *Angle,
3584 INTEGER4 *Anchor,
3585 double *LineSpacing,
3586 INTEGER4 *TextColor,
3587 INTEGER4 *Scope,
3588 INTEGER4 *Clipping,
3589 char *String,
3590 char *mfc)
3592 return TECTXT112(XOrThetaPos,
3593 YOrRPos,
3594 ZOrUnusedPos,
3595 PosCoordMode,
3596 AttachToZone,
3597 Zone,
3598 BFont,
3599 FontHeightUnits,
3600 FontHeight,
3601 BoxType,
3602 BoxMargin,
3603 BoxLineThickness,
3604 BoxColor,
3605 BoxFillColor,
3606 Angle,
3607 Anchor,
3608 LineSpacing,
3609 TextColor,
3610 Scope,
3611 Clipping,
3612 String,
3613 mfc);
3616 LIBFUNCTION INTEGER4 LIBCALL tectxt110_(double *XOrThetaPos,
3617 double *YOrRPos,
3618 double *ZOrUnusedPos,
3619 INTEGER4 *PosCoordMode,
3620 INTEGER4 *AttachToZone,
3621 INTEGER4 *Zone,
3622 INTEGER4 *BFont,
3623 INTEGER4 *FontHeightUnits,
3624 double *FontHeight,
3625 INTEGER4 *BoxType,
3626 double *BoxMargin,
3627 double *BoxLineThickness,
3628 INTEGER4 *BoxColor,
3629 INTEGER4 *BoxFillColor,
3630 double *Angle,
3631 INTEGER4 *Anchor,
3632 double *LineSpacing,
3633 INTEGER4 *TextColor,
3634 INTEGER4 *Scope,
3635 INTEGER4 *Clipping,
3636 char *String,
3637 char *mfc)
3639 return TECTXT112(XOrThetaPos,
3640 YOrRPos,
3641 ZOrUnusedPos,
3642 PosCoordMode,
3643 AttachToZone,
3644 Zone,
3645 BFont,
3646 FontHeightUnits,
3647 FontHeight,
3648 BoxType,
3649 BoxMargin,
3650 BoxLineThickness,
3651 BoxColor,
3652 BoxFillColor,
3653 Angle,
3654 Anchor,
3655 LineSpacing,
3656 TextColor,
3657 Scope,
3658 Clipping,
3659 String,
3660 mfc);
3663 LIBFUNCTION INTEGER4 LIBCALL tectxt100_(double *XOrThetaPos,
3664 double *YOrRPos,
3665 double *ZOrUnusedPos,
3666 INTEGER4 *PosCoordMode,
3667 INTEGER4 *AttachToZone,
3668 INTEGER4 *Zone,
3669 INTEGER4 *BFont,
3670 INTEGER4 *FontHeightUnits,
3671 double *FontHeight,
3672 INTEGER4 *BoxType,
3673 double *BoxMargin,
3674 double *BoxLineThickness,
3675 INTEGER4 *BoxColor,
3676 INTEGER4 *BoxFillColor,
3677 double *Angle,
3678 INTEGER4 *Anchor,
3679 double *LineSpacing,
3680 INTEGER4 *TextColor,
3681 INTEGER4 *Scope,
3682 INTEGER4 *Clipping,
3683 char *String,
3684 char *mfc)
3686 return TECTXT112(XOrThetaPos,
3687 YOrRPos,
3688 ZOrUnusedPos,
3689 PosCoordMode,
3690 AttachToZone,
3691 Zone,
3692 BFont,
3693 FontHeightUnits,
3694 FontHeight,
3695 BoxType,
3696 BoxMargin,
3697 BoxLineThickness,
3698 BoxColor,
3699 BoxFillColor,
3700 Angle,
3701 Anchor,
3702 LineSpacing,
3703 TextColor,
3704 Scope,
3705 Clipping,
3706 String,
3707 mfc);
3710 LIBFUNCTION INTEGER4 LIBCALL tectxt_(double *XPos,
3711 double *YPos,
3712 INTEGER4 *PosCoordMode,
3713 INTEGER4 *AttachToZone,
3714 INTEGER4 *Zone,
3715 INTEGER4 *BFont,
3716 INTEGER4 *FontHeightUnits,
3717 double *FontHeight,
3718 INTEGER4 *BoxType,
3719 double *BoxMargin,
3720 double *BoxLineThickness,
3721 INTEGER4 *BoxColor,
3722 INTEGER4 *BoxFillColor,
3723 double *Angle,
3724 INTEGER4 *Anchor,
3725 double *LineSpacing,
3726 INTEGER4 *TextColor,
3727 INTEGER4 *Scope,
3728 char *Text,
3729 char *mfc)
3731 return TECTXT(XPos,
3732 YPos,
3733 PosCoordMode,
3734 AttachToZone,
3735 Zone,
3736 BFont,
3737 FontHeightUnits,
3738 FontHeight,
3739 BoxType,
3740 BoxMargin,
3741 BoxLineThickness,
3742 BoxColor,
3743 BoxFillColor,
3744 Angle,
3745 Anchor,
3746 LineSpacing,
3747 TextColor,
3748 Scope,
3749 Text,
3750 mfc);
3752 #endif
3756 * TECFILXXX
3758 INTEGER4 LIBCALL TECFIL112(INTEGER4 *F)
3760 if ((*F < 1) || (*F > MaxNumFiles))
3762 #if defined MAKEARCHIVE
3763 PRINT1("Err: (TECFIL112) Invalid file number requested (%d). File not changed.\n", *F);
3764 #endif
3765 return (-1);
3768 if (!IsOpen[*F-1])
3770 #if defined MAKEARCHIVE
3771 int I;
3772 PRINT1("Err: (TECFIL112) file %d is not open. File not changed.\n", *F);
3773 PRINT0("\n\nFile states are:\n");
3774 for (I = 0; I < MaxNumFiles; I++)
3775 PRINT2("file %d, IsOpen=%d\n", I + 1, IsOpen[I]);
3776 PRINT1("Current File is: %d\n", CurFile + 1);
3777 #endif
3778 return (-1);
3780 CurFile = *F - 1;
3781 #if defined MAKEARCHIVE
3782 if (DebugLevel[CurFile])
3784 PRINT1("Switching to file #%d\n\n", CurFile + 1);
3785 PRINT0("Current State is:\n");
3786 PRINT1(" Debug = %d\n", DebugLevel[CurFile]);
3787 PRINT1(" NumVars = %d\n", NumVars[CurFile]);
3788 PRINT1(" DestFName = %s\n", DestFName[CurFile]);
3789 PRINT1(" BlckFName = %s\n", BlckFName[CurFile]);
3790 PRINT1(" ZoneType = %s\n", ZoneTypes[ZoneType[CurFile]]);
3792 if (ZoneType[CurFile] == ORDERED)
3794 PRINT1(" IMax = %d\n", IMax[CurFile]);
3795 PRINT1(" JMax = %d\n", JMax[CurFile]);
3796 PRINT1(" KMax = %d\n", KMax[CurFile]);
3798 else
3800 PRINT1(" NumPoints = %d\n", IMax[CurFile]);
3801 PRINT1(" NumElmnts = %d\n", JMax[CurFile]);
3803 PRINT1(" NumDataValuesWritten = %d\n", NumDataValuesWritten[CurFile]);
3804 PRINT1(" CurZone = %d\n", CurZone[CurFile] + 1);
3806 #endif /* MAKEARCHIVE */
3807 return (0);
3810 INTEGER4 LIBCALL TECFIL111(INTEGER4 *F)
3812 return TECFIL112(F);
3815 INTEGER4 LIBCALL TECFIL110(INTEGER4 *F)
3817 return TECFIL112(F);
3820 INTEGER4 LIBCALL TECFIL100(INTEGER4 *F)
3822 return TECFIL112(F);
3825 INTEGER4 LIBCALL TECFIL(INTEGER4 *F)
3827 return TECFIL112(F);
3830 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
3831 LIBFUNCTION INTEGER4 LIBCALL tecfil112_(INTEGER4 *F)
3833 return TECFIL112(F);
3836 LIBFUNCTION INTEGER4 LIBCALL tecfil111_(INTEGER4 *F)
3838 return TECFIL112(F);
3841 LIBFUNCTION INTEGER4 LIBCALL tecfil110_(INTEGER4 *F)
3843 return TECFIL112(F);
3846 LIBFUNCTION INTEGER4 LIBCALL tecfil100_(INTEGER4 *F)
3848 return TECFIL112(F);
3851 LIBFUNCTION INTEGER4 LIBCALL tecfil_(INTEGER4 *F)
3853 return TECFIL112(F);
3855 #endif
3858 * TECFOREIGNXXX
3860 void LIBCALL TECFOREIGN112(INTEGER4 *OutputForeignByteOrder)
3862 REQUIRE(VALID_REF(OutputForeignByteOrder));
3864 DoWriteForeign = (*OutputForeignByteOrder != 0);
3867 void LIBCALL TECFOREIGN111(INTEGER4 *OutputForeignByteOrder)
3869 TECFOREIGN112(OutputForeignByteOrder);
3872 void LIBCALL TECFOREIGN110(INTEGER4 *OutputForeignByteOrder)
3874 TECFOREIGN112(OutputForeignByteOrder);
3877 void LIBCALL TECFOREIGN100(INTEGER4 *OutputForeignByteOrder)
3879 TECFOREIGN112(OutputForeignByteOrder);
3882 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
3883 LIBFUNCTION void LIBCALL tecforeign112_(INTEGER4 *OutputForeignByteOrder)
3885 TECFOREIGN112(OutputForeignByteOrder);
3888 LIBFUNCTION void LIBCALL tecforeign111_(INTEGER4 *OutputForeignByteOrder)
3890 TECFOREIGN112(OutputForeignByteOrder);
3893 LIBFUNCTION void LIBCALL tecforeign110_(INTEGER4 *OutputForeignByteOrder)
3895 TECFOREIGN112(OutputForeignByteOrder);
3898 LIBFUNCTION void LIBCALL tecforeign100_(INTEGER4 *OutputForeignByteOrder)
3900 TECFOREIGN112(OutputForeignByteOrder);
3902 #endif
3904 #if defined MAKEARCHIVE
3907 * A valid auxiliary data name character must begin with a '_' or alpha
3908 * character and may be followed by one or more '_', '.', alpha or digit
3909 * characters.
3911 static Boolean_t AuxDataIsValidNameChar(char Char,
3912 Boolean_t IsLeadChar)
3914 Boolean_t IsValidNameChar;
3916 REQUIRE(0 <= Char && "Char <= 127");
3917 REQUIRE(VALID_BOOLEAN(IsLeadChar));
3919 IsValidNameChar = (Char == '_' ||
3920 isalpha(Char));
3921 if (!IsLeadChar)
3922 IsValidNameChar = (IsValidNameChar ||
3923 Char == '.' ||
3924 isdigit(Char));
3926 ENSURE(VALID_BOOLEAN(IsValidNameChar));
3927 return IsValidNameChar;
3931 * Indicates if the auxiliary data name is valid. A valid auxiliary data name
3932 * must begin with a '_' or alpha character and may be followed by one or
3933 * more '_', '.', alpha or digit characters.
3935 static Boolean_t AuxDataIsValidName(const char *Name)
3937 Boolean_t IsValidName;
3938 const char *NPtr;
3939 REQUIRE(VALID_REF(Name));
3941 for (NPtr = Name, IsValidName = AuxDataIsValidNameChar(*NPtr, TRUE);
3942 IsValidName && *NPtr != '\0';
3943 NPtr++)
3945 IsValidName = AuxDataIsValidNameChar(*NPtr, FALSE);
3948 ENSURE(VALID_BOOLEAN(IsValidName));
3949 return IsValidName;
3952 #endif /* MAKEARCHIVE */
3955 * TECAUXSTRXXX
3957 LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR112(char *Name,
3958 char *Value)
3960 if (CheckFile("TECAUXSTR112") < 0)
3961 return (-1);
3963 #if defined MAKEARCHIVE
3964 if (DebugLevel[CurFile])
3965 PRINT2("\nInserting data set aux data: '%s' = '%s'\n", Name, Value);
3966 #endif
3968 if ((Name == NULL) || !AuxDataIsValidName(Name))
3970 #if defined MAKEARCHIVE
3971 PRINT0("Err: (TECAUXSTR112) Invalid Name string\n");
3972 #endif
3973 NumErrs[CurFile]++;
3974 return (-1);
3977 if ((Value == NULL) || (*Value == '\0'))
3979 #if defined MAKEARCHIVE
3980 if (DebugLevel[CurFile])
3981 PRINT0("Err: (TECAUXSTR112) Invalid Value string\n");
3982 #endif
3983 NumErrs[CurFile]++;
3984 return (-1);
3988 * Because the auxiliary data is at the end of the header section we don't
3989 * need to seek back to it.
3991 if (!WriteBinaryReal(HeadFile[CurFile], DataSetAuxMarker, FieldDataType_Float) ||
3992 !DumpDatafileString(HeadFile[CurFile], Name, TRUE /* WriteBinary */) ||
3993 !WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)AuxDataType_String) ||
3994 !DumpDatafileString(HeadFile[CurFile], (const char *)Value, TRUE /* WriteBinary */))
3996 #if defined MAKEARCHIVE
3997 if (DebugLevel[CurFile])
3998 printf("Err: (TECAUXSTR112) Write failure for file %d\n", CurFile + 1);
3999 #endif
4000 NumErrs[CurFile]++;
4001 return (-1);
4003 return (0);
4006 LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR111(char *Name,
4007 char *Value)
4009 return TECAUXSTR112(Name, Value);
4012 LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR110(char *Name,
4013 char *Value)
4015 return TECAUXSTR112(Name, Value);
4018 LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR100(char *Name,
4019 char *Value)
4021 return TECAUXSTR112(Name, Value);
4024 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
4025 LIBFUNCTION INTEGER4 LIBCALL tecauxstr112_(char *Name,
4026 char *Value)
4028 return TECAUXSTR112(Name, Value);
4031 LIBFUNCTION INTEGER4 LIBCALL tecauxstr111_(char *Name,
4032 char *Value)
4034 return TECAUXSTR112(Name, Value);
4037 LIBFUNCTION INTEGER4 LIBCALL tecauxstr110_(char *Name,
4038 char *Value)
4040 return TECAUXSTR112(Name, Value);
4043 LIBFUNCTION INTEGER4 LIBCALL tecauxstr100_(char *Name,
4044 char *Value)
4046 return TECAUXSTR112(Name, Value);
4048 #endif
4052 * TECZAUXSTRXXX
4054 LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR112(char *Name,
4055 char *Value)
4057 if (CheckFile("TECZAUXSTR112") < 0)
4058 return (-1);
4060 if (CurZone[CurFile] == -1)
4062 #if defined MAKEARCHIVE
4063 PRINT0("Err: (TECZAUXSTR112) Must call TECZNE112 prior to TECZAUXSTR112\n");
4064 #endif
4065 NumErrs[CurFile]++;
4066 return (-1);
4070 #if defined MAKEARCHIVE
4071 if (DebugLevel[CurFile])
4072 PRINT2("\nInserting zone aux data: '%s' = '%s'\n", Name, Value);
4073 #endif
4075 if ((Name == NULL) || !AuxDataIsValidName(Name))
4077 #if defined MAKEARCHIVE
4078 PRINT0("Err: (TECZAUXSTR112) Invalid Name string\n");
4079 #endif
4080 NumErrs[CurFile]++;
4081 return (-1);
4084 if ((Value == NULL) || (*Value == '\0'))
4086 #if defined MAKEARCHIVE
4087 if (DebugLevel[CurFile])
4088 PRINT0("Err: (TECZAUXSTR112) Invalid Value string\n");
4089 #endif
4090 NumErrs[CurFile]++;
4091 return (-1);
4095 * Have to back over the 0 already written, then write another one afterward.
4097 if (TP_FSEEK(HeadFile[CurFile]->File, -4, SEEK_CUR) ||
4098 !WriteBinaryInt32(HeadFile[CurFile], 1) ||
4099 !DumpDatafileString(HeadFile[CurFile], Name, TRUE /* WriteBinary */) ||
4100 !WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)AuxDataType_String) ||
4101 !DumpDatafileString(HeadFile[CurFile], (const char *)Value, TRUE /* WriteBinary */) ||
4102 !WriteBinaryInt32(HeadFile[CurFile], 0))
4104 #if defined MAKEARCHIVE
4105 if (DebugLevel[CurFile])
4106 printf("Err: (TECZAUXSTR112) Write failure for file %d\n", CurFile + 1);
4107 #endif
4108 NumErrs[CurFile]++;
4109 return (-1);
4112 return (0);
4115 LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR111(char *Name,
4116 char *Value)
4118 return TECZAUXSTR112(Name, Value);
4121 LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR110(char *Name,
4122 char *Value)
4124 return TECZAUXSTR112(Name, Value);
4127 LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR100(char *Name,
4128 char *Value)
4130 return TECZAUXSTR112(Name, Value);
4133 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
4134 LIBFUNCTION INTEGER4 LIBCALL teczauxstr112_(char *Name,
4135 char *Value)
4137 return TECZAUXSTR112(Name, Value);
4140 LIBFUNCTION INTEGER4 LIBCALL teczauxstr111_(char *Name,
4141 char *Value)
4143 return TECZAUXSTR112(Name, Value);
4146 LIBFUNCTION INTEGER4 LIBCALL teczauxstr110_(char *Name,
4147 char *Value)
4149 return TECZAUXSTR112(Name, Value);
4152 LIBFUNCTION INTEGER4 LIBCALL teczauxstr100_(char *Name,
4153 char *Value)
4155 return TECZAUXSTR112(Name, Value);
4157 #endif
4161 * TECVAUXSTRXXX
4163 LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR112(INTEGER4 *Var,
4164 char *Name,
4165 char *Value)
4167 if (CheckFile("TECVAUXSTR112") < 0)
4168 return (-1);
4170 #if defined MAKEARCHIVE
4171 if (DebugLevel[CurFile])
4172 PRINT2("\nInserting variable aux data: '%s' = '%s'\n", Name, Value);
4173 #endif
4175 if ((Name == NULL) || !AuxDataIsValidName(Name))
4177 #if defined MAKEARCHIVE
4178 PRINT0("Err: (TECVAUXSTR112) Invalid Name string\n");
4179 #endif
4180 NumErrs[CurFile]++;
4181 return (-1);
4184 if ((Value == NULL) || (*Value == '\0'))
4186 #if defined MAKEARCHIVE
4187 if (DebugLevel[CurFile])
4188 PRINT0("Err: (TECVAUXSTR112) Invalid Value string\n");
4189 #endif
4190 NumErrs[CurFile]++;
4191 return (-1);
4194 if (!WriteBinaryReal(HeadFile[CurFile], VarAuxMarker, FieldDataType_Float) ||
4195 !WriteBinaryInt32(HeadFile[CurFile], *Var - 1) ||
4196 !DumpDatafileString(HeadFile[CurFile], Name, TRUE /* WriteBinary */) ||
4197 !WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)AuxDataType_String) ||
4198 !DumpDatafileString(HeadFile[CurFile], (const char *)Value, TRUE /* WriteBinary */))
4200 #if defined MAKEARCHIVE
4201 if (DebugLevel[CurFile])
4202 printf("Err: (TECVAUXSTR112) Write failure for file %d\n", CurFile + 1);
4203 #endif
4204 NumErrs[CurFile]++;
4205 return (-1);
4208 return (0);
4211 LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR111(INTEGER4 *Var,
4212 char *Name,
4213 char *Value)
4215 return TECVAUXSTR112(Var, Name, Value);
4218 LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR110(INTEGER4 *Var,
4219 char *Name,
4220 char *Value)
4222 return TECVAUXSTR112(Var, Name, Value);
4225 LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR100(INTEGER4 *Var,
4226 char *Name,
4227 char *Value)
4229 return TECVAUXSTR112(Var, Name, Value);
4232 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
4233 LIBFUNCTION INTEGER4 LIBCALL tecvauxstr112_(INTEGER4 *Var,
4234 char *Name,
4235 char *Value)
4237 return TECVAUXSTR112(Var, Name, Value);
4240 LIBFUNCTION INTEGER4 LIBCALL tecvauxstr111_(INTEGER4 *Var,
4241 char *Name,
4242 char *Value)
4244 return TECVAUXSTR112(Var, Name, Value);
4247 LIBFUNCTION INTEGER4 LIBCALL tecvauxstr110_(INTEGER4 *Var,
4248 char *Name,
4249 char *Value)
4251 return TECVAUXSTR112(Var, Name, Value);
4254 LIBFUNCTION INTEGER4 LIBCALL tecvauxstr100_(INTEGER4 *Var,
4255 char *Name,
4256 char *Value)
4258 return TECVAUXSTR112(Var, Name, Value);
4260 #endif
4264 * TECFACEXXX
4266 LIBFUNCTION INTEGER4 LIBCALL TECFACE112(INTEGER4 *FaceConnections)
4268 INTEGER4 i, *Ptr;
4270 /* Mark that the face neighbors have been written for the zone even if it fails so as not to add extra error messages. */
4271 FaceNeighborsOrMapWritten[CurFile][CurZone[CurFile]] = TRUE;
4273 if (CheckFile("TECFACE112") < 0)
4274 return (-1);
4276 if (ZoneType[CurFile] == FEPOLYGON ||
4277 ZoneType[CurFile] == FEPOLYHEDRON)
4279 /* Wrong way to specify face neighbors for polygons and polyhedrons */
4280 #if defined MAKEARCHIVE
4281 PRINT0("Err: (TECFACE112) Cannot call TECFACE112 for polygonal or polyhedral zones.\n");
4282 #endif
4283 NumErrs[CurFile]++;
4284 return (-1);
4287 if (FileTypes[CurFile] == SOLUTIONFILE)
4289 #if defined MAKEARCHIVE
4290 PRINT0("Err: (TECFACE112) Cannot call TECFACE112 if the file type is SOLUTIONFILE.\n");
4291 #endif
4292 NumErrs[CurFile]++;
4293 return (-1);
4296 #if defined MAKEARCHIVE
4297 if (DebugLevel[CurFile])
4298 PRINT0("\nInserting face neighbor data\n");
4299 #endif
4301 if (FaceConnections == NULL)
4303 #if defined MAKEARCHIVE
4304 PRINT0("Err: (TECFACE112) Invalid array\n");
4305 #endif
4306 NumErrs[CurFile]++;
4307 return (-1);
4311 * Face neighbor connection have the following format for both
4312 * binary:
4314 * LOCALONETOONE 3 cz,fz,cz
4315 * LOCALONETOMANY nz+4 cz,fz,oz,nz,cz1,cz2,...,czn
4316 * GLOBALONETOONE 4 cz,fz,ZZ,CZ
4317 * GLOBALONETOMANY 2*nz+4 cz,fz,oz,nz,ZZ1,CZ1,ZZ2,CZ2,...,ZZn,CZn
4319 * Where:
4320 * cz = cell in current zone
4321 * fz = face of cell in current zone
4322 * oz = face obsuration flag (only applies to one-to-many):
4323 * 0 = face partially obscured
4324 * 1 = face entirely obscured
4325 * nz = number of cell or zone/cell associations (only applies to one-to-many)
4326 * ZZ = remote Zone
4327 * CZ = cell in remote zone
4329 * NOTE:
4330 * As of version 103 Tecplot assumes that face neighbors are zero based
4331 * instead of ones based. Since we have to maintain the contract we
4332 * subtract 1 for the caller.
4334 Ptr = FaceConnections;
4335 i = 0;
4336 while (i < NumFaceConnections[CurFile][CurZone[CurFile]])
4338 INTEGER4 n;
4339 INTEGER4 NumNum = 0;
4341 switch (FaceNeighborMode[CurFile])
4343 case FaceNeighborMode_LocalOneToOne:
4344 NumNum = 3;
4345 i++;
4346 break;
4347 case FaceNeighborMode_LocalOneToMany:
4348 NumNum = 4 + Ptr[3];
4349 i += Ptr[3];
4350 break;
4351 case FaceNeighborMode_GlobalOneToOne:
4352 NumNum = 4;
4353 i++;
4354 break;
4355 case FaceNeighborMode_GlobalOneToMany:
4356 NumNum = 4 + 2 * Ptr[3];
4357 i += Ptr[3];
4358 break;
4359 default:
4360 CHECK(FALSE);
4361 break;
4364 n = 0;
4365 if (FaceNeighborMode[CurFile] == FaceNeighborMode_LocalOneToMany ||
4366 FaceNeighborMode[CurFile] == FaceNeighborMode_GlobalOneToMany)
4369 * Write cz,fz,oz,nz: we do this by hand because the oz and nz values
4370 * are not zero based values.
4372 if (!WriteBinaryInt32(BlckFile[CurFile], Ptr[n++] - 1) || /* zero based as of version 103 */
4373 !WriteBinaryInt32(BlckFile[CurFile], Ptr[n++] - 1) || /* zero based as of version 103 */
4374 !WriteBinaryInt32(BlckFile[CurFile], Ptr[n++]) || /* ones based */
4375 !WriteBinaryInt32(BlckFile[CurFile], Ptr[n++])) /* ones based */
4377 #if defined MAKEARCHIVE
4378 if (DebugLevel[CurFile])
4379 printf("Err: (TECFACE112) Write failure for file %d\n", CurFile + 1);
4380 #endif
4381 NumErrs[CurFile]++;
4382 return (-1);
4386 /* starting from where we left off, output the remaining values */
4387 for (; n < NumNum; n++)
4388 if (!WriteBinaryInt32(BlckFile[CurFile], Ptr[n] - 1)) /* zero based as of version 103 */
4390 #if defined MAKEARCHIVE
4391 if (DebugLevel[CurFile])
4392 printf("Err: (TECFACE112) Write failure for file %d\n", CurFile + 1);
4393 #endif
4394 NumErrs[CurFile]++;
4395 return (-1);
4397 Ptr += NumNum;
4400 return (0);
4403 LIBFUNCTION INTEGER4 LIBCALL TECFACE111(INTEGER4 *FaceConnections)
4405 return TECFACE112(FaceConnections);
4408 LIBFUNCTION INTEGER4 LIBCALL TECFACE110(INTEGER4 *FaceConnections)
4410 return TECFACE112(FaceConnections);
4413 LIBFUNCTION INTEGER4 LIBCALL TECFACE100(INTEGER4 *FaceConnections)
4415 return TECFACE112(FaceConnections);
4418 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
4419 LIBFUNCTION INTEGER4 LIBCALL tecface112_(INTEGER4 *FaceConnections)
4421 return TECFACE112(FaceConnections);
4424 LIBFUNCTION INTEGER4 LIBCALL tecface111_(INTEGER4 *FaceConnections)
4426 return TECFACE112(FaceConnections);
4429 LIBFUNCTION INTEGER4 LIBCALL tecface110_(INTEGER4 *FaceConnections)
4431 return TECFACE112(FaceConnections);
4434 LIBFUNCTION INTEGER4 LIBCALL tecface100_(INTEGER4 *FaceConnections)
4436 return TECFACE112(FaceConnections);
4438 #endif
4442 * TECPOLYXXX
4444 LIBFUNCTION INTEGER4 LIBCALL TECPOLY112(INTEGER4 *FaceNodeCounts,
4445 INTEGER4 *FaceNodes,
4446 INTEGER4 *FaceLeftElems,
4447 INTEGER4 *FaceRightElems,
4448 INTEGER4 *FaceBndryConnectionCounts,
4449 INTEGER4 *FaceBndryConnectionElems,
4450 INTEGER4 *FaceBndryConnectionZones)
4452 INTEGER4 NumFaces = KMax[CurFile];
4453 INTEGER4 Result = 0;
4454 LgIndex_t Index;
4455 LgIndex_t MinNeighborValue = TECIO_NO_NEIGHBORING_ELEM;
4457 /* Mark that the face map has been written for the zone even if it fails so as not to add extra error messages. */
4458 FaceNeighborsOrMapWritten[CurFile][CurZone[CurFile]] = TRUE;
4460 if (NumFaces == 0 ||
4461 (ZoneType[CurFile] != FEPOLYGON &&
4462 ZoneType[CurFile] != FEPOLYHEDRON))
4464 #if defined MAKEARCHIVE
4465 PRINT0("Err: (TECPOLY112) The zone type must be FEPOLYGON or FEPOLYHEDRON and have NumFaces (KMax) > 0.\n");
4466 PRINT1(" NumFaces = %d\n", NumFaces);
4467 #endif
4468 NumErrs[CurFile]++;
4469 return (-1);
4472 if (ZoneType[CurFile] == FEPOLYHEDRON) /* FEPOLYGON doesn't need TotalNumFaceNodes since this is 2*NumFaces */
4474 if (TotalNumFaceNodes[CurFile][CurZone[CurFile]] <= 0)
4476 #if defined MAKEARCHIVE
4477 PRINT0("Err: (TECPOLY112) TotalNumFaceNodes MUST be specified for polyhedral zones.\n");
4478 PRINT1(" TotalNumFaceNodes = %d\n", TotalNumFaceNodes[CurFile][CurZone[CurFile]]);
4479 #endif
4480 NumErrs[CurFile]++;
4481 return (-1);
4484 else
4486 if (TotalNumFaceNodes[CurFile][CurZone[CurFile]] != (2 * NumFaces))
4488 #if defined MAKEARCHIVE
4489 PRINT0("Err: (TECPOLY112) TotalNumFaceNodes is specified for the polygonal zone but is not equal to 2 * NumFaces.\n");
4490 PRINT2(" TotalNumFaceNodes = %d. If specified, it must be 2 * %d.", TotalNumFaceNodes[CurFile][CurZone[CurFile]], NumFaces);
4491 #endif
4492 NumErrs[CurFile]++;
4493 return (-1);
4497 if ((TotalNumFaceBndryFaces[CurFile] > 0 &&
4498 TotalNumFaceBndryConns[CurFile] > 0) ||
4499 (TotalNumFaceBndryFaces[CurFile] == 0 &&
4500 TotalNumFaceBndryConns[CurFile] == 0))
4502 if (TotalNumFaceBndryFaces[CurFile] > 0)
4503 MinNeighborValue = -TotalNumFaceBndryFaces[CurFile];
4505 else
4507 #if defined MAKEARCHIVE
4508 PRINT0("Err: (TECPOLY112) TotalNumFaceBndryFaces and TotalNumFaceBndryConns must both be 0 or both be > 0.\n");
4509 PRINT2(" TotalNumFaceBndryFaces = %d, TotalNumFaceBndryConns = %d\n", TotalNumFaceBndryFaces[CurFile], TotalNumFaceBndryConns[CurFile]);
4510 #endif
4511 NumErrs[CurFile]++;
4512 return (-1);
4515 /* Write the facenodesoffsets array from the facenodecounts array. */
4516 if (Result == 0)
4518 if (ZoneType[CurFile] == FEPOLYHEDRON) /* FEPOLYGON doesn't need to specify facenodesoffsets */
4520 Int32_t FaceNodeSum = 0;
4521 if (!WriteBinaryInt32(BlckFile[CurFile], 0))
4522 Result = -1;
4523 for (Index = 0; (Result == 0) && (Index < NumFaces); Index++)
4525 FaceNodeSum += FaceNodeCounts[Index];
4526 if (FaceNodeCounts[Index] < 3)
4528 #if defined MAKEARCHIVE
4529 PRINT1("Err: (TECPOLY112) Invalid face node count value at face %d. There must be at least 3 nodes in a face.\n", Index + 1);
4530 PRINT1(" Face node count value = %d.\n", FaceNodeCounts[Index]);
4531 #endif
4532 NumErrs[CurFile]++;
4533 return (-1);
4535 else if (FaceNodeSum > TotalNumFaceNodes[CurFile][CurZone[CurFile]])
4537 #if defined MAKEARCHIVE
4538 PRINT1("Err: (TECPOLY112) The running face node count exceeds the TotalNumFaceNodes (%d) specified.\n", TotalNumFaceNodes[CurFile][CurZone[CurFile]]);
4539 PRINT1(" Face node count value = %d.\n", FaceNodeCounts[Index]);
4540 #endif
4541 NumErrs[CurFile]++;
4542 return (-1);
4544 else if (!WriteBinaryInt32(BlckFile[CurFile], FaceNodeSum))
4545 Result = -1;
4550 /* Write the facenodes array but convert 1-based to 0-based. */
4551 for (Index = 0; (Result == 0) && (Index < TotalNumFaceNodes[CurFile][CurZone[CurFile]]); Index++)
4553 if (FaceNodes[Index] < 1 ||
4554 FaceNodes[Index] > IMax[CurFile])
4556 #if defined MAKEARCHIVE
4557 PRINT1("Err: (TECPOLY112) Invalid face node value at node %d:\n", Index + 1);
4558 PRINT2(" face node value = %d, valid values are are 1 to %d (inclusive).\n", FaceNodes[Index], IMax[CurFile]);
4559 #endif
4560 NumErrs[CurFile]++;
4561 return (-1);
4563 else if (!WriteBinaryInt32(BlckFile[CurFile], FaceNodes[Index] - 1))
4564 Result = -1;
4567 /* Write the left elements array but convert 1-based to 0-based. */
4568 for (Index = 0; (Result == 0) && (Index < NumFaces); Index++)
4570 if (FaceLeftElems[Index] < MinNeighborValue ||
4571 FaceLeftElems[Index] > JMax[CurFile])
4573 #if defined MAKEARCHIVE
4574 PRINT1("Err: (TECPOLY112) Invalid left neighbor value at face %d:\n", Index);
4575 PRINT2(" left neighbor value = %d, min value = %d,", FaceLeftElems[Index], MinNeighborValue);
4576 PRINT1(" max value = %d.\n", JMax[CurFile]);
4577 #endif
4578 NumErrs[CurFile]++;
4579 return (-1);
4581 else if (!WriteBinaryInt32(BlckFile[CurFile], FaceLeftElems[Index] - 1))
4582 Result = -1;
4584 /* Write the right elements array but convert 1-based to 0-based. */
4585 for (Index = 0; (Result == 0) && (Index < NumFaces); Index++)
4587 if (FaceRightElems[Index] < MinNeighborValue ||
4588 FaceRightElems[Index] > JMax[CurFile])
4590 #if defined MAKEARCHIVE
4591 PRINT1("Err: (TECPOLY112) Invalid right neighbor value at face %d:\n", Index);
4592 PRINT2(" right neighbor value = %d, min value = %d,", FaceRightElems[Index], MinNeighborValue);
4593 PRINT1(" max value = %d.\n", JMax[CurFile]);
4594 #endif
4595 NumErrs[CurFile]++;
4596 return (-1);
4598 else if (!WriteBinaryInt32(BlckFile[CurFile], FaceRightElems[Index] - 1))
4599 Result = -1;
4601 if (Result == 0 &&
4602 (FaceLeftElems[Index] == TECIO_NO_NEIGHBORING_ELEM &&
4603 FaceRightElems[Index] == TECIO_NO_NEIGHBORING_ELEM))
4605 #if defined MAKEARCHIVE
4606 PRINT1("Err: (TECPOLY112) Both left and right neighbors are set to no neighboring element at face %d.\n", Index);
4607 #endif
4608 NumErrs[CurFile]++;
4609 return (-1);
4613 /* Write the boundary arrays. */
4614 if (Result == 0 && TotalNumFaceBndryFaces[CurFile] > 0)
4616 /* Write the boundaryconnectionoffsets array from the boundaryconnectioncounts array. */
4619 * As a convenience for the ASCII format, TecUtil, and TECIO layers if any
4620 * boundary connections exists we automatically add a no-neighboring
4621 * connection as the first item so that they can user 0 for no-neighboring
4622 * element in the element list regardless if they have boundary connections
4623 * or not.
4625 * The first 2 offsets are always 0 so that -1 in the left/right element
4626 * arrays always indicates "no neighboring element".
4628 if (!(WriteBinaryInt32(BlckFile[CurFile], 0) &&
4629 WriteBinaryInt32(BlckFile[CurFile], 0)))
4630 Result = -1;
4632 Int32_t BndryConnCount = 0;
4633 for (Index = 0; (Result == 0) && (Index < TotalNumFaceBndryFaces[CurFile]); Index++)
4635 BndryConnCount += FaceBndryConnectionCounts[Index];
4636 if (FaceBndryConnectionCounts[Index] < 0 ||
4637 BndryConnCount > TotalNumFaceBndryConns[CurFile])
4639 #if defined MAKEARCHIVE
4640 PRINT1("Err: (TECPOLY112) Invalid boundary connection count at boundary face %d:\n", Index + 1);
4641 PRINT1(" boundary connection count = %d.\n", FaceBndryConnectionCounts[Index]);
4642 #endif
4643 NumErrs[CurFile]++;
4644 return (-1);
4646 else if (!WriteBinaryInt32(BlckFile[CurFile], BndryConnCount))
4647 Result = -1;
4649 if (BndryConnCount != TotalNumFaceBndryConns[CurFile])
4651 #if defined MAKEARCHIVE
4652 PRINT0("Err: (TECPOLY112) Invalid number of boundary connections:\n");
4653 PRINT2(" number of boundary connections written = %d, total number of boundary connections = %d.",
4654 BndryConnCount, TotalNumFaceBndryConns[CurFile]);
4655 #endif
4656 NumErrs[CurFile]++;
4657 return (-1);
4660 /* Write the boundary connection elements but convert 1-based to 0-based. */
4661 BndryConnCount = 0;
4662 for (Index = 0; (Result == 0) && (Index < TotalNumFaceBndryFaces[CurFile]); Index++)
4664 for (LgIndex_t BIndex = 0; (Result == 0) && (BIndex < FaceBndryConnectionCounts[Index]); BIndex++)
4666 if (BIndex > 0 &&
4667 FaceBndryConnectionElems[BndryConnCount] == TECIO_NO_NEIGHBORING_ELEM)
4669 #if defined MAKEARCHIVE
4670 PRINT1("Err: (TECPOLY112) Partially obscured faces must specify no neighboring element first. See boundary connections for face %d.\n", Index + 1);
4671 #endif
4672 NumErrs[CurFile]++;
4673 return (-1);
4675 if (FaceBndryConnectionElems[BndryConnCount] < TECIO_NO_NEIGHBORING_ELEM)
4677 #if defined MAKEARCHIVE
4678 PRINT1("Err: (TECPOLY112) Invalid boundary element value at boundary connections for face %d:\n", Index + 1);
4679 #endif
4680 NumErrs[CurFile]++;
4681 return (-1);
4683 if (FaceBndryConnectionElems[BndryConnCount] == TECIO_NO_NEIGHBORING_ELEM &&
4684 FaceBndryConnectionZones[BndryConnCount] != TECIO_NO_NEIGHBORING_ZONE)
4686 #if defined MAKEARCHIVE
4687 PRINT1("Err: (TECPOLY112) Invalid boundary element/zone pair at boundary connections for face %d:\n", Index + 1);
4688 PRINT0(" Boundary elements specified as no neighboring element must also specify no neighboring zone.\n");
4689 #endif
4690 NumErrs[CurFile]++;
4691 return (-1);
4693 else if (!WriteBinaryInt32(BlckFile[CurFile], FaceBndryConnectionElems[BndryConnCount] - 1))
4694 Result = -1;
4695 BndryConnCount++;
4699 /* Write the boundary connection zones but convert 1-based to 0-based. */
4700 BndryConnCount = 0;
4701 for (Index = 0; (Result == 0) && (Index < TotalNumFaceBndryFaces[CurFile]); Index++)
4703 for (LgIndex_t BIndex = 0; (Result == 0) && (BIndex < FaceBndryConnectionCounts[Index]); BIndex++)
4705 if (FaceBndryConnectionZones[BndryConnCount] < TECIO_NO_NEIGHBORING_ZONE)
4707 #if defined MAKEARCHIVE
4708 PRINT1("Err: (TECPOLY112) Invalid boundary zone value at boundary connections for face %d:\n", Index + 1);
4709 #endif
4710 NumErrs[CurFile]++;
4711 return (-1);
4713 else if (!WriteBinaryInt32(BlckFile[CurFile], FaceBndryConnectionZones[BndryConnCount] - 1))
4714 Result = -1;
4715 BndryConnCount++;
4719 if (Result != 0)
4721 Result = -1;
4722 WriteErr("TECPOLY112");
4725 return Result;
4728 #if !defined INDEX_16_BIT // not supported in this test-only mode
4729 LIBFUNCTION INTEGER4 LIBCALL TECPOLY111(INTEGER4 *FaceNodeCounts,
4730 INTEGER4 *FaceNodes,
4731 INTEGER4 *FaceLeftElems,
4732 INTEGER4 *FaceRightElems,
4733 INTEGER4 *FaceBndryConnectionCounts,
4734 INTEGER4 *FaceBndryConnectionElems,
4735 INTEGER2 *FaceBndryConnectionZones)
4737 INTEGER4 Result = 0;
4738 EntIndex_t *FBCZones = NULL;
4740 if (TotalNumFaceBndryConns[CurFile] > 0)
4742 ALLOC_ARRAY(TotalNumFaceBndryConns[CurFile], EntIndex_t, "32-bit FaceBndryConnectionZones");
4744 if (FBCZones != NULL)
4746 for (LgIndex_t ZoneI = 0; ZoneI < TotalNumFaceBndryFaces[CurFile]; ZoneI++)
4747 FBCZones[ZoneI] = (EntIndex_t)FaceBndryConnectionZones[ZoneI];
4749 else
4751 #if defined MAKEARCHIVE
4752 PRINT0("Err: (TECPOLY111) Out of memory allocating temporary data.\n");
4753 #endif
4754 NumErrs[CurFile]++;
4755 return (-1);
4759 Result = TECPOLY112(FaceNodeCounts,
4760 FaceNodes,
4761 FaceLeftElems,
4762 FaceRightElems,
4763 FaceBndryConnectionCounts,
4764 FaceBndryConnectionElems,
4765 FBCZones);
4767 if (FBCZones != NULL)
4768 FREE_ARRAY(FBCZones, "32-bit FaceBndryConnectionZones");
4770 return Result;
4772 #endif // INDEX_16_BIT -- not supported in this test-only mode
4774 #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
4775 LIBFUNCTION INTEGER4 LIBCALL tecpoly112_(INTEGER4 *FaceNodeCounts,
4776 INTEGER4 *FaceNodes,
4777 INTEGER4 *FaceLeftElems,
4778 INTEGER4 *FaceRightElems,
4779 INTEGER4 *FaceBndryConnectionOffsets,
4780 INTEGER4 *FaceBndryConnectionElems,
4781 INTEGER4 *FaceBndryConnectionZones)
4783 return TECPOLY112(FaceNodeCounts,
4784 FaceNodes,
4785 FaceLeftElems,
4786 FaceRightElems,
4787 FaceBndryConnectionOffsets,
4788 FaceBndryConnectionElems,
4789 FaceBndryConnectionZones);
4792 LIBFUNCTION INTEGER4 LIBCALL tecpoly111_(INTEGER4 *FaceNodeCounts,
4793 INTEGER4 *FaceNodes,
4794 INTEGER4 *FaceLeftElems,
4795 INTEGER4 *FaceRightElems,
4796 INTEGER4 *FaceBndryConnectionOffsets,
4797 INTEGER4 *FaceBndryConnectionElems,
4798 INTEGER2 *FaceBndryConnectionZones)
4800 return TECPOLY111(FaceNodeCounts,
4801 FaceNodes,
4802 FaceLeftElems,
4803 FaceRightElems,
4804 FaceBndryConnectionOffsets,
4805 FaceBndryConnectionElems,
4806 FaceBndryConnectionZones);
4808 #endif
4810 #if defined TECPLOTKERNEL
4811 /* CORE SOURCE CODE REMOVED */
4812 #endif