Changes in src/atom.cpp [ad2b411:1b2d30]
- File:
-
- 1 edited
-
src/atom.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/atom.cpp
rad2b411 r1b2d30 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp"8 6 9 7 #include "atom.hpp" … … 16 14 #include "vector.hpp" 17 15 #include "World.hpp" 18 #include "molecule.hpp"19 16 20 17 /************************************* Functions for class atom *************************************/ … … 24 21 */ 25 22 atom::atom() : 26 father(this), sort(&nr), mol(0)23 previous(NULL), next(NULL), father(this), sort(&nr) 27 24 { 28 25 node = &x; // TesselPoint::x can only be referenced from here … … 32 29 */ 33 30 atom::atom(atom *pointer) : 34 ParticleInfo(pointer),father(pointer), sort(&nr) 31 ParticleInfo(pointer), 32 previous(NULL), next(NULL), father(pointer), sort(&nr) 35 33 { 36 34 type = pointer->type; // copy element of atom … … 39 37 FixedIon = pointer->FixedIon; 40 38 node = &x; 41 mol = 0;42 39 }; 43 40 44 41 atom *atom::clone(){ 45 42 atom *res = new atom(this); 43 res->previous=0; 44 res->next=0; 46 45 res->father = this; 47 46 res->sort = &res->nr; … … 51 50 res->FixedIon = FixedIon; 52 51 res->node = &x; 53 res->mol = 0;54 52 World::getInstance().registerAtom(res); 55 53 return res; … … 61 59 atom::~atom() 62 60 { 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 }69 61 }; 70 62 … … 75 67 atom *atom::GetTrueFather() 76 68 { 77 if(father == this){ // top most father is the one that points on itself 78 return this; 79 } 80 else if(!father) { 81 return 0; 82 } 83 else { 84 return father->GetTrueFather(); 85 } 69 atom *walker = this; 70 do { 71 if (walker == walker->father) // top most father is the one that points on itself 72 break; 73 walker = walker->father; 74 } while (walker != NULL); 75 return walker; 86 76 }; 87 77 … … 159 149 * \return true - \a *out present, false - \a *out is NULL 160 150 */ 161 bool atom::OutputArrayIndexed(o fstream * const out, const int *ElementNo, int *AtomNo, const char *comment) const151 bool atom::OutputArrayIndexed(ostream * const out, const int *ElementNo, int *AtomNo, const char *comment) const 162 152 { 163 153 AtomNo[type->Z]++; // increment number … … 236 226 * \param *AtomNo pointer to atom counter that is increased by one 237 227 */ 238 void atom::OutputMPQCLine(o fstream * const out, const Vector *center, int *AtomNo = NULL) const228 void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const 239 229 { 240 230 *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl; … … 315 305 } 316 306 317 atomId_t atom::getId() const{307 atomId_t atom::getId() { 318 308 return id; 319 309 } 320 321 void atom::setMolecule(molecule *_mol){322 // take this atom from the old molecule323 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 310 340 311 atom* NewAtom(atomId_t _id){
Note:
See TracChangeset
for help on using the changeset viewer.
