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