Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule.cpp

    r2ba827 r24a5e0  
    88#include <boost/bind.hpp>
    99
     10#include "World.hpp"
    1011#include "atom.hpp"
    1112#include "bond.hpp"
     
    3031 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
    3132 */
    32 molecule::molecule(const periodentafel * const teil) : elemente(teil), start(new atom), end(new atom),
     33molecule::molecule(const periodentafel * const teil) : elemente(teil), start(World::get()->createAtom()), end(World::get()->createAtom()),
    3334  first(new bond(start, end, 1, -1)), last(new bond(start, end, 1, -1)), MDSteps(0), AtomCount(0),
    3435  BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.),
    35   ActiveFlag(false), IndexNr(-1), last_atom(0), InternalPointer(start),
    36   formula(this,boost::bind(&molecule::calcFormula,this))
     36  ActiveFlag(false), IndexNr(-1),
     37  formula(this,boost::bind(&molecule::calcFormula,this)),
     38  last_atom(0),
     39  InternalPointer(start)
    3740{
    3841  // init atom chain list
     
    5255};
    5356
     57molecule *NewMolecule(){
     58  return new molecule(World::get()->getPeriode());
     59}
     60
    5461/** Destructor of class molecule.
    5562 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
     
    6067  delete(first);
    6168  delete(last);
    62   delete(end);
    63   delete(start);
    64 };
    65 
     69  end->getWorld()->destroyAtom(end);
     70  start->getWorld()->destroyAtom(start);
     71};
     72
     73
     74void DeleteMolecule(molecule *mol){
     75  delete mol;
     76}
    6677
    6778// getter and setter
     
    7384  OBSERVE;
    7485  strncpy(name,_name.c_str(),MAXSTRINGSIZE);
     86}
     87
     88moleculeId_t molecule::getId(){
     89  return id;
     90}
     91
     92void molecule::setId(moleculeId_t _id){
     93  id =_id;
    7594}
    7695
     
    135154  OBSERVE;
    136155  if (pointer != NULL) {
    137     atom *walker = new atom(pointer);
     156    atom *walker = pointer->clone();
    138157    walker->Name = Malloc<char>(strlen(pointer->Name) + 1, "atom::atom: *Name");
    139158    strcpy (walker->Name, pointer->Name);
     
    242261  switch(TopBond->BondDegree) {
    243262    case 1:
    244       FirstOtherAtom = new atom();    // new atom
     263      FirstOtherAtom = World::get()->createAtom();    // new atom
    245264      FirstOtherAtom->type = elemente->FindElement(1);  // element is Hydrogen
    246265      FirstOtherAtom->v.CopyVector(&TopReplacement->v); // copy velocity
     
    299318
    300319      // create the two Hydrogens ...
    301       FirstOtherAtom = new atom();
    302       SecondOtherAtom = new atom();
     320      FirstOtherAtom = World::get()->createAtom();
     321      SecondOtherAtom = World::get()->createAtom();
    303322      FirstOtherAtom->type = elemente->FindElement(1);
    304323      SecondOtherAtom->type = elemente->FindElement(1);
     
    354373    case 3:
    355374      // take the "usual" tetraoidal angle and add the three Hydrogen in direction of the bond (height of the tetraoid)
    356       FirstOtherAtom = new atom();
    357       SecondOtherAtom = new atom();
    358       ThirdOtherAtom = new atom();
     375      FirstOtherAtom = World::get()->createAtom();
     376      SecondOtherAtom = World::get()->createAtom();
     377      ThirdOtherAtom = World::get()->createAtom();
    359378      FirstOtherAtom->type = elemente->FindElement(1);
    360379      SecondOtherAtom->type = elemente->FindElement(1);
     
    475494    MDSteps++;
    476495  for(i=0;i<NumberOfAtoms;i++){
    477     Walker = new atom;
     496    Walker = World::get()->createAtom();
    478497    getline(xyzfile,line,'\n');
    479498    istringstream *item = new istringstream(line);
Note: See TracChangeset for help on using the changeset viewer.