FrontISTR  5.7.1
Large-scale structural analysis program with finit element method
CHECDB_SGroup.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  CHECDB_SGroup Ver.1.0
7 */
8 
9 #include "CHECDB.h"
10 #include "CHECData.h"
11 
12 using namespace std;
13 using namespace hecd_util;
14 
16  name[0] = 0;
17 }
18 
20 
21 void CHECDB_SGroup::Clear() { ItemList.clear(); }
22 
24  if (ItemList.size() == 0) return;
25 
26  hecd->WriteHeader("!SGROUP", "S", "SGRP", name);
27  vector<CItem>::iterator iter;
28 
29  for (iter = ItemList.begin(); iter != ItemList.end(); iter++) {
30  hecd->WriteData("II", iter->elem, iter->surf);
31  }
32 }
33 
34 bool CHECDB_SGroup::Read(CHECData *hecd, char *header_line) {
35  int rcode[5];
36 
37  if (!hecd->ParseHeader(header_line, rcode, "S", "SGRP", name)) return false;
38 
39  char line[256];
40  const int max_id_n = 100;
41  int id[max_id_n];
42  int i, n, n2;
43 
44  while (1) {
45  if (!hecd->ReadLine(line)) break;
46 
47  if (line[0] == '!') {
48  hecd->PushReadLine(line);
49  break;
50  }
51 
52  n = hecd->ParseIntDataArray(line, id);
53 
54  if (n < 0) return false;
55 
56  n2 = n / 2;
57 
58  if (n2 % 2 != 0) return false;
59 
60  for (i = 0; i < n2; i++) {
61  ItemList.push_back(CItem(id[2 * i], id[2 * i + 1]));
62  }
63  }
64 
65  return true;
66 }
@ HECDB_SGROUP
Definition: CHECDB.h:25
virtual void Write(class CHECData *hecd)
virtual bool Read(class CHECData *hecd, char *header_line)
char name[hec_name_size]
Definition: CHECDB.h:230
std::vector< CItem > ItemList
Definition: CHECDB.h:237
virtual void Clear()
virtual ~CHECDB_SGroup()
virtual int ParseIntDataArray(char *line, int *data)
Definition: CHECData.cpp:617
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 bool ReadLine(char *s, int size=256)
Definition: CHECData.cpp:307
virtual void WriteHeader(const char *name, const char *fmt="",...)
Definition: CHECData.cpp:68
virtual void PushReadLine(const char *s)
Definition: CHECData.cpp:328