FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
CFSTRDB_Film.cpp
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright (c) 2019 FrontISTR Commons
3 * This software is released under the MIT License, see LICENSE.txt
4 *****************************************************************************/
5/*
6 CFSTRDB_Film Ver.1.0
7*/
8
9#include "CFSTRDB.h"
10#include "CHECData.h"
11
12using namespace std;
13using namespace hecd_util;
14
15// static method
16
17const char *CFSTRDB_Film::LoadTypeName(int type) {
18 const char *pn[] = {"F0", "F1", "F2", "F3", "F4", "F5", "F6", "unknown"};
19
20 if (type < 0 || type >= TypeNumber()) return "";
21
22 return pn[type];
23}
24
26 amp1[0] = 0;
27 amp2[0] = 0;
28}
29
31
33 ItemList.clear();
34 amp1[0] = 0;
35 amp2[0] = 0;
36}
37
39 char buff[256];
40
41 if (ItemList.size() == 0) return;
42
43 strcpy(buff, "!FILM");
44
45 if (amp1[0] != 0) {
46 strcat(buff, ",AMP1=");
47 strcat(buff, amp1);
48 }
49
50 if (amp2[0] != 0) {
51 strcat(buff, ",AMP2=");
52 strcat(buff, amp2);
53 }
54
55 hecd->WriteHeader(buff);
56 vector<CItem>::iterator iter;
57
58 for (iter = ItemList.begin(); iter != ItemList.end(); iter++) {
59 hecd->WriteData("SSFF", iter->egrp, LoadTypeName(iter->type), iter->value,
60 iter->sink);
61 }
62}
63
64bool CFSTRDB_Film::Read(CHECData *hecd, char *header_line) {
65 int rcode[10];
66 char s[256];
67 int type;
68 amp1[0] = 0;
69 amp2[0] = 0;
70
71 if (!hecd->ParseHeader(header_line, rcode, "SS", "AMP1", amp1, "AMP2", amp2))
72 return false;
73
74 while (1) {
75 CItem item;
76 bool fg =
77 hecd->ReadData(rcode, "SSFF", item.egrp, s, &item.value, &item.sink);
78
79 if (!fg) break;
80
82 toupper(s);
83
84 for (type = 0; type < TypeNumber(); type++) {
85 if (strcmp(LoadTypeName(type), s) == 0) break;
86 }
87
88 if (type == TypeNumber()) return false;
89
90 item.type = type;
91 ItemList.push_back(item);
92 }
93
94 return true;
95}
@ FSTRDB_FILM
Definition: CFSTRDB.h:49
char egrp[hec_name_size]
Definition: CFSTRDB.h:498
static const char * LoadTypeName(int type)
virtual bool Read(class CHECData *hecd, char *header_line)
virtual void Clear()
virtual ~CFSTRDB_Film()
virtual void Write(class CHECData *hecd)
static int TypeNumber()
Definition: CFSTRDB.h:493
char amp1[hec_name_size]
Definition: CFSTRDB.h:515
std::vector< CItem > ItemList
Definition: CFSTRDB.h:520
char amp2[hec_name_size]
Definition: CFSTRDB.h:516
virtual bool ReadData(int *rcode, const char *fmt,...)
Definition: CHECData.cpp:548
virtual bool ParseHeader(char *header_line, int *rcode, const char *fmt,...)
Definition: CHECData.cpp:506
virtual void WriteData(const char *fmt,...)
Definition: CHECData.cpp:162
virtual void WriteHeader(const char *name, const char *fmt="",...)
Definition: CHECData.cpp:68
void toupper(char *s)
Definition: hecd_util.cpp:37
void cleanup_token(char *s)
Definition: hecd_util.cpp:13