--- trunk/src/brains/MoleculeCreator.cpp 2005/01/12 22:41:40 246 +++ trunk/src/brains/MoleculeCreator.cpp 2005/03/08 21:06:49 403 @@ -52,6 +52,7 @@ #include "brains/MoleculeCreator.hpp" #include "primitives/GhostBend.hpp" +#include "primitives/GhostTorsion.hpp" #include "types/DirectionalAtomType.hpp" #include "types/FixedBondType.hpp" #include "utils/simError.h" @@ -252,8 +253,9 @@ RigidBody* MoleculeCreator::createRigidBody(MoleculeSt //The third part is the index of the rigidbody defined in meta-data file //For example, Butane_RB_0 is a valid rigid body name of butane molecule /**@todo replace itoa by lexi_cast */ - rb->setType(mol->getType() + "_RB_" + toString(mol->getNRigidBodies())); - + std::string s = OOPSE_itoa(mol->getNRigidBodies(), 10); + rb->setType(mol->getType() + "_RB_" + s.c_str()); + return rb; } @@ -376,34 +378,60 @@ Torsion* MoleculeCreator::createTorsion(ForceField* ff } Torsion* MoleculeCreator::createTorsion(ForceField* ff, Molecule* mol, TorsionStamp* stamp) { - TorsionType* torsionType; - Atom* atomA; - Atom* atomB; - Atom* atomC; - Atom* atomD; - atomA = mol->getAtomAt(stamp->getA()); - atomB = mol->getAtomAt(stamp->getB()); - atomC = mol->getAtomAt(stamp->getC()); - atomD = mol->getAtomAt(stamp->getD()); - - assert(atomA && atomB && atomC && atomD); - - torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(), - atomC->getType(), atomD->getType()); + Atom* atomA = mol->getAtomAt(stamp->getA()); + Atom* atomB = mol->getAtomAt(stamp->getB()); + Atom* atomC = mol->getAtomAt(stamp->getC()); + Torsion* torsion; - if (torsionType == NULL) { - sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]", - atomA->getType().c_str(), - atomB->getType().c_str(), - atomC->getType().c_str(), - atomD->getType().c_str()); + if (stamp->getD() != -1) { + Atom* atomD = mol->getAtomAt(stamp->getD()); - painCave.isFatal = 1; - simError(); + assert(atomA && atomB && atomC && atomD); + + TorsionType* torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(), + atomC->getType(), atomD->getType()); + + if (torsionType == NULL) { + sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]", + atomA->getType().c_str(), + atomB->getType().c_str(), + atomC->getType().c_str(), + atomD->getType().c_str()); + + painCave.isFatal = 1; + simError(); + } + + torsion = new Torsion(atomA, atomB, atomC, atomD, torsionType); } - - return new Torsion(atomA, atomB, atomC, atomD, torsionType); + else { + + DirectionalAtom* dAtom = dynamic_cast(atomC); + if (dAtom == NULL) { + sprintf(painCave.errMsg, "Can not cast Atom to DirectionalAtom"); + painCave.isFatal = 1; + simError(); + } + + TorsionType* torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(), + atomC->getType(), "GHOST"); + + if (torsionType == NULL) { + sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]", + atomA->getType().c_str(), + atomB->getType().c_str(), + atomC->getType().c_str(), + "GHOST"); + + painCave.isFatal = 1; + simError(); + } + + torsion = new GhostTorsion(atomA, atomB, dAtom, torsionType); + } + + return torsion; } CutoffGroup* MoleculeCreator::createCutoffGroup(Molecule* mol, CutoffGroupStamp* stamp) {