PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/tecxxx.cpp

https://github.com/Ingenierias2003/OpenFOAM-1.7.x
C++ | 4812 lines | 4687 code | 48 blank | 77 comment | 98 complexity | 5fe49e9e034ec3c2048bcba2da04635a MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1
  1. /*
  2. * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM
  3. *
  4. * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide.
  5. *
  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.
  13. *
  14. * This limited grant of distribution does not supersede Tecplot, Inc.'s
  15. * copyright in TecIO. Contact Tecplot, Inc. for further information.
  16. *
  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/
  22. *
  23. */
  24. #include "stdafx.h"
  25. #include "MASTER.h"
  26. #define TECPLOTENGINEMODULE
  27. /*
  28. ******************************************************************
  29. ******************************************************************
  30. ******* ********
  31. ****** (C) 1988-2008 Tecplot, Inc. *******
  32. ******* ********
  33. ******************************************************************
  34. ******************************************************************
  35. */
  36. /* Source file revision $Revision: 7627 $ */
  37. #include "GLOBAL.h"
  38. #include "TASSERT.h"
  39. #include "Q_UNICODE.h"
  40. #include "SYSTEM.h"
  41. #include "FILESTREAM.h"
  42. #if defined TECPLOTKERNEL
  43. /* CORE SOURCE CODE REMOVED */
  44. #endif
  45. #include "DATAIO4.h"
  46. #include "DATASET0.h"
  47. #include "TECXXX.h"
  48. #include "DATAUTIL.h"
  49. #include "ALLOC.h"
  50. #include <vector>
  51. #if !defined MAKEARCHIVE
  52. #include "AUXDATA.h"
  53. #endif /* MAKEARCHIVE */
  54. #if defined MSWIN
  55. #include <io.h>
  56. #endif
  57. #if defined UNIXX
  58. #include <stdio.h>
  59. #include <sys/types.h>
  60. #include <sys/stat.h>
  61. #endif
  62. #if defined TECPLOTKERNEL
  63. /* CORE SOURCE CODE REMOVED */
  64. #endif
  65. using namespace std;
  66. #if defined MAKEARCHIVE
  67. #if defined MSWIN && defined _DEBUG
  68. /* For debug .dll builds, send debug info to debug window. */
  69. #define PRINT0(s) do { OutputDebugString(s); } while (0)
  70. #define PRINT1(s,a1) do { char buffer[512]; sprintf(buffer,s,a1); OutputDebugString(buffer); } while (0)
  71. #define PRINT2(s,a1,a2) do { char buffer[512]; sprintf(buffer,s,a1,a2); OutputDebugString(buffer); } while (0)
  72. #else
  73. /* For all other builds (including release .dll), send debug info to stdout. */
  74. #define PRINT0(s) printf(s)
  75. #define PRINT1(s,a1) printf(s,a1)
  76. #define PRINT2(s,a1,a2) printf(s,a1,a2)
  77. #endif
  78. #else
  79. #if defined MSWIN
  80. /* For nonarchive, Windows, don't send debug info. */
  81. #define PRINT0(s) ((void)0)
  82. #define PRINT1(s,a1) ((void)0)
  83. #define PRINT2(s,a1,a2) ((void)0)
  84. #else
  85. /* For nonarchive, nonwindows, send debug info to stdout. */
  86. #define PRINT0(s) printf(s)
  87. #define PRINT1(s,a1) printf(s,a1)
  88. #define PRINT2(s,a1,a2) printf(s,a1,a2)
  89. #endif
  90. #endif
  91. typedef char *FNameType;
  92. typedef FILE *FilePtr;
  93. #define MaxNumFiles 10
  94. #define MAX_DUPLIST_VARS 50 /* maybe crank up in the future */
  95. #define BYTES_PER_CHUNK 4096
  96. #define TECIO_NO_NEIGHBORING_ELEM 0
  97. #define TECIO_NO_NEIGHBORING_ZONE 0
  98. #if defined MAKEARCHIVE
  99. static LgIndex_t DebugLevel[MaxNumFiles] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  100. #endif
  101. static INTEGER4 IsOpen[MaxNumFiles] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  102. static INTEGER4 NumErrs[MaxNumFiles] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  103. static INTEGER4 NumVars[MaxNumFiles];
  104. static FNameType DestFName[MaxNumFiles] = {NULL, NULL, NULL, NULL, NULL,
  105. NULL, NULL, NULL, NULL, NULL
  106. };
  107. static FNameType BlckFName[MaxNumFiles] = {NULL, NULL, NULL, NULL, NULL,
  108. NULL, NULL, NULL, NULL, NULL
  109. };
  110. static FileStream_s* BlckFile[MaxNumFiles];
  111. static FileStream_s* HeadFile[MaxNumFiles];
  112. static vector<FileOffset_t> MinMaxOffset[MaxNumFiles]; /* vector dimensioned by num zones */
  113. static vector<double> VarMinValue[MaxNumFiles]; /* vector dimensioned by num vars */
  114. static vector<double> VarMaxValue[MaxNumFiles]; /* vector dimensioned by num vars */
  115. static INTEGER4 DoWriteForeign = FALSE; /* ...default is to write native */
  116. static INTEGER4 IsWritingNative[MaxNumFiles];
  117. static INTEGER4 IsBlock[MaxNumFiles];
  118. static INTEGER4 ZoneType[MaxNumFiles];
  119. static LgIndex_t IMax[MaxNumFiles]; /* ones based indices */
  120. static LgIndex_t JMax[MaxNumFiles]; /* ones based indices */
  121. static LgIndex_t KMax[MaxNumFiles]; /* ones based indices */
  122. static vector<LgIndex_t> TotalNumFaceNodes[MaxNumFiles]; /* vector dimensioned by num zones */
  123. static LgIndex_t TotalNumFaceBndryFaces[MaxNumFiles];
  124. static LgIndex_t TotalNumFaceBndryConns[MaxNumFiles];
  125. static LgIndex_t ICellMax[MaxNumFiles];
  126. static LgIndex_t JCellMax[MaxNumFiles];
  127. static LgIndex_t KCellMax[MaxNumFiles];
  128. static vector<INTEGER4> NumFaceConnections[MaxNumFiles]; /* vector dimensioned by num zones */
  129. static INTEGER4 FaceNeighborMode[MaxNumFiles];
  130. static vector<INTEGER4> FaceNeighborsOrMapWritten[MaxNumFiles]; /* vector dimensioned by num zones */
  131. static INTEGER4 NumIndices[MaxNumFiles];
  132. static LgIndex_t NumDataValuesWritten[MaxNumFiles];
  133. static LgIndex_t NumOrderedCCDataValuesWritten[MaxNumFiles]; /* CC data only */
  134. static LgIndex_t NumDataValuesToWrite[MaxNumFiles];
  135. static vector<LgIndex_t> NumRunningVarValues[MaxNumFiles]; /* vector dimensioned by num vars */
  136. static vector<Boolean_t> IsSharedVar[MaxNumFiles]; /* vector dimensioned by num vars */
  137. static vector<Boolean_t> IsPassiveVar[MaxNumFiles]; /* vector dimensioned by num vars */
  138. static INTEGER4 CurZone[MaxNumFiles]; /* zero based zone numbers */
  139. static INTEGER4 CurVar[MaxNumFiles]; /* zero based var numbers */
  140. static INTEGER4 FieldDataType;
  141. static INTEGER4 CurFile = -1;
  142. static vector<Boolean_t> IsCellCentered[MaxNumFiles]; /* vector dimensioned by num vars */
  143. static Boolean_t HasFECONNECT[MaxNumFiles];
  144. static INTEGER4 FileTypes[MaxNumFiles];
  145. static vector<INTEGER4> NumConnectivityNodes[MaxNumFiles]; /* vector dimensioned by num zones */
  146. static vector<Boolean_t> ConnectivityWritten[MaxNumFiles]; /* vector dimensioned by num zones */
  147. /*
  148. * From preplot.cpp:
  149. *
  150. * ZoneType 0=ORDERED,1=FELINESEG,2=FETRIANGLE,
  151. * 3=FEQUADRILATERAL,4=FETETRAHEDRON,5=FEBRICK,
  152. * 6=FEPOLYGON,7=FEPOLYHEDRON
  153. */
  154. #define ORDERED 0
  155. #define FELINESEG 1
  156. #define FETRIANGLE 2
  157. #define FEQUADRILATERAL 3
  158. #define FETETRAHEDRON 4
  159. #define FEBRICK 5
  160. #define FEPOLYGON 6
  161. #define FEPOLYHEDRON 7
  162. /*
  163. * FileType 0=FULLFILE,1=GRIDFILE,2=SOLUTIONFILE
  164. */
  165. #define FULLFILE 0
  166. #define GRIDFILE 1
  167. #define SOLUTIONFILE 2
  168. #if defined MAKEARCHIVE
  169. static char const* ZoneTypes[] =
  170. {
  171. "ORDERED",
  172. "FELINESEG",
  173. "FETRIANGLE",
  174. "FEQUADRILATERAL",
  175. "FETETRAHEDRON",
  176. "FEBRICK",
  177. "FEPOLYGON",
  178. "FEPOLYHEDRON"
  179. };
  180. #endif /* MAKEARCHIVE */
  181. static void WriteErr(const char *routine_name)
  182. {
  183. #if defined MAKEARCHIVE
  184. PRINT2("Err: (%s) Write failure on file %d.\n", routine_name, CurFile + 1);
  185. #endif
  186. NumErrs[CurFile]++;
  187. }
  188. static LgIndex_t TecXXXZoneNum = 0;
  189. Boolean_t ParseDupList(LgIndex_t **ShareVarFromZone,
  190. LgIndex_t *ShareConnectivityFromZone,
  191. const char *DupList)
  192. {
  193. Boolean_t IsOk = TRUE;
  194. REQUIRE(VALID_REF(ShareVarFromZone) && *ShareVarFromZone == NULL);
  195. REQUIRE(VALID_REF(ShareConnectivityFromZone));
  196. REQUIRE(VALID_REF(DupList));
  197. while (IsOk && *DupList)
  198. {
  199. /* skip leading spaces */
  200. while (*DupList && *DupList == ' ')
  201. DupList++;
  202. /* is this the FECONNECT keyword? */
  203. if (*DupList && !strncmp(DupList, "FECONNECT", 9))
  204. *ShareConnectivityFromZone = TecXXXZoneNum;
  205. else if (*DupList && !isdigit(*DupList))
  206. IsOk = FALSE; /* syntax error */
  207. else if (*DupList)
  208. {
  209. char *NotUsed = NULL;
  210. EntIndex_t WhichVar = strtol(DupList, &NotUsed, 10);
  211. EntIndex_t numVarsForFile = NumVars[CurFile];
  212. if (0 < WhichVar && WhichVar < numVarsForFile)
  213. {
  214. if (!(*ShareVarFromZone))
  215. {
  216. *ShareVarFromZone = ALLOC_ARRAY(numVarsForFile, LgIndex_t, "Variable sharing list");
  217. if (*ShareVarFromZone)
  218. memset(*ShareVarFromZone, (char)0, numVarsForFile * sizeof(LgIndex_t));
  219. }
  220. if (*ShareVarFromZone)
  221. (*ShareVarFromZone)[WhichVar - 1] = TecXXXZoneNum;
  222. else
  223. IsOk = FALSE;
  224. }
  225. else
  226. {
  227. /* Invalid var num */
  228. IsOk = FALSE;
  229. }
  230. }
  231. /*
  232. * Skip to the comma. This
  233. * will also allow the syntax error
  234. * of more than one consecutive comma
  235. */
  236. while (*DupList && *DupList != ',')
  237. DupList++;
  238. /* skip past the comma (can handle the syntax error of more than 1 comma) */
  239. while (*DupList && *DupList == ',')
  240. DupList++;
  241. }
  242. return IsOk;
  243. }
  244. /**
  245. */
  246. static FileStream_s *OpenFileStream(const char *FilePath,
  247. const char *AccessMode,
  248. Boolean_t IsByteOrderNative)
  249. {
  250. REQUIRE(VALID_REF(FilePath));
  251. REQUIRE(VALID_REF(AccessMode));
  252. FileStream_s *Result = NULL;
  253. FILE *File = TP_FOPEN(FilePath, AccessMode);
  254. if (File != NULL)
  255. {
  256. Result = FileStreamAlloc(File, IsByteOrderNative);
  257. if (Result == NULL)
  258. TP_FCLOSE(File);
  259. }
  260. ENSURE((VALID_REF(Result) && VALID_REF(Result->File)) || Result == NULL);
  261. return Result;
  262. }
  263. /**
  264. */
  265. static void CloseFileStream(FileStream_s **FileStream)
  266. {
  267. REQUIRE(VALID_REF(FileStream));
  268. REQUIRE(VALID_REF(*FileStream) || *FileStream == NULL);
  269. if (*FileStream != NULL)
  270. {
  271. TP_FCLOSE((*FileStream)->File);
  272. FileStreamDealloc(FileStream);
  273. }
  274. ENSURE(*FileStream == NULL);
  275. }
  276. /**
  277. * Get the best terminator (separator) character to use for the string. First
  278. * precedence goes to the new line then the command and finally by default the
  279. * space. NOTE: We use a do loop to allow it to be used as a single statement.
  280. */
  281. #define GET_BEST_TERMINATOR_CHAR(CompoundStr, TerminatorChar) \
  282. do \
  283. { \
  284. if (strchr((CompoundStr), '\n') != NULL) \
  285. (TerminatorChar) = '\n'; \
  286. else if (strchr((CompoundStr), ',') != NULL) \
  287. (TerminatorChar) = ','; \
  288. else \
  289. (TerminatorChar) = ' '; \
  290. } while (0)
  291. /**
  292. * TECINIXXX
  293. */
  294. INTEGER4 LIBCALL TECINI112(char *Title,
  295. char *Variables,
  296. char *FName,
  297. char *ScratchDir,
  298. INTEGER4 *FileType,
  299. INTEGER4 *Debug,
  300. INTEGER4 *VIsDouble)
  301. {
  302. size_t L;
  303. int I;
  304. char RName[80];
  305. char *CPtr;
  306. int NewFile = -1;
  307. /*
  308. * Note that users should not mix TECXXX, TEC100XXX, and TEC110XXX calls, but
  309. * just in case, initialize the TecXXXZoneNum variable. It may not help, but
  310. * it doesn't hurt...
  311. */
  312. TecXXXZoneNum = 0;
  313. #if defined MAKEARCHIVE
  314. InitInputSpecs();
  315. #endif
  316. for (I = 0; (I < MaxNumFiles) && (NewFile == -1); I++)
  317. {
  318. if (!IsOpen[I])
  319. NewFile = I;
  320. }
  321. if (NewFile == -1)
  322. {
  323. #if defined MAKEARCHIVE
  324. PRINT1("Err: (TECINI112) Too many files (%d) opened for printing.\n", NewFile);
  325. #endif
  326. return (-1);
  327. }
  328. if (CurFile == -1)
  329. CurFile = 0;
  330. #if defined MAKEARCHIVE
  331. DebugLevel[NewFile] = *Debug;
  332. #endif
  333. /* check sizes for array sized by number of variables */
  334. CHECK(VarMinValue[NewFile].empty());
  335. CHECK(VarMaxValue[NewFile].empty());
  336. CHECK(NumRunningVarValues[NewFile].empty());
  337. CHECK(IsSharedVar[NewFile].empty());
  338. CHECK(IsPassiveVar[NewFile].empty());
  339. CHECK(IsCellCentered[NewFile].empty());
  340. /* check sizes for array sized by number of zones */
  341. CHECK(MinMaxOffset[NewFile].empty());
  342. CHECK(TotalNumFaceNodes[NewFile].empty());
  343. CHECK(NumFaceConnections[NewFile].empty());
  344. CHECK(FaceNeighborsOrMapWritten[NewFile].empty());
  345. CHECK(NumConnectivityNodes[NewFile].empty());
  346. CHECK(ConnectivityWritten[NewFile].empty());
  347. CurZone[NewFile] = -1;
  348. L = 0;
  349. if (FName != NULL)
  350. L = strlen(FName);
  351. if (L == 0)
  352. {
  353. #if defined MAKEARCHIVE
  354. PRINT1("Err: (TECINI112) Bad file name for file %d.\n", NewFile);
  355. #endif
  356. return (-1);
  357. }
  358. DestFName[NewFile] = ALLOC_ARRAY(L + 1, char, "data set fname");
  359. strcpy(DestFName[NewFile], FName);
  360. #if defined (DOS)
  361. {
  362. sprintf(RName, "BLCKFILE.%03d", (int)(NewFile + 1));
  363. }
  364. #else
  365. {
  366. sprintf(RName, "tp%1dXXXXXX", NewFile + 1);
  367. }
  368. #endif
  369. L = strlen(RName);
  370. if (ScratchDir != NULL)
  371. L += strlen(ScratchDir) + 1; /* +1 for the slash delimeter */
  372. BlckFName[NewFile] = ALLOC_ARRAY(L + 1, char, "data set fname");
  373. if (ScratchDir != NULL)
  374. {
  375. strcpy(BlckFName[NewFile], ScratchDir);
  376. #if defined DOS || defined MSWIN
  377. {
  378. strcat(BlckFName[NewFile], "\\");
  379. }
  380. #else
  381. {
  382. strcat(BlckFName[NewFile], "/");
  383. }
  384. #endif
  385. }
  386. else
  387. BlckFName[NewFile][0] = '\0';
  388. strcat(BlckFName[NewFile], RName);
  389. CHECK(strlen(BlckFName[NewFile]) <= L);
  390. #if defined MSWIN
  391. {
  392. _mktemp(BlckFName[NewFile]);
  393. }
  394. #elif defined UNIXX
  395. {
  396. /*
  397. * POSIX compiant behavior is to make
  398. * sure umask is set correctly first.
  399. */
  400. mode_t OrigUmask = umask(0022); /* ...should produce rw------- */
  401. int FileDesc = mkstemp(BlckFName[NewFile]);
  402. if (FileDesc != -1)
  403. close(FileDesc);
  404. umask(OrigUmask);
  405. }
  406. #endif
  407. #if defined MAKEARCHIVE
  408. if (DebugLevel[NewFile])
  409. {
  410. PRINT2("Scratch File #%d: %s\n", NewFile + 1, BlckFName[NewFile]);
  411. PRINT2("Dest File #%d: %s\n", NewFile + 1, DestFName[NewFile]);
  412. }
  413. #endif
  414. IsWritingNative[NewFile] = !DoWriteForeign;
  415. #if defined TECPLOTKERNEL
  416. /* CORE SOURCE CODE REMOVED */
  417. #endif
  418. HeadFile[NewFile] = OpenFileStream(DestFName[NewFile], "wb", IsWritingNative[NewFile]);
  419. BlckFile[NewFile] = OpenFileStream(BlckFName[NewFile], "wb", IsWritingNative[NewFile]);
  420. if (BlckFile[NewFile] == NULL)
  421. {
  422. #if defined MAKEARCHIVE
  423. PRINT0("Err: (TECINI112) Cannot open scratch file for output.\n");
  424. PRINT0(" Check permissions in scratch directory.\n");
  425. #endif
  426. NumErrs[NewFile]++;
  427. return (-1);
  428. }
  429. if (HeadFile[NewFile] == NULL)
  430. {
  431. #if defined MAKEARCHIVE
  432. PRINT0("Err: (TECINI112) Cannot open plot file. Check permissions.\n");
  433. #endif
  434. NumErrs[NewFile]++;
  435. return (-1);
  436. }
  437. writeBinaryVersionNumber(*HeadFile[NewFile],
  438. TecplotBinaryFileVersion);
  439. WriteBinaryMagic(HeadFile[NewFile]);
  440. /* Write file type */
  441. if (*FileType >= FULLFILE && *FileType <= SOLUTIONFILE)
  442. FileTypes[NewFile] = *FileType;
  443. else
  444. {
  445. #if defined MAKEARCHIVE
  446. PRINT0("Err: (TECINI112) Bad filetype argument. Check documentation.\n");
  447. #endif
  448. NumErrs[NewFile]++;
  449. return (-1);
  450. }
  451. CHECK(TecplotBinaryFileVersion == 112);
  452. if (!WriteBinaryInt32(HeadFile[NewFile], (LgIndex_t)FileTypes[NewFile]))
  453. {
  454. WriteErr("TECINI112");
  455. return (-1);
  456. }
  457. if (!DumpDatafileString(HeadFile[NewFile],
  458. Title,
  459. TRUE))
  460. {
  461. WriteErr("TECINI112");
  462. return (-1);
  463. }
  464. NumVars[NewFile] = 0;
  465. CPtr = Variables;
  466. /*
  467. * Three possible variable name separators are accepted with the following
  468. * precidence: newline, comma, and space.
  469. */
  470. {
  471. char terminator;
  472. GET_BEST_TERMINATOR_CHAR(CPtr, terminator);
  473. while (*CPtr)
  474. {
  475. /* strip leading spaces */
  476. while (*CPtr && *CPtr == ' ')
  477. CPtr++;
  478. if (*CPtr)
  479. {
  480. NumVars[NewFile]++;
  481. /* skip to terminating character */
  482. while (*CPtr && *CPtr != terminator)
  483. CPtr++;
  484. /* skip past terminating character */
  485. if (*CPtr)
  486. CPtr++;
  487. }
  488. }
  489. }
  490. #if 0
  491. /* A grid file can have no variables in it as long as there is a connectivity list */
  492. if (NumVars[NewFile] == 0 && FileTypes[NewFile] != GRIDFILE)
  493. {
  494. #if defined MAKEARCHIVE
  495. PRINT0("Err: (TECINI110) No variable names were defined.\n");
  496. #endif
  497. NumErrs[NewFile]++;
  498. return (-1);
  499. }
  500. #endif
  501. #if defined MAKEARCHIVE
  502. if (DebugLevel[NewFile])
  503. PRINT1("NumVars=%d\n", NumVars[NewFile]);
  504. #endif
  505. /* make sure var-sized arrays are big enough for all vars */
  506. try
  507. {
  508. VarMinValue[NewFile].resize(NumVars[NewFile]);
  509. VarMaxValue[NewFile].resize(NumVars[NewFile]);
  510. NumRunningVarValues[NewFile].resize(NumVars[NewFile]);
  511. IsSharedVar[NewFile].resize(NumVars[NewFile]);
  512. IsPassiveVar[NewFile].resize(NumVars[NewFile]);
  513. IsCellCentered[NewFile].resize(NumVars[NewFile]);
  514. }
  515. catch (std::bad_alloc const&)
  516. {
  517. #if defined MAKEARCHIVE
  518. PRINT0("Err: (TECINI112) Memory allocation error.\n");
  519. #endif
  520. NumErrs[NewFile]++;
  521. return (-1);
  522. }
  523. if (!WriteBinaryInt32(HeadFile[NewFile], (LgIndex_t)NumVars[NewFile]))
  524. {
  525. WriteErr("TECINI110");
  526. return (-1);
  527. }
  528. CPtr = Variables;
  529. {
  530. char terminator;
  531. char TString[MaxChrsVarName+1];
  532. int I;
  533. GET_BEST_TERMINATOR_CHAR(CPtr, terminator);
  534. while (*CPtr)
  535. {
  536. /* skip leading space characters */
  537. while (*CPtr && *CPtr == ' ')
  538. CPtr++;
  539. if (*CPtr)
  540. {
  541. I = 0;
  542. /* skip to terminator */
  543. while (*CPtr && *CPtr != terminator)
  544. {
  545. TString[I++] = *CPtr++;
  546. }
  547. /* skip past terminator */
  548. if (*CPtr)
  549. CPtr++;
  550. /* strip trailing spaces */
  551. I--;
  552. while (I >= 0 && TString[I] == ' ')
  553. I--;
  554. TString[I+1] = '\0';
  555. if (!DumpDatafileString(HeadFile[NewFile], TString, TRUE))
  556. {
  557. WriteErr("TECINI110");
  558. return (-1);
  559. }
  560. }
  561. }
  562. }
  563. IsOpen[NewFile] = 1;
  564. if (*VIsDouble)
  565. FieldDataType = FieldDataType_Double;
  566. else
  567. FieldDataType = FieldDataType_Float;
  568. return (0);
  569. }
  570. INTEGER4 LIBCALL TECINI111(char *Title,
  571. char *Variables,
  572. char *FName,
  573. char *ScratchDir,
  574. INTEGER4 *FileType,
  575. INTEGER4 *Debug,
  576. INTEGER4 *VIsDouble)
  577. {
  578. return TECINI112(Title,
  579. Variables,
  580. FName,
  581. ScratchDir,
  582. FileType,
  583. Debug,
  584. VIsDouble);
  585. }
  586. INTEGER4 LIBCALL TECINI110(char *Title,
  587. char *Variables,
  588. char *FName,
  589. char *ScratchDir,
  590. INTEGER4 *Debug,
  591. INTEGER4 *VIsDouble)
  592. {
  593. INTEGER4 FType = FULLFILE;
  594. TecXXXZoneNum = 0;
  595. return TECINI112(Title,
  596. Variables,
  597. FName,
  598. ScratchDir,
  599. &FType,
  600. Debug,
  601. VIsDouble);
  602. }
  603. INTEGER4 LIBCALL TECINI100(char *Title,
  604. char *Variables,
  605. char *FName,
  606. char *ScratchDir,
  607. INTEGER4 *Debug,
  608. INTEGER4 *VIsDouble)
  609. {
  610. INTEGER4 FType = FULLFILE;
  611. TecXXXZoneNum = 0;
  612. return TECINI112(Title,
  613. Variables,
  614. FName,
  615. ScratchDir,
  616. &FType,
  617. Debug,
  618. VIsDouble);
  619. }
  620. INTEGER4 LIBCALL TECINI(char *Title,
  621. char *Variables,
  622. char *FName,
  623. char *ScratchDir,
  624. INTEGER4 *Debug,
  625. INTEGER4 *VIsDouble)
  626. {
  627. INTEGER4 FType = FULLFILE;
  628. TecXXXZoneNum = 0;
  629. return TECINI112(Title,
  630. Variables,
  631. FName,
  632. ScratchDir,
  633. &FType,
  634. Debug,
  635. VIsDouble);
  636. }
  637. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  638. LIBFUNCTION INTEGER4 LIBCALL tecini112_(char *Title,
  639. char *Variables,
  640. char *FName,
  641. char *ScratchDir,
  642. INTEGER4 *FileType,
  643. INTEGER4 *Debug,
  644. INTEGER4 *VIsDouble)
  645. {
  646. return TECINI112(Title, Variables, FName, ScratchDir, FileType, Debug, VIsDouble);
  647. }
  648. LIBFUNCTION INTEGER4 LIBCALL tecini111_(char *Title,
  649. char *Variables,
  650. char *FName,
  651. char *ScratchDir,
  652. INTEGER4 *FileType,
  653. INTEGER4 *Debug,
  654. INTEGER4 *VIsDouble)
  655. {
  656. return TECINI112(Title, Variables, FName, ScratchDir, FileType, Debug, VIsDouble);
  657. }
  658. LIBFUNCTION INTEGER4 LIBCALL tecini110_(char *Title,
  659. char *Variables,
  660. char *FName,
  661. char *ScratchDir,
  662. INTEGER4 *Debug,
  663. INTEGER4 *VIsDouble)
  664. {
  665. INTEGER4 FType = FULLFILE;
  666. return TECINI112(Title, Variables, FName, ScratchDir, &FType, Debug, VIsDouble);
  667. }
  668. LIBFUNCTION INTEGER4 LIBCALL tecini100_(char *Title,
  669. char *Variables,
  670. char *FName,
  671. char *ScratchDir,
  672. INTEGER4 *Debug,
  673. INTEGER4 *VIsDouble)
  674. {
  675. INTEGER4 FType = FULLFILE;
  676. return TECINI112(Title, Variables, FName, ScratchDir, &FType, Debug, VIsDouble);
  677. }
  678. LIBFUNCTION INTEGER4 LIBCALL tecini_(char *Title,
  679. char *Variables,
  680. char *FName,
  681. char *ScratchDir,
  682. INTEGER4 *Debug,
  683. INTEGER4 *VIsDouble)
  684. {
  685. INTEGER4 FType = FULLFILE;
  686. return TECINI112(Title,
  687. Variables,
  688. FName,
  689. ScratchDir,
  690. &FType,
  691. Debug,
  692. VIsDouble);
  693. }
  694. #endif
  695. static int CheckData(const char *routine_name)
  696. {
  697. if (NumDataValuesToWrite[CurFile] != NumDataValuesWritten[CurFile])
  698. {
  699. #if defined MAKEARCHIVE
  700. PRINT2("Err: (%s) Wrong number of data values in file %d:\n", routine_name, CurFile + 1);
  701. PRINT2(" %d data values for Zone %d were processed,\n", NumDataValuesWritten[CurFile], CurZone[CurFile] + 1);
  702. PRINT1(" %d data values were expected.\n", NumDataValuesToWrite[CurFile]);
  703. #endif
  704. NumErrs[CurFile]++;
  705. return (-1);
  706. }
  707. return (0);
  708. }
  709. static int CheckFile(const char *routine_name)
  710. {
  711. if ((CurFile == -1) || (!IsOpen[CurFile]))
  712. {
  713. #if defined MAKEARCHIVE
  714. PRINT2("Err: (%s) Attempt to use invalid file (%d).\n",
  715. routine_name, CurFile + 1);
  716. #endif
  717. return (-1);
  718. }
  719. return (0);
  720. }
  721. /**
  722. * Advances CurVar[CurFile] to the next non-shared active variable. TECDATXXX
  723. * clients should not supply values for shared or passive variables.
  724. */
  725. static void AdvanceToNextVarWithValues(void)
  726. {
  727. /* search for the next variable with values */
  728. do
  729. {
  730. CurVar[CurFile]++;
  731. }
  732. while (CurVar[CurFile] < NumVars[CurFile] &&
  733. (IsSharedVar[CurFile][CurVar[CurFile]] ||
  734. IsPassiveVar[CurFile][CurVar[CurFile]]));
  735. }
  736. /**
  737. * TECZNEXXX
  738. */
  739. INTEGER4 LIBCALL TECZNE112(char *ZnTitle,
  740. INTEGER4 *ZnType,
  741. INTEGER4 *IMxOrNumPts,
  742. INTEGER4 *JMxOrNumElements,
  743. INTEGER4 *KMxOrNumFaces,
  744. INTEGER4 *ICellMx,
  745. INTEGER4 *JCellMx,
  746. INTEGER4 *KCellMx,
  747. double *SolutionTime,
  748. INTEGER4 *StrandID,
  749. INTEGER4 *ParentZone,
  750. INTEGER4 *IsBlk,
  751. INTEGER4 *NumFaceConn,
  752. INTEGER4 *FNMode,
  753. INTEGER4 *NumFaceNodes,
  754. INTEGER4 *NumFaceBndryFaces,
  755. INTEGER4 *NumFaceBndryConns,
  756. INTEGER4 *PassiveVarList,
  757. INTEGER4 *ValueLocation,
  758. INTEGER4 *ShareVarFromZone,
  759. INTEGER4 *ShareConnectivityFromZone)
  760. {
  761. int I;
  762. int IsOk = 1;
  763. if (CheckFile("TECZNE112") < 0)
  764. return (-1);
  765. if (CurZone[CurFile] > -1)
  766. {
  767. if (CheckData("TECZNE112") < 0)
  768. return (-1);
  769. }
  770. if (NumVars[CurFile] == 0)
  771. {
  772. WriteErr("TECZNE112");
  773. #if defined MAKEARCHIVE
  774. PRINT1("Err: (TECZNE112) Cannot write out zones if numvars is equal to zero (file %d).\n",
  775. CurFile + 1);
  776. #endif
  777. return (-1);
  778. }
  779. if (CurZone[CurFile] > MaxNumZonesOrVars - 2) /* -1 based */
  780. {
  781. WriteErr("TECZNE112");
  782. #if defined MAKEARCHIVE
  783. PRINT2("Err: (TECZNE112) Exceeded max number of zones (%d) in file %d.\n",
  784. MaxNumZonesOrVars, CurFile + 1);
  785. #endif
  786. return (-1);
  787. }
  788. if (*StrandID < -1)
  789. {
  790. #if defined MAKEARCHIVE
  791. PRINT2("Err: (TECZNE112) Invalid StrandID supplied for file %d, zone %d.\n",
  792. CurFile + 1, CurZone[CurFile] + 1 + 1);
  793. #endif
  794. return (-1);
  795. }
  796. if (*ParentZone < 0)
  797. {
  798. #if defined MAKEARCHIVE
  799. PRINT2("Err: (TECZNE112) Invalid ParentZone supplied for file %d, zone %d.\n",
  800. CurFile + 1, CurZone[CurFile] + 1 + 1);
  801. #endif
  802. return (-1);
  803. }
  804. /*
  805. * This is a temporary error. Point format should no longer be written to the file
  806. * and should instead be converted to block format before being written. Since the
  807. * conversion has not yet been implemented, it is an error to use point data.
  808. * TODO (JN): Remove this error when point to block conversion has been implemented.
  809. */
  810. if (*IsBlk != 1)
  811. {
  812. #if defined MAKEARCHIVE
  813. PRINT2("Err: (TECZNE112) Point data is not currently allowed. "
  814. " Please use block format for file %d, zone %d.\n",
  815. CurFile + 1, CurZone[CurFile] + 1 + 1);
  816. #endif
  817. return (-1);
  818. }
  819. NumDataValuesWritten[CurFile] = 0;
  820. NumOrderedCCDataValuesWritten[CurFile] = 0;
  821. CurZone[CurFile]++;
  822. /* Resize zone-dimensioned arrays (CurZone[] is 0-based) */
  823. try
  824. {
  825. MinMaxOffset[CurFile].resize(CurZone[CurFile] + 1);
  826. TotalNumFaceNodes[CurFile].resize(CurZone[CurFile] + 1);
  827. NumFaceConnections[CurFile].resize(CurZone[CurFile] + 1);
  828. FaceNeighborsOrMapWritten[CurFile].resize(CurZone[CurFile] + 1);
  829. NumConnectivityNodes[CurFile].resize(CurZone[CurFile] + 1);
  830. ConnectivityWritten[CurFile].resize(CurZone[CurFile] + 1);
  831. }
  832. catch (std::bad_alloc const&)
  833. {
  834. #if defined MAKEARCHIVE
  835. PRINT0("Err: (TECZNE112) Memory allocation error.\n");
  836. #endif
  837. NumErrs[CurFile]++;
  838. return (-1);
  839. }
  840. ZoneType[CurFile] = *ZnType;
  841. IMax[CurFile] = *IMxOrNumPts;
  842. JMax[CurFile] = *JMxOrNumElements;
  843. KMax[CurFile] = *KMxOrNumFaces;
  844. ICellMax[CurFile] = *ICellMx;
  845. JCellMax[CurFile] = *JCellMx;
  846. KCellMax[CurFile] = *KCellMx;
  847. /* Set the flags that connectivity, face neighbors or face map hasn't been written for the zone yet. */
  848. FaceNeighborsOrMapWritten[CurFile][CurZone[CurFile]] = FALSE;
  849. ConnectivityWritten[CurFile][CurZone[CurFile]] = FALSE;
  850. if (ZoneType[CurFile] == ZoneType_FEPolygon ||
  851. ZoneType[CurFile] == ZoneType_FEPolyhedron)
  852. {
  853. NumFaceConnections[CurFile][CurZone[CurFile]] = 0; /* ...not used for polytope data */
  854. FaceNeighborMode[CurFile] = 0; /* ...not used for polytope data */
  855. NumConnectivityNodes[CurFile][CurZone[CurFile]] = 0; /* ...not used for polytope data */
  856. IsBlock[CurFile] = TRUE; /* ...polytope data is always block */
  857. TotalNumFaceNodes[CurFile][CurZone[CurFile]] = *NumFaceNodes;
  858. TotalNumFaceBndryFaces[CurFile] = *NumFaceBndryFaces;
  859. TotalNumFaceBndryConns[CurFile] = *NumFaceBndryConns;
  860. }
  861. else /* ...classic data */
  862. {
  863. IsBlock[CurFile] = *IsBlk;
  864. NumFaceConnections[CurFile][CurZone[CurFile]] = *NumFaceConn;
  865. FaceNeighborMode[CurFile] = *FNMode;
  866. TotalNumFaceNodes[CurFile][CurZone[CurFile]] = 0; /* ...not used for classic data */
  867. TotalNumFaceBndryFaces[CurFile] = 0; /* ...not used for classic data */
  868. TotalNumFaceBndryConns[CurFile] = 0; /* ...not used for classic data */
  869. }
  870. WriteBinaryReal(HeadFile[CurFile],
  871. (double)ZoneMarker,
  872. FieldDataType_Float);
  873. if (!DumpDatafileString(HeadFile[CurFile],
  874. ZnTitle,
  875. TRUE))
  876. {
  877. WriteErr("TECZNE112");
  878. return (-1);
  879. }
  880. if ((ShareVarFromZone && *ShareConnectivityFromZone) &&
  881. CurZone[CurFile] == 0)
  882. {
  883. /* can't have a duplist if there's nothing to duplicate */
  884. IsOk = 0;
  885. }
  886. if (IsOk == 0)
  887. {
  888. #if defined MAKEARCHIVE
  889. PRINT1("Err: (TECZNE112) Bad zone format for file %d.\n", CurFile + 1);
  890. #endif
  891. NumErrs[CurFile]++;
  892. return (-1);
  893. }
  894. switch (ZoneType[CurFile])
  895. {
  896. case ORDERED:
  897. NumIndices[CurFile] = 0;
  898. break;
  899. case FELINESEG:
  900. NumIndices[CurFile] = 2;
  901. break;
  902. case FETRIANGLE:
  903. NumIndices[CurFile] = 3;
  904. break;
  905. case FEQUADRILATERAL:
  906. NumIndices[CurFile] = 4;
  907. break;
  908. case FETETRAHEDRON:
  909. NumIndices[CurFile] = 4;
  910. break;
  911. case FEBRICK:
  912. NumIndices[CurFile] = 8;
  913. break;
  914. }
  915. /* ...not used for poly or ordered data and don't count sharing or solution files. */
  916. if (ZoneType[CurFile] != ZoneType_FEPolygon &&
  917. ZoneType[CurFile] != ZoneType_FEPolyhedron &&
  918. *ShareConnectivityFromZone == 0 &&
  919. FileTypes[CurFile] != SOLUTIONFILE)
  920. NumConnectivityNodes[CurFile][CurZone[CurFile]] = NumIndices[CurFile] * JMax[CurFile];
  921. /*
  922. * We do not check any return values until the end. If these calls fail,
  923. * WriteFieldDataType below should fail as well.
  924. */
  925. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)(*ParentZone) - 1); /* ...ParentZone is zero based for binary file */
  926. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)(*StrandID) - 1); /* ...StrandID is zero based for binary file */
  927. WriteBinaryReal(HeadFile[CurFile], *SolutionTime, FieldDataType_Double);
  928. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t) - 1); /* No Zone Color Assignment */
  929. WriteBinaryInt32(HeadFile[CurFile], ZoneType[CurFile]);
  930. NumDataValuesToWrite[CurFile] = 0;
  931. for (I = 0; I < NumVars[CurFile]; I++)
  932. {
  933. IsSharedVar[CurFile][I] = (ShareVarFromZone != NULL && ShareVarFromZone[I] != 0); /* ...shared? */
  934. IsPassiveVar[CurFile][I] = (PassiveVarList != NULL && PassiveVarList[I] == 1); /* ...passive? */
  935. }
  936. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)(ValueLocation != NULL ? 1 : 0)); /* ...are var locations specified? */
  937. if (ValueLocation)
  938. {
  939. for (I = 0; I < NumVars[CurFile]; I++)
  940. {
  941. int VIndex;
  942. LgIndex_t NumNodes;
  943. LgIndex_t NumCells;
  944. if (ZoneType[CurFile] == ORDERED)
  945. {
  946. NumNodes = IMax[CurFile] * JMax[CurFile] * KMax[CurFile];
  947. NumCells = (MAX(IMax[CurFile] - 1, 1) *
  948. MAX(JMax[CurFile] - 1, 1) *
  949. MAX(KMax[CurFile] - 1, 1));
  950. }
  951. else
  952. {
  953. NumNodes = IMax[CurFile];
  954. NumCells = JMax[CurFile];
  955. }
  956. if (IsSharedVar[CurFile][I])
  957. VIndex = ShareVarFromZone[I] - 1;
  958. else
  959. VIndex = I;
  960. if (VIndex == 0)
  961. NumRunningVarValues[CurFile][I] = 0;
  962. else
  963. NumRunningVarValues[CurFile][VIndex] = NumRunningVarValues[CurFile][VIndex-1];
  964. IsCellCentered[CurFile][VIndex] = (ValueLocation[I] == ValueLocation_CellCentered);
  965. if (ValueLocation[I] == ValueLocation_CellCentered)
  966. {
  967. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)1);
  968. if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
  969. {
  970. NumDataValuesToWrite[CurFile] += NumCells;
  971. NumRunningVarValues[CurFile][VIndex] += NumCells;
  972. }
  973. }
  974. else if (ValueLocation[I] == ValueLocation_Nodal)
  975. {
  976. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0);
  977. if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
  978. {
  979. NumDataValuesToWrite[CurFile] += NumNodes;
  980. NumRunningVarValues[CurFile][VIndex] += NumNodes;
  981. }
  982. }
  983. else
  984. {
  985. #if defined MAKEARCHIVE
  986. PRINT2("Err: (TECZNE112) Bad zone value location for file %d, variable %d.\n", CurFile + 1, I + 1);
  987. #endif
  988. NumErrs[CurFile]++;
  989. return(-1);
  990. }
  991. }
  992. }
  993. else
  994. {
  995. LgIndex_t NumNodes;
  996. if (ZoneType[CurFile] == ORDERED)
  997. {
  998. NumNodes = IMax[CurFile] * JMax[CurFile] * KMax[CurFile];
  999. }
  1000. else
  1001. {
  1002. NumNodes = IMax[CurFile];
  1003. }
  1004. for (I = 0; I < NumVars[CurFile]; I++)
  1005. {
  1006. int VIndex;
  1007. if (IsSharedVar[CurFile][I])
  1008. VIndex = ShareVarFromZone[I] - 1;
  1009. else
  1010. VIndex = I;
  1011. if (VIndex == 0)
  1012. NumRunningVarValues[CurFile][I] = 0;
  1013. else
  1014. NumRunningVarValues[CurFile][VIndex] = NumRunningVarValues[CurFile][VIndex-1];
  1015. IsCellCentered[CurFile][VIndex] = FALSE;
  1016. if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
  1017. {
  1018. NumDataValuesToWrite[CurFile] += NumNodes;
  1019. NumRunningVarValues[CurFile][VIndex] += NumNodes;
  1020. }
  1021. }
  1022. }
  1023. /*
  1024. * As of binary version 108 Tecplot introduced
  1025. * the ability to output its auto-generated face
  1026. * neighbor array in its raw form. For now
  1027. * TecIO will always decline to perform this
  1028. * step and instead fall back to the delivering
  1029. * one neighbor at a time.
  1030. */
  1031. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0); /* IsRawFNAvailable */
  1032. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)NumFaceConnections[CurFile][CurZone[CurFile]]);
  1033. if (NumFaceConnections[CurFile][CurZone[CurFile]] > 0)
  1034. {
  1035. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)FaceNeighborMode[CurFile]);
  1036. if (ZoneType[CurFile] != ORDERED)
  1037. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0); /* FEFaceNeighborsComplete */
  1038. }
  1039. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)IMax[CurFile]);
  1040. if (ZoneType[CurFile] == FEPOLYGON ||
  1041. ZoneType[CurFile] == FEPOLYHEDRON)
  1042. {
  1043. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)KMax[CurFile]);
  1044. /*
  1045. * As of binary version 111 these items moved from the data section to
  1046. * the header.
  1047. */
  1048. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceNodes[CurFile][CurZone[CurFile]]);
  1049. if (TotalNumFaceBndryFaces[CurFile] > 0)
  1050. {
  1051. /* Each boundary face must have >= 1 boundary connection. */
  1052. if (TotalNumFaceBndryConns[CurFile] < TotalNumFaceBndryFaces[CurFile])
  1053. {
  1054. #if defined MAKEARCHIVE
  1055. PRINT1("Err: (TECZNE112) There must be at least 1 boundary connection for each boundary face in zone %d.\n",
  1056. CurZone[CurFile] + 1);
  1057. PRINT2(" %d boundary faces and %d boundary connections were specified.\n",
  1058. TotalNumFaceBndryFaces[CurFile], TotalNumFaceBndryConns[CurFile]);
  1059. #endif
  1060. NumErrs[CurFile]++;
  1061. return(-1);
  1062. }
  1063. /*
  1064. * As a convenience for the ASCII format, TecUtil, and TECIO layers if any
  1065. * boundary connections exists we automatically add a no-neighboring
  1066. * connection as the first item so that they can user 0 for no-neighboring
  1067. * element in the element list regardless if they have boundary connections
  1068. * or not.
  1069. */
  1070. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceBndryFaces[CurFile] + 1); /* ...add a boundary face for no neighboring element as a convenience */
  1071. }
  1072. else
  1073. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceBndryFaces[CurFile]);
  1074. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)TotalNumFaceBndryConns[CurFile]);
  1075. }
  1076. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)JMax[CurFile]);
  1077. if (ZoneType[CurFile] == ORDERED)
  1078. {
  1079. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)KMax[CurFile]);
  1080. }
  1081. else
  1082. {
  1083. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)ICellMax[CurFile]);
  1084. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)JCellMax[CurFile]);
  1085. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)KCellMax[CurFile]);
  1086. }
  1087. /*
  1088. * Aux data. This has to be over-written by the aux data writing routine.
  1089. * Because it currently at the end of the header section we don't need to
  1090. * keep track of the position for seeking back to it.
  1091. */
  1092. WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)0);
  1093. WriteBinaryReal(BlckFile[CurFile],
  1094. (double)ZoneMarker,
  1095. FieldDataType_Float);
  1096. for (I = 0; I < NumVars[CurFile]; I++)
  1097. {
  1098. if (!WriteFieldDataType(BlckFile[CurFile],
  1099. (FieldDataType_e)FieldDataType,
  1100. TRUE))
  1101. {
  1102. WriteErr("TECZNE112");
  1103. return (-1);
  1104. }
  1105. }
  1106. /* Passive variable identification */
  1107. if (PassiveVarList)
  1108. {
  1109. WriteBinaryInt32(BlckFile[CurFile], 1);
  1110. for (I = 0; I < NumVars[CurFile]; I++)
  1111. WriteBinaryInt32(BlckFile[CurFile], PassiveVarList[I]);
  1112. }
  1113. else
  1114. WriteBinaryInt32(BlckFile[CurFile], 0);
  1115. /* get the CurVar[CurFile] on the first active variable */
  1116. CurVar[CurFile] = -1;
  1117. AdvanceToNextVarWithValues();
  1118. /* Variable & Connectivity Sharing */
  1119. if (ShareVarFromZone)
  1120. {
  1121. WriteBinaryInt32(BlckFile[CurFile], 1);
  1122. for (I = 0; I < NumVars[CurFile]; I++)
  1123. WriteBinaryInt32(BlckFile[CurFile], ShareVarFromZone[I] - 1);
  1124. }
  1125. else
  1126. WriteBinaryInt32(BlckFile[CurFile], 0);
  1127. WriteBinaryInt32(BlckFile[CurFile], *ShareConnectivityFromZone - 1);
  1128. /*
  1129. * Create place holders or the variable min/max value. We will come back
  1130. * later after writing the data portion with the real min/max values. In the
  1131. * mean time, keep track of the starting point so we can seek back to this
  1132. * place.
  1133. */
  1134. MinMaxOffset[CurFile][CurZone[CurFile]] = (FileOffset_t)TP_FTELL(BlckFile[CurFile]->File);
  1135. for (I = 0; I < NumVars[CurFile]; I++)
  1136. {
  1137. /* initialize to unset values */
  1138. VarMinValue[CurFile][I] = LARGEDOUBLE;
  1139. VarMaxValue[CurFile][I] = -LARGEDOUBLE;
  1140. if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
  1141. {
  1142. WriteBinaryReal(BlckFile[CurFile], 0.0, FieldDataType_Double);
  1143. WriteBinaryReal(BlckFile[CurFile], 0.0, FieldDataType_Double);
  1144. }
  1145. }
  1146. #if defined MAKEARCHIVE
  1147. if (DebugLevel[CurFile])
  1148. {
  1149. PRINT1("Writing Zone %d:\n", CurZone[CurFile] + 1);
  1150. PRINT1(" Title = %s\n", ZnTitle);
  1151. PRINT1(" Type = %s\n", ZoneTypes[ZoneType[CurFile]]);
  1152. PRINT1(" IMax = %d\n", IMax[CurFile]);
  1153. PRINT1(" JMax = %d\n", JMax[CurFile]);
  1154. PRINT1(" KMax = %d\n", KMax[CurFile]);
  1155. if (ShareVarFromZone)
  1156. {
  1157. char DupList[1024] = "";
  1158. for (I = 0; I < NumVars[CurFile]; I++)
  1159. {
  1160. if (I > 0)
  1161. strcat(DupList, ",");
  1162. sprintf(&DupList[strlen(DupList)], "%d", ShareVarFromZone[I]);
  1163. }
  1164. PRINT1(" DupList = %s\n", DupList);
  1165. }
  1166. }
  1167. #endif
  1168. return (0);
  1169. }
  1170. INTEGER4 LIBCALL TECZNE111(char *ZnTitle,
  1171. INTEGER4 *ZnType,
  1172. INTEGER4 *IMxOrNumPts,
  1173. INTEGER4 *JMxOrNumElements,
  1174. INTEGER4 *KMxOrNumFaces,
  1175. INTEGER4 *ICellMx,
  1176. INTEGER4 *JCellMx,
  1177. INTEGER4 *KCellMx,
  1178. double *SolutionTime,
  1179. INTEGER4 *StrandID,
  1180. INTEGER4 *ParentZone,
  1181. INTEGER4 *IsBlk,
  1182. INTEGER4 *NumFaceConn,
  1183. INTEGER4 *FNMode,
  1184. INTEGER4 *NumFaceNodes,
  1185. INTEGER4 *NumFaceBndryFaces,
  1186. INTEGER4 *NumFaceBndryConns,
  1187. INTEGER4 *PassiveVarList,
  1188. INTEGER4 *ValueLocation,
  1189. INTEGER4 *ShareVarFromZone,
  1190. INTEGER4 *ShareConnectivityFromZone)
  1191. {
  1192. return TECZNE112(ZnTitle,
  1193. ZnType,
  1194. IMxOrNumPts,
  1195. JMxOrNumElements,
  1196. KMxOrNumFaces,
  1197. ICellMx,
  1198. JCellMx,
  1199. KCellMx,
  1200. SolutionTime,
  1201. StrandID,
  1202. ParentZone,
  1203. IsBlk,
  1204. NumFaceConn,
  1205. FNMode,
  1206. NumFaceNodes,
  1207. NumFaceBndryFaces,
  1208. NumFaceBndryConns,
  1209. PassiveVarList,
  1210. ValueLocation,
  1211. ShareVarFromZone,
  1212. ShareConnectivityFromZone);
  1213. }
  1214. INTEGER4 LIBCALL TECZNE110(char *ZnTitle,
  1215. INTEGER4 *ZnType,
  1216. INTEGER4 *IMxOrNumPts,
  1217. INTEGER4 *JMxOrNumElements,
  1218. INTEGER4 *KMx,
  1219. INTEGER4 *ICellMx,
  1220. INTEGER4 *JCellMx,
  1221. INTEGER4 *KCellMx,
  1222. double *SolutionTime,
  1223. INTEGER4 *StrandID,
  1224. INTEGER4 *ParentZone,
  1225. INTEGER4 *IsBlk,
  1226. INTEGER4 *NumFaceConn,
  1227. INTEGER4 *FNMode,
  1228. INTEGER4 *PassiveVarList,
  1229. INTEGER4 *ValueLocation,
  1230. INTEGER4 *ShareVarFromZone,
  1231. INTEGER4 *ShareConnectivityFromZone)
  1232. {
  1233. INTEGER4 NumFaceNodes = 0;
  1234. INTEGER4 NumFaceBndryFaces = 0;
  1235. INTEGER4 NumFaceBndryConns = 0;
  1236. return TECZNE112(ZnTitle,
  1237. ZnType,
  1238. IMxOrNumPts,
  1239. JMxOrNumElements,
  1240. KMx,
  1241. ICellMx,
  1242. JCellMx,
  1243. KCellMx,
  1244. SolutionTime,
  1245. StrandID,
  1246. ParentZone,
  1247. IsBlk,
  1248. NumFaceConn,
  1249. FNMode,
  1250. &NumFaceNodes,
  1251. &NumFaceBndryFaces,
  1252. &NumFaceBndryConns,
  1253. PassiveVarList,
  1254. ValueLocation,
  1255. ShareVarFromZone,
  1256. ShareConnectivityFromZone);
  1257. }
  1258. INTEGER4 LIBCALL TECZNE100(char *ZnTitle,
  1259. INTEGER4 *ZnType,
  1260. INTEGER4 *IMxOrNumPts,
  1261. INTEGER4 *JMxOrNumElements,
  1262. INTEGER4 *KMx,
  1263. INTEGER4 *ICellMx,
  1264. INTEGER4 *JCellMx,
  1265. INTEGER4 *KCellMx,
  1266. INTEGER4 *IsBlk,
  1267. INTEGER4 *NumFaceConn,
  1268. INTEGER4 *FNMode,
  1269. INTEGER4 *ValueLocation,
  1270. INTEGER4 *ShareVarFromZone,
  1271. INTEGER4 *ShareConnectivityFromZone)
  1272. {
  1273. double SolutionTime = 0.0;
  1274. INTEGER4 StrandID = STRAND_ID_STATIC + 1; /* TECXXX is ones based for StrandID */
  1275. INTEGER4 ParentZone = BAD_SET_VALUE + 1; /* TECXXX is ones based for ParentZone */
  1276. INTEGER4 NumFaceNodes = 0;
  1277. INTEGER4 NumFaceBndryFaces = 0;
  1278. INTEGER4 NumFaceBndryConns = 0;
  1279. return TECZNE112(ZnTitle,
  1280. ZnType,
  1281. IMxOrNumPts,
  1282. JMxOrNumElements,
  1283. KMx,
  1284. ICellMx,
  1285. JCellMx,
  1286. KCellMx,
  1287. &SolutionTime,
  1288. &StrandID,
  1289. &ParentZone,
  1290. IsBlk,
  1291. NumFaceConn,
  1292. FNMode,
  1293. &NumFaceNodes,
  1294. &NumFaceBndryFaces,
  1295. &NumFaceBndryConns,
  1296. NULL, /* PassiveVarList */
  1297. ValueLocation,
  1298. ShareVarFromZone,
  1299. ShareConnectivityFromZone);
  1300. }
  1301. #if !defined INDEX_16_BIT // not supported in this test-only mode
  1302. INTEGER4 LIBCALL TECZNE(char *ZoneTitle,
  1303. INTEGER4 *IMx,
  1304. INTEGER4 *JMx,
  1305. INTEGER4 *KMx,
  1306. char *ZFormat,
  1307. char *DupList)
  1308. {
  1309. LgIndex_t ZoneType;
  1310. LgIndex_t IsBlock;
  1311. LgIndex_t *ShareVarFromZone = NULL;
  1312. LgIndex_t ShareConnectivityFromZone;
  1313. LgIndex_t Result = 0;
  1314. if (ZFormat == NULL)
  1315. Result = -1;
  1316. else if (!strcmp(ZFormat, "BLOCK"))
  1317. {
  1318. IsBlock = 1;
  1319. ZoneType = ZoneType_Ordered;
  1320. }
  1321. else if (!strcmp(ZFormat, "FEBLOCK"))
  1322. {
  1323. IsBlock = 1;
  1324. switch (*KMx)
  1325. {
  1326. /*
  1327. * From preplot.c:
  1328. *
  1329. * ZoneType 0=ORDERED,1=FELINESEG,2=FETRIANGLE,
  1330. * 3=FEQUADRILATERAL,4=FETETRAHEDRON,5=FEBRICK
  1331. */
  1332. case 0: /* Triangular. */
  1333. ZoneType = 2;
  1334. break;
  1335. case 1: /* Quadrilateral */
  1336. ZoneType = 3;
  1337. break;
  1338. case 2: /* Tetrahedral */
  1339. ZoneType = 4;
  1340. break;
  1341. case 3: /* Brick. */
  1342. ZoneType = 5;
  1343. break;
  1344. }
  1345. }
  1346. else if (!strcmp(ZFormat, "POINT"))
  1347. {
  1348. IsBlock = 0;
  1349. ZoneType = ZoneType_Ordered;
  1350. }
  1351. else if (!strcmp(ZFormat, "FEPOINT"))
  1352. {
  1353. IsBlock = 0;
  1354. switch (*KMx)
  1355. {
  1356. case 0: /* Triangular. */
  1357. ZoneType = 2;
  1358. break;
  1359. case 1: /* Quadrilateral */
  1360. ZoneType = 3;
  1361. break;
  1362. case 2: /* Tetrahedral */
  1363. ZoneType = 4;
  1364. break;
  1365. case 3: /* Brick. */
  1366. ZoneType = 5;
  1367. break;
  1368. }
  1369. }
  1370. else
  1371. Result = -1;
  1372. ShareConnectivityFromZone = 0;
  1373. if (Result == 0 &&
  1374. DupList &&
  1375. !ParseDupList(&ShareVarFromZone, &ShareConnectivityFromZone, DupList))
  1376. {
  1377. Result = -1;
  1378. }
  1379. /*Result = TECZNE((char *)ZoneTitle, IMx, JMx, KMx, (char *)ZFormat,(char*)DupList);*/
  1380. if (Result == 0)
  1381. {
  1382. INTEGER4 ICellMx = 0;
  1383. INTEGER4 JCellMx = 0;
  1384. INTEGER4 KCellMx = 0;
  1385. INTEGER4 NumFaceConnections = 0;
  1386. INTEGER4 FaceNeighborMode = FaceNeighborMode_LocalOneToOne;
  1387. double SolutionTime = 0.0;
  1388. INTEGER4 StrandID = STRAND_ID_STATIC + 1; /* TECXXX is ones based for StrandID */
  1389. INTEGER4 ParentZone = BAD_SET_VALUE + 1; /* TECXXX is ones based for ParentZone */
  1390. INTEGER4 NumFaceNodes = 0;
  1391. INTEGER4 NumFaceBndryFaces = 0;
  1392. INTEGER4 NumFaceBndryConns = 0;
  1393. Result = TECZNE112((char *)ZoneTitle,
  1394. &ZoneType,
  1395. IMx,
  1396. JMx,
  1397. KMx,
  1398. &ICellMx,
  1399. &JCellMx,
  1400. &KCellMx,
  1401. &SolutionTime,
  1402. &StrandID,
  1403. &ParentZone,
  1404. &IsBlock,
  1405. &NumFaceConnections,
  1406. &FaceNeighborMode,
  1407. &NumFaceNodes,
  1408. &NumFaceBndryFaces,
  1409. &NumFaceBndryConns,
  1410. NULL, /* PassiveVarList */
  1411. NULL, /* ValueLocation */
  1412. DupList ? ShareVarFromZone : NULL,
  1413. &ShareConnectivityFromZone);
  1414. TecXXXZoneNum++;
  1415. }
  1416. if (ShareVarFromZone)
  1417. FREE_ARRAY(ShareVarFromZone, "Variable sharing list");
  1418. return (INTEGER4) Result;
  1419. }
  1420. #endif // INDEX_16_BIT -- not supported in this test-only mode
  1421. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  1422. LIBFUNCTION INTEGER4 LIBCALL teczne112_(char *ZoneTitle,
  1423. INTEGER4 *ZnType,
  1424. INTEGER4 *IMxOrNumPts,
  1425. INTEGER4 *JMxOrNumElements,
  1426. INTEGER4 *KMx,
  1427. INTEGER4 *ICellMx,
  1428. INTEGER4 *JCellMx,
  1429. INTEGER4 *KCellMx,
  1430. double *SolutionTime,
  1431. INTEGER4 *StrandID,
  1432. INTEGER4 *ParentZone,
  1433. INTEGER4 *IsBlk,
  1434. INTEGER4 *NumFaceConn,
  1435. INTEGER4 *FNMode,
  1436. INTEGER4 *NumFaceNodes,
  1437. INTEGER4 *NumFaceBndryFaces,
  1438. INTEGER4 *NumFaceBndryConns,
  1439. INTEGER4 *PassiveVarList,
  1440. INTEGER4 *ValueLocation,
  1441. INTEGER4 *ShareVarFromZone,
  1442. INTEGER4 *ShareConnectivityFromZone)
  1443. {
  1444. return TECZNE112(ZoneTitle,
  1445. ZnType,
  1446. IMxOrNumPts,
  1447. JMxOrNumElements,
  1448. KMx,
  1449. ICellMx,
  1450. JCellMx,
  1451. KCellMx,
  1452. SolutionTime,
  1453. StrandID,
  1454. ParentZone,
  1455. IsBlk,
  1456. NumFaceConn,
  1457. FNMode,
  1458. NumFaceNodes,
  1459. NumFaceBndryFaces,
  1460. NumFaceBndryConns,
  1461. PassiveVarList,
  1462. ValueLocation,
  1463. ShareVarFromZone,
  1464. ShareConnectivityFromZone);
  1465. }
  1466. LIBFUNCTION INTEGER4 LIBCALL teczne111_(char *ZoneTitle,
  1467. INTEGER4 *ZnType,
  1468. INTEGER4 *IMxOrNumPts,
  1469. INTEGER4 *JMxOrNumElements,
  1470. INTEGER4 *KMx,
  1471. INTEGER4 *ICellMx,
  1472. INTEGER4 *JCellMx,
  1473. INTEGER4 *KCellMx,
  1474. double *SolutionTime,
  1475. INTEGER4 *StrandID,
  1476. INTEGER4 *ParentZone,
  1477. INTEGER4 *IsBlk,
  1478. INTEGER4 *NumFaceConn,
  1479. INTEGER4 *FNMode,
  1480. INTEGER4 *NumFaceNodes,
  1481. INTEGER4 *NumFaceBndryFaces,
  1482. INTEGER4 *NumFaceBndryConns,
  1483. INTEGER4 *PassiveVarList,
  1484. INTEGER4 *ValueLocation,
  1485. INTEGER4 *ShareVarFromZone,
  1486. INTEGER4 *ShareConnectivityFromZone)
  1487. {
  1488. return TECZNE112(ZoneTitle,
  1489. ZnType,
  1490. IMxOrNumPts,
  1491. JMxOrNumElements,
  1492. KMx,
  1493. ICellMx,
  1494. JCellMx,
  1495. KCellMx,
  1496. SolutionTime,
  1497. StrandID,
  1498. ParentZone,
  1499. IsBlk,
  1500. NumFaceConn,
  1501. FNMode,
  1502. NumFaceNodes,
  1503. NumFaceBndryFaces,
  1504. NumFaceBndryConns,
  1505. PassiveVarList,
  1506. ValueLocation,
  1507. ShareVarFromZone,
  1508. ShareConnectivityFromZone);
  1509. }
  1510. LIBFUNCTION INTEGER4 LIBCALL teczne110_(char *ZoneTitle,
  1511. INTEGER4 *ZnType,
  1512. INTEGER4 *IMxOrNumPts,
  1513. INTEGER4 *JMxOrNumElements,
  1514. INTEGER4 *KMx,
  1515. INTEGER4 *ICellMx,
  1516. INTEGER4 *JCellMx,
  1517. INTEGER4 *KCellMx,
  1518. double *SolutionTime,
  1519. INTEGER4 *StrandID,
  1520. INTEGER4 *ParentZone,
  1521. INTEGER4 *IsBlk,
  1522. INTEGER4 *NumFaceConn,
  1523. INTEGER4 *FNMode,
  1524. INTEGER4 *PassiveVarList,
  1525. INTEGER4 *ValueLocation,
  1526. INTEGER4 *ShareVarFromZone,
  1527. INTEGER4 *ShareConnectivityFromZone)
  1528. {
  1529. INTEGER4 NumFaceNodes = 0;
  1530. INTEGER4 NumFaceBndryFaces = 0;
  1531. INTEGER4 NumFaceBndryConns = 0;
  1532. return TECZNE112(ZoneTitle,
  1533. ZnType,
  1534. IMxOrNumPts,
  1535. JMxOrNumElements,
  1536. KMx,
  1537. ICellMx,
  1538. JCellMx,
  1539. KCellMx,
  1540. SolutionTime,
  1541. StrandID,
  1542. ParentZone,
  1543. IsBlk,
  1544. NumFaceConn,
  1545. FNMode,
  1546. &NumFaceNodes,
  1547. &NumFaceBndryFaces,
  1548. &NumFaceBndryConns,
  1549. PassiveVarList,
  1550. ValueLocation,
  1551. ShareVarFromZone,
  1552. ShareConnectivityFromZone);
  1553. }
  1554. LIBFUNCTION INTEGER4 LIBCALL teczne100_(char *ZoneTitle,
  1555. INTEGER4 *ZnType,
  1556. INTEGER4 *IMxOrNumPts,
  1557. INTEGER4 *JMxOrNumElements,
  1558. INTEGER4 *KMx,
  1559. INTEGER4 *ICellMx,
  1560. INTEGER4 *JCellMx,
  1561. INTEGER4 *KCellMx,
  1562. INTEGER4 *IsBlk,
  1563. INTEGER4 *NumFaceConn,
  1564. INTEGER4 *FNMode,
  1565. INTEGER4 *ValueLocation,
  1566. INTEGER4 *ShareVarFromZone,
  1567. INTEGER4 *ShareConnectivityFromZone)
  1568. {
  1569. return TECZNE100(ZoneTitle,
  1570. ZnType,
  1571. IMxOrNumPts,
  1572. JMxOrNumElements,
  1573. KMx,
  1574. ICellMx,
  1575. JCellMx,
  1576. KCellMx,
  1577. IsBlk,
  1578. NumFaceConn,
  1579. FNMode,
  1580. ValueLocation,
  1581. ShareVarFromZone,
  1582. ShareConnectivityFromZone);
  1583. }
  1584. LIBFUNCTION INTEGER4 LIBCALL teczne_(char *ZoneTitle,
  1585. INTEGER4 *IMx,
  1586. INTEGER4 *JMx,
  1587. INTEGER4 *KMx,
  1588. char *ZFormat,
  1589. char *DupList)
  1590. {
  1591. return TECZNE(ZoneTitle,
  1592. IMx,
  1593. JMx,
  1594. KMx,
  1595. ZFormat,
  1596. DupList);
  1597. }
  1598. #endif
  1599. /**
  1600. * Rewrite the var min/max place holders which currently have zero in them.
  1601. */
  1602. static void RewritePendingMinMaxValues(void)
  1603. {
  1604. FileOffset_t CurrentOffset = (FileOffset_t)TP_FTELL(BlckFile[CurFile]->File);
  1605. TP_FSEEK(BlckFile[CurFile]->File, MinMaxOffset[CurFile][CurZone[CurFile]], SEEK_SET);
  1606. int I;
  1607. for (I = 0; I < NumVars[CurFile]; I++)
  1608. {
  1609. if (!IsSharedVar[CurFile][I] && !IsPassiveVar[CurFile][I])
  1610. {
  1611. WriteBinaryReal(BlckFile[CurFile], VarMinValue[CurFile][I], FieldDataType_Double);
  1612. WriteBinaryReal(BlckFile[CurFile], VarMaxValue[CurFile][I], FieldDataType_Double);
  1613. }
  1614. }
  1615. /* return the original position */
  1616. TP_FSEEK(BlckFile[CurFile]->File, CurrentOffset, SEEK_SET);
  1617. }
  1618. /**
  1619. * TECDATXXX
  1620. */
  1621. INTEGER4 LIBCALL TECDAT112(INTEGER4 *N,
  1622. void *Data,
  1623. INTEGER4 *IsDouble)
  1624. {
  1625. LgIndex_t I;
  1626. double *dptr = (double *)Data;
  1627. float *fptr = (float *)Data;
  1628. if (CheckFile("TECDAT112") < 0)
  1629. return (-1);
  1630. #if defined MAKEARCHIVE
  1631. if (DebugLevel[CurFile] && (*N > 1))
  1632. PRINT2("Writing %d values to file %d.\n", *N, CurFile + 1);
  1633. #endif
  1634. for (I = 0; I < *N; I++)
  1635. {
  1636. double Value = (*IsDouble == 1 ? dptr[I] : fptr[I]);
  1637. /* keep track of var min/max */
  1638. if (Value < VarMinValue[CurFile][CurVar[CurFile]])
  1639. VarMinValue[CurFile][CurVar[CurFile]] = Value;
  1640. if (Value > VarMaxValue[CurFile][CurVar[CurFile]])
  1641. VarMaxValue[CurFile][CurVar[CurFile]] = Value;
  1642. if (!WriteBinaryReal(BlckFile[CurFile], Value, (FieldDataType_e)FieldDataType))
  1643. {
  1644. WriteErr("TECDAT112");
  1645. return (-1);
  1646. }
  1647. /*
  1648. * As of version 103 Tecplot writes binary data files so that the ordered
  1649. * cell centered field data includes the ghost cells. This makes it much
  1650. * easier for Tecplot to map the data when reading by simply writing out
  1651. * field data's as a block. As of version 104 the ghost cells of the
  1652. * slowest moving index are not included.
  1653. */
  1654. if (IsCellCentered[CurFile][CurVar[CurFile]] && ZoneType[CurFile] == ORDERED)
  1655. {
  1656. CHECK(IsBlock[CurFile]); /* ...ordered CC data must be block format */
  1657. LgIndex_t PIndex = (NumOrderedCCDataValuesWritten[CurFile]);
  1658. LgIndex_t FinalIMax = MAX(IMax[CurFile] - 1, 1);
  1659. LgIndex_t FinalJMax = MAX(JMax[CurFile] - 1, 1);
  1660. LgIndex_t FinalKMax = MAX(KMax[CurFile] - 1, 1);
  1661. LgIndex_t IIndex = (PIndex % IMax[CurFile]);
  1662. LgIndex_t JIndex = ((PIndex % (IMax[CurFile] * JMax[CurFile])) / IMax[CurFile]);
  1663. LgIndex_t KIndex = (PIndex / (IMax[CurFile] * JMax[CurFile]));
  1664. LgIndex_t IMaxAdjust = 0;
  1665. LgIndex_t JMaxAdjust = 0;
  1666. LgIndex_t KMaxAdjust = 0;
  1667. if (KMax[CurFile] > 1)
  1668. KMaxAdjust = 1; /* ...K is slowest */
  1669. else if (JMax[CurFile] > 1)
  1670. JMaxAdjust = 1; /* ...J is slowest */
  1671. else if (IMax[CurFile] > 1)
  1672. IMaxAdjust = 1; /* ...I is slowest */
  1673. if (IIndex + 1 == FinalIMax && FinalIMax < IMax[CurFile] - IMaxAdjust)
  1674. {
  1675. NumOrderedCCDataValuesWritten[CurFile]++;
  1676. if (!WriteBinaryReal(BlckFile[CurFile], 0.0, (FieldDataType_e)FieldDataType))
  1677. {
  1678. WriteErr("TECDAT112");
  1679. return (-1);
  1680. }
  1681. }
  1682. if (IIndex + 1 == FinalIMax &&
  1683. (JIndex + 1 == FinalJMax && FinalJMax < JMax[CurFile] - JMaxAdjust))
  1684. {
  1685. LgIndex_t II;
  1686. for (II = 1; II <= IMax[CurFile] - IMaxAdjust; II++)
  1687. {
  1688. NumOrderedCCDataValuesWritten[CurFile]++;
  1689. if (!WriteBinaryReal(BlckFile[CurFile], 0.0, (FieldDataType_e)FieldDataType))
  1690. {
  1691. WriteErr("TECDAT112");
  1692. return (-1);
  1693. }
  1694. }
  1695. }
  1696. if (IIndex + 1 == FinalIMax &&
  1697. JIndex + 1 == FinalJMax &&
  1698. (KIndex + 1 == FinalKMax && FinalKMax < KMax[CurFile] - KMaxAdjust))
  1699. {
  1700. LgIndex_t JJ, II;
  1701. for (JJ = 1; JJ <= JMax[CurFile] - JMaxAdjust; JJ++)
  1702. for (II = 1; II <= IMax[CurFile] - IMaxAdjust; II++)
  1703. {
  1704. NumOrderedCCDataValuesWritten[CurFile]++;
  1705. if (!WriteBinaryReal(BlckFile[CurFile], 0.0, (FieldDataType_e)FieldDataType))
  1706. {
  1707. WriteErr("TECDAT112");
  1708. return (-1);
  1709. }
  1710. }
  1711. }
  1712. /* increment for the original cell value */
  1713. NumOrderedCCDataValuesWritten[CurFile]++;
  1714. }
  1715. /* update the number of data points written */
  1716. NumDataValuesWritten[CurFile]++;
  1717. if (IsBlock[CurFile])
  1718. {
  1719. /* for block format update the variable when all values have been given */
  1720. if (NumRunningVarValues[CurFile][CurVar[CurFile]] == NumDataValuesWritten[CurFile])
  1721. {
  1722. AdvanceToNextVarWithValues(); /* ...move on to the next variable */
  1723. if (CurVar[CurFile] < NumVars[CurFile] &&
  1724. IsCellCentered[CurFile][CurVar[CurFile]] &&
  1725. ZoneType[CurFile] == ORDERED)
  1726. NumOrderedCCDataValuesWritten[CurFile] = 0; /* reset for next CC variable */
  1727. }
  1728. }
  1729. else
  1730. {
  1731. /* for point format update the variable after each value */
  1732. AdvanceToNextVarWithValues();
  1733. if (CurVar[CurFile] >= NumVars[CurFile])
  1734. {
  1735. /* reset to the first active variable */
  1736. CurVar[CurFile] = -1;
  1737. AdvanceToNextVarWithValues();
  1738. }
  1739. }
  1740. #if defined MAKEARCHIVE
  1741. if (DebugLevel[CurFile] > 1)
  1742. PRINT2("%d %G\n", NumDataValuesWritten[CurFile] + I + 1, Value);
  1743. #endif
  1744. }
  1745. /*
  1746. * If this is the last call to TECDAT112,
  1747. * then we may have to set the 'repeat adjacency list'
  1748. * flag in the file.
  1749. */
  1750. if (HasFECONNECT[CurFile] &&
  1751. /* (essentialy this is CheckData() but we don't want to print
  1752. an error message) */
  1753. (NumDataValuesToWrite[CurFile] == NumDataValuesWritten[CurFile]))
  1754. {
  1755. if (!WriteBinaryInt32(BlckFile[CurFile], (LgIndex_t)1))
  1756. {
  1757. WriteErr("TECDAT112");
  1758. return (-1);
  1759. }
  1760. }
  1761. /* re-write min/max values when all data has been delivered */
  1762. if (NumDataValuesToWrite[CurFile] == NumDataValuesWritten[CurFile])
  1763. RewritePendingMinMaxValues();
  1764. return (0);
  1765. }
  1766. INTEGER4 LIBCALL TECDAT111(INTEGER4 *N,
  1767. void *Data,
  1768. INTEGER4 *IsDouble)
  1769. {
  1770. return TECDAT112(N,
  1771. Data,
  1772. IsDouble);
  1773. }
  1774. INTEGER4 LIBCALL TECDAT110(INTEGER4 *N,
  1775. void *FieldData,
  1776. INTEGER4 *IsDouble)
  1777. {
  1778. return TECDAT112(N,
  1779. FieldData,
  1780. IsDouble);
  1781. }
  1782. INTEGER4 LIBCALL TECDAT100(INTEGER4 *N,
  1783. void *FieldData,
  1784. INTEGER4 *IsDouble)
  1785. {
  1786. return TECDAT112(N,
  1787. FieldData,
  1788. IsDouble);
  1789. }
  1790. INTEGER4 LIBCALL TECDAT(INTEGER4 *N,
  1791. void *FieldData,
  1792. INTEGER4 *IsDouble)
  1793. {
  1794. return TECDAT112(N,
  1795. FieldData,
  1796. IsDouble);
  1797. }
  1798. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  1799. LIBFUNCTION INTEGER4 LIBCALL tecdat112_(INTEGER4 *N,
  1800. void *Data,
  1801. INTEGER4 *IsDouble)
  1802. {
  1803. return TECDAT112(N, Data, IsDouble);
  1804. }
  1805. LIBFUNCTION INTEGER4 LIBCALL tecdat111_(INTEGER4 *N,
  1806. void *Data,
  1807. INTEGER4 *IsDouble)
  1808. {
  1809. return TECDAT112(N, Data, IsDouble);
  1810. }
  1811. LIBFUNCTION INTEGER4 LIBCALL tecdat110_(INTEGER4 *N,
  1812. void *Data,
  1813. INTEGER4 *IsDouble)
  1814. {
  1815. return TECDAT112(N, Data, IsDouble);
  1816. }
  1817. LIBFUNCTION INTEGER4 LIBCALL tecdat100_(INTEGER4 *N,
  1818. void *Data,
  1819. INTEGER4 *IsDouble)
  1820. {
  1821. return TECDAT112(N, Data, IsDouble);
  1822. }
  1823. LIBFUNCTION INTEGER4 LIBCALL tecdat_(INTEGER4 *N,
  1824. void *FieldData,
  1825. INTEGER4 *IsDouble)
  1826. {
  1827. return TECDAT112(N,
  1828. FieldData,
  1829. IsDouble);
  1830. }
  1831. #endif
  1832. /**
  1833. * TECNODXXX
  1834. */
  1835. INTEGER4 LIBCALL TECNOD112(INTEGER4 *NData)
  1836. {
  1837. LgIndex_t L = NumConnectivityNodes[CurFile][CurZone[CurFile]];
  1838. LgIndex_t I;
  1839. ConnectivityWritten[CurFile][CurZone[CurFile]] = TRUE;
  1840. if (CheckFile("TECNOD112") < 0)
  1841. return (-1);
  1842. if (ZoneType[CurFile] == FEPOLYGON ||
  1843. ZoneType[CurFile] == FEPOLYHEDRON)
  1844. {
  1845. /* Wrong way to specify connectivity for polygons and polyhedrons */
  1846. #if defined MAKEARCHIVE
  1847. PRINT0("Err: (TECNOD112) Cannot call TECNOD112 for polygonal or polyhedral zones.\n");
  1848. #endif
  1849. NumErrs[CurFile]++;
  1850. return (-1);
  1851. }
  1852. if (HasFECONNECT[CurFile])
  1853. {
  1854. /*
  1855. * The connectivity list is duplicated,
  1856. * so we shouldn't be calling TECNOD112()
  1857. */
  1858. return (-1);
  1859. }
  1860. if (FileTypes[CurFile] == SOLUTIONFILE)
  1861. {
  1862. #if defined MAKEARCHIVE
  1863. PRINT0("Err: (TECNOD112) Cannot call TECNOD112 if file type is SOLUTIONFILE.\n");
  1864. #endif
  1865. NumErrs[CurFile]++;
  1866. return (-1);
  1867. }
  1868. if (ZoneType[CurFile] == ORDERED)
  1869. {
  1870. #if defined MAKEARCHIVE
  1871. PRINT0("Err: (TECNOD112) Cannot call TECNOD110 if zone type is ORDERED.\n");
  1872. #endif
  1873. NumErrs[CurFile]++;
  1874. return (-1);
  1875. }
  1876. if (CheckData("TECNOD112") < 0)
  1877. return (-1);
  1878. for (I = 0; I < L; I++)
  1879. {
  1880. if ((NData[I] > IMax[CurFile]) ||
  1881. (NData[I] < 1))
  1882. {
  1883. #if defined MAKEARCHIVE
  1884. PRINT1("Err: (TECNOD112) Invalid node map value at position %d:\n", I);
  1885. PRINT2(" node map value = %d, max value = %d.\n", NData[I], IMax[CurFile]);
  1886. #endif
  1887. NumErrs[CurFile]++;
  1888. return (-1);
  1889. }
  1890. /*
  1891. * As of version 103 Tecplot assumes that node maps are zero based
  1892. * instead of ones based. Since we have to maintain the contract we
  1893. * subtract 1 for the caller.
  1894. */
  1895. if (!WriteBinaryInt32(BlckFile[CurFile], NData[I] - 1)) /* zero based */
  1896. {
  1897. WriteErr("TECNOD112");
  1898. return (-1);
  1899. }
  1900. }
  1901. return (0);
  1902. }
  1903. INTEGER4 LIBCALL TECNOD111(INTEGER4 *NData)
  1904. {
  1905. return TECNOD112(NData);
  1906. }
  1907. INTEGER4 LIBCALL TECNOD110(INTEGER4 *NData)
  1908. {
  1909. return TECNOD112(NData);
  1910. }
  1911. INTEGER4 LIBCALL TECNOD100(INTEGER4 *NData)
  1912. {
  1913. return TECNOD112(NData);
  1914. }
  1915. INTEGER4 LIBCALL TECNOD(INTEGER4 *NData)
  1916. {
  1917. return TECNOD112(NData);
  1918. }
  1919. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  1920. LIBFUNCTION INTEGER4 LIBCALL tecnod112_(INTEGER4 *NData)
  1921. {
  1922. return TECNOD112(NData);
  1923. }
  1924. LIBFUNCTION INTEGER4 LIBCALL tecnod111_(INTEGER4 *NData)
  1925. {
  1926. return TECNOD112(NData);
  1927. }
  1928. LIBFUNCTION INTEGER4 LIBCALL tecnod110_(INTEGER4 *NData)
  1929. {
  1930. return TECNOD112(NData);
  1931. }
  1932. LIBFUNCTION INTEGER4 LIBCALL tecnod100_(INTEGER4 *NData)
  1933. {
  1934. return TECNOD112(NData);
  1935. }
  1936. LIBFUNCTION INTEGER4 LIBCALL tecnod_(INTEGER4 *NData)
  1937. {
  1938. return TECNOD112(NData);
  1939. }
  1940. #endif
  1941. /**
  1942. * TECENDXXX
  1943. */
  1944. INTEGER4 LIBCALL TECEND112(void)
  1945. {
  1946. int RetVal = 0;
  1947. /**
  1948. * Validate that all zone data was given for the file since there are no
  1949. * more chances to give it. Note that solution files don't define the
  1950. * connectivity again.
  1951. */
  1952. if (FileTypes[CurFile] != SOLUTIONFILE)
  1953. {
  1954. for (int ZoneIndex = 0; (RetVal == 0) && (ZoneIndex <= CurZone[CurFile]); ZoneIndex++)
  1955. {
  1956. if (((NumConnectivityNodes[CurFile][ZoneIndex] > 0) &&
  1957. (ConnectivityWritten[CurFile][ZoneIndex] == FALSE)))
  1958. {
  1959. #if defined MAKEARCHIVE
  1960. PRINT1("Err: (TECEND112) File %d is being closed without writing connectivity data.\n", CurFile + 1);
  1961. PRINT1(" Zone %d was defined with a Classic FE zone type but TECNOD112() was not called.\n", ZoneIndex + 1);
  1962. #endif
  1963. NumErrs[CurFile]++;
  1964. RetVal = -1;
  1965. }
  1966. if (((NumFaceConnections[CurFile][ZoneIndex] > 0) &&
  1967. (FaceNeighborsOrMapWritten[CurFile][ZoneIndex] == FALSE)))
  1968. {
  1969. #if defined MAKEARCHIVE
  1970. PRINT1("Err: (TECEND112) File %d is being closed without writing face neighbor data.\n", CurFile + 1);
  1971. PRINT2(" %d connections were specified for zone %d but TECFACE112() was not called.\n",
  1972. NumFaceConnections[CurFile][ZoneIndex], ZoneIndex + 1);
  1973. #endif
  1974. NumErrs[CurFile]++;
  1975. RetVal = -1;
  1976. }
  1977. else if (((TotalNumFaceNodes[CurFile][ZoneIndex] > 0) &&
  1978. (FaceNeighborsOrMapWritten[CurFile][ZoneIndex] == FALSE)))
  1979. {
  1980. #if defined MAKEARCHIVE
  1981. PRINT1("Err: (TECEND112) File %d is being closed without writing face map data.\n", CurFile + 1);
  1982. PRINT2(" %d face nodes were specified for zone %d but TECPOLY112() was not called.\n",
  1983. TotalNumFaceNodes[CurFile][ZoneIndex], ZoneIndex + 1);
  1984. #endif
  1985. NumErrs[CurFile]++;
  1986. RetVal = -1;
  1987. }
  1988. }
  1989. }
  1990. if (RetVal == 0)
  1991. {
  1992. if (CheckFile("TECEND112") < 0)
  1993. RetVal = -1;
  1994. }
  1995. if (RetVal == 0)
  1996. {
  1997. if (CheckData("TECEND112") < 0)
  1998. RetVal = -1;
  1999. }
  2000. if (RetVal == 0)
  2001. if (!WriteBinaryReal(HeadFile[CurFile], EndHeaderMarker, FieldDataType_Float))
  2002. {
  2003. WriteErr("TECEND112");
  2004. RetVal = -1;
  2005. }
  2006. CloseFileStream(&BlckFile[CurFile]);
  2007. if (RetVal == 0)
  2008. {
  2009. BlckFile[CurFile] = OpenFileStream(BlckFName[CurFile], "rb", IsWritingNative[CurFile]);
  2010. /* Append data from BlckFile to HeadFile... */
  2011. char buffer[BYTES_PER_CHUNK];
  2012. size_t bytesRead = 0;
  2013. while ((RetVal == 0) &&
  2014. (feof(BlckFile[CurFile]->File) == 0))
  2015. {
  2016. bytesRead = fread((void*)buffer, 1, BYTES_PER_CHUNK, BlckFile[CurFile]->File);
  2017. if (ferror(BlckFile[CurFile]->File) == 0)
  2018. {
  2019. if (bytesRead != fwrite((void*)buffer, 1, bytesRead, HeadFile[CurFile]->File))
  2020. {
  2021. /* do not call WriteErr, use custom message instead */
  2022. #if defined MAKEARCHIVE
  2023. PRINT1("Err: (TECEND112) Write failure during repack on file %d.\n", CurFile + 1);
  2024. #endif
  2025. NumErrs[CurFile]++;
  2026. RetVal = -1;
  2027. }
  2028. }
  2029. else
  2030. {
  2031. /* do not call WriteErr, use custom message instead */
  2032. #if defined MAKEARCHIVE
  2033. PRINT1("Err: (TECEND112) Write failure during repack on file %d.\n", CurFile + 1);
  2034. #endif
  2035. NumErrs[CurFile]++;
  2036. RetVal = -1;
  2037. }
  2038. }
  2039. CloseFileStream(&BlckFile[CurFile]);
  2040. }
  2041. TP_UNLINK(BlckFName[CurFile]);
  2042. CloseFileStream(&HeadFile[CurFile]);
  2043. #if defined MAKEARCHIVE
  2044. if (DebugLevel[CurFile])
  2045. {
  2046. PRINT1("File %d closed.\n", CurFile + 1);
  2047. if (NumErrs[CurFile])
  2048. {
  2049. PRINT0("********************************************\n");
  2050. PRINT1(" %d Errors occurred on this file\n", NumErrs[CurFile]);
  2051. PRINT0("********************************************\n");
  2052. }
  2053. }
  2054. #endif
  2055. NumErrs[CurFile] = 0;
  2056. IsOpen[CurFile] = 0;
  2057. if (DestFName[CurFile])
  2058. FREE_ARRAY(DestFName[CurFile], "data set fname");
  2059. if (BlckFName[CurFile])
  2060. FREE_ARRAY(BlckFName[CurFile], "data set fname");
  2061. BlckFName[CurFile] = NULL;
  2062. DestFName[CurFile] = NULL;
  2063. /* reset arrays sized by number of variables */
  2064. VarMinValue[CurFile].clear();
  2065. VarMaxValue[CurFile].clear();
  2066. NumRunningVarValues[CurFile].clear();
  2067. IsSharedVar[CurFile].clear();
  2068. IsPassiveVar[CurFile].clear();
  2069. IsCellCentered[CurFile].clear();
  2070. /* reset arrays sized by number of zones */
  2071. MinMaxOffset[CurFile].clear();
  2072. TotalNumFaceNodes[CurFile].clear();
  2073. NumFaceConnections[CurFile].clear();
  2074. FaceNeighborsOrMapWritten[CurFile].clear();
  2075. NumConnectivityNodes[CurFile].clear();
  2076. ConnectivityWritten[CurFile].clear();
  2077. CurFile = 0;
  2078. while ((CurFile < MaxNumFiles) && !IsOpen[CurFile])
  2079. CurFile++;
  2080. if (CurFile == MaxNumFiles)
  2081. CurFile = -1;
  2082. return RetVal;
  2083. }
  2084. INTEGER4 LIBCALL TECEND111(void)
  2085. {
  2086. return TECEND112();
  2087. }
  2088. INTEGER4 LIBCALL TECEND110(void)
  2089. {
  2090. return TECEND112();
  2091. }
  2092. INTEGER4 LIBCALL TECEND100(void)
  2093. {
  2094. return TECEND112();
  2095. }
  2096. INTEGER4 LIBCALL TECEND(void)
  2097. {
  2098. return TECEND112();
  2099. }
  2100. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  2101. LIBFUNCTION INTEGER4 LIBCALL tecend112_(void)
  2102. {
  2103. return TECEND112();
  2104. }
  2105. LIBFUNCTION INTEGER4 LIBCALL tecend111_(void)
  2106. {
  2107. return TECEND112();
  2108. }
  2109. LIBFUNCTION INTEGER4 LIBCALL tecend110_(void)
  2110. {
  2111. return TECEND112();
  2112. }
  2113. LIBFUNCTION INTEGER4 LIBCALL tecend100_(void)
  2114. {
  2115. return TECEND112();
  2116. }
  2117. LIBFUNCTION INTEGER4 LIBCALL tecend_(void)
  2118. {
  2119. return TECEND112();
  2120. }
  2121. #endif
  2122. static void GetNextLabel(const char **CPtr,
  2123. char *NextLabel)
  2124. {
  2125. int N = 0;
  2126. char *NPtr = NextLabel;
  2127. *NPtr = '\0';
  2128. /* Find label start */
  2129. while ((**CPtr) && (**CPtr != '"'))
  2130. (*CPtr)++;
  2131. if (**CPtr)
  2132. (*CPtr)++;
  2133. while ((N < 60) && (**CPtr) && (**CPtr != '"'))
  2134. {
  2135. if (**CPtr == '\\')
  2136. {
  2137. (*CPtr)++;
  2138. }
  2139. *NPtr++ = **CPtr;
  2140. N++;
  2141. (*CPtr)++;
  2142. }
  2143. if (**CPtr)
  2144. (*CPtr)++;
  2145. *NPtr = '\0';
  2146. }
  2147. /**
  2148. * TECLABXXX
  2149. */
  2150. INTEGER4 LIBCALL TECLAB112(char *S)
  2151. {
  2152. const char *CPtr = (const char *)S;
  2153. LgIndex_t N = 0;
  2154. char Label[60];
  2155. if (CheckFile("TECLAB112") < 0)
  2156. return (-1);
  2157. #if defined MAKEARCHIVE
  2158. if (DebugLevel[CurFile])
  2159. PRINT0("\nInserting Custom Labels:\n");
  2160. #endif
  2161. do
  2162. {
  2163. GetNextLabel(&CPtr, Label);
  2164. if (*Label)
  2165. N++;
  2166. }
  2167. while (*Label);
  2168. if (N == 0)
  2169. {
  2170. #if defined MAKEARCHIVE
  2171. PRINT1("Err: (TECLAB112) Invalid custom label string: %s\n",
  2172. (S ? S : " "));
  2173. #endif
  2174. NumErrs[CurFile]++;
  2175. return (-1);
  2176. }
  2177. WriteBinaryReal(HeadFile[CurFile], CustomLabelMarker, FieldDataType_Float);
  2178. if (!WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)N))
  2179. {
  2180. WriteErr("TECLAB112");
  2181. return (-1);
  2182. }
  2183. CPtr = (const char *)S;
  2184. do
  2185. {
  2186. GetNextLabel(&CPtr, Label);
  2187. if (*Label)
  2188. {
  2189. if (!DumpDatafileString(HeadFile[CurFile], Label, TRUE))
  2190. {
  2191. WriteErr("TECLAB112");
  2192. return (-1);
  2193. }
  2194. #if defined MAKEARCHIVE
  2195. if (DebugLevel[CurFile])
  2196. printf(" %s\n", Label);
  2197. #endif
  2198. }
  2199. }
  2200. while (*Label);
  2201. return (0);
  2202. }
  2203. INTEGER4 LIBCALL TECLAB111(char *S)
  2204. {
  2205. return TECLAB112(S);
  2206. }
  2207. INTEGER4 LIBCALL TECLAB110(char *S)
  2208. {
  2209. return TECLAB112(S);
  2210. }
  2211. INTEGER4 LIBCALL TECLAB100(char *S)
  2212. {
  2213. return TECLAB112(S);
  2214. }
  2215. INTEGER4 LIBCALL TECLAB(char *S)
  2216. {
  2217. return TECLAB112(S);
  2218. }
  2219. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  2220. LIBFUNCTION INTEGER4 LIBCALL teclab112_(char *S)
  2221. {
  2222. return TECLAB112(S);
  2223. }
  2224. LIBFUNCTION INTEGER4 LIBCALL teclab111_(char *S)
  2225. {
  2226. return TECLAB112(S);
  2227. }
  2228. LIBFUNCTION INTEGER4 LIBCALL teclab110_(char *S)
  2229. {
  2230. return TECLAB112(S);
  2231. }
  2232. LIBFUNCTION INTEGER4 LIBCALL teclab100_(char *S)
  2233. {
  2234. return TECLAB112(S);
  2235. }
  2236. LIBFUNCTION INTEGER4 LIBCALL teclab_(char *S)
  2237. {
  2238. return TECLAB112(S);
  2239. }
  2240. #endif
  2241. /**
  2242. * TECUSRXXX
  2243. */
  2244. INTEGER4 LIBCALL TECUSR112(char *S)
  2245. {
  2246. if (CheckFile("TECUSR112") < 0)
  2247. return (-1);
  2248. #if defined MAKEARCHIVE
  2249. if (DebugLevel[CurFile])
  2250. PRINT1("\nInserting UserRec: %s\n", S);
  2251. #endif
  2252. if ((S == NULL) || (*S == '\0'))
  2253. {
  2254. #if defined MAKEARCHIVE
  2255. PRINT0("Err: (TECUSR112) Invalid TECUSR110 string\n");
  2256. #endif
  2257. NumErrs[CurFile]++;
  2258. return (-1);
  2259. }
  2260. WriteBinaryReal(HeadFile[CurFile], UserRecMarker, FieldDataType_Float);
  2261. if (!DumpDatafileString(HeadFile[CurFile], S, TRUE))
  2262. {
  2263. #if defined MAKEARCHIVE
  2264. if (DebugLevel[CurFile])
  2265. printf("Err: (TECUSR112) Write failure for file %d\n", CurFile + 1);
  2266. #endif
  2267. NumErrs[CurFile]++;
  2268. return (-1);
  2269. }
  2270. return (0);
  2271. }
  2272. INTEGER4 LIBCALL TECUSR111(char *S)
  2273. {
  2274. return TECUSR112(S);
  2275. }
  2276. INTEGER4 LIBCALL TECUSR110(char *S)
  2277. {
  2278. return TECUSR112(S);
  2279. }
  2280. INTEGER4 LIBCALL TECUSR100(char *S)
  2281. {
  2282. return TECUSR112(S);
  2283. }
  2284. INTEGER4 LIBCALL TECUSR(char *S)
  2285. {
  2286. return TECUSR112(S);
  2287. }
  2288. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  2289. LIBFUNCTION INTEGER4 LIBCALL tecusr112_(char *S)
  2290. {
  2291. return TECUSR112(S);
  2292. }
  2293. LIBFUNCTION INTEGER4 LIBCALL tecusr111_(char *S)
  2294. {
  2295. return TECUSR112(S);
  2296. }
  2297. LIBFUNCTION INTEGER4 LIBCALL tecusr110_(char *S)
  2298. {
  2299. return TECUSR112(S);
  2300. }
  2301. LIBFUNCTION INTEGER4 LIBCALL tecusr100_(char *S)
  2302. {
  2303. return TECUSR112(S);
  2304. }
  2305. LIBFUNCTION INTEGER4 LIBCALL tecusr_(char *S)
  2306. {
  2307. return TECUSR112(S);
  2308. }
  2309. #endif
  2310. #if 0 // NOT_CURRENTLY_USED
  2311. static int WriteGeomDataBlock(float *Data,
  2312. LgIndex_t NumPts)
  2313. {
  2314. LgIndex_t I;
  2315. for (I = 0; I < NumPts; I++)
  2316. {
  2317. if (!WriteBinaryReal(HeadFile[CurFile], Data[I], FieldDataType_Float))
  2318. {
  2319. return (-1);
  2320. }
  2321. }
  2322. return (0);
  2323. }
  2324. static void ShowDebugColor(LgIndex_t Color)
  2325. {
  2326. #if defined MAKEARCHIVE
  2327. switch (Color)
  2328. {
  2329. case 0 : PRINT0("BLACK\n"); break;
  2330. case 1 : PRINT0("RED\n"); break;
  2331. case 2 : PRINT0("GREEN\n"); break;
  2332. case 3 : PRINT0("BLUE\n"); break;
  2333. case 4 : PRINT0("CYAN\n"); break;
  2334. case 5 : PRINT0("YELLOW\n"); break;
  2335. case 6 : PRINT0("PURPLE\n"); break;
  2336. case 7 : PRINT0("WHITE\n"); break;
  2337. case 8 :
  2338. case 9 :
  2339. case 10:
  2340. case 11:
  2341. case 12:
  2342. case 13:
  2343. case 14:
  2344. case 15: PRINT1("CUSTOM%1d\n", Color-7); break;
  2345. default : PRINT0("INVALID\n");
  2346. }
  2347. #endif
  2348. }
  2349. #endif /* NOT_CURRENTLY_USED */
  2350. /**
  2351. * TECGEOXXX
  2352. */
  2353. INTEGER4 LIBCALL TECGEO112(double *XOrThetaPos,
  2354. double *YOrRPos,
  2355. double *ZPos,
  2356. INTEGER4 *PosCoordMode, /* 0=Grid, 1=Frame, 3=Grid3D */
  2357. INTEGER4 *AttachToZone,
  2358. INTEGER4 *Zone,
  2359. INTEGER4 *Color,
  2360. INTEGER4 *FillColor,
  2361. INTEGER4 *IsFilled,
  2362. INTEGER4 *GeomType,
  2363. INTEGER4 *LinePattern,
  2364. double *PatternLength,
  2365. double *LineThickness,
  2366. INTEGER4 *NumEllipsePts,
  2367. INTEGER4 *ArrowheadStyle,
  2368. INTEGER4 *ArrowheadAttachment,
  2369. double *ArrowheadSize,
  2370. double *ArrowheadAngle,
  2371. INTEGER4 *Scope,
  2372. INTEGER4 *Clipping,
  2373. INTEGER4 *NumSegments,
  2374. INTEGER4 *NumSegPts,
  2375. float *XOrThetaGeomData,
  2376. float *YOrRGeomData,
  2377. float *ZGeomData,
  2378. char *mfc)
  2379. {
  2380. int I, RetVal;
  2381. int RawDataSize = 0;
  2382. double Fract;
  2383. Geom_s Geom;
  2384. if (CheckFile("TECGEO112") < 0)
  2385. return (-1);
  2386. Geom.PositionCoordSys = (CoordSys_e) * PosCoordMode;
  2387. if (Geom.PositionCoordSys == CoordSys_Frame)
  2388. Fract = 0.01;
  2389. else
  2390. Fract = 1.0;
  2391. Geom.AnchorPos.Generic.V1 = (*XOrThetaPos) * Fract;
  2392. Geom.AnchorPos.Generic.V2 = (*YOrRPos) * Fract;
  2393. Geom.AnchorPos.Generic.V3 = (*ZPos) * Fract;
  2394. Geom.AttachToZone = *AttachToZone != 0;
  2395. Geom.Zone = *Zone - 1;
  2396. Geom.BColor = (ColorIndex_t) * Color;
  2397. Geom.FillBColor = (ColorIndex_t) * FillColor;
  2398. Geom.IsFilled = *IsFilled;
  2399. Geom.GeomType = (GeomType_e) * GeomType;
  2400. Geom.LinePattern = (LinePattern_e) * LinePattern;
  2401. Geom.PatternLength = *PatternLength / 100.0;
  2402. Geom.LineThickness = *LineThickness / 100.0;
  2403. Geom.NumEllipsePts = *NumEllipsePts;
  2404. Geom.ArrowheadStyle = (ArrowheadStyle_e) * ArrowheadStyle;
  2405. Geom.ArrowheadAttachment = (ArrowheadAttachment_e) * ArrowheadAttachment;
  2406. Geom.ArrowheadSize = *ArrowheadSize / 100.0;
  2407. Geom.ArrowheadAngle = *ArrowheadAngle / DEGPERRADIANS;
  2408. Geom.Scope = (Scope_e) * Scope;
  2409. Geom.DrawOrder = DrawOrder_AfterData;
  2410. Geom.Clipping = (Clipping_e) * Clipping;
  2411. Geom.NumSegments = *NumSegments;
  2412. Geom.MacroFunctionCommand = mfc;
  2413. Geom.ImageFileName = NULL;
  2414. Geom.ImageNumber = 0;
  2415. Geom.MaintainAspectRatio = TRUE;
  2416. Geom.PixelAspectRatio = 1.0;
  2417. Geom.ImageResizeFilter = ImageResizeFilter_Texture;
  2418. if (Geom.GeomType == GeomType_LineSegs3D)
  2419. {
  2420. Geom.GeomType = GeomType_LineSegs;
  2421. Geom.PositionCoordSys = CoordSys_Grid3D;
  2422. }
  2423. #if defined MAKEARCHIVE
  2424. if (DebugLevel[CurFile])
  2425. PRINT0("\nInserting Geometry\n");
  2426. #endif
  2427. switch (Geom.GeomType)
  2428. {
  2429. case GeomType_LineSegs :
  2430. {
  2431. int I;
  2432. RawDataSize = 0;
  2433. for (I = 0; I < *NumSegments; I++)
  2434. {
  2435. Geom.NumSegPts[I] = NumSegPts[I];
  2436. RawDataSize += NumSegPts[I];
  2437. }
  2438. } break;
  2439. case GeomType_Rectangle :
  2440. case GeomType_Square :
  2441. case GeomType_Circle :
  2442. case GeomType_Ellipse :
  2443. {
  2444. RawDataSize = 1;
  2445. } break;
  2446. case GeomType_Image :
  2447. {
  2448. CHECK(FALSE); /* Images not allowed in data files. */
  2449. } break;
  2450. default :
  2451. {
  2452. CHECK(FALSE);
  2453. } break;
  2454. }
  2455. Geom.DataType = FieldDataType_Float;
  2456. Geom.GeomData.Generic.V1Base = AllocScratchNodalFieldDataPtr(RawDataSize, FieldDataType_Float, TRUE);
  2457. Geom.GeomData.Generic.V2Base = AllocScratchNodalFieldDataPtr(RawDataSize, FieldDataType_Float, TRUE);
  2458. Geom.GeomData.Generic.V3Base = AllocScratchNodalFieldDataPtr(RawDataSize, FieldDataType_Float, TRUE);
  2459. for (I = 0; I < RawDataSize; I++)
  2460. {
  2461. SetFieldValue(Geom.GeomData.Generic.V1Base, I, (double)XOrThetaGeomData[I]*Fract);
  2462. SetFieldValue(Geom.GeomData.Generic.V2Base, I, (double)YOrRGeomData[I]*Fract);
  2463. SetFieldValue(Geom.GeomData.Generic.V3Base, I, (double)ZGeomData[I]*Fract);
  2464. }
  2465. if (DumpGeometry(HeadFile[CurFile], &Geom, TRUE, FALSE))
  2466. RetVal = 0;
  2467. else
  2468. RetVal = -1;
  2469. DeallocScratchNodalFieldDataPtr(&Geom.GeomData.Generic.V1Base);
  2470. DeallocScratchNodalFieldDataPtr(&Geom.GeomData.Generic.V2Base);
  2471. DeallocScratchNodalFieldDataPtr(&Geom.GeomData.Generic.V3Base);
  2472. return RetVal;
  2473. }
  2474. INTEGER4 LIBCALL TECGEO111(double *XOrThetaPos,
  2475. double *YOrRPos,
  2476. double *ZPos,
  2477. INTEGER4 *PosCoordMode, /* 0=Grid, 1=Frame, 3=Grid3D */
  2478. INTEGER4 *AttachToZone,
  2479. INTEGER4 *Zone,
  2480. INTEGER4 *Color,
  2481. INTEGER4 *FillColor,
  2482. INTEGER4 *IsFilled,
  2483. INTEGER4 *GeomType,
  2484. INTEGER4 *LinePattern,
  2485. double *PatternLength,
  2486. double *LineThickness,
  2487. INTEGER4 *NumEllipsePts,
  2488. INTEGER4 *ArrowheadStyle,
  2489. INTEGER4 *ArrowheadAttachment,
  2490. double *ArrowheadSize,
  2491. double *ArrowheadAngle,
  2492. INTEGER4 *Scope,
  2493. INTEGER4 *Clipping,
  2494. INTEGER4 *NumSegments,
  2495. INTEGER4 *NumSegPts,
  2496. float *XOrThetaGeomData,
  2497. float *YOrRGeomData,
  2498. float *ZGeomData,
  2499. char *mfc)
  2500. {
  2501. return TECGEO112(XOrThetaPos,
  2502. YOrRPos,
  2503. ZPos,
  2504. PosCoordMode,
  2505. AttachToZone,
  2506. Zone,
  2507. Color,
  2508. FillColor,
  2509. IsFilled,
  2510. GeomType,
  2511. LinePattern,
  2512. PatternLength,
  2513. LineThickness,
  2514. NumEllipsePts,
  2515. ArrowheadStyle,
  2516. ArrowheadAttachment,
  2517. ArrowheadSize,
  2518. ArrowheadAngle,
  2519. Scope,
  2520. Clipping,
  2521. NumSegments,
  2522. NumSegPts,
  2523. XOrThetaGeomData,
  2524. YOrRGeomData,
  2525. ZGeomData,
  2526. mfc);
  2527. }
  2528. INTEGER4 LIBCALL TECGEO110(double *XOrThetaPos,
  2529. double *YOrRPos,
  2530. double *ZPos,
  2531. INTEGER4 *PosCoordMode, /* 0=Grid, 1=Frame, 3=Grid3D */
  2532. INTEGER4 *AttachToZone,
  2533. INTEGER4 *Zone,
  2534. INTEGER4 *Color,
  2535. INTEGER4 *FillColor,
  2536. INTEGER4 *IsFilled,
  2537. INTEGER4 *GeomType,
  2538. INTEGER4 *LinePattern,
  2539. double *PatternLength,
  2540. double *LineThickness,
  2541. INTEGER4 *NumEllipsePts,
  2542. INTEGER4 *ArrowheadStyle,
  2543. INTEGER4 *ArrowheadAttachment,
  2544. double *ArrowheadSize,
  2545. double *ArrowheadAngle,
  2546. INTEGER4 *Scope,
  2547. INTEGER4 *Clipping,
  2548. INTEGER4 *NumSegments,
  2549. INTEGER4 *NumSegPts,
  2550. float *XOrThetaGeomData,
  2551. float *YOrRGeomData,
  2552. float *ZGeomData,
  2553. char *mfc)
  2554. {
  2555. return TECGEO112(XOrThetaPos,
  2556. YOrRPos,
  2557. ZPos,
  2558. PosCoordMode,
  2559. AttachToZone,
  2560. Zone,
  2561. Color,
  2562. FillColor,
  2563. IsFilled,
  2564. GeomType,
  2565. LinePattern,
  2566. PatternLength,
  2567. LineThickness,
  2568. NumEllipsePts,
  2569. ArrowheadStyle,
  2570. ArrowheadAttachment,
  2571. ArrowheadSize,
  2572. ArrowheadAngle,
  2573. Scope,
  2574. Clipping,
  2575. NumSegments,
  2576. NumSegPts,
  2577. XOrThetaGeomData,
  2578. YOrRGeomData,
  2579. ZGeomData,
  2580. mfc);
  2581. }
  2582. INTEGER4 LIBCALL TECGEO100(double *XOrThetaPos,
  2583. double *YOrRPos,
  2584. double *ZPos,
  2585. INTEGER4 *PosCoordMode, /* 0=Grid, 1=Frame, 3=Grid3D */
  2586. INTEGER4 *AttachToZone,
  2587. INTEGER4 *Zone,
  2588. INTEGER4 *Color,
  2589. INTEGER4 *FillColor,
  2590. INTEGER4 *IsFilled,
  2591. INTEGER4 *GeomType,
  2592. INTEGER4 *LinePattern,
  2593. double *PatternLength,
  2594. double *LineThickness,
  2595. INTEGER4 *NumEllipsePts,
  2596. INTEGER4 *ArrowheadStyle,
  2597. INTEGER4 *ArrowheadAttachment,
  2598. double *ArrowheadSize,
  2599. double *ArrowheadAngle,
  2600. INTEGER4 *Scope,
  2601. INTEGER4 *Clipping,
  2602. INTEGER4 *NumSegments,
  2603. INTEGER4 *NumSegPts,
  2604. float *XOrThetaGeomData,
  2605. float *YOrRGeomData,
  2606. float *ZGeomData,
  2607. char *mfc)
  2608. {
  2609. return TECGEO112(XOrThetaPos,
  2610. YOrRPos,
  2611. ZPos,
  2612. PosCoordMode,
  2613. AttachToZone,
  2614. Zone,
  2615. Color,
  2616. FillColor,
  2617. IsFilled,
  2618. GeomType,
  2619. LinePattern,
  2620. PatternLength,
  2621. LineThickness,
  2622. NumEllipsePts,
  2623. ArrowheadStyle,
  2624. ArrowheadAttachment,
  2625. ArrowheadSize,
  2626. ArrowheadAngle,
  2627. Scope,
  2628. Clipping,
  2629. NumSegments,
  2630. NumSegPts,
  2631. XOrThetaGeomData,
  2632. YOrRGeomData,
  2633. ZGeomData,
  2634. mfc);
  2635. }
  2636. INTEGER4 LIBCALL TECGEO(double *XPos,
  2637. double *YPos,
  2638. double *ZPos,
  2639. INTEGER4 *PosCoordMode,
  2640. INTEGER4 *AttachToZone,
  2641. INTEGER4 *Zone,
  2642. INTEGER4 *Color,
  2643. INTEGER4 *FillColor,
  2644. INTEGER4 *IsFilled,
  2645. INTEGER4 *GeomType,
  2646. INTEGER4 *LinePattern,
  2647. double *PatternLength,
  2648. double *LineThickness,
  2649. INTEGER4 *NumEllipsePts,
  2650. INTEGER4 *ArrowheadStyle,
  2651. INTEGER4 *ArrowheadAttachment,
  2652. double *ArrowheadSize,
  2653. double *ArrowheadAngle,
  2654. INTEGER4 *Scope,
  2655. INTEGER4 *NumSegments,
  2656. INTEGER4 *NumSegPts,
  2657. float *XGeomData,
  2658. float *YGeomData,
  2659. float *ZGeomData,
  2660. char *mfc)
  2661. {
  2662. int Clipping = (int)Clipping_ClipToViewport;
  2663. return TECGEO112(XPos,
  2664. YPos,
  2665. ZPos,
  2666. PosCoordMode,
  2667. AttachToZone,
  2668. Zone,
  2669. Color,
  2670. FillColor,
  2671. IsFilled,
  2672. GeomType,
  2673. LinePattern,
  2674. PatternLength,
  2675. LineThickness,
  2676. NumEllipsePts,
  2677. ArrowheadStyle,
  2678. ArrowheadAttachment,
  2679. ArrowheadSize,
  2680. ArrowheadAngle,
  2681. Scope,
  2682. &Clipping,
  2683. NumSegments,
  2684. NumSegPts,
  2685. XGeomData,
  2686. YGeomData,
  2687. ZGeomData,
  2688. mfc);
  2689. }
  2690. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  2691. LIBFUNCTION INTEGER4 LIBCALL tecgeo112_(double *XPos,
  2692. double *YPos,
  2693. double *ZPos,
  2694. INTEGER4 *PosCoordMode,
  2695. INTEGER4 *AttachToZone,
  2696. INTEGER4 *Zone,
  2697. INTEGER4 *Color,
  2698. INTEGER4 *FillColor,
  2699. INTEGER4 *IsFilled,
  2700. INTEGER4 *GeomType,
  2701. INTEGER4 *LinePattern,
  2702. double *PatternLength,
  2703. double *LineThickness,
  2704. INTEGER4 *NumEllipsePts,
  2705. INTEGER4 *ArrowheadStyle,
  2706. INTEGER4 *ArrowheadAttachment,
  2707. double *ArrowheadSize,
  2708. double *ArrowheadAngle,
  2709. INTEGER4 *Scope,
  2710. INTEGER4 *Clipping,
  2711. INTEGER4 *NumSegments,
  2712. INTEGER4 *NumSegPts,
  2713. float *XGeomData,
  2714. float *YGeomData,
  2715. float *ZGeomData,
  2716. char *mfc)
  2717. {
  2718. return TECGEO112(XPos,
  2719. YPos,
  2720. ZPos,
  2721. PosCoordMode,
  2722. AttachToZone,
  2723. Zone,
  2724. Color,
  2725. FillColor,
  2726. IsFilled,
  2727. GeomType,
  2728. LinePattern,
  2729. PatternLength,
  2730. LineThickness,
  2731. NumEllipsePts,
  2732. ArrowheadStyle,
  2733. ArrowheadAttachment,
  2734. ArrowheadSize,
  2735. ArrowheadAngle,
  2736. Scope,
  2737. Clipping,
  2738. NumSegments,
  2739. NumSegPts,
  2740. XGeomData,
  2741. YGeomData,
  2742. ZGeomData,
  2743. mfc);
  2744. }
  2745. LIBFUNCTION INTEGER4 LIBCALL tecgeo111_(double *XPos,
  2746. double *YPos,
  2747. double *ZPos,
  2748. INTEGER4 *PosCoordMode,
  2749. INTEGER4 *AttachToZone,
  2750. INTEGER4 *Zone,
  2751. INTEGER4 *Color,
  2752. INTEGER4 *FillColor,
  2753. INTEGER4 *IsFilled,
  2754. INTEGER4 *GeomType,
  2755. INTEGER4 *LinePattern,
  2756. double *PatternLength,
  2757. double *LineThickness,
  2758. INTEGER4 *NumEllipsePts,
  2759. INTEGER4 *ArrowheadStyle,
  2760. INTEGER4 *ArrowheadAttachment,
  2761. double *ArrowheadSize,
  2762. double *ArrowheadAngle,
  2763. INTEGER4 *Scope,
  2764. INTEGER4 *Clipping,
  2765. INTEGER4 *NumSegments,
  2766. INTEGER4 *NumSegPts,
  2767. float *XGeomData,
  2768. float *YGeomData,
  2769. float *ZGeomData,
  2770. char *mfc)
  2771. {
  2772. return TECGEO112(XPos,
  2773. YPos,
  2774. ZPos,
  2775. PosCoordMode,
  2776. AttachToZone,
  2777. Zone,
  2778. Color,
  2779. FillColor,
  2780. IsFilled,
  2781. GeomType,
  2782. LinePattern,
  2783. PatternLength,
  2784. LineThickness,
  2785. NumEllipsePts,
  2786. ArrowheadStyle,
  2787. ArrowheadAttachment,
  2788. ArrowheadSize,
  2789. ArrowheadAngle,
  2790. Scope,
  2791. Clipping,
  2792. NumSegments,
  2793. NumSegPts,
  2794. XGeomData,
  2795. YGeomData,
  2796. ZGeomData,
  2797. mfc);
  2798. }
  2799. LIBFUNCTION INTEGER4 LIBCALL tecgeo110_(double *XPos,
  2800. double *YPos,
  2801. double *ZPos,
  2802. INTEGER4 *PosCoordMode,
  2803. INTEGER4 *AttachToZone,
  2804. INTEGER4 *Zone,
  2805. INTEGER4 *Color,
  2806. INTEGER4 *FillColor,
  2807. INTEGER4 *IsFilled,
  2808. INTEGER4 *GeomType,
  2809. INTEGER4 *LinePattern,
  2810. double *PatternLength,
  2811. double *LineThickness,
  2812. INTEGER4 *NumEllipsePts,
  2813. INTEGER4 *ArrowheadStyle,
  2814. INTEGER4 *ArrowheadAttachment,
  2815. double *ArrowheadSize,
  2816. double *ArrowheadAngle,
  2817. INTEGER4 *Scope,
  2818. INTEGER4 *Clipping,
  2819. INTEGER4 *NumSegments,
  2820. INTEGER4 *NumSegPts,
  2821. float *XGeomData,
  2822. float *YGeomData,
  2823. float *ZGeomData,
  2824. char *mfc)
  2825. {
  2826. return TECGEO112(XPos,
  2827. YPos,
  2828. ZPos,
  2829. PosCoordMode,
  2830. AttachToZone,
  2831. Zone,
  2832. Color,
  2833. FillColor,
  2834. IsFilled,
  2835. GeomType,
  2836. LinePattern,
  2837. PatternLength,
  2838. LineThickness,
  2839. NumEllipsePts,
  2840. ArrowheadStyle,
  2841. ArrowheadAttachment,
  2842. ArrowheadSize,
  2843. ArrowheadAngle,
  2844. Scope,
  2845. Clipping,
  2846. NumSegments,
  2847. NumSegPts,
  2848. XGeomData,
  2849. YGeomData,
  2850. ZGeomData,
  2851. mfc);
  2852. }
  2853. LIBFUNCTION INTEGER4 LIBCALL tecgeo100_(double *XPos,
  2854. double *YPos,
  2855. double *ZPos,
  2856. INTEGER4 *PosCoordMode,
  2857. INTEGER4 *AttachToZone,
  2858. INTEGER4 *Zone,
  2859. INTEGER4 *Color,
  2860. INTEGER4 *FillColor,
  2861. INTEGER4 *IsFilled,
  2862. INTEGER4 *GeomType,
  2863. INTEGER4 *LinePattern,
  2864. double *PatternLength,
  2865. double *LineThickness,
  2866. INTEGER4 *NumEllipsePts,
  2867. INTEGER4 *ArrowheadStyle,
  2868. INTEGER4 *ArrowheadAttachment,
  2869. double *ArrowheadSize,
  2870. double *ArrowheadAngle,
  2871. INTEGER4 *Scope,
  2872. INTEGER4 *Clipping,
  2873. INTEGER4 *NumSegments,
  2874. INTEGER4 *NumSegPts,
  2875. float *XGeomData,
  2876. float *YGeomData,
  2877. float *ZGeomData,
  2878. char *mfc)
  2879. {
  2880. return TECGEO112(XPos,
  2881. YPos,
  2882. ZPos,
  2883. PosCoordMode,
  2884. AttachToZone,
  2885. Zone,
  2886. Color,
  2887. FillColor,
  2888. IsFilled,
  2889. GeomType,
  2890. LinePattern,
  2891. PatternLength,
  2892. LineThickness,
  2893. NumEllipsePts,
  2894. ArrowheadStyle,
  2895. ArrowheadAttachment,
  2896. ArrowheadSize,
  2897. ArrowheadAngle,
  2898. Scope,
  2899. Clipping,
  2900. NumSegments,
  2901. NumSegPts,
  2902. XGeomData,
  2903. YGeomData,
  2904. ZGeomData,
  2905. mfc);
  2906. }
  2907. LIBFUNCTION INTEGER4 LIBCALL tecgeo_(double *XPos,
  2908. double *YPos,
  2909. double *ZPos,
  2910. INTEGER4 *PosCoordMode,
  2911. INTEGER4 *AttachToZone,
  2912. INTEGER4 *Zone,
  2913. INTEGER4 *Color,
  2914. INTEGER4 *FillColor,
  2915. INTEGER4 *IsFilled,
  2916. INTEGER4 *GeomType,
  2917. INTEGER4 *LinePattern,
  2918. double *PatternLength,
  2919. double *LineThickness,
  2920. INTEGER4 *NumEllipsePts,
  2921. INTEGER4 *ArrowheadStyle,
  2922. INTEGER4 *ArrowheadAttachment,
  2923. double *ArrowheadSize,
  2924. double *ArrowheadAngle,
  2925. INTEGER4 *Scope,
  2926. INTEGER4 *NumSegments,
  2927. INTEGER4 *NumSegPts,
  2928. float *XGeomData,
  2929. float *YGeomData,
  2930. float *ZGeomData,
  2931. char *mfc)
  2932. {
  2933. return TECGEO(XPos,
  2934. YPos,
  2935. ZPos,
  2936. PosCoordMode,
  2937. AttachToZone,
  2938. Zone,
  2939. Color,
  2940. FillColor,
  2941. IsFilled,
  2942. GeomType,
  2943. LinePattern,
  2944. PatternLength,
  2945. LineThickness,
  2946. NumEllipsePts,
  2947. ArrowheadStyle,
  2948. ArrowheadAttachment,
  2949. ArrowheadSize,
  2950. ArrowheadAngle,
  2951. Scope,
  2952. NumSegments,
  2953. NumSegPts,
  2954. XGeomData,
  2955. YGeomData,
  2956. ZGeomData,
  2957. mfc);
  2958. }
  2959. #endif
  2960. /**
  2961. * TECTXTXXX
  2962. */
  2963. INTEGER4 LIBCALL TECTXT112(double *XOrThetaPos,
  2964. double *YOrRPos,
  2965. double *ZOrUnusedPos,
  2966. INTEGER4 *PosCoordMode,
  2967. INTEGER4 *AttachToZone,
  2968. INTEGER4 *Zone,
  2969. INTEGER4 *BFont,
  2970. INTEGER4 *FontHeightUnits,
  2971. double *FontHeight,
  2972. INTEGER4 *BoxType,
  2973. double *BoxMargin,
  2974. double *BoxLineThickness,
  2975. INTEGER4 *BoxColor,
  2976. INTEGER4 *BoxFillColor,
  2977. double *Angle,
  2978. INTEGER4 *Anchor,
  2979. double *LineSpacing,
  2980. INTEGER4 *TextColor,
  2981. INTEGER4 *Scope,
  2982. INTEGER4 *Clipping,
  2983. char *String,
  2984. char *mfc)
  2985. {
  2986. int RetVal;
  2987. Text_s Text;
  2988. double Fract;
  2989. if (CheckFile("TECTXT112") < 0)
  2990. return (-1);
  2991. Text.PositionCoordSys = (CoordSys_e) * PosCoordMode;
  2992. if (Text.PositionCoordSys == CoordSys_Frame)
  2993. Fract = 0.01;
  2994. else
  2995. Fract = 1.0;
  2996. Text.AnchorPos.Generic.V1 = (*XOrThetaPos) * Fract;
  2997. Text.AnchorPos.Generic.V2 = (*YOrRPos) * Fract;
  2998. Text.AnchorPos.Generic.V3 = (*ZOrUnusedPos) * Fract;
  2999. Text.AttachToZone = *AttachToZone != 0;
  3000. Text.Zone = *Zone - 1;
  3001. Text.BColor = (ColorIndex_t) * TextColor;
  3002. Text.TextShape.Font = (Font_e) * BFont;
  3003. Text.TextShape.SizeUnits = (Units_e) * FontHeightUnits;
  3004. if (Text.TextShape.SizeUnits == Units_Frame)
  3005. Text.TextShape.Height = (*FontHeight) / 100.0;
  3006. else
  3007. Text.TextShape.Height = *FontHeight;
  3008. Text.Box.BoxType = (TextBox_e) * BoxType;
  3009. Text.Box.Margin = *BoxMargin / 100.0;
  3010. Text.Box.LineThickness = *BoxLineThickness / 100.0;
  3011. Text.Box.BColor = (ColorIndex_t) * BoxColor;
  3012. Text.Box.FillBColor = (ColorIndex_t) * BoxFillColor;
  3013. Text.Anchor = (TextAnchor_e) * Anchor;
  3014. Text.LineSpacing = *LineSpacing;
  3015. Text.Angle = *Angle / DEGPERRADIANS;
  3016. Text.Scope = (Scope_e) * Scope;
  3017. Text.Text = String;
  3018. Text.MacroFunctionCommand = mfc;
  3019. Text.Clipping = (Clipping_e) * Clipping;
  3020. #if defined MAKEARCHIVE
  3021. if (DebugLevel[CurFile])
  3022. PRINT1("\nInserting Text: %s\n", String);
  3023. #endif
  3024. if (DumpText(HeadFile[CurFile], &Text, TRUE, FALSE))
  3025. RetVal = 0;
  3026. else
  3027. RetVal = -1;
  3028. return RetVal;
  3029. }
  3030. INTEGER4 LIBCALL TECTXT111(double *XOrThetaPos,
  3031. double *YOrRPos,
  3032. double *ZOrUnusedPos,
  3033. INTEGER4 *PosCoordMode,
  3034. INTEGER4 *AttachToZone,
  3035. INTEGER4 *Zone,
  3036. INTEGER4 *BFont,
  3037. INTEGER4 *FontHeightUnits,
  3038. double *FontHeight,
  3039. INTEGER4 *BoxType,
  3040. double *BoxMargin,
  3041. double *BoxLineThickness,
  3042. INTEGER4 *BoxColor,
  3043. INTEGER4 *BoxFillColor,
  3044. double *Angle,
  3045. INTEGER4 *Anchor,
  3046. double *LineSpacing,
  3047. INTEGER4 *TextColor,
  3048. INTEGER4 *Scope,
  3049. INTEGER4 *Clipping,
  3050. char *String,
  3051. char *mfc)
  3052. {
  3053. return TECTXT112(XOrThetaPos,
  3054. YOrRPos,
  3055. ZOrUnusedPos,
  3056. PosCoordMode,
  3057. AttachToZone,
  3058. Zone,
  3059. BFont,
  3060. FontHeightUnits,
  3061. FontHeight,
  3062. BoxType,
  3063. BoxMargin,
  3064. BoxLineThickness,
  3065. BoxColor,
  3066. BoxFillColor,
  3067. Angle,
  3068. Anchor,
  3069. LineSpacing,
  3070. TextColor,
  3071. Scope,
  3072. Clipping,
  3073. String,
  3074. mfc);
  3075. }
  3076. INTEGER4 LIBCALL TECTXT110(double *XOrThetaPos,
  3077. double *YOrRPos,
  3078. double *ZOrUnusedPos,
  3079. INTEGER4 *PosCoordMode,
  3080. INTEGER4 *AttachToZone,
  3081. INTEGER4 *Zone,
  3082. INTEGER4 *BFont,
  3083. INTEGER4 *FontHeightUnits,
  3084. double *FontHeight,
  3085. INTEGER4 *BoxType,
  3086. double *BoxMargin,
  3087. double *BoxLineThickness,
  3088. INTEGER4 *BoxColor,
  3089. INTEGER4 *BoxFillColor,
  3090. double *Angle,
  3091. INTEGER4 *Anchor,
  3092. double *LineSpacing,
  3093. INTEGER4 *TextColor,
  3094. INTEGER4 *Scope,
  3095. INTEGER4 *Clipping,
  3096. char *String,
  3097. char *mfc)
  3098. {
  3099. return TECTXT112(XOrThetaPos,
  3100. YOrRPos,
  3101. ZOrUnusedPos,
  3102. PosCoordMode,
  3103. AttachToZone,
  3104. Zone,
  3105. BFont,
  3106. FontHeightUnits,
  3107. FontHeight,
  3108. BoxType,
  3109. BoxMargin,
  3110. BoxLineThickness,
  3111. BoxColor,
  3112. BoxFillColor,
  3113. Angle,
  3114. Anchor,
  3115. LineSpacing,
  3116. TextColor,
  3117. Scope,
  3118. Clipping,
  3119. String,
  3120. mfc);
  3121. }
  3122. INTEGER4 LIBCALL TECTXT100(double *XOrThetaPos,
  3123. double *YOrRPos,
  3124. double *ZOrUnusedPos,
  3125. INTEGER4 *PosCoordMode,
  3126. INTEGER4 *AttachToZone,
  3127. INTEGER4 *Zone,
  3128. INTEGER4 *BFont,
  3129. INTEGER4 *FontHeightUnits,
  3130. double *FontHeight,
  3131. INTEGER4 *BoxType,
  3132. double *BoxMargin,
  3133. double *BoxLineThickness,
  3134. INTEGER4 *BoxColor,
  3135. INTEGER4 *BoxFillColor,
  3136. double *Angle,
  3137. INTEGER4 *Anchor,
  3138. double *LineSpacing,
  3139. INTEGER4 *TextColor,
  3140. INTEGER4 *Scope,
  3141. INTEGER4 *Clipping,
  3142. char *String,
  3143. char *mfc)
  3144. {
  3145. return TECTXT112(XOrThetaPos,
  3146. YOrRPos,
  3147. ZOrUnusedPos,
  3148. PosCoordMode,
  3149. AttachToZone,
  3150. Zone,
  3151. BFont,
  3152. FontHeightUnits,
  3153. FontHeight,
  3154. BoxType,
  3155. BoxMargin,
  3156. BoxLineThickness,
  3157. BoxColor,
  3158. BoxFillColor,
  3159. Angle,
  3160. Anchor,
  3161. LineSpacing,
  3162. TextColor,
  3163. Scope,
  3164. Clipping,
  3165. String,
  3166. mfc);
  3167. }
  3168. INTEGER4 LIBCALL TECTXT(double *XPos,
  3169. double *YPos,
  3170. INTEGER4 *PosCoordMode,
  3171. INTEGER4 *AttachToZone,
  3172. INTEGER4 *Zone,
  3173. INTEGER4 *BFont,
  3174. INTEGER4 *FontHeightUnits,
  3175. double *FontHeight,
  3176. INTEGER4 *BoxType,
  3177. double *BoxMargin,
  3178. double *BoxLineThickness,
  3179. INTEGER4 *BoxColor,
  3180. INTEGER4 *BoxFillColor,
  3181. double *Angle,
  3182. INTEGER4 *Anchor,
  3183. double *LineSpacing,
  3184. INTEGER4 *TextColor,
  3185. INTEGER4 *Scope,
  3186. char *Text,
  3187. char *mfc)
  3188. {
  3189. double ZPos = 0.0;
  3190. int Clipping = (int)Clipping_ClipToViewport;
  3191. return TECTXT112(XPos,
  3192. YPos,
  3193. &ZPos,
  3194. PosCoordMode,
  3195. AttachToZone,
  3196. Zone,
  3197. BFont,
  3198. FontHeightUnits,
  3199. FontHeight,
  3200. BoxType,
  3201. BoxMargin,
  3202. BoxLineThickness,
  3203. BoxColor,
  3204. BoxFillColor,
  3205. Angle,
  3206. Anchor,
  3207. LineSpacing,
  3208. TextColor,
  3209. Scope,
  3210. &Clipping,
  3211. Text,
  3212. mfc);
  3213. }
  3214. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  3215. LIBFUNCTION INTEGER4 LIBCALL tectxt112_(double *XOrThetaPos,
  3216. double *YOrRPos,
  3217. double *ZOrUnusedPos,
  3218. INTEGER4 *PosCoordMode,
  3219. INTEGER4 *AttachToZone,
  3220. INTEGER4 *Zone,
  3221. INTEGER4 *BFont,
  3222. INTEGER4 *FontHeightUnits,
  3223. double *FontHeight,
  3224. INTEGER4 *BoxType,
  3225. double *BoxMargin,
  3226. double *BoxLineThickness,
  3227. INTEGER4 *BoxColor,
  3228. INTEGER4 *BoxFillColor,
  3229. double *Angle,
  3230. INTEGER4 *Anchor,
  3231. double *LineSpacing,
  3232. INTEGER4 *TextColor,
  3233. INTEGER4 *Scope,
  3234. INTEGER4 *Clipping,
  3235. char *String,
  3236. char *mfc)
  3237. {
  3238. return TECTXT112(XOrThetaPos,
  3239. YOrRPos,
  3240. ZOrUnusedPos,
  3241. PosCoordMode,
  3242. AttachToZone,
  3243. Zone,
  3244. BFont,
  3245. FontHeightUnits,
  3246. FontHeight,
  3247. BoxType,
  3248. BoxMargin,
  3249. BoxLineThickness,
  3250. BoxColor,
  3251. BoxFillColor,
  3252. Angle,
  3253. Anchor,
  3254. LineSpacing,
  3255. TextColor,
  3256. Scope,
  3257. Clipping,
  3258. String,
  3259. mfc);
  3260. }
  3261. LIBFUNCTION INTEGER4 LIBCALL tectxt111_(double *XOrThetaPos,
  3262. double *YOrRPos,
  3263. double *ZOrUnusedPos,
  3264. INTEGER4 *PosCoordMode,
  3265. INTEGER4 *AttachToZone,
  3266. INTEGER4 *Zone,
  3267. INTEGER4 *BFont,
  3268. INTEGER4 *FontHeightUnits,
  3269. double *FontHeight,
  3270. INTEGER4 *BoxType,
  3271. double *BoxMargin,
  3272. double *BoxLineThickness,
  3273. INTEGER4 *BoxColor,
  3274. INTEGER4 *BoxFillColor,
  3275. double *Angle,
  3276. INTEGER4 *Anchor,
  3277. double *LineSpacing,
  3278. INTEGER4 *TextColor,
  3279. INTEGER4 *Scope,
  3280. INTEGER4 *Clipping,
  3281. char *String,
  3282. char *mfc)
  3283. {
  3284. return TECTXT112(XOrThetaPos,
  3285. YOrRPos,
  3286. ZOrUnusedPos,
  3287. PosCoordMode,
  3288. AttachToZone,
  3289. Zone,
  3290. BFont,
  3291. FontHeightUnits,
  3292. FontHeight,
  3293. BoxType,
  3294. BoxMargin,
  3295. BoxLineThickness,
  3296. BoxColor,
  3297. BoxFillColor,
  3298. Angle,
  3299. Anchor,
  3300. LineSpacing,
  3301. TextColor,
  3302. Scope,
  3303. Clipping,
  3304. String,
  3305. mfc);
  3306. }
  3307. LIBFUNCTION INTEGER4 LIBCALL tectxt110_(double *XOrThetaPos,
  3308. double *YOrRPos,
  3309. double *ZOrUnusedPos,
  3310. INTEGER4 *PosCoordMode,
  3311. INTEGER4 *AttachToZone,
  3312. INTEGER4 *Zone,
  3313. INTEGER4 *BFont,
  3314. INTEGER4 *FontHeightUnits,
  3315. double *FontHeight,
  3316. INTEGER4 *BoxType,
  3317. double *BoxMargin,
  3318. double *BoxLineThickness,
  3319. INTEGER4 *BoxColor,
  3320. INTEGER4 *BoxFillColor,
  3321. double *Angle,
  3322. INTEGER4 *Anchor,
  3323. double *LineSpacing,
  3324. INTEGER4 *TextColor,
  3325. INTEGER4 *Scope,
  3326. INTEGER4 *Clipping,
  3327. char *String,
  3328. char *mfc)
  3329. {
  3330. return TECTXT112(XOrThetaPos,
  3331. YOrRPos,
  3332. ZOrUnusedPos,
  3333. PosCoordMode,
  3334. AttachToZone,
  3335. Zone,
  3336. BFont,
  3337. FontHeightUnits,
  3338. FontHeight,
  3339. BoxType,
  3340. BoxMargin,
  3341. BoxLineThickness,
  3342. BoxColor,
  3343. BoxFillColor,
  3344. Angle,
  3345. Anchor,
  3346. LineSpacing,
  3347. TextColor,
  3348. Scope,
  3349. Clipping,
  3350. String,
  3351. mfc);
  3352. }
  3353. LIBFUNCTION INTEGER4 LIBCALL tectxt100_(double *XOrThetaPos,
  3354. double *YOrRPos,
  3355. double *ZOrUnusedPos,
  3356. INTEGER4 *PosCoordMode,
  3357. INTEGER4 *AttachToZone,
  3358. INTEGER4 *Zone,
  3359. INTEGER4 *BFont,
  3360. INTEGER4 *FontHeightUnits,
  3361. double *FontHeight,
  3362. INTEGER4 *BoxType,
  3363. double *BoxMargin,
  3364. double *BoxLineThickness,
  3365. INTEGER4 *BoxColor,
  3366. INTEGER4 *BoxFillColor,
  3367. double *Angle,
  3368. INTEGER4 *Anchor,
  3369. double *LineSpacing,
  3370. INTEGER4 *TextColor,
  3371. INTEGER4 *Scope,
  3372. INTEGER4 *Clipping,
  3373. char *String,
  3374. char *mfc)
  3375. {
  3376. return TECTXT112(XOrThetaPos,
  3377. YOrRPos,
  3378. ZOrUnusedPos,
  3379. PosCoordMode,
  3380. AttachToZone,
  3381. Zone,
  3382. BFont,
  3383. FontHeightUnits,
  3384. FontHeight,
  3385. BoxType,
  3386. BoxMargin,
  3387. BoxLineThickness,
  3388. BoxColor,
  3389. BoxFillColor,
  3390. Angle,
  3391. Anchor,
  3392. LineSpacing,
  3393. TextColor,
  3394. Scope,
  3395. Clipping,
  3396. String,
  3397. mfc);
  3398. }
  3399. LIBFUNCTION INTEGER4 LIBCALL tectxt_(double *XPos,
  3400. double *YPos,
  3401. INTEGER4 *PosCoordMode,
  3402. INTEGER4 *AttachToZone,
  3403. INTEGER4 *Zone,
  3404. INTEGER4 *BFont,
  3405. INTEGER4 *FontHeightUnits,
  3406. double *FontHeight,
  3407. INTEGER4 *BoxType,
  3408. double *BoxMargin,
  3409. double *BoxLineThickness,
  3410. INTEGER4 *BoxColor,
  3411. INTEGER4 *BoxFillColor,
  3412. double *Angle,
  3413. INTEGER4 *Anchor,
  3414. double *LineSpacing,
  3415. INTEGER4 *TextColor,
  3416. INTEGER4 *Scope,
  3417. char *Text,
  3418. char *mfc)
  3419. {
  3420. return TECTXT(XPos,
  3421. YPos,
  3422. PosCoordMode,
  3423. AttachToZone,
  3424. Zone,
  3425. BFont,
  3426. FontHeightUnits,
  3427. FontHeight,
  3428. BoxType,
  3429. BoxMargin,
  3430. BoxLineThickness,
  3431. BoxColor,
  3432. BoxFillColor,
  3433. Angle,
  3434. Anchor,
  3435. LineSpacing,
  3436. TextColor,
  3437. Scope,
  3438. Text,
  3439. mfc);
  3440. }
  3441. #endif
  3442. /**
  3443. * TECFILXXX
  3444. */
  3445. INTEGER4 LIBCALL TECFIL112(INTEGER4 *F)
  3446. {
  3447. if ((*F < 1) || (*F > MaxNumFiles))
  3448. {
  3449. #if defined MAKEARCHIVE
  3450. PRINT1("Err: (TECFIL112) Invalid file number requested (%d). File not changed.\n", *F);
  3451. #endif
  3452. return (-1);
  3453. }
  3454. if (!IsOpen[*F-1])
  3455. {
  3456. #if defined MAKEARCHIVE
  3457. int I;
  3458. PRINT1("Err: (TECFIL112) file %d is not open. File not changed.\n", *F);
  3459. PRINT0("\n\nFile states are:\n");
  3460. for (I = 0; I < MaxNumFiles; I++)
  3461. PRINT2("file %d, IsOpen=%d\n", I + 1, IsOpen[I]);
  3462. PRINT1("Current File is: %d\n", CurFile + 1);
  3463. #endif
  3464. return (-1);
  3465. }
  3466. CurFile = *F - 1;
  3467. #if defined MAKEARCHIVE
  3468. if (DebugLevel[CurFile])
  3469. {
  3470. PRINT1("Switching to file #%d\n\n", CurFile + 1);
  3471. PRINT0("Current State is:\n");
  3472. PRINT1(" Debug = %d\n", DebugLevel[CurFile]);
  3473. PRINT1(" NumVars = %d\n", NumVars[CurFile]);
  3474. PRINT1(" DestFName = %s\n", DestFName[CurFile]);
  3475. PRINT1(" BlckFName = %s\n", BlckFName[CurFile]);
  3476. PRINT1(" ZoneType = %s\n", ZoneTypes[ZoneType[CurFile]]);
  3477. if (ZoneType[CurFile] == ORDERED)
  3478. {
  3479. PRINT1(" IMax = %d\n", IMax[CurFile]);
  3480. PRINT1(" JMax = %d\n", JMax[CurFile]);
  3481. PRINT1(" KMax = %d\n", KMax[CurFile]);
  3482. }
  3483. else
  3484. {
  3485. PRINT1(" NumPoints = %d\n", IMax[CurFile]);
  3486. PRINT1(" NumElmnts = %d\n", JMax[CurFile]);
  3487. }
  3488. PRINT1(" NumDataValuesWritten = %d\n", NumDataValuesWritten[CurFile]);
  3489. PRINT1(" CurZone = %d\n", CurZone[CurFile] + 1);
  3490. }
  3491. #endif /* MAKEARCHIVE */
  3492. return (0);
  3493. }
  3494. INTEGER4 LIBCALL TECFIL111(INTEGER4 *F)
  3495. {
  3496. return TECFIL112(F);
  3497. }
  3498. INTEGER4 LIBCALL TECFIL110(INTEGER4 *F)
  3499. {
  3500. return TECFIL112(F);
  3501. }
  3502. INTEGER4 LIBCALL TECFIL100(INTEGER4 *F)
  3503. {
  3504. return TECFIL112(F);
  3505. }
  3506. INTEGER4 LIBCALL TECFIL(INTEGER4 *F)
  3507. {
  3508. return TECFIL112(F);
  3509. }
  3510. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  3511. LIBFUNCTION INTEGER4 LIBCALL tecfil112_(INTEGER4 *F)
  3512. {
  3513. return TECFIL112(F);
  3514. }
  3515. LIBFUNCTION INTEGER4 LIBCALL tecfil111_(INTEGER4 *F)
  3516. {
  3517. return TECFIL112(F);
  3518. }
  3519. LIBFUNCTION INTEGER4 LIBCALL tecfil110_(INTEGER4 *F)
  3520. {
  3521. return TECFIL112(F);
  3522. }
  3523. LIBFUNCTION INTEGER4 LIBCALL tecfil100_(INTEGER4 *F)
  3524. {
  3525. return TECFIL112(F);
  3526. }
  3527. LIBFUNCTION INTEGER4 LIBCALL tecfil_(INTEGER4 *F)
  3528. {
  3529. return TECFIL112(F);
  3530. }
  3531. #endif
  3532. /**
  3533. * TECFOREIGNXXX
  3534. */
  3535. void LIBCALL TECFOREIGN112(INTEGER4 *OutputForeignByteOrder)
  3536. {
  3537. REQUIRE(VALID_REF(OutputForeignByteOrder));
  3538. DoWriteForeign = (*OutputForeignByteOrder != 0);
  3539. }
  3540. void LIBCALL TECFOREIGN111(INTEGER4 *OutputForeignByteOrder)
  3541. {
  3542. TECFOREIGN112(OutputForeignByteOrder);
  3543. }
  3544. void LIBCALL TECFOREIGN110(INTEGER4 *OutputForeignByteOrder)
  3545. {
  3546. TECFOREIGN112(OutputForeignByteOrder);
  3547. }
  3548. void LIBCALL TECFOREIGN100(INTEGER4 *OutputForeignByteOrder)
  3549. {
  3550. TECFOREIGN112(OutputForeignByteOrder);
  3551. }
  3552. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  3553. LIBFUNCTION void LIBCALL tecforeign112_(INTEGER4 *OutputForeignByteOrder)
  3554. {
  3555. TECFOREIGN112(OutputForeignByteOrder);
  3556. }
  3557. LIBFUNCTION void LIBCALL tecforeign111_(INTEGER4 *OutputForeignByteOrder)
  3558. {
  3559. TECFOREIGN112(OutputForeignByteOrder);
  3560. }
  3561. LIBFUNCTION void LIBCALL tecforeign110_(INTEGER4 *OutputForeignByteOrder)
  3562. {
  3563. TECFOREIGN112(OutputForeignByteOrder);
  3564. }
  3565. LIBFUNCTION void LIBCALL tecforeign100_(INTEGER4 *OutputForeignByteOrder)
  3566. {
  3567. TECFOREIGN112(OutputForeignByteOrder);
  3568. }
  3569. #endif
  3570. #if defined MAKEARCHIVE
  3571. /**
  3572. * A valid auxiliary data name character must begin with a '_' or alpha
  3573. * character and may be followed by one or more '_', '.', alpha or digit
  3574. * characters.
  3575. */
  3576. static Boolean_t AuxDataIsValidNameChar(char Char,
  3577. Boolean_t IsLeadChar)
  3578. {
  3579. Boolean_t IsValidNameChar;
  3580. REQUIRE(0 <= Char && "Char <= 127");
  3581. REQUIRE(VALID_BOOLEAN(IsLeadChar));
  3582. IsValidNameChar = (Char == '_' ||
  3583. isalpha(Char));
  3584. if (!IsLeadChar)
  3585. IsValidNameChar = (IsValidNameChar ||
  3586. Char == '.' ||
  3587. isdigit(Char));
  3588. ENSURE(VALID_BOOLEAN(IsValidNameChar));
  3589. return IsValidNameChar;
  3590. }
  3591. /**
  3592. * Indicates if the auxiliary data name is valid. A valid auxiliary data name
  3593. * must begin with a '_' or alpha character and may be followed by one or
  3594. * more '_', '.', alpha or digit characters.
  3595. */
  3596. static Boolean_t AuxDataIsValidName(const char *Name)
  3597. {
  3598. Boolean_t IsValidName;
  3599. const char *NPtr;
  3600. REQUIRE(VALID_REF(Name));
  3601. for (NPtr = Name, IsValidName = AuxDataIsValidNameChar(*NPtr, TRUE);
  3602. IsValidName && *NPtr != '\0';
  3603. NPtr++)
  3604. {
  3605. IsValidName = AuxDataIsValidNameChar(*NPtr, FALSE);
  3606. }
  3607. ENSURE(VALID_BOOLEAN(IsValidName));
  3608. return IsValidName;
  3609. }
  3610. #endif /* MAKEARCHIVE */
  3611. /**
  3612. * TECAUXSTRXXX
  3613. */
  3614. LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR112(char *Name,
  3615. char *Value)
  3616. {
  3617. if (CheckFile("TECAUXSTR112") < 0)
  3618. return (-1);
  3619. #if defined MAKEARCHIVE
  3620. if (DebugLevel[CurFile])
  3621. PRINT2("\nInserting data set aux data: '%s' = '%s'\n", Name, Value);
  3622. #endif
  3623. if ((Name == NULL) || !AuxDataIsValidName(Name))
  3624. {
  3625. #if defined MAKEARCHIVE
  3626. PRINT0("Err: (TECAUXSTR112) Invalid Name string\n");
  3627. #endif
  3628. NumErrs[CurFile]++;
  3629. return (-1);
  3630. }
  3631. if ((Value == NULL) || (*Value == '\0'))
  3632. {
  3633. #if defined MAKEARCHIVE
  3634. if (DebugLevel[CurFile])
  3635. PRINT0("Err: (TECAUXSTR112) Invalid Value string\n");
  3636. #endif
  3637. NumErrs[CurFile]++;
  3638. return (-1);
  3639. }
  3640. /*
  3641. * Because the auxiliary data is at the end of the header section we don't
  3642. * need to seek back to it.
  3643. */
  3644. if (!WriteBinaryReal(HeadFile[CurFile], DataSetAuxMarker, FieldDataType_Float) ||
  3645. !DumpDatafileString(HeadFile[CurFile], Name, TRUE /* WriteBinary */) ||
  3646. !WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)AuxDataType_String) ||
  3647. !DumpDatafileString(HeadFile[CurFile], (const char *)Value, TRUE /* WriteBinary */))
  3648. {
  3649. #if defined MAKEARCHIVE
  3650. if (DebugLevel[CurFile])
  3651. printf("Err: (TECAUXSTR112) Write failure for file %d\n", CurFile + 1);
  3652. #endif
  3653. NumErrs[CurFile]++;
  3654. return (-1);
  3655. }
  3656. return (0);
  3657. }
  3658. LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR111(char *Name,
  3659. char *Value)
  3660. {
  3661. return TECAUXSTR112(Name, Value);
  3662. }
  3663. LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR110(char *Name,
  3664. char *Value)
  3665. {
  3666. return TECAUXSTR112(Name, Value);
  3667. }
  3668. LIBFUNCTION INTEGER4 LIBCALL TECAUXSTR100(char *Name,
  3669. char *Value)
  3670. {
  3671. return TECAUXSTR112(Name, Value);
  3672. }
  3673. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  3674. LIBFUNCTION INTEGER4 LIBCALL tecauxstr112_(char *Name,
  3675. char *Value)
  3676. {
  3677. return TECAUXSTR112(Name, Value);
  3678. }
  3679. LIBFUNCTION INTEGER4 LIBCALL tecauxstr111_(char *Name,
  3680. char *Value)
  3681. {
  3682. return TECAUXSTR112(Name, Value);
  3683. }
  3684. LIBFUNCTION INTEGER4 LIBCALL tecauxstr110_(char *Name,
  3685. char *Value)
  3686. {
  3687. return TECAUXSTR112(Name, Value);
  3688. }
  3689. LIBFUNCTION INTEGER4 LIBCALL tecauxstr100_(char *Name,
  3690. char *Value)
  3691. {
  3692. return TECAUXSTR112(Name, Value);
  3693. }
  3694. #endif
  3695. /**
  3696. * TECZAUXSTRXXX
  3697. */
  3698. LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR112(char *Name,
  3699. char *Value)
  3700. {
  3701. if (CheckFile("TECZAUXSTR112") < 0)
  3702. return (-1);
  3703. if (CurZone[CurFile] == -1)
  3704. {
  3705. #if defined MAKEARCHIVE
  3706. PRINT0("Err: (TECZAUXSTR112) Must call TECZNE112 prior to TECZAUXSTR112\n");
  3707. #endif
  3708. NumErrs[CurFile]++;
  3709. return (-1);
  3710. }
  3711. #if defined MAKEARCHIVE
  3712. if (DebugLevel[CurFile])
  3713. PRINT2("\nInserting zone aux data: '%s' = '%s'\n", Name, Value);
  3714. #endif
  3715. if ((Name == NULL) || !AuxDataIsValidName(Name))
  3716. {
  3717. #if defined MAKEARCHIVE
  3718. PRINT0("Err: (TECZAUXSTR112) Invalid Name string\n");
  3719. #endif
  3720. NumErrs[CurFile]++;
  3721. return (-1);
  3722. }
  3723. if ((Value == NULL) || (*Value == '\0'))
  3724. {
  3725. #if defined MAKEARCHIVE
  3726. if (DebugLevel[CurFile])
  3727. PRINT0("Err: (TECZAUXSTR112) Invalid Value string\n");
  3728. #endif
  3729. NumErrs[CurFile]++;
  3730. return (-1);
  3731. }
  3732. /*
  3733. * Have to back over the 0 already written, then write another one afterward.
  3734. */
  3735. if (TP_FSEEK(HeadFile[CurFile]->File, -4, SEEK_CUR) ||
  3736. !WriteBinaryInt32(HeadFile[CurFile], 1) ||
  3737. !DumpDatafileString(HeadFile[CurFile], Name, TRUE /* WriteBinary */) ||
  3738. !WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)AuxDataType_String) ||
  3739. !DumpDatafileString(HeadFile[CurFile], (const char *)Value, TRUE /* WriteBinary */) ||
  3740. !WriteBinaryInt32(HeadFile[CurFile], 0))
  3741. {
  3742. #if defined MAKEARCHIVE
  3743. if (DebugLevel[CurFile])
  3744. printf("Err: (TECZAUXSTR112) Write failure for file %d\n", CurFile + 1);
  3745. #endif
  3746. NumErrs[CurFile]++;
  3747. return (-1);
  3748. }
  3749. return (0);
  3750. }
  3751. LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR111(char *Name,
  3752. char *Value)
  3753. {
  3754. return TECZAUXSTR112(Name, Value);
  3755. }
  3756. LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR110(char *Name,
  3757. char *Value)
  3758. {
  3759. return TECZAUXSTR112(Name, Value);
  3760. }
  3761. LIBFUNCTION INTEGER4 LIBCALL TECZAUXSTR100(char *Name,
  3762. char *Value)
  3763. {
  3764. return TECZAUXSTR112(Name, Value);
  3765. }
  3766. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  3767. LIBFUNCTION INTEGER4 LIBCALL teczauxstr112_(char *Name,
  3768. char *Value)
  3769. {
  3770. return TECZAUXSTR112(Name, Value);
  3771. }
  3772. LIBFUNCTION INTEGER4 LIBCALL teczauxstr111_(char *Name,
  3773. char *Value)
  3774. {
  3775. return TECZAUXSTR112(Name, Value);
  3776. }
  3777. LIBFUNCTION INTEGER4 LIBCALL teczauxstr110_(char *Name,
  3778. char *Value)
  3779. {
  3780. return TECZAUXSTR112(Name, Value);
  3781. }
  3782. LIBFUNCTION INTEGER4 LIBCALL teczauxstr100_(char *Name,
  3783. char *Value)
  3784. {
  3785. return TECZAUXSTR112(Name, Value);
  3786. }
  3787. #endif
  3788. /**
  3789. * TECVAUXSTRXXX
  3790. */
  3791. LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR112(INTEGER4 *Var,
  3792. char *Name,
  3793. char *Value)
  3794. {
  3795. if (CheckFile("TECVAUXSTR112") < 0)
  3796. return (-1);
  3797. #if defined MAKEARCHIVE
  3798. if (DebugLevel[CurFile])
  3799. PRINT2("\nInserting variable aux data: '%s' = '%s'\n", Name, Value);
  3800. #endif
  3801. if ((Name == NULL) || !AuxDataIsValidName(Name))
  3802. {
  3803. #if defined MAKEARCHIVE
  3804. PRINT0("Err: (TECVAUXSTR112) Invalid Name string\n");
  3805. #endif
  3806. NumErrs[CurFile]++;
  3807. return (-1);
  3808. }
  3809. if ((Value == NULL) || (*Value == '\0'))
  3810. {
  3811. #if defined MAKEARCHIVE
  3812. if (DebugLevel[CurFile])
  3813. PRINT0("Err: (TECVAUXSTR112) Invalid Value string\n");
  3814. #endif
  3815. NumErrs[CurFile]++;
  3816. return (-1);
  3817. }
  3818. if (!WriteBinaryReal(HeadFile[CurFile], VarAuxMarker, FieldDataType_Float) ||
  3819. !WriteBinaryInt32(HeadFile[CurFile], *Var - 1) ||
  3820. !DumpDatafileString(HeadFile[CurFile], Name, TRUE /* WriteBinary */) ||
  3821. !WriteBinaryInt32(HeadFile[CurFile], (LgIndex_t)AuxDataType_String) ||
  3822. !DumpDatafileString(HeadFile[CurFile], (const char *)Value, TRUE /* WriteBinary */))
  3823. {
  3824. #if defined MAKEARCHIVE
  3825. if (DebugLevel[CurFile])
  3826. printf("Err: (TECVAUXSTR112) Write failure for file %d\n", CurFile + 1);
  3827. #endif
  3828. NumErrs[CurFile]++;
  3829. return (-1);
  3830. }
  3831. return (0);
  3832. }
  3833. LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR111(INTEGER4 *Var,
  3834. char *Name,
  3835. char *Value)
  3836. {
  3837. return TECVAUXSTR112(Var, Name, Value);
  3838. }
  3839. LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR110(INTEGER4 *Var,
  3840. char *Name,
  3841. char *Value)
  3842. {
  3843. return TECVAUXSTR112(Var, Name, Value);
  3844. }
  3845. LIBFUNCTION INTEGER4 LIBCALL TECVAUXSTR100(INTEGER4 *Var,
  3846. char *Name,
  3847. char *Value)
  3848. {
  3849. return TECVAUXSTR112(Var, Name, Value);
  3850. }
  3851. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  3852. LIBFUNCTION INTEGER4 LIBCALL tecvauxstr112_(INTEGER4 *Var,
  3853. char *Name,
  3854. char *Value)
  3855. {
  3856. return TECVAUXSTR112(Var, Name, Value);
  3857. }
  3858. LIBFUNCTION INTEGER4 LIBCALL tecvauxstr111_(INTEGER4 *Var,
  3859. char *Name,
  3860. char *Value)
  3861. {
  3862. return TECVAUXSTR112(Var, Name, Value);
  3863. }
  3864. LIBFUNCTION INTEGER4 LIBCALL tecvauxstr110_(INTEGER4 *Var,
  3865. char *Name,
  3866. char *Value)
  3867. {
  3868. return TECVAUXSTR112(Var, Name, Value);
  3869. }
  3870. LIBFUNCTION INTEGER4 LIBCALL tecvauxstr100_(INTEGER4 *Var,
  3871. char *Name,
  3872. char *Value)
  3873. {
  3874. return TECVAUXSTR112(Var, Name, Value);
  3875. }
  3876. #endif
  3877. /**
  3878. * TECFACEXXX
  3879. */
  3880. LIBFUNCTION INTEGER4 LIBCALL TECFACE112(INTEGER4 *FaceConnections)
  3881. {
  3882. INTEGER4 i, *Ptr;
  3883. /* Mark that the face neighbors have been written for the zone even if it fails so as not to add extra error messages. */
  3884. FaceNeighborsOrMapWritten[CurFile][CurZone[CurFile]] = TRUE;
  3885. if (CheckFile("TECFACE112") < 0)
  3886. return (-1);
  3887. if (ZoneType[CurFile] == FEPOLYGON ||
  3888. ZoneType[CurFile] == FEPOLYHEDRON)
  3889. {
  3890. /* Wrong way to specify face neighbors for polygons and polyhedrons */
  3891. #if defined MAKEARCHIVE
  3892. PRINT0("Err: (TECFACE112) Cannot call TECFACE112 for polygonal or polyhedral zones.\n");
  3893. #endif
  3894. NumErrs[CurFile]++;
  3895. return (-1);
  3896. }
  3897. if (FileTypes[CurFile] == SOLUTIONFILE)
  3898. {
  3899. #if defined MAKEARCHIVE
  3900. PRINT0("Err: (TECFACE112) Cannot call TECFACE112 if the file type is SOLUTIONFILE.\n");
  3901. #endif
  3902. NumErrs[CurFile]++;
  3903. return (-1);
  3904. }
  3905. #if defined MAKEARCHIVE
  3906. if (DebugLevel[CurFile])
  3907. PRINT0("\nInserting face neighbor data\n");
  3908. #endif
  3909. if (FaceConnections == NULL)
  3910. {
  3911. #if defined MAKEARCHIVE
  3912. PRINT0("Err: (TECFACE112) Invalid array\n");
  3913. #endif
  3914. NumErrs[CurFile]++;
  3915. return (-1);
  3916. }
  3917. /*
  3918. * Face neighbor connection have the following format for both
  3919. * binary:
  3920. *
  3921. * LOCALONETOONE 3 cz,fz,cz
  3922. * LOCALONETOMANY nz+4 cz,fz,oz,nz,cz1,cz2,...,czn
  3923. * GLOBALONETOONE 4 cz,fz,ZZ,CZ
  3924. * GLOBALONETOMANY 2*nz+4 cz,fz,oz,nz,ZZ1,CZ1,ZZ2,CZ2,...,ZZn,CZn
  3925. *
  3926. * Where:
  3927. * cz = cell in current zone
  3928. * fz = face of cell in current zone
  3929. * oz = face obsuration flag (only applies to one-to-many):
  3930. * 0 = face partially obscured
  3931. * 1 = face entirely obscured
  3932. * nz = number of cell or zone/cell associations (only applies to one-to-many)
  3933. * ZZ = remote Zone
  3934. * CZ = cell in remote zone
  3935. *
  3936. * NOTE:
  3937. * As of version 103 Tecplot assumes that face neighbors are zero based
  3938. * instead of ones based. Since we have to maintain the contract we
  3939. * subtract 1 for the caller.
  3940. */
  3941. Ptr = FaceConnections;
  3942. i = 0;
  3943. while (i < NumFaceConnections[CurFile][CurZone[CurFile]])
  3944. {
  3945. INTEGER4 n;
  3946. INTEGER4 NumNum = 0;
  3947. switch (FaceNeighborMode[CurFile])
  3948. {
  3949. case FaceNeighborMode_LocalOneToOne:
  3950. NumNum = 3;
  3951. i++;
  3952. break;
  3953. case FaceNeighborMode_LocalOneToMany:
  3954. NumNum = 4 + Ptr[3];
  3955. i += Ptr[3];
  3956. break;
  3957. case FaceNeighborMode_GlobalOneToOne:
  3958. NumNum = 4;
  3959. i++;
  3960. break;
  3961. case FaceNeighborMode_GlobalOneToMany:
  3962. NumNum = 4 + 2 * Ptr[3];
  3963. i += Ptr[3];
  3964. break;
  3965. default:
  3966. CHECK(FALSE);
  3967. break;
  3968. }
  3969. n = 0;
  3970. if (FaceNeighborMode[CurFile] == FaceNeighborMode_LocalOneToMany ||
  3971. FaceNeighborMode[CurFile] == FaceNeighborMode_GlobalOneToMany)
  3972. {
  3973. /*
  3974. * Write cz,fz,oz,nz: we do this by hand because the oz and nz values
  3975. * are not zero based values.
  3976. */
  3977. if (!WriteBinaryInt32(BlckFile[CurFile], Ptr[n++] - 1) || /* zero based as of version 103 */
  3978. !WriteBinaryInt32(BlckFile[CurFile], Ptr[n++] - 1) || /* zero based as of version 103 */
  3979. !WriteBinaryInt32(BlckFile[CurFile], Ptr[n++]) || /* ones based */
  3980. !WriteBinaryInt32(BlckFile[CurFile], Ptr[n++])) /* ones based */
  3981. {
  3982. #if defined MAKEARCHIVE
  3983. if (DebugLevel[CurFile])
  3984. printf("Err: (TECFACE112) Write failure for file %d\n", CurFile + 1);
  3985. #endif
  3986. NumErrs[CurFile]++;
  3987. return (-1);
  3988. }
  3989. }
  3990. /* starting from where we left off, output the remaining values */
  3991. for (; n < NumNum; n++)
  3992. if (!WriteBinaryInt32(BlckFile[CurFile], Ptr[n] - 1)) /* zero based as of version 103 */
  3993. {
  3994. #if defined MAKEARCHIVE
  3995. if (DebugLevel[CurFile])
  3996. printf("Err: (TECFACE112) Write failure for file %d\n", CurFile + 1);
  3997. #endif
  3998. NumErrs[CurFile]++;
  3999. return (-1);
  4000. }
  4001. Ptr += NumNum;
  4002. }
  4003. return (0);
  4004. }
  4005. LIBFUNCTION INTEGER4 LIBCALL TECFACE111(INTEGER4 *FaceConnections)
  4006. {
  4007. return TECFACE112(FaceConnections);
  4008. }
  4009. LIBFUNCTION INTEGER4 LIBCALL TECFACE110(INTEGER4 *FaceConnections)
  4010. {
  4011. return TECFACE112(FaceConnections);
  4012. }
  4013. LIBFUNCTION INTEGER4 LIBCALL TECFACE100(INTEGER4 *FaceConnections)
  4014. {
  4015. return TECFACE112(FaceConnections);
  4016. }
  4017. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  4018. LIBFUNCTION INTEGER4 LIBCALL tecface112_(INTEGER4 *FaceConnections)
  4019. {
  4020. return TECFACE112(FaceConnections);
  4021. }
  4022. LIBFUNCTION INTEGER4 LIBCALL tecface111_(INTEGER4 *FaceConnections)
  4023. {
  4024. return TECFACE112(FaceConnections);
  4025. }
  4026. LIBFUNCTION INTEGER4 LIBCALL tecface110_(INTEGER4 *FaceConnections)
  4027. {
  4028. return TECFACE112(FaceConnections);
  4029. }
  4030. LIBFUNCTION INTEGER4 LIBCALL tecface100_(INTEGER4 *FaceConnections)
  4031. {
  4032. return TECFACE112(FaceConnections);
  4033. }
  4034. #endif
  4035. /**
  4036. * TECPOLYXXX
  4037. */
  4038. LIBFUNCTION INTEGER4 LIBCALL TECPOLY112(INTEGER4 *FaceNodeCounts,
  4039. INTEGER4 *FaceNodes,
  4040. INTEGER4 *FaceLeftElems,
  4041. INTEGER4 *FaceRightElems,
  4042. INTEGER4 *FaceBndryConnectionCounts,
  4043. INTEGER4 *FaceBndryConnectionElems,
  4044. INTEGER4 *FaceBndryConnectionZones)
  4045. {
  4046. INTEGER4 NumFaces = KMax[CurFile];
  4047. INTEGER4 Result = 0;
  4048. LgIndex_t Index;
  4049. LgIndex_t MinNeighborValue = TECIO_NO_NEIGHBORING_ELEM;
  4050. /* Mark that the face map has been written for the zone even if it fails so as not to add extra error messages. */
  4051. FaceNeighborsOrMapWritten[CurFile][CurZone[CurFile]] = TRUE;
  4052. if (NumFaces == 0 ||
  4053. (ZoneType[CurFile] != FEPOLYGON &&
  4054. ZoneType[CurFile] != FEPOLYHEDRON))
  4055. {
  4056. #if defined MAKEARCHIVE
  4057. PRINT0("Err: (TECPOLY112) The zone type must be FEPOLYGON or FEPOLYHEDRON and have NumFaces (KMax) > 0.\n");
  4058. PRINT1(" NumFaces = %d\n", NumFaces);
  4059. #endif
  4060. NumErrs[CurFile]++;
  4061. return (-1);
  4062. }
  4063. if (ZoneType[CurFile] == FEPOLYHEDRON) /* FEPOLYGON doesn't need TotalNumFaceNodes since this is 2*NumFaces */
  4064. {
  4065. if (TotalNumFaceNodes[CurFile][CurZone[CurFile]] <= 0)
  4066. {
  4067. #if defined MAKEARCHIVE
  4068. PRINT0("Err: (TECPOLY112) TotalNumFaceNodes MUST be specified for polyhedral zones.\n");
  4069. PRINT1(" TotalNumFaceNodes = %d\n", TotalNumFaceNodes[CurFile][CurZone[CurFile]]);
  4070. #endif
  4071. NumErrs[CurFile]++;
  4072. return (-1);
  4073. }
  4074. }
  4075. else
  4076. {
  4077. if (TotalNumFaceNodes[CurFile][CurZone[CurFile]] != (2 * NumFaces))
  4078. {
  4079. #if defined MAKEARCHIVE
  4080. PRINT0("Err: (TECPOLY112) TotalNumFaceNodes is specified for the polygonal zone but is not equal to 2 * NumFaces.\n");
  4081. PRINT2(" TotalNumFaceNodes = %d. If specified, it must be 2 * %d.", TotalNumFaceNodes[CurFile][CurZone[CurFile]], NumFaces);
  4082. #endif
  4083. NumErrs[CurFile]++;
  4084. return (-1);
  4085. }
  4086. }
  4087. if ((TotalNumFaceBndryFaces[CurFile] > 0 &&
  4088. TotalNumFaceBndryConns[CurFile] > 0) ||
  4089. (TotalNumFaceBndryFaces[CurFile] == 0 &&
  4090. TotalNumFaceBndryConns[CurFile] == 0))
  4091. {
  4092. if (TotalNumFaceBndryFaces[CurFile] > 0)
  4093. MinNeighborValue = -TotalNumFaceBndryFaces[CurFile];
  4094. }
  4095. else
  4096. {
  4097. #if defined MAKEARCHIVE
  4098. PRINT0("Err: (TECPOLY112) TotalNumFaceBndryFaces and TotalNumFaceBndryConns must both be 0 or both be > 0.\n");
  4099. PRINT2(" TotalNumFaceBndryFaces = %d, TotalNumFaceBndryConns = %d\n", TotalNumFaceBndryFaces[CurFile], TotalNumFaceBndryConns[CurFile]);
  4100. #endif
  4101. NumErrs[CurFile]++;
  4102. return (-1);
  4103. }
  4104. /* Write the facenodesoffsets array from the facenodecounts array. */
  4105. if (Result == 0)
  4106. {
  4107. if (ZoneType[CurFile] == FEPOLYHEDRON) /* FEPOLYGON doesn't need to specify facenodesoffsets */
  4108. {
  4109. Int32_t FaceNodeSum = 0;
  4110. if (!WriteBinaryInt32(BlckFile[CurFile], 0))
  4111. Result = -1;
  4112. for (Index = 0; (Result == 0) && (Index < NumFaces); Index++)
  4113. {
  4114. FaceNodeSum += FaceNodeCounts[Index];
  4115. if (FaceNodeCounts[Index] < 3)
  4116. {
  4117. #if defined MAKEARCHIVE
  4118. PRINT1("Err: (TECPOLY112) Invalid face node count value at face %d. There must be at least 3 nodes in a face.\n", Index + 1);
  4119. PRINT1(" Face node count value = %d.\n", FaceNodeCounts[Index]);
  4120. #endif
  4121. NumErrs[CurFile]++;
  4122. return (-1);
  4123. }
  4124. else if (FaceNodeSum > TotalNumFaceNodes[CurFile][CurZone[CurFile]])
  4125. {
  4126. #if defined MAKEARCHIVE
  4127. PRINT1("Err: (TECPOLY112) The running face node count exceeds the TotalNumFaceNodes (%d) specified.\n", TotalNumFaceNodes[CurFile][CurZone[CurFile]]);
  4128. PRINT1(" Face node count value = %d.\n", FaceNodeCounts[Index]);
  4129. #endif
  4130. NumErrs[CurFile]++;
  4131. return (-1);
  4132. }
  4133. else if (!WriteBinaryInt32(BlckFile[CurFile], FaceNodeSum))
  4134. Result = -1;
  4135. }
  4136. }
  4137. }
  4138. /* Write the facenodes array but convert 1-based to 0-based. */
  4139. for (Index = 0; (Result == 0) && (Index < TotalNumFaceNodes[CurFile][CurZone[CurFile]]); Index++)
  4140. {
  4141. if (FaceNodes[Index] < 1 ||
  4142. FaceNodes[Index] > IMax[CurFile])
  4143. {
  4144. #if defined MAKEARCHIVE
  4145. PRINT1("Err: (TECPOLY112) Invalid face node value at node %d:\n", Index + 1);
  4146. PRINT2(" face node value = %d, valid values are are 1 to %d (inclusive).\n", FaceNodes[Index], IMax[CurFile]);
  4147. #endif
  4148. NumErrs[CurFile]++;
  4149. return (-1);
  4150. }
  4151. else if (!WriteBinaryInt32(BlckFile[CurFile], FaceNodes[Index] - 1))
  4152. Result = -1;
  4153. }
  4154. /* Write the left elements array but convert 1-based to 0-based. */
  4155. for (Index = 0; (Result == 0) && (Index < NumFaces); Index++)
  4156. {
  4157. if (FaceLeftElems[Index] < MinNeighborValue ||
  4158. FaceLeftElems[Index] > JMax[CurFile])
  4159. {
  4160. #if defined MAKEARCHIVE
  4161. PRINT1("Err: (TECPOLY112) Invalid left neighbor value at face %d:\n", Index);
  4162. PRINT2(" left neighbor value = %d, min value = %d,", FaceLeftElems[Index], MinNeighborValue);
  4163. PRINT1(" max value = %d.\n", JMax[CurFile]);
  4164. #endif
  4165. NumErrs[CurFile]++;
  4166. return (-1);
  4167. }
  4168. else if (!WriteBinaryInt32(BlckFile[CurFile], FaceLeftElems[Index] - 1))
  4169. Result = -1;
  4170. }
  4171. /* Write the right elements array but convert 1-based to 0-based. */
  4172. for (Index = 0; (Result == 0) && (Index < NumFaces); Index++)
  4173. {
  4174. if (FaceRightElems[Index] < MinNeighborValue ||
  4175. FaceRightElems[Index] > JMax[CurFile])
  4176. {
  4177. #if defined MAKEARCHIVE
  4178. PRINT1("Err: (TECPOLY112) Invalid right neighbor value at face %d:\n", Index);
  4179. PRINT2(" right neighbor value = %d, min value = %d,", FaceRightElems[Index], MinNeighborValue);
  4180. PRINT1(" max value = %d.\n", JMax[CurFile]);
  4181. #endif
  4182. NumErrs[CurFile]++;
  4183. return (-1);
  4184. }
  4185. else if (!WriteBinaryInt32(BlckFile[CurFile], FaceRightElems[Index] - 1))
  4186. Result = -1;
  4187. if (Result == 0 &&
  4188. (FaceLeftElems[Index] == TECIO_NO_NEIGHBORING_ELEM &&
  4189. FaceRightElems[Index] == TECIO_NO_NEIGHBORING_ELEM))
  4190. {
  4191. #if defined MAKEARCHIVE
  4192. PRINT1("Err: (TECPOLY112) Both left and right neighbors are set to no neighboring element at face %d.\n", Index);
  4193. #endif
  4194. NumErrs[CurFile]++;
  4195. return (-1);
  4196. }
  4197. }
  4198. /* Write the boundary arrays. */
  4199. if (Result == 0 && TotalNumFaceBndryFaces[CurFile] > 0)
  4200. {
  4201. /* Write the boundaryconnectionoffsets array from the boundaryconnectioncounts array. */
  4202. /*
  4203. * As a convenience for the ASCII format, TecUtil, and TECIO layers if any
  4204. * boundary connections exists we automatically add a no-neighboring
  4205. * connection as the first item so that they can user 0 for no-neighboring
  4206. * element in the element list regardless if they have boundary connections
  4207. * or not.
  4208. *
  4209. * The first 2 offsets are always 0 so that -1 in the left/right element
  4210. * arrays always indicates "no neighboring element".
  4211. */
  4212. if (!(WriteBinaryInt32(BlckFile[CurFile], 0) &&
  4213. WriteBinaryInt32(BlckFile[CurFile], 0)))
  4214. Result = -1;
  4215. Int32_t BndryConnCount = 0;
  4216. for (Index = 0; (Result == 0) && (Index < TotalNumFaceBndryFaces[CurFile]); Index++)
  4217. {
  4218. BndryConnCount += FaceBndryConnectionCounts[Index];
  4219. if (FaceBndryConnectionCounts[Index] < 0 ||
  4220. BndryConnCount > TotalNumFaceBndryConns[CurFile])
  4221. {
  4222. #if defined MAKEARCHIVE
  4223. PRINT1("Err: (TECPOLY112) Invalid boundary connection count at boundary face %d:\n", Index + 1);
  4224. PRINT1(" boundary connection count = %d.\n", FaceBndryConnectionCounts[Index]);
  4225. #endif
  4226. NumErrs[CurFile]++;
  4227. return (-1);
  4228. }
  4229. else if (!WriteBinaryInt32(BlckFile[CurFile], BndryConnCount))
  4230. Result = -1;
  4231. }
  4232. if (BndryConnCount != TotalNumFaceBndryConns[CurFile])
  4233. {
  4234. #if defined MAKEARCHIVE
  4235. PRINT0("Err: (TECPOLY112) Invalid number of boundary connections:\n");
  4236. PRINT2(" number of boundary connections written = %d, total number of boundary connections = %d.",
  4237. BndryConnCount, TotalNumFaceBndryConns[CurFile]);
  4238. #endif
  4239. NumErrs[CurFile]++;
  4240. return (-1);
  4241. }
  4242. /* Write the boundary connection elements but convert 1-based to 0-based. */
  4243. BndryConnCount = 0;
  4244. for (Index = 0; (Result == 0) && (Index < TotalNumFaceBndryFaces[CurFile]); Index++)
  4245. {
  4246. for (LgIndex_t BIndex = 0; (Result == 0) && (BIndex < FaceBndryConnectionCounts[Index]); BIndex++)
  4247. {
  4248. if (BIndex > 0 &&
  4249. FaceBndryConnectionElems[BndryConnCount] == TECIO_NO_NEIGHBORING_ELEM)
  4250. {
  4251. #if defined MAKEARCHIVE
  4252. PRINT1("Err: (TECPOLY112) Partially obscured faces must specify no neighboring element first. See boundary connections for face %d.\n", Index + 1);
  4253. #endif
  4254. NumErrs[CurFile]++;
  4255. return (-1);
  4256. }
  4257. if (FaceBndryConnectionElems[BndryConnCount] < TECIO_NO_NEIGHBORING_ELEM)
  4258. {
  4259. #if defined MAKEARCHIVE
  4260. PRINT1("Err: (TECPOLY112) Invalid boundary element value at boundary connections for face %d:\n", Index + 1);
  4261. #endif
  4262. NumErrs[CurFile]++;
  4263. return (-1);
  4264. }
  4265. if (FaceBndryConnectionElems[BndryConnCount] == TECIO_NO_NEIGHBORING_ELEM &&
  4266. FaceBndryConnectionZones[BndryConnCount] != TECIO_NO_NEIGHBORING_ZONE)
  4267. {
  4268. #if defined MAKEARCHIVE
  4269. PRINT1("Err: (TECPOLY112) Invalid boundary element/zone pair at boundary connections for face %d:\n", Index + 1);
  4270. PRINT0(" Boundary elements specified as no neighboring element must also specify no neighboring zone.\n");
  4271. #endif
  4272. NumErrs[CurFile]++;
  4273. return (-1);
  4274. }
  4275. else if (!WriteBinaryInt32(BlckFile[CurFile], FaceBndryConnectionElems[BndryConnCount] - 1))
  4276. Result = -1;
  4277. BndryConnCount++;
  4278. }
  4279. }
  4280. /* Write the boundary connection zones but convert 1-based to 0-based. */
  4281. BndryConnCount = 0;
  4282. for (Index = 0; (Result == 0) && (Index < TotalNumFaceBndryFaces[CurFile]); Index++)
  4283. {
  4284. for (LgIndex_t BIndex = 0; (Result == 0) && (BIndex < FaceBndryConnectionCounts[Index]); BIndex++)
  4285. {
  4286. if (FaceBndryConnectionZones[BndryConnCount] < TECIO_NO_NEIGHBORING_ZONE)
  4287. {
  4288. #if defined MAKEARCHIVE
  4289. PRINT1("Err: (TECPOLY112) Invalid boundary zone value at boundary connections for face %d:\n", Index + 1);
  4290. #endif
  4291. NumErrs[CurFile]++;
  4292. return (-1);
  4293. }
  4294. else if (!WriteBinaryInt32(BlckFile[CurFile], FaceBndryConnectionZones[BndryConnCount] - 1))
  4295. Result = -1;
  4296. BndryConnCount++;
  4297. }
  4298. }
  4299. }
  4300. if (Result != 0)
  4301. {
  4302. Result = -1;
  4303. WriteErr("TECPOLY112");
  4304. }
  4305. return Result;
  4306. }
  4307. #if !defined INDEX_16_BIT // not supported in this test-only mode
  4308. LIBFUNCTION INTEGER4 LIBCALL TECPOLY111(INTEGER4 *FaceNodeCounts,
  4309. INTEGER4 *FaceNodes,
  4310. INTEGER4 *FaceLeftElems,
  4311. INTEGER4 *FaceRightElems,
  4312. INTEGER4 *FaceBndryConnectionCounts,
  4313. INTEGER4 *FaceBndryConnectionElems,
  4314. INTEGER2 *FaceBndryConnectionZones)
  4315. {
  4316. INTEGER4 Result = 0;
  4317. EntIndex_t *FBCZones = NULL;
  4318. if (TotalNumFaceBndryConns[CurFile] > 0)
  4319. {
  4320. ALLOC_ARRAY(TotalNumFaceBndryConns[CurFile], EntIndex_t, "32-bit FaceBndryConnectionZones");
  4321. if (FBCZones != NULL)
  4322. {
  4323. for (LgIndex_t ZoneI = 0; ZoneI < TotalNumFaceBndryFaces[CurFile]; ZoneI++)
  4324. FBCZones[ZoneI] = (EntIndex_t)FaceBndryConnectionZones[ZoneI];
  4325. }
  4326. else
  4327. {
  4328. #if defined MAKEARCHIVE
  4329. PRINT0("Err: (TECPOLY111) Out of memory allocating temporary data.\n");
  4330. #endif
  4331. NumErrs[CurFile]++;
  4332. return (-1);
  4333. }
  4334. }
  4335. Result = TECPOLY112(FaceNodeCounts,
  4336. FaceNodes,
  4337. FaceLeftElems,
  4338. FaceRightElems,
  4339. FaceBndryConnectionCounts,
  4340. FaceBndryConnectionElems,
  4341. FBCZones);
  4342. if (FBCZones != NULL)
  4343. FREE_ARRAY(FBCZones, "32-bit FaceBndryConnectionZones");
  4344. return Result;
  4345. }
  4346. #endif // INDEX_16_BIT -- not supported in this test-only mode
  4347. #if defined MAKEARCHIVE && !defined _WIN32 /* every platform but Windows Intel */
  4348. LIBFUNCTION INTEGER4 LIBCALL tecpoly112_(INTEGER4 *FaceNodeCounts,
  4349. INTEGER4 *FaceNodes,
  4350. INTEGER4 *FaceLeftElems,
  4351. INTEGER4 *FaceRightElems,
  4352. INTEGER4 *FaceBndryConnectionOffsets,
  4353. INTEGER4 *FaceBndryConnectionElems,
  4354. INTEGER4 *FaceBndryConnectionZones)
  4355. {
  4356. return TECPOLY112(FaceNodeCounts,
  4357. FaceNodes,
  4358. FaceLeftElems,
  4359. FaceRightElems,
  4360. FaceBndryConnectionOffsets,
  4361. FaceBndryConnectionElems,
  4362. FaceBndryConnectionZones);
  4363. }
  4364. LIBFUNCTION INTEGER4 LIBCALL tecpoly111_(INTEGER4 *FaceNodeCounts,
  4365. INTEGER4 *FaceNodes,
  4366. INTEGER4 *FaceLeftElems,
  4367. INTEGER4 *FaceRightElems,
  4368. INTEGER4 *FaceBndryConnectionOffsets,
  4369. INTEGER4 *FaceBndryConnectionElems,
  4370. INTEGER2 *FaceBndryConnectionZones)
  4371. {
  4372. return TECPOLY111(FaceNodeCounts,
  4373. FaceNodes,
  4374. FaceLeftElems,
  4375. FaceRightElems,
  4376. FaceBndryConnectionOffsets,
  4377. FaceBndryConnectionElems,
  4378. FaceBndryConnectionZones);
  4379. }
  4380. #endif
  4381. #if defined TECPLOTKERNEL
  4382. /* CORE SOURCE CODE REMOVED */
  4383. #endif