| 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 | 
+ | 
    } 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) { | 
| 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()); | 
| 111 | 
+ | 
        } else { | 
| 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 | 
  | 
    } | 
| 84 | 
– | 
 | 
| 156 | 
  | 
    return currShape; | 
| 157 | 
< | 
} | 
| 157 | 
> | 
  } | 
| 158 | 
  | 
 | 
| 159 | 
< | 
Shape* ShapeBuilder::internalCreateShape(DirectionalAtom* datom) { | 
| 160 | 
< | 
    AtomType* atomType = datom->getAtomType(); | 
| 161 | 
< | 
    Shape* currShape = NULL; | 
| 162 | 
< | 
    if (atomType->isGayBerne()) { | 
| 163 | 
< | 
        DirectionalAtomType* dAtomType = dynamic_cast<DirectionalAtomType*>(atomType); | 
| 164 | 
< | 
 | 
| 165 | 
< | 
        GenericData* data = dAtomType->getPropertyByName("GayBerne"); | 
| 166 | 
< | 
        if (data != NULL) { | 
| 167 | 
< | 
            GayBerneParamGenericData* gayBerneData = dynamic_cast<GayBerneParamGenericData*>(data); | 
| 168 | 
< | 
 | 
| 169 | 
< | 
            if (gayBerneData != NULL) {   | 
| 170 | 
< | 
                GayBerneParam gayBerneParam = gayBerneData->getData(); | 
| 171 | 
< | 
                currShape = new Ellipsoid(datom->getPos(), gayBerneParam.GB_sigma/2.0, gayBerneParam.GB_l2b_ratio*gayBerneParam.GB_sigma/2.0, datom->getA()); | 
| 172 | 
< | 
            } 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 | 
< | 
            } | 
| 108 | 
< | 
        } else { | 
| 109 | 
< | 
          sprintf( painCave.errMsg, "Can not find Parameters for GayBerne\n"); | 
| 110 | 
< | 
          painCave.severity = OOPSE_ERROR; | 
| 111 | 
< | 
          painCave.isFatal = 1; | 
| 112 | 
< | 
          simError();     | 
| 113 | 
< | 
        }             | 
| 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 | 
< | 
    return currShape; | 
| 174 | 
> | 
     | 
| 175 | 
> | 
    return compositeShape; | 
| 176 | 
> | 
  }   | 
| 177 | 
  | 
} | 
| 117 | 
– | 
Shape* ShapeBuilder::internalCreateShape(RigidBody* rb) { | 
| 118 | 
– | 
 | 
| 119 | 
– | 
        std::vector<Atom*>::iterator ai;  | 
| 120 | 
– | 
        CompositeShape* compositeShape = new CompositeShape; | 
| 121 | 
– | 
        Atom* atom; | 
| 122 | 
– | 
        for (atom = rb->beginAtom(ai); atom != NULL; atom = rb->nextAtom(ai)) { | 
| 123 | 
– | 
            Shape* currShape = NULL; | 
| 124 | 
– | 
            if (atom->isDirectionalAtom()){ | 
| 125 | 
– | 
                currShape = internalCreateShape(static_cast<DirectionalAtom*>(atom)); | 
| 126 | 
– | 
            }else if (atom->isAtom()){ | 
| 127 | 
– | 
                currShape =  internalCreateShape(static_cast<Atom*>(atom)); | 
| 128 | 
– | 
            } | 
| 129 | 
– | 
            if (currShape != NULL) | 
| 130 | 
– | 
                compositeShape->addShape(currShape); | 
| 131 | 
– | 
        } | 
| 132 | 
– | 
 | 
| 133 | 
– | 
        return compositeShape; | 
| 134 | 
– | 
} | 
| 135 | 
– | 
 | 
| 136 | 
– | 
} |