Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/atom.cpp

    r321a11 r2319ed  
    1313atom::atom()
    1414{
    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;
     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;
    3131};
     32
     33/** Constructor of class atom.
     34 *
     35 */
     36atom::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
    3251
    3352/** Destructor of class atom.
     
    3554atom::~atom()
    3655{
    37         Free((void **)&Name, "atom::~atom: *Name");
    38         Free((void **)&ComponentNr, "atom::~atom: *ComponentNr");
     56  Free((void **)&Name, "atom::~atom: *Name");
     57  Free((void **)&ComponentNr, "atom::~atom: *ComponentNr");
    3958};
    4059
     
    4564atom *atom::GetTrueFather()
    4665{
    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;
     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;
    5473};
    5574
     
    6281bool atom::Output(int ElementNo, int AtomNo, ofstream *out, const char *comment) const
    6382{
    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;
     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;
    7796};
    7897
     
    82101bool atom::OutputXYZLine(ofstream *out) const
    83102{
    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;
     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;
    89108};
    90109
    91 ostream & operator << (ostream &ost, const atom &a)
     110ostream & operator << (ostream &ost, const atom &a) 
    92111{
    93         ost << "[" << a.Name << "|" << &a << "]";
    94         return ost;
     112  ost << "[" << a.Name << "|" << &a << "]";
     113  return ost;
    95114};
    96115
     
    99118 * \return true - this one's is smaller, false - not
    100119 */
    101 bool atom::Compare(const atom &ptr)
     120bool atom::Compare(atom &ptr)
    102121{
    103         if (nr < ptr.nr)
    104                 return true;
    105         else
    106                 return false;
     122  if (nr < ptr.nr)
     123    return true;
     124  else
     125    return false;
    107126};
    108127
    109128bool operator < (atom &a, atom &b)
    110129{
    111         return a.Compare(b);
     130  return a.Compare(b);
    112131};
    113132
Note: See TracChangeset for help on using the changeset viewer.