--- trunk/src/applications/hydrodynamics/ShapeBuilder.cpp 2006/03/20 19:12:14 908 +++ trunk/src/applications/hydrodynamics/ShapeBuilder.cpp 2006/04/25 02:06:12 944 @@ -43,94 +43,135 @@ namespace oopse { #include "applications/hydrodynamics/Ellipsoid.hpp" #include "applications/hydrodynamics/CompositeShape.hpp" namespace oopse { - -Shape* ShapeBuilder::createShape(StuntDouble* sd) { + + Shape* ShapeBuilder::createShape(StuntDouble* sd) { Shape* currShape = NULL; - if (sd->isDirectionalAtom()) { - currShape = internalCreateShape(static_cast(sd)); - } else if (sd->isAtom()) { - currShape = internalCreateShape(static_cast(sd)); - } else if (sd->isRigidBody()) { - currShape = internalCreateShape(static_cast(sd)); - } - - - - return currShape; - -} - -Shape* ShapeBuilder::internalCreateShape(Atom* atom) { + if (sd->isDirectionalAtom()) { + currShape = internalCreateShape(static_cast(sd)); + } else if (sd->isAtom()) { + currShape = internalCreateShape(static_cast(sd)); + } else if (sd->isRigidBody()) { + currShape = internalCreateShape(static_cast(sd)); + } + return currShape; + } + + Shape* ShapeBuilder::internalCreateShape(Atom* atom) { AtomType* atomType = atom->getAtomType(); Shape* currShape = NULL; if (atomType->isLennardJones()){ - GenericData* data = atomType->getPropertyByName("LennardJones"); - if (data != NULL) { - LJParamGenericData* ljData = dynamic_cast(data); - - if (ljData != NULL) { - LJParam ljParam = ljData->getData(); - currShape = new Spheric(atom->getPos(), ljParam.sigma/2.0); + GenericData* data = atomType->getPropertyByName("LennardJones"); + if (data != NULL) { + LJParamGenericData* ljData = dynamic_cast(data); + + if (ljData != NULL) { + LJParam ljParam = ljData->getData(); + currShape = new Spheric(atom->getPos(), ljParam.sigma/2.0); } else { + sprintf( painCave.errMsg, + "Can not cast GenericData to LJParam\n"); + painCave.severity = OOPSE_ERROR; + painCave.isFatal = 1; + simError(); + } + } + } else if (atomType->isEAM()) { + GenericData* data = atomType->getPropertyByName("EAM"); + if (data != NULL) { + EAMParamGenericData* eamData = dynamic_cast(data); + + if (eamData != NULL) { + EAMParam eamParam = eamData->getData(); + currShape = new Spheric(atom->getPos(), eamParam.rcut); + } else { + sprintf( painCave.errMsg, + "Can not cast GenericData to EAMParam\n"); + painCave.severity = OOPSE_ERROR; + painCave.isFatal = 1; + simError(); + } + } + } + return currShape; + } + + Shape* ShapeBuilder::internalCreateShape(DirectionalAtom* datom) { + AtomType* atomType = datom->getAtomType(); + Shape* currShape = NULL; + if (atomType->isGayBerne()) { + DirectionalAtomType* dAtomType = dynamic_cast(atomType); + + GenericData* data = dAtomType->getPropertyByName("GayBerne"); + if (data != NULL) { + GayBerneParamGenericData* gayBerneData = dynamic_cast(data); + + if (gayBerneData != NULL) { + GayBerneParam gayBerneParam = gayBerneData->getData(); + currShape = new Ellipsoid(datom->getPos(), gayBerneParam.GB_sigma/2.0, gayBerneParam.GB_l2b_ratio*gayBerneParam.GB_sigma/2.0, datom->getA()); + } else { + sprintf( painCave.errMsg, + "Can not cast GenericData to GayBerneParam\n"); + painCave.severity = OOPSE_ERROR; + painCave.isFatal = 1; + simError(); + } + } else { + sprintf( painCave.errMsg, "Can not find Parameters for GayBerne\n"); + painCave.severity = OOPSE_ERROR; + painCave.isFatal = 1; + simError(); + } + } else if (atomType->isLennardJones()) { + GenericData* data = atomType->getPropertyByName("LennardJones"); + if (data != NULL) { + LJParamGenericData* ljData = dynamic_cast(data); + + if (ljData != NULL) { + LJParam ljParam = ljData->getData(); + currShape = new Spheric(datom->getPos(), ljParam.sigma/2.0); + } else { + sprintf( painCave.errMsg, + "Can not cast GenericData to LJParam\n"); + painCave.severity = OOPSE_ERROR; + painCave.isFatal = 1; + simError(); + } + } else if (atomType->isEAM()) { + GenericData* data = atomType->getPropertyByName("EAM"); + if (data != NULL) { + EAMParamGenericData* eamData = dynamic_cast(data); + if (eamData != NULL) { + EAMParam eamParam = eamData->getData(); + currShape = new Spheric(datom->getPos(), eamParam.rcut); + } else { sprintf( painCave.errMsg, - "Can not cast GenericData to LJParam\n"); + "Can not cast GenericData to EAMParam\n"); painCave.severity = OOPSE_ERROR; painCave.isFatal = 1; simError(); - } + } } - + } } - return currShape; -} + } -Shape* ShapeBuilder::internalCreateShape(DirectionalAtom* datom) { - AtomType* atomType = datom->getAtomType(); - Shape* currShape = NULL; - if (atomType->isGayBerne()) { - DirectionalAtomType* dAtomType = dynamic_cast(atomType); - - GenericData* data = dAtomType->getPropertyByName("GayBerne"); - if (data != NULL) { - GayBerneParamGenericData* gayBerneData = dynamic_cast(data); - - if (gayBerneData != NULL) { - GayBerneParam gayBerneParam = gayBerneData->getData(); - currShape = new Ellipsoid(datom->getPos(), gayBerneParam.GB_sigma/2.0, gayBerneParam.GB_l2b_ratio*gayBerneParam.GB_sigma/2.0, datom->getA()); - } else { - sprintf( painCave.errMsg, - "Can not cast GenericData to GayBerneParam\n"); - painCave.severity = OOPSE_ERROR; - painCave.isFatal = 1; - simError(); - } - } else { - sprintf( painCave.errMsg, "Can not find Parameters for GayBerne\n"); - painCave.severity = OOPSE_ERROR; - painCave.isFatal = 1; - simError(); - } + Shape* ShapeBuilder::internalCreateShape(RigidBody* rb) { + + std::vector::iterator ai; + CompositeShape* compositeShape = new CompositeShape; + Atom* atom; + for (atom = rb->beginAtom(ai); atom != NULL; atom = rb->nextAtom(ai)) { + Shape* currShape = NULL; + if (atom->isDirectionalAtom()){ + currShape = internalCreateShape(static_cast(atom)); + }else if (atom->isAtom()){ + currShape = internalCreateShape(static_cast(atom)); + } + if (currShape != NULL) + compositeShape->addShape(currShape); } - return currShape; + + return compositeShape; + } } -Shape* ShapeBuilder::internalCreateShape(RigidBody* rb) { - - std::vector::iterator ai; - CompositeShape* compositeShape = new CompositeShape; - Atom* atom; - for (atom = rb->beginAtom(ai); atom != NULL; atom = rb->nextAtom(ai)) { - Shape* currShape = NULL; - if (atom->isDirectionalAtom()){ - currShape = internalCreateShape(static_cast(atom)); - }else if (atom->isAtom()){ - currShape = internalCreateShape(static_cast(atom)); - } - if (currShape != NULL) - compositeShape->addShape(currShape); - } - - return compositeShape; -} - -}