110 const std::string &filename
152 const std::string &mode
168if (mode.compare(
"in") == 0) {
169 if (!ifile_handle.is_open()) {
175 ifile_handle.open(
dgf_name, ifstream::in | ifstream::binary);
176 if (!ifile_handle.good()) {
err = 1; }
180else if (mode.compare(
"out") == 0) {
181 if (!ofile_handle.is_open()) {
187 ofile_handle.open(
dgf_name, ifstream::out);
188 if (!ofile_handle.good()) {
err = 1; }
192else if (mode.compare(
"app") == 0) {
193 if (!ofile_handle.is_open()) {
199 ofile_handle.open(
dgf_name, ifstream::out | ifstream::app);
200 if (!ofile_handle.good()) {
err = 1; }
215 const std::string &mode
231if (mode.compare(
"in") == 0) {
232 if (ifile_handle.is_open()) {
233 ifile_handle.close();
236else if (mode.compare(
"out") == 0) {
237 if (ofile_handle.is_open()) {
238 ofile_handle.close();
241else if (mode.compare(
"app") == 0) {
242 if (ofile_handle.is_open()) {
243 ofile_handle.close();
246else if (mode.compare(
"inout") == 0) {
247 if (ifile_handle.is_open()) {
248 ifile_handle.close();
250 if (ofile_handle.is_open()) {
251 ofile_handle.close();
338out <<
"dgf object:" << endl;
339out <<
" dgf name : '" <<
dgf_name <<
"'" << endl;
340out <<
" input stream status : ";
341if (ifile_handle.is_open()) { out <<
"open"; }
342else { out <<
"closed"; }
344out <<
" output stream status : ";
345if (ofile_handle.is_open()) { out <<
"open"; }
346else { out <<
"closed"; }
351 out <<
" **ERROR** dgf file is missing!!" << endl;
356 out <<
" # of vertices : " <<
data.
nV << endl;
359 out <<
" # of simplicies : " <<
data.
nS << endl;
362 out <<
" vertex dataset names : " <<
data.
sV_data << endl;
363 out <<
" # of vertex data : " <<
data.
nV_data << endl;
366 out <<
" simplex dataset names : " <<
data.
sS_data << endl;
367 out <<
" # of simplex data : " <<
data.
nS_data << endl;
371if (dgf_error.size() > 0) {
373 out <<
"ERROR report: " << endl;
376 out <<
" vertex: " << endl;
377 switch (dgf_error[0][0]) {
378 case 0: {out <<
" no errors" << endl;
break; }
379 case 1: {out <<
" **WARNING** unterminated data block!!" << endl;
break; }
380 case 2: {out <<
" **WARNING** missing data" << endl;
break; }
384 out <<
" simplex: " << endl;
385 switch (dgf_error[1][0]) {
386 case 0: {out <<
" no errors" << endl;
break; }
387 case 1: {out <<
" **WARNING** unterminated data block!!" << endl;
break; }
388 case 2: {out <<
" **WARNING** missing data" << endl;
break; }
393 for (i = 0; i < n; i++) {
394 out <<
" vertex dataset '" <<
data.
sV_data[i] <<
"': " << endl;
395 switch (dgf_error[2][i]) {
396 case 0: {out <<
" no errors" << endl;
break; }
397 case 1: {out <<
" **WARNING** unterminated data block!!" << endl;
break; }
398 case 2: {out <<
" **WARNING** missing data" << endl;
break; }
404 for (i = 0; i < n; i++) {
405 out <<
" simplex dataset '" <<
data.
sS_data[i] <<
"': " << endl;
406 switch (dgf_error[3][i]) {
407 case 0: {out <<
" no errors" << endl;
break; }
408 case 1: {out <<
" **WARNING** unterminated data block!!" << endl;
break; }
409 case 2: {out <<
" **WARNING** missing data" << endl;
break; }
519 std::vector<std::vector<double> > &V,
520 std::vector<std::vector<int> > &S
571 std::vector<std::array<double,3> > &V,
572 std::vector<std::vector<int> > &S
625 std::vector<std::array<double,3> > &V,
626 std::vector<std::vector<int> > &S,
627 std::vector<int> &PID,
628 const std::string &pidName
654int nData = PID.size() ;
655err = dgf::readSimplexData(ifile_handle, nData, PID, pidName ) ;
656if (nData == (
int) PID.size()) {
657 PID.resize(nS - nData, 0);
679 std::vector<std::vector<double> > &V,
680 std::vector<std::vector<int> > &S
746 std::vector<std::array<double,3> > &V,
747 std::vector<std::vector<int> > &S
783void DGFObj::loadVData(
808void DGFObj::loadSData(
833void DGFObj::appendVData(
858void DGFObj::appendSData(
894 std::ifstream &file_handle,
903std::streamoff current_pos;
904std::string line, word;
905std::stringstream sline;
913if (!file_handle.good()) {
return(1); }
920current_pos = file_handle.tellg();
924while (!file_handle.eof()
925 && ((word.compare(
"#") != 0)
926 && (word.compare(
"VERTEX") != 0)
927 && (word.compare(
"SIMPLEX") != 0)
928 && (word.compare(
"VERTEXDATA") != 0)
929 && (word.compare(
"SIMPLEXDATA") != 0))) {
932 current_pos = file_handle.tellg();
933 getline(file_handle, line);
944if ((word.compare(
"#") == 0)
945 || (word.compare(
"VERTEX") == 0)
946 || (word.compare(
"SIMPLEX") == 0)
947 || (word.compare(
"VERTEXDATA") == 0)
948 || (word.compare(
"SIMPLEXDATA") == 0)){
950 file_handle.seekg(current_pos);
973 std::ifstream &file_handle,
976 std::vector<std::string> &sV_data,
977 std::vector<std::string> &sS_data,
978 std::vector<int> &nV_data,
979 std::vector<int> &nS_data
988std::streamoff start_pos;
989std::string line, word;
990std::stringstream sline;
998if (!file_handle.good()) {
return(1); }
1013start_pos = file_handle.tellg();
1015file_handle.seekg(0);
1021while (!file_handle.eof()) {
1024 getline(file_handle, line);
1030 if (sline >> word) {
1031 if (word.compare(
"VERTEX") == 0) {
1036 else if (word.compare(
"SIMPLEX") == 0) {
1041 else if (word.compare(
"VERTEXDATA") == 0) {
1044 if (sline >> word) { sV_data.push_back(word); }
1045 else { sV_data.push_back(
""); }
1050 nV_data.push_back(n);
1052 else if (word.compare(
"SIMPLEXDATA") == 0) {
1055 if (sline >> word) { sS_data.push_back(word); }
1056 else { sS_data.push_back(
""); }
1061 nS_data.push_back(n);
1070file_handle.seekg(start_pos);
1091 std::ifstream &file_handle,
1100std::streamoff current_pos;
1101std::string line, word;
1102std::stringstream sline;
1110if (!file_handle.good()) {
return(1); };
1121current_pos = file_handle.tellg();
1122while (!file_handle.eof()
1123 && ((word.compare(
"#") != 0)
1124 && (word.compare(
"VERTEX") != 0)
1125 && (word.compare(
"SIMPLEX") != 0)
1126 && (word.compare(
"VERTEXDATA") != 0)
1127 && (word.compare(
"SIMPLEXDATA") != 0))) {
1130 getline(file_handle, line);
1131 current_pos = file_handle.tellg();
1137 if (!(sline >> word)) {
1141if (word.compare(
"#") != 0) {
1142 file_handle.clear();
1143 file_handle.seekg(current_pos);
1170 std::ifstream &file_handle,
1171 std::vector<std::vector<int> > &err_code
1179unsigned int err = 0;
1180std::streamoff start_pos;
1182std::string line, word;
1183std::stringstream sline;
1191if (!file_handle.good()) {
return(1); }
1202start_pos = file_handle.tellg();
1203file_handle.seekg(0);
1209while ((!file_handle.eof()) && (word.compare(
"#") != 0)) {
1212 getline(file_handle, line);
1218 if (sline >> word) {
1219 if (word.compare(
"VERTEX") == 0) {
1220 err_code[0].resize(1);
1223 else if (word.compare(
"SIMPLEX") == 0) {
1224 err_code[1].resize(1);
1227 else if (word.compare(
"VERTEXDATA") == 0) {
1229 err_code[2].push_back(loc_err);
1231 else if (word.compare(
"SIMPLEXDATA") == 0) {
1233 err_code[3].push_back(loc_err);
1242file_handle.seekg(start_pos);
1271 std::ifstream &file_handle,
1274 std::vector<std::vector<double> > &V,
1275 std::vector<std::vector<int> > &S
1283unsigned int err = 0;
1284std::streamoff start_pos;
1285std::string line, word;
1286std::stringstream sline;
1294if (!file_handle.good()) {
return(1); }
1300start_pos = file_handle.tellg();
1301file_handle.seekg(0);
1307while (!file_handle.eof()
1308 && (word.compare(
"#") != 0)) {
1311 getline(file_handle, line);
1317 if (sline >> word) {
1318 if (word.compare(
"VERTEX") == 0) {
1319 err = readData(file_handle, nV, V);
1321 else if (word.compare(
"SIMPLEX") == 0) {
1322 err = readData(file_handle, nS, S);
1331file_handle.seekg(start_pos);
1359 std::ifstream &file_handle,
1362 std::vector<std::array<double,3> > &V,
1363 std::vector<std::vector<int> > &S
1371unsigned int err = 0;
1372std::streamoff start_pos;
1373std::string line, word;
1374std::stringstream sline;
1382if (!file_handle.good()) {
return(1); }
1388start_pos = file_handle.tellg();
1389file_handle.seekg(0);
1395while (!file_handle.eof()
1396 && (word.compare(
"#") != 0)) {
1399 getline(file_handle, line);
1405 if (sline >> word) {
1406 if (word.compare(
"VERTEX") == 0) {
1407 err = dgf::readData(file_handle, nV, V);
1409 else if (word.compare(
"SIMPLEX") == 0) {
1410 err = dgf::readData(file_handle, nS, S);
1419file_handle.seekg(start_pos);
1440 std::ofstream &file_handle,
1443 std::vector<std::vector<double> > &V,
1444 std::vector<std::vector<int> > &S
1452unsigned int err = 0;
1460if (!file_handle.good()) {
return(1); }
1467file_handle <<
"VERTEX" << endl;
1468err = dgf::writeData(file_handle, nV, V);
1471file_handle <<
"SIMPLEX" << endl;
1472err = dgf::writeData(file_handle, nS, S);
1492 std::ofstream &file_handle,
1495 std::vector<std::array<double,3> > &V,
1496 std::vector<std::vector<int> > &S
1504unsigned int err = 0;
1512if (!file_handle.good()) {
return(1); }
1519file_handle <<
"VERTEX" << endl;
1520err = dgf::writeData(file_handle, nV, V);
1523file_handle <<
"SIMPLEX" << endl;
1524err = dgf::writeData(file_handle, nS, S);
void close(const std::string &a="inout")
void save(int &, int &, std::vector< std::vector< double > > &, std::vector< std::vector< int > > &)
void open(const std::string &)
void display(std::ostream &)
void load(int &, int &, std::vector< std::vector< double > > &, std::vector< std::vector< int > > &)
std::string & trim(std::string &s)
unsigned int scan(std::ifstream &, int &, int &, std::vector< std::string > &, std::vector< std::string > &, std::vector< int > &, std::vector< int > &)
unsigned int writeMesh(std::ofstream &, int &, int &, std::vector< std::vector< double > > &, std::vector< std::vector< int > > &)
unsigned int check(std::ifstream &, std::vector< std::vector< int > > &)
unsigned int checkData(std::ifstream &, int &)
unsigned int readMesh(std::ifstream &, int &, int &, std::vector< std::vector< double > > &, std::vector< std::vector< int > > &)
unsigned int scanData(std::ifstream &, int &)
std::vector< std::string > sS_data
std::vector< std::string > sV_data
std::vector< int > nV_data
std::vector< int > nS_data