--- trunk/src/utils/ElementsTable.cpp 2008/09/14 01:32:26 1293 +++ branches/development/src/utils/ElementsTable.cpp 2010/07/09 23:08:25 1465 @@ -1,7 +1,7 @@ This basic Periodic Table class was originally taken f /********************************************************************** This basic Periodic Table class was originally taken from the data.cpp -file in OpenBabel. The code has been modified to match the OOPSE coding style. +file in OpenBabel. The code has been modified to match the OpenMD coding style. We have retained the OpenBabel copyright and GPL license on this class: @@ -53,13 +53,13 @@ extern "C" int strncasecmp(const char *s1, const char #define BUFF_SIZE 32768 #endif -namespace oopse { +namespace OpenMD { ElementsTable etab; ElementsTable::ElementsTable() { init_ = false; - STR_DEFINE(dir_, FRC_PATH ); + dir_ = std::string("TO_STRING(FRC_PATH)"); envvar_ = "FORCE_PARAM_PATH"; filename_ = "element.txt"; } @@ -78,7 +78,6 @@ namespace oopse { RealType red, green, blue; // skip comment line (at the top) - if (line[0] != '#') { sscanf(line,"%d %5s %lf %*f %lf %d %lf %lf %lf %lf %lf %lf %lf %255s", &num, @@ -110,7 +109,7 @@ namespace oopse { return elements_.size(); } - char *ElementsTable::GetSymbol(int atomicnum) { + const char *ElementsTable::GetSymbol(int atomicnum) { if (!init_) Init(); @@ -295,21 +294,28 @@ namespace oopse { buffer = getenv(envvar_.c_str()); buffer += FILE_SEP_CHAR; + + + if (!subdir_.empty()) { subbuffer = buffer; subbuffer += subdir_; subbuffer += FILE_SEP_CHAR; } + + buffer += filename_; subbuffer += filename_; + ifs1.open(subbuffer.c_str()); ifsP= &ifs1; - if (!(*ifsP)) { + if (!(ifsP->is_open())) { ifs2.open(buffer.c_str()); ifsP = &ifs2; } + } else { sprintf( painCave.errMsg, "ElementsTable error.\n" @@ -322,7 +328,7 @@ namespace oopse { if ((*ifsP)) { while(ifsP->getline(charBuffer,BUFF_SIZE)) ParseLine(charBuffer); - + if (ifs1) ifs1.close(); if (ifs2)