--- trunk/OOPSE/libmdtools/AtomVisitor.cpp 2004/04/19 03:52:27 1118 +++ trunk/OOPSE/libmdtools/AtomVisitor.cpp 2004/04/20 05:39:38 1126 @@ -2,7 +2,18 @@ #include "AtomVisitor.hpp" #include "DirectionalAtom.hpp" #include "MatVec3.h" +#include "RigidBody.hpp" +void BaseAtomVisitor::visit(RigidBody* rb){ + //vector myAtoms; + //vector::iterator atomIter; + + //myAtoms = rb->getAtoms(); + + //for(atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter) + // (*atomIter)->accept(this); +} + void BaseAtomVisitor::setVisited(Atom* atom){ GenericData* data; data = atom->getProperty("VISITED"); @@ -43,7 +54,7 @@ void SSDAtomVisitor::visit(DirectionalAtom* datom){ bool haveAtomData; //if atom is not SSD atom, just skip it - if(!strcmp(datom->getType(), "SSD")) + if(strcmp(datom->getType(), "SSD")) return; data = datom->getProperty("ATOMDATA"); @@ -129,6 +140,27 @@ void SSDAtomVisitor::visit(DirectionalAtom* datom){ } +const string SSDAtomVisitor::toString(){ + char buffer[65535]; + string result; + + sprintf(buffer ,"------------------------------------------------------------------\n"); + result += buffer; + + sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); + result += buffer; + + sprintf(buffer , "Visitor Description: Convert SSD into 4 differnet atoms\n"); + result += buffer; + + sprintf(buffer ,"------------------------------------------------------------------\n"); + result += buffer; + + return result; +} + +//----------------------------------------------------------------------------// + void DefaultAtomVisitor::visit(Atom* atom){ AtomData* atomData; AtomInfo* atomInfo; @@ -138,6 +170,9 @@ void DefaultAtomVisitor::visit(Atom* atom){ return; atomInfo =new AtomInfo; + + atomData = new AtomData; + atomData->setID("ATOMDATA"); atom->getPos(pos); atomInfo->AtomType = atom->getType(); @@ -148,8 +183,9 @@ void DefaultAtomVisitor::visit(Atom* atom){ atomInfo->dipole[1] = 0.0; atomInfo->dipole[2] = 0.0; - atomData = new AtomData; - atomData->setID("ATOMDATA"); + + atomData->addAtomInfo(atomInfo); + atom->addProperty(atomData); setVisited(atom); @@ -166,6 +202,8 @@ void DefaultAtomVisitor::visit(DirectionalAtom* datom) datom->getPos(pos); datom->getU(u); + atomData = new AtomData; + atomData->setID("ATOMDATA"); atomInfo =new AtomInfo; atomInfo->AtomType = datom->getType(); @@ -176,10 +214,29 @@ void DefaultAtomVisitor::visit(DirectionalAtom* datom) atomInfo->dipole[1] = u[1]; atomInfo->dipole[2] = u[2]; - atomData = new AtomData; - atomData->setID("ATOMDATA"); + atomData->addAtomInfo(atomInfo); + datom->addProperty(atomData); setVisited(datom); } - + + +const string DefaultAtomVisitor::toString(){ + char buffer[65535]; + string result; + + sprintf(buffer ,"------------------------------------------------------------------\n"); + result += buffer; + + sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); + result += buffer; + + sprintf(buffer , "Visitor Description: copy atom infomation into atom data\n"); + result += buffer; + + sprintf(buffer ,"------------------------------------------------------------------\n"); + result += buffer; + + return result; +}