45#include "io/AtomTypesSectionParser.hpp"
48#include "types/AtomType.hpp"
49#include "utils/simError.h"
53 AtomTypesSectionParser::AtomTypesSectionParser() {
54 setSectionName(
"AtomTypes");
57 void AtomTypesSectionParser::parseLine(ForceField& ff,
58 const std::string& line,
int lineNo) {
59 StringTokenizer tokenizer(line);
60 int nTokens = tokenizer.countTokens();
65 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
66 "AtomTypesSectionParser Error: Not enough tokens at line %d\n",
72 std::string atomTypeName = tokenizer.nextToken();
73 std::string baseAtomTypeName = tokenizer.nextToken();
75 AtomType* baseAtomType =
76 dynamic_cast<AtomType*
>(ff.getAtomType(baseAtomTypeName));
78 if (baseAtomType == NULL) {
80 painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
81 "AtomTypesSectionParser Error: Could not find matching base atom "
84 baseAtomTypeName.c_str(), lineNo);
89 AtomType* atomType = ff.getAtomType(atomTypeName);
91 if (atomType == NULL) {
92 atomType =
new AtomType();
93 atomType->useBase(baseAtomType);
94 int ident = ff.getNAtomType();
95 atomType->setIdent(ident);
96 atomType->setName(atomTypeName);
97 ff.addAtomType(atomTypeName, atomType);
99 std::cerr <<
"duplicate atom type: " << atomTypeName <<
" on line "
103 if (tokenizer.hasMoreTokens()) {
104 RealType mass = tokenizer.nextTokenAsDouble();
105 atomType->setMass(mass);
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.