Changes in src/atom.cpp [321a11:2319ed]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/atom.cpp
r321a11 r2319ed 13 13 atom::atom() 14 14 { 15 16 17 18 father = this;// generally, father is itself19 20 21 22 23 24 25 26 27 28 29 30 15 Name = NULL; 16 previous = NULL; 17 next = NULL; 18 father = this; // generally, father is itself 19 Ancestor = NULL; 20 type = NULL; 21 sort = NULL; 22 FixedIon = 0; 23 nr = -1; 24 GraphNr = -1; 25 ComponentNr = NULL; 26 IsCyclic = false; 27 SeparationVertex = false; 28 LowpointNr = -1; 29 AdaptiveOrder = 0; 30 MaxOrder = false; 31 31 }; 32 33 /** Constructor of class atom. 34 * 35 */ 36 atom::atom(atom *pointer) 37 { 38 Name = NULL; 39 previous = NULL; 40 next = NULL; 41 father = this; // generally, father is itself 42 Ancestor = NULL; 43 type = pointer->type; // copy element of atom 44 x.CopyVector(&pointer->x); // copy coordination 45 v.CopyVector(&pointer->v); // copy velocity 46 FixedIon = pointer->FixedIon; 47 nr = -1; 48 sort = &nr; 49 } 50 32 51 33 52 /** Destructor of class atom. … … 35 54 atom::~atom() 36 55 { 37 38 56 Free((void **)&Name, "atom::~atom: *Name"); 57 Free((void **)&ComponentNr, "atom::~atom: *ComponentNr"); 39 58 }; 40 59 … … 45 64 atom *atom::GetTrueFather() 46 65 { 47 48 49 50 51 52 53 66 atom *walker = this; 67 do { 68 if (walker == walker->father) // top most father is the one that points on itself 69 break; 70 walker = walker->father; 71 } while (walker != NULL); 72 return walker; 54 73 }; 55 74 … … 62 81 bool atom::Output(int ElementNo, int AtomNo, ofstream *out, const char *comment) const 63 82 { 64 65 *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t"<< fixed << setprecision(9) << showpoint;66 67 68 69 70 71 72 73 74 75 76 83 if (out != NULL) { 84 *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t" << fixed << setprecision(9) << showpoint; 85 *out << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2]; 86 *out << "\t" << FixedIon; 87 if (v.Norm() > MYEPSILON) 88 *out << "\t" << scientific << setprecision(6) << v.x[0] << "\t" << v.x[1] << "\t" << v.x[2] << "\t"; 89 if (comment != NULL) 90 *out << " # " << comment << endl; 91 else 92 *out << " # molecule nr " << nr << endl; 93 return true; 94 } else 95 return false; 77 96 }; 78 97 … … 82 101 bool atom::OutputXYZLine(ofstream *out) const 83 102 { 84 85 86 87 88 103 if (out != NULL) { 104 *out << type->symbol << "\t" << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2] << "\t" << endl; 105 return true; 106 } else 107 return false; 89 108 }; 90 109 91 ostream & operator << (ostream &ost, const atom &a) 110 ostream & operator << (ostream &ost, const atom &a) 92 111 { 93 94 112 ost << "[" << a.Name << "|" << &a << "]"; 113 return ost; 95 114 }; 96 115 … … 99 118 * \return true - this one's is smaller, false - not 100 119 */ 101 bool atom::Compare( constatom &ptr)120 bool atom::Compare(atom &ptr) 102 121 { 103 104 105 106 122 if (nr < ptr.nr) 123 return true; 124 else 125 return false; 107 126 }; 108 127 109 128 bool operator < (atom &a, atom &b) 110 129 { 111 130 return a.Compare(b); 112 131 }; 113 132
Note:
See TracChangeset
for help on using the changeset viewer.