ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/brains/MoleculeCreator.cpp
(Generate patch)

Comparing trunk/OOPSE-2.0/src/brains/MoleculeCreator.cpp (file contents):
Revision 1930 by gezelter, Wed Jan 12 22:41:40 2005 UTC vs.
Revision 1976 by tim, Fri Feb 4 22:44:15 2005 UTC

# Line 52 | Line 52
52  
53   #include "brains/MoleculeCreator.hpp"
54   #include "primitives/GhostBend.hpp"
55 + #include "primitives/GhostTorsion.hpp"
56   #include "types/DirectionalAtomType.hpp"
57   #include "types/FixedBondType.hpp"
58   #include "utils/simError.h"
# Line 252 | Line 253 | RigidBody* MoleculeCreator::createRigidBody(MoleculeSt
253      //The third part is the index of the rigidbody defined in meta-data file
254      //For example, Butane_RB_0 is a valid rigid body name of butane molecule
255      /**@todo replace itoa by lexi_cast */
256 <    rb->setType(mol->getType() + "_RB_" + toString(mol->getNRigidBodies()));
257 <    
256 >    char buffer [33];  
257 >    sprintf(buffer, "%d", mol->getNRigidBodies());
258 >    //rb->setType(mol->getType() + "_RB_" + toString<int>(mol->getNRigidBodies()));
259 >    rb->setType(mol->getType() + "_RB_" + buffer);
260 >
261      return rb;
262   }    
263  
# Line 376 | Line 380 | Torsion* MoleculeCreator::createTorsion(ForceField* ff
380   }    
381  
382   Torsion* MoleculeCreator::createTorsion(ForceField* ff, Molecule* mol, TorsionStamp* stamp) {
379    TorsionType* torsionType;
380    Atom* atomA;
381    Atom* atomB;
382    Atom* atomC;
383    Atom* atomD;
383  
384 <    atomA = mol->getAtomAt(stamp->getA());
385 <    atomB = mol->getAtomAt(stamp->getB());
386 <    atomC = mol->getAtomAt(stamp->getC());
387 <    atomD = mol->getAtomAt(stamp->getD());
389 <
390 <    assert(atomA && atomB && atomC && atomD);
391 <    
392 <    torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(),
393 <                                                       atomC->getType(), atomD->getType());
384 >    Atom* atomA = mol->getAtomAt(stamp->getA());
385 >    Atom* atomB = mol->getAtomAt(stamp->getB());
386 >    Atom* atomC = mol->getAtomAt(stamp->getC());
387 >    Torsion* torsion;
388  
389 <    if (torsionType == NULL) {
390 <        sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]",
397 <                   atomA->getType().c_str(),
398 <                   atomB->getType().c_str(),
399 <                   atomC->getType().c_str(),
400 <                   atomD->getType().c_str());
389 >    if (stamp->getD() != -1) {
390 >        Atom* atomD = mol->getAtomAt(stamp->getD());
391  
392 <        painCave.isFatal = 1;
393 <        simError();
392 >        assert(atomA && atomB && atomC && atomD);
393 >        
394 >        TorsionType* torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(),
395 >                                                           atomC->getType(), atomD->getType());
396 >
397 >        if (torsionType == NULL) {
398 >            sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]",
399 >                       atomA->getType().c_str(),
400 >                       atomB->getType().c_str(),
401 >                       atomC->getType().c_str(),
402 >                       atomD->getType().c_str());
403 >
404 >            painCave.isFatal = 1;
405 >            simError();
406 >        }
407 >        
408 >        torsion = new Torsion(atomA, atomB, atomC, atomD, torsionType);      
409      }
410 <    
411 <    return new Torsion(atomA, atomB, atomC, atomD, torsionType);      
410 >    else {
411 >
412 >        DirectionalAtom* dAtom = dynamic_cast<DirectionalAtom*>(atomC);
413 >        if (dAtom == NULL) {
414 >            sprintf(painCave.errMsg, "Can not cast Atom to DirectionalAtom");
415 >            painCave.isFatal = 1;
416 >            simError();
417 >        }        
418 >
419 >        TorsionType* torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(),
420 >                                                           atomC->getType(), "GHOST");
421 >
422 >        if (torsionType == NULL) {
423 >            sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]",
424 >                       atomA->getType().c_str(),
425 >                       atomB->getType().c_str(),
426 >                       atomC->getType().c_str(),
427 >                       "GHOST");
428 >
429 >            painCave.isFatal = 1;
430 >            simError();
431 >        }
432 >        
433 >        torsion = new GhostTorsion(atomA, atomB, dAtom, torsionType);              
434 >    }
435 >
436 >    return torsion;
437   }    
438  
439   CutoffGroup* MoleculeCreator::createCutoffGroup(Molecule* mol, CutoffGroupStamp* stamp) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines