Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/atom.cpp

    ra80241 r215df0  
    44 *
    55 */
    6 
    7 #include "Helpers/MemDebug.hpp"
    86
    97#include "atom.hpp"
     
    1614#include "vector.hpp"
    1715#include "World.hpp"
    18 #include "molecule.hpp"
    1916
    2017/************************************* Functions for class atom *************************************/
     
    2421 */
    2522atom::atom() :
    26   father(this), sort(&nr), mol(0)
     23  previous(NULL), next(NULL), father(this), sort(&nr)
    2724{
    2825  node = &x;  // TesselPoint::x can only be referenced from here
     
    3229 */
    3330atom::atom(atom *pointer) :
    34     ParticleInfo(pointer),father(pointer), sort(&nr)
     31    ParticleInfo(pointer),
     32    previous(NULL), next(NULL), father(pointer), sort(&nr)
    3533{
    3634  type = pointer->type;  // copy element of atom
     
    3937  FixedIon = pointer->FixedIon;
    4038  node = &x;
    41   mol = 0;
    4239};
    4340
    4441atom *atom::clone(){
    4542  atom *res = new atom(this);
     43  res->previous=0;
     44  res->next=0;
    4645  res->father = this;
    4746  res->sort = &res->nr;
     
    5150  res->FixedIon = FixedIon;
    5251  res->node = &x;
    53   res->mol = 0;
    5452  World::getInstance().registerAtom(res);
    5553  return res;
     
    6159atom::~atom()
    6260{
    63   removeFromMolecule();
    64   for(BondList::iterator iter=ListOfBonds.begin(); iter!=ListOfBonds.end();){
    65     // deleting the bond will invalidate the iterator !!!
    66     bond *bond =*(iter++);
    67     delete(bond);
    68   }
     61  unlink(this);
    6962};
    7063
     
    279272{
    280273  if (ComponentNr != NULL)
    281     delete[](ComponentNr);
    282   ComponentNr = new int[ListOfBonds.size()+1];
     274    Free(&ComponentNr);
     275  ComponentNr = Malloc<int>(ListOfBonds.size()+1, "atom::InitComponentNumbers: *ComponentNr");
    283276  for (int i=ListOfBonds.size()+1;i--;)
    284277    ComponentNr[i] = -1;
     
    319312}
    320313
    321 void atom::setMolecule(molecule *_mol){
    322   // take this atom from the old molecule
    323   removeFromMolecule();
    324   mol = _mol;
    325   if(!mol->containsAtom(this)){
    326     mol->AddAtom(this);
    327   }
    328 }
    329 
    330 void atom::removeFromMolecule(){
    331   if(mol){
    332     if(mol->containsAtom(this)){
    333       mol->erase(this);
    334     }
    335     mol=0;
    336   }
    337 }
    338 
    339 
    340314atom* NewAtom(atomId_t _id){
    341315  atom * res =new atom();
Note: See TracChangeset for help on using the changeset viewer.