FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
CFSTRDB_Radiate.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_Radiate 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_Radiate::LoadTypeName(int type) {
18 const char *pn[] = {"R0", "R1", "R2", "R3", "R4", "R5", "R6", "unknown"};
19
20 if (type < 0 || type >= TypeNumber()) return "";
21
22 return pn[type];
23}
24
26 : CFSTRDataBlock(FSTRDB_RADIATE), ItemList() {
27 amp1[0] = 0;
28 amp2[0] = 0;
29}
30
32
34 ItemList.clear();
35 amp1[0] = 0;
36 amp2[0] = 0;
37}
38
40 char buff[256];
41
42 if (ItemList.size() == 0) return;
43
44 strcpy(buff, "!RADIATE");
45
46 if (amp1[0] != 0) {
47 strcat(buff, ",AMP1=");
48 strcat(buff, amp1);
49 }
50
51 if (amp2[0] != 0) {
52 strcat(buff, ",AMP2=");
53 strcat(buff, amp2);
54 }
55
56 hecd->WriteHeader(buff);
57 vector<CItem>::iterator iter;
58
59 for (iter = ItemList.begin(); iter != ItemList.end(); iter++) {
60 hecd->WriteData("SSFF", iter->egrp, LoadTypeName(iter->type), iter->value,
61 iter->sink);
62 }
63}
64
65bool CFSTRDB_Radiate::Read(CHECData *hecd, char *header_line) {
66 int rcode[10];
67 char s[256];
68 int type;
69 amp1[0] = 0;
70 amp2[0] = 0;
71
72 if (!hecd->ParseHeader(header_line, rcode, "SS", "AMP1", amp1, "AMP2", amp2))
73 return false;
74
75 while (1) {
76 CItem item;
77 bool fg =
78 hecd->ReadData(rcode, "SSFF", item.egrp, s, &item.value, &item.sink);
79
80 if (!fg) break;
81
83 toupper(s);
84
85 for (type = 0; type < TypeNumber(); type++) {
86 if (strcmp(LoadTypeName(type), s) == 0) break;
87 }
88
89 if (type == TypeNumber()) return false;
90
91 item.type = type;
92 ItemList.push_back(item);
93 }
94
95 return true;
96}
@ FSTRDB_RADIATE
Definition: CFSTRDB.h:51
char egrp[hec_name_size]
Definition: CFSTRDB.h:579
char amp2[hec_name_size]
Definition: CFSTRDB.h:597
std::vector< CItem > ItemList
Definition: CFSTRDB.h:601
virtual bool Read(class CHECData *hecd, char *header_line)
static const char * LoadTypeName(int type)
virtual void Write(class CHECData *hecd)
virtual void Clear()
static int TypeNumber()
Definition: CFSTRDB.h:574
char amp1[hec_name_size]
Definition: CFSTRDB.h:596
virtual ~CFSTRDB_Radiate()
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