| 43 |  | #include "applications/hydrodynamics/Ellipsoid.hpp" | 
| 44 |  | #include "applications/hydrodynamics/CompositeShape.hpp" | 
| 45 |  | namespace oopse { | 
| 46 | < |  | 
| 47 | < | Shape* ShapeBuilder::createShape(StuntDouble* sd) { | 
| 46 | > |  | 
| 47 | > | Shape* ShapeBuilder::createShape(StuntDouble* sd) { | 
| 48 |  | Shape* currShape = NULL; | 
| 49 | < | if (sd->isDirectionalAtom()) { | 
| 50 | < | currShape = internalCreateShape(static_cast<DirectionalAtom*>(sd)); | 
| 51 | < | } else if (sd->isAtom()) { | 
| 52 | < | currShape = internalCreateShape(static_cast<Atom*>(sd)); | 
| 53 | < | } else if (sd->isRigidBody()) { | 
| 54 | < | currShape = internalCreateShape(static_cast<RigidBody*>(sd)); | 
| 55 | < | } | 
| 56 | < |  | 
| 57 | < |  | 
| 58 | < |  | 
| 59 | < | return currShape; | 
| 60 | < |  | 
| 61 | < | } | 
| 62 | < |  | 
| 63 | < | Shape* ShapeBuilder::internalCreateShape(Atom* atom) { | 
| 49 | > | if (sd->isDirectionalAtom()) { | 
| 50 | > | currShape = internalCreateShape(static_cast<DirectionalAtom*>(sd)); | 
| 51 | > | } else if (sd->isAtom()) { | 
| 52 | > | currShape = internalCreateShape(static_cast<Atom*>(sd)); | 
| 53 | > | } else if (sd->isRigidBody()) { | 
| 54 | > | currShape = internalCreateShape(static_cast<RigidBody*>(sd)); | 
| 55 | > | } | 
| 56 | > | return currShape; | 
| 57 | > | } | 
| 58 | > |  | 
| 59 | > | Shape* ShapeBuilder::internalCreateShape(Atom* atom) { | 
| 60 |  | AtomType* atomType = atom->getAtomType(); | 
| 61 |  | Shape* currShape = NULL; | 
| 62 |  | if (atomType->isLennardJones()){ | 
| 63 | < | GenericData* data = atomType->getPropertyByName("LennardJones"); | 
| 64 | < | if (data != NULL) { | 
| 65 | < | LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data); | 
| 66 | < |  | 
| 67 | < | if (ljData != NULL) { | 
| 68 | < | LJParam ljParam = ljData->getData(); | 
| 69 | < | currShape = new Spheric(atom->getPos(), ljParam.sigma/2.0); | 
| 63 | > | GenericData* data = atomType->getPropertyByName("LennardJones"); | 
| 64 | > | if (data != NULL) { | 
| 65 | > | LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data); | 
| 66 | > |  | 
| 67 | > | if (ljData != NULL) { | 
| 68 | > | LJParam ljParam = ljData->getData(); | 
| 69 | > | currShape = new Spheric(atom->getPos(), ljParam.sigma/2.0); | 
| 70 |  | } else { | 
| 71 | < | sprintf( painCave.errMsg, | 
| 72 | < | "Can not cast GenericData to LJParam\n"); | 
| 73 | < | painCave.severity = OOPSE_ERROR; | 
| 74 | < | painCave.isFatal = 1; | 
| 75 | < | simError(); | 
| 76 | < | } | 
| 77 | < | } | 
| 78 | < |  | 
| 79 | < | } | 
| 80 | < |  | 
| 71 | > | sprintf( painCave.errMsg, | 
| 72 | > | "Can not cast GenericData to LJParam\n"); | 
| 73 | > | painCave.severity = OOPSE_ERROR; | 
| 74 | > | painCave.isFatal = 1; | 
| 75 | > | simError(); | 
| 76 | > | } | 
| 77 | > | } | 
| 78 | > | } else if (atomType->isEAM()) { | 
| 79 | > | GenericData* data = atomType->getPropertyByName("EAM"); | 
| 80 | > | if (data != NULL) { | 
| 81 | > | EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data); | 
| 82 | > |  | 
| 83 | > | if (eamData != NULL) { | 
| 84 | > | EAMParam eamParam = eamData->getData(); | 
| 85 | > | currShape = new Spheric(atom->getPos(), eamParam.rcut); | 
| 86 | > | } else { | 
| 87 | > | sprintf( painCave.errMsg, | 
| 88 | > | "Can not cast GenericData to EAMParam\n"); | 
| 89 | > | painCave.severity = OOPSE_ERROR; | 
| 90 | > | painCave.isFatal = 1; | 
| 91 | > | simError(); | 
| 92 | > | } | 
| 93 | > | } | 
| 94 | > | } | 
| 95 |  | return currShape; | 
| 96 | < | } | 
| 97 | < |  | 
| 98 | < | Shape* ShapeBuilder::internalCreateShape(DirectionalAtom* datom) { | 
| 96 | > | } | 
| 97 | > |  | 
| 98 | > | Shape* ShapeBuilder::internalCreateShape(DirectionalAtom* datom) { | 
| 99 |  | AtomType* atomType = datom->getAtomType(); | 
| 100 |  | Shape* currShape = NULL; | 
| 101 |  | if (atomType->isGayBerne()) { | 
| 102 | < | DirectionalAtomType* dAtomType = dynamic_cast<DirectionalAtomType*>(atomType); | 
| 103 | < |  | 
| 104 | < | GenericData* data = dAtomType->getPropertyByName("GayBerne"); | 
| 105 | < | if (data != NULL) { | 
| 106 | < | GayBerneParamGenericData* gayBerneData = dynamic_cast<GayBerneParamGenericData*>(data); | 
| 107 | < |  | 
| 108 | < | if (gayBerneData != NULL) { | 
| 109 | < | GayBerneParam gayBerneParam = gayBerneData->getData(); | 
| 110 | < | currShape = new Ellipsoid(datom->getPos(), gayBerneParam.GB_sigma/2.0, gayBerneParam.GB_l2b_ratio*gayBerneParam.GB_sigma/2.0, datom->getA()); | 
| 101 | < | } else { | 
| 102 | < | sprintf( painCave.errMsg, | 
| 103 | < | "Can not cast GenericData to GayBerneParam\n"); | 
| 104 | < | painCave.severity = OOPSE_ERROR; | 
| 105 | < | painCave.isFatal = 1; | 
| 106 | < | simError(); | 
| 107 | < | } | 
| 102 | > | DirectionalAtomType* dAtomType = dynamic_cast<DirectionalAtomType*>(atomType); | 
| 103 | > |  | 
| 104 | > | GenericData* data = dAtomType->getPropertyByName("GayBerne"); | 
| 105 | > | if (data != NULL) { | 
| 106 | > | GayBerneParamGenericData* gayBerneData = dynamic_cast<GayBerneParamGenericData*>(data); | 
| 107 | > |  | 
| 108 | > | if (gayBerneData != NULL) { | 
| 109 | > | GayBerneParam gayBerneParam = gayBerneData->getData(); | 
| 110 | > | currShape = new Ellipsoid(datom->getPos(), gayBerneParam.GB_sigma/2.0, gayBerneParam.GB_l2b_ratio*gayBerneParam.GB_sigma/2.0, datom->getA()); | 
| 111 |  | } else { | 
| 112 | < | sprintf( painCave.errMsg, "Can not find Parameters for GayBerne\n"); | 
| 113 | < | painCave.severity = OOPSE_ERROR; | 
| 114 | < | painCave.isFatal = 1; | 
| 115 | < | simError(); | 
| 116 | < | } | 
| 117 | < | }else if (atomType->isLennardJones()){ | 
| 118 | < | GenericData* data = atomType->getPropertyByName("LennardJones"); | 
| 119 | < | if (data != NULL) { | 
| 120 | < | LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data); | 
| 121 | < |  | 
| 122 | < | if (ljData != NULL) { | 
| 123 | < | LJParam ljParam = ljData->getData(); | 
| 124 | < | currShape = new Spheric(datom->getPos(), ljParam.sigma/2.0); | 
| 112 | > | sprintf( painCave.errMsg, | 
| 113 | > | "Can not cast GenericData to GayBerneParam\n"); | 
| 114 | > | painCave.severity = OOPSE_ERROR; | 
| 115 | > | painCave.isFatal = 1; | 
| 116 | > | simError(); | 
| 117 | > | } | 
| 118 | > | } else { | 
| 119 | > | sprintf( painCave.errMsg, "Can not find Parameters for GayBerne\n"); | 
| 120 | > | painCave.severity = OOPSE_ERROR; | 
| 121 | > | painCave.isFatal = 1; | 
| 122 | > | simError(); | 
| 123 | > | } | 
| 124 | > | } else if (atomType->isLennardJones()) { | 
| 125 | > | GenericData* data = atomType->getPropertyByName("LennardJones"); | 
| 126 | > | if (data != NULL) { | 
| 127 | > | LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data); | 
| 128 | > |  | 
| 129 | > | if (ljData != NULL) { | 
| 130 | > | LJParam ljParam = ljData->getData(); | 
| 131 | > | currShape = new Spheric(datom->getPos(), ljParam.sigma/2.0); | 
| 132 |  | } else { | 
| 133 | + | sprintf( painCave.errMsg, | 
| 134 | + | "Can not cast GenericData to LJParam\n"); | 
| 135 | + | painCave.severity = OOPSE_ERROR; | 
| 136 | + | painCave.isFatal = 1; | 
| 137 | + | simError(); | 
| 138 | + | } | 
| 139 | + | } else if (atomType->isEAM()) { | 
| 140 | + | GenericData* data = atomType->getPropertyByName("EAM"); | 
| 141 | + | if (data != NULL) { | 
| 142 | + | EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data); | 
| 143 | + | if (eamData != NULL) { | 
| 144 | + | EAMParam eamParam = eamData->getData(); | 
| 145 | + | currShape = new Spheric(datom->getPos(), eamParam.rcut); | 
| 146 | + | } else { | 
| 147 |  | sprintf( painCave.errMsg, | 
| 148 | < | "Can not cast GenericData to LJParam\n"); | 
| 148 | > | "Can not cast GenericData to EAMParam\n"); | 
| 149 |  | painCave.severity = OOPSE_ERROR; | 
| 150 |  | painCave.isFatal = 1; | 
| 151 |  | simError(); | 
| 152 | < | } | 
| 152 | > | } | 
| 153 |  | } | 
| 154 | < |  | 
| 154 | > | } | 
| 155 |  | } | 
| 156 |  | return currShape; | 
| 157 | < | } | 
| 134 | < | Shape* ShapeBuilder::internalCreateShape(RigidBody* rb) { | 
| 157 | > | } | 
| 158 |  |  | 
| 159 | < | std::vector<Atom*>::iterator ai; | 
| 160 | < | CompositeShape* compositeShape = new CompositeShape; | 
| 161 | < | Atom* atom; | 
| 162 | < | for (atom = rb->beginAtom(ai); atom != NULL; atom = rb->nextAtom(ai)) { | 
| 163 | < | Shape* currShape = NULL; | 
| 164 | < | if (atom->isDirectionalAtom()){ | 
| 165 | < | currShape = internalCreateShape(static_cast<DirectionalAtom*>(atom)); | 
| 166 | < | }else if (atom->isAtom()){ | 
| 167 | < | currShape =  internalCreateShape(static_cast<Atom*>(atom)); | 
| 168 | < | } | 
| 169 | < | if (currShape != NULL) | 
| 170 | < | compositeShape->addShape(currShape); | 
| 171 | < | } | 
| 172 | < |  | 
| 173 | < | return compositeShape; | 
| 159 | > | Shape* ShapeBuilder::internalCreateShape(RigidBody* rb) { | 
| 160 | > |  | 
| 161 | > | std::vector<Atom*>::iterator ai; | 
| 162 | > | CompositeShape* compositeShape = new CompositeShape; | 
| 163 | > | Atom* atom; | 
| 164 | > | for (atom = rb->beginAtom(ai); atom != NULL; atom = rb->nextAtom(ai)) { | 
| 165 | > | Shape* currShape = NULL; | 
| 166 | > | if (atom->isDirectionalAtom()){ | 
| 167 | > | currShape = internalCreateShape(static_cast<DirectionalAtom*>(atom)); | 
| 168 | > | }else if (atom->isAtom()){ | 
| 169 | > | currShape =  internalCreateShape(static_cast<Atom*>(atom)); | 
| 170 | > | } | 
| 171 | > | if (currShape != NULL) | 
| 172 | > | compositeShape->addShape(currShape); | 
| 173 | > | } | 
| 174 | > |  | 
| 175 | > | return compositeShape; | 
| 176 | > | } | 
| 177 |  | } | 
| 152 | – |  | 
| 153 | – | } |