Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/atom.cpp

    r357fba r321a11  
    55 */
    66
    7 #include "atom.hpp"
     7#include "molecules.hpp"
    88
    99/************************************* Functions for class atom *************************************/
     
    1313atom::atom()
    1414{
    15   father = this;  // generally, father is itself
    16   previous = NULL;
    17   next = NULL;
    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;
    3131};
    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 itself
    41   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 atom
    50   x.CopyVector(&pointer->x); // copy coordination
    51   v.CopyVector(&pointer->v); // copy velocity
    52   FixedIon = pointer->FixedIon;
    53   nr = -1;
    54   sort = &nr;
    55 }
    56 
    5732
    5833/** Destructor of class atom.
     
    6035atom::~atom()
    6136{
    62   Free((void **)&ComponentNr, "atom::~atom: *ComponentNr");
     37        Free((void **)&Name, "atom::~atom: *Name");
     38        Free((void **)&ComponentNr, "atom::~atom: *ComponentNr");
    6339};
    6440
     
    6945atom *atom::GetTrueFather()
    7046{
    71   atom *walker = this;
    72   do {
    73     if (walker == walker->father) // top most father is the one that points on itself
    74       break;
    75     walker = walker->father;
    76   } while (walker != NULL);
    77   return walker;
     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;
    7854};
    7955
     
    8662bool atom::Output(int ElementNo, int AtomNo, ofstream *out, const char *comment) const
    8763{
    88   if (out != NULL) {
    89     *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t"  << fixed << setprecision(9) << showpoint;
    90     *out << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2];
    91     *out << "\t" << FixedIon;
    92     if (v.Norm() > MYEPSILON)
    93       *out << "\t" << scientific << setprecision(6) << v.x[0] << "\t" << v.x[1] << "\t" << v.x[2] << "\t";
    94     if (comment != NULL)
    95       *out << " # " << comment << endl;
    96     else
    97       *out << " # molecule nr " << nr << endl;
    98     return true;
    99   } else
    100     return false;
     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;
    10177};
    10278
     
    10682bool atom::OutputXYZLine(ofstream *out) const
    10783{
    108   if (out != NULL) {
    109     *out << type->symbol << "\t" << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2] << "\t" << endl;
    110     return true;
    111   } else
    112     return false;
     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;
    11389};
    11490
    115 ostream & operator << (ostream &ost, const atom &a) 
     91ostream & operator << (ostream &ost, const atom &a)
    11692{
    117   ost << "[" << a.Name << "|" << &a << "]";
    118   return ost;
     93        ost << "[" << a.Name << "|" << &a << "]";
     94        return ost;
    11995};
    12096
     
    12399 * \return true - this one's is smaller, false - not
    124100 */
    125 bool atom::Compare(atom &ptr)
     101bool atom::Compare(const atom &ptr)
    126102{
    127   if (nr < ptr.nr)
    128     return true;
    129   else
    130     return false;
     103        if (nr < ptr.nr)
     104                return true;
     105        else
     106                return false;
    131107};
    132108
    133109bool operator < (atom &a, atom &b)
    134110{
    135   return a.Compare(b);
     111        return a.Compare(b);
    136112};
    137113
Note: See TracChangeset for help on using the changeset viewer.