FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
CNFDB_601.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  CNFDB_601 Ver.1.0
7  -----------------------------
8  601 Material
9 */
10 
11 #include <vector>
12 #include "CNFData.h"
13 #include "CNFDB_601.h"
14 
15 using namespace std;
16 
17 // 601 Material
18 
20 
22  int i;
23  char buff[256];
24  // #1
25  nfd->ReadLineEx(buff);
26  nfd->ReadRecord(buff, "IIIIIII", &ID, &format, &color, &type, &subtype,
27  &layer, &FunctionCount);
28  // #2
29  nfd->ReadLineEx(buff);
30  nfd->ReadStr(buff, title, sizeof(title));
31  // #3
32  nfd->ReadLineEx(buff);
33  nfd->ReadRecord(buff, "I", &Bcount);
34  // #4
35  nfd->ReadLineEx(buff);
36  nfd->ReadRecord(buff, "IIIIIIIIII", &bval[0], &bval[1], &bval[2], &bval[3],
37  &bval[4], &bval[5], &bval[6], &bval[7], &bval[8], &bval[9]);
38  // #5
39  nfd->ReadLineEx(buff);
40  nfd->ReadRecord(buff, "I", &Icount);
41  // #6
42  nfd->ReadLineEx(buff);
43  nfd->ReadRecord(buff, "IIIIIIIIII", &ival[0], &ival[1], &ival[2], &ival[3],
44  &ival[4], &ival[5], &ival[6], &ival[7], &ival[8], &ival[9]);
45  // #7
46  nfd->ReadLineEx(buff);
47  nfd->ReadRecord(buff, "IIIIIIIIII", &ival[10], &ival[11], &ival[12],
48  &ival[13], &ival[14], &ival[15], &ival[16], &ival[17],
49  &ival[18], &ival[19]);
50  // #8
51  nfd->ReadLineEx(buff);
52  nfd->ReadRecord(buff, "IIIII", &ival[20], &ival[21], &ival[22], &ival[23],
53  &ival[24]);
54  // #9
55  nfd->ReadLineEx(buff);
56  nfd->ReadRecord(buff, "I", &Mcount);
57 
58  // #10-29
59  for (i = 0; i < 20; i++) {
60  int j = i * 10;
61  nfd->ReadLineEx(buff);
62  nfd->ReadRecord(buff, "FFFFFFFFFF", &mval[j], &mval[j + 1], &mval[j + 2],
63  &mval[j + 3], &mval[j + 4], &mval[j + 5], &mval[j + 6],
64  &mval[j + 7], &mval[j + 8], &mval[j + 9]);
65  }
66 
67  // #30
68  nfd->ReadLineEx(buff);
69  nfd->ReadRecord(buff, "I", &Fcount);
70 
71  // #31-35
72  for (i = 0; i < 5; i++) {
73  int j = i * 10;
74  nfd->ReadLineEx(buff);
75  nfd->ReadRecord(buff, "IIIIIIIIII", &fval[j], &fval[j + 1], &fval[j + 2],
76  &fval[j + 3], &fval[j + 4], &fval[j + 5], &fval[j + 6],
77  &fval[j + 7], &fval[j + 8], &fval[j + 9]);
78  }
79 
80  // #36
81  nfd->ReadLineEx(buff);
82  nfd->ReadRecord(buff, "I", &Tcount);
83  // #37-43
84  int rec_n = Tcount / 10;
85 
86  for (i = 0; i < rec_n; i++) {
87  int j = i * 10;
88  nfd->ReadLineEx(buff);
89  nfd->ReadRecord(buff, "IIIIIIIIII", &tval[j], &tval[j + 1], &tval[j + 2],
90  &tval[j + 3], &tval[j + 4], &tval[j + 5], &tval[j + 6],
91  &tval[j + 7], &tval[j + 8], &tval[j + 9]);
92  }
93 
94  // # ---------------------
95  for (i = 0; i < FunctionCount; i++) {
96  cfunc_rec rec;
97  // ##1
98  nfd->ReadLineEx(buff);
99  nfd->ReadRecord(buff, "II", &rec.ID, &rec.type);
100  // ##2
101  nfd->ReadLineEx(buff);
102  nfd->ReadStr(buff, rec.title, sizeof(rec.title));
103 
104  // ## -------------------
105  while (1) {
106  nf_int index;
107  nf_float x, y;
108  nfd->ReadLineEx(buff);
109  nfd->ReadRecord(buff, "IFF", &index, &x, &y);
110 
111  if (index == -1) break;
112 
113  cfunc_rec::cdata_pair data(index, x, y);
114  rec.data.push_back(data);
115  }
116 
117  func_list.push_back(rec);
118  }
119 }
120 
121 void CNFDB_601::WriteData(CNFData *nfd, FILE *fp) {
122  int i;
123  // #1
124  nfd->WriteData(fp, "IIIIIIIn", ID, format, color, type, subtype, layer,
125  FunctionCount);
126  // #2
127  nfd->WriteStr(fp, title);
128  // #3
129  nfd->WriteData(fp, "In", Bcount);
130  // #4
131  nfd->WriteData(fp, "IIIIIIIIIIn", bval[0], bval[1], bval[2], bval[3], bval[4],
132  bval[5], bval[6], bval[7], bval[8], bval[9]);
133  // #5
134  nfd->WriteData(fp, "In", Icount);
135  // #6
136  nfd->WriteData(fp, "IIIIIIIIIIn", ival[0], ival[1], ival[2], ival[3], ival[4],
137  ival[5], ival[6], ival[7], ival[8], ival[9]);
138  // #7
139  nfd->WriteData(fp, "IIIIIIIIIIn", ival[10], ival[11], ival[12], ival[13],
140  ival[14], ival[15], ival[16], ival[17], ival[18], ival[19]);
141  // #8
142  nfd->WriteData(fp, "IIIIIn", ival[20], ival[21], ival[22], ival[23],
143  ival[24]);
144  // #9
145  nfd->WriteData(fp, "In", Mcount);
146 
147  // #10-29
148  for (i = 0; i < 20; i++) {
149  int j = i * 10;
150  nfd->WriteData(fp, "FFFFFFFFFFn", mval[j], mval[j + 1], mval[j + 2],
151  mval[j + 3], mval[j + 4], mval[j + 5], mval[j + 6],
152  mval[j + 7], mval[j + 8], mval[j + 9]);
153  }
154 
155  // #30
156  nfd->WriteData(fp, "In", Fcount);
157 
158  // #31-35
159  for (i = 0; i < 5; i++) {
160  int j = i * 10;
161  nfd->WriteData(fp, "IIIIIIIIIIn", fval[j], fval[j + 1], fval[j + 2],
162  fval[j + 3], fval[j + 4], fval[j + 5], fval[j + 6],
163  fval[j + 7], fval[j + 8], fval[j + 9]);
164  }
165 
166  // #36
167  nfd->WriteData(fp, "In", Tcount);
168  // #37-43
169  int rec_n = Tcount / 10;
170 
171  for (i = 0; i < rec_n; i++) {
172  int j = i * 10;
173  nfd->WriteData(fp, "IIIIIIIIIIn", tval[j], tval[j + 1], tval[j + 2],
174  tval[j + 3], tval[j + 4], tval[j + 5], tval[j + 6],
175  tval[j + 7], tval[j + 8], tval[j + 9]);
176  }
177 
178  // # ---------------------
179  vector<cfunc_rec>::iterator iter;
180 
181  for (iter = func_list.begin(); iter != func_list.end(); iter++) {
182  // ##1
183  nfd->WriteData(fp, "IIn", iter->ID, iter->type);
184  // ##2
185  nfd->WriteStr(fp, iter->title);
186  // ## -------------------
187  vector<cfunc_rec::cdata_pair>::iterator id;
188 
189  for (id = iter->data.begin(); id != iter->data.end(); id++) {
190  nfd->WriteData(fp, "IFFn", id->index, id->x, id->y);
191  }
192 
193  nfd->WriteData(fp, "IFFn", -1, 0.0, 0.0);
194  }
195 }
CNFData::ReadRecord
void ReadRecord(char *buff, const char *fmt,...)
Definition: CNFData.cpp:308
CNFDB_601::WriteData
virtual void WriteData(class CNFData *nfd, FILE *fp)
Definition: CNFDB_601.cpp:121
CNFDB_601::layer
nf_int layer
Definition: CNFDB_601.h:54
CNFDB_601::func_list
std::vector< cfunc_rec > func_list
Definition: CNFDB_601.h:79
CNFDB_601::Fcount
nf_int Fcount
Definition: CNFDB_601.h:71
CNFDataBlock
Definition: CNFDataBlock.h:24
CNFDB_601::cfunc_rec::cdata_pair
Definition: CNFDB_601.h:31
CNFData::WriteStr
void WriteStr(FILE *fp, const char *s)
Definition: CNFData.cpp:452
CNFDB_601::type
nf_int type
Definition: CNFDB_601.h:52
CNFDB_601::cfunc_rec
Definition: CNFDB_601.h:29
CNFData.h
CNFDB_601::CNFDB_601
CNFDB_601()
Definition: CNFDB_601.cpp:19
CNFDB_601::tval
nf_int tval[70]
Definition: CNFDB_601.h:77
CNFDB_601::color
nf_int color
Definition: CNFDB_601.h:51
CNFDB_601::format
nf_int format
Definition: CNFDB_601.h:50
CNFDB_601::bval
nf_bool bval[10]
Definition: CNFDB_601.h:61
CNFDB_601::cfunc_rec::ID
nf_int ID
Definition: CNFDB_601.h:40
CNFDB_601::mval
nf_float mval[200]
Definition: CNFDB_601.h:69
CNFDB_601::Read
virtual void Read(class CNFData *nfd)
Definition: CNFDB_601.cpp:21
CNFData::ReadLineEx
void ReadLineEx(char *buff, int size=255)
Definition: CNFData.cpp:367
CNFData
Definition: CNFData.h:46
CNFData::WriteData
void WriteData(FILE *fp, const char *fmt,...)
Definition: CNFData.cpp:486
CNFDB_601::ID
nf_int ID
Definition: CNFDB_601.h:49
data
CNFData data
Definition: neu_reporter.cpp:18
CNFData::ReadStr
void ReadStr(char *buff, char *s, int size)
Definition: CNFData.cpp:373
CNFDB_601::cfunc_rec::data
std::vector< cdata_pair > data
Definition: CNFDB_601.h:45
CNFDB_601::ival
nf_int ival[25]
Definition: CNFDB_601.h:65
CNFDB_601::FunctionCount
nf_int FunctionCount
Definition: CNFDB_601.h:55
CNFDB_601::fval
nf_int fval[50]
Definition: CNFDB_601.h:73
CNFDB_601::subtype
nf_int subtype
Definition: CNFDB_601.h:53
CNFDB_601::cfunc_rec::type
nf_int type
Definition: CNFDB_601.h:41
CNFDB_601::Icount
nf_int Icount
Definition: CNFDB_601.h:63
nf_int
int nf_int
Definition: CNFDataBlock.h:19
CNFDB_601::title
nf_char title[26]
Definition: CNFDB_601.h:57
CNFDB_601::Bcount
nf_int Bcount
Definition: CNFDB_601.h:59
CNFDB_601.h
CNFDB_601::cfunc_rec::title
nf_char title[80]
Definition: CNFDB_601.h:43
CNFDB_601::Mcount
nf_int Mcount
Definition: CNFDB_601.h:67
CNFDB_601::Tcount
nf_int Tcount
Definition: CNFDB_601.h:75
nf_float
double nf_float
Definition: CNFDataBlock.h:21