Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/bond.cpp

    r6ac7ee rce5ac3  
    1414bond::bond()
    1515{
    16         leftatom = NULL;
    17         rightatom = NULL;
    18         previous = NULL;
    19         next = NULL;
    20         nr = -1;
    21         HydrogenBond = 0;
    22         BondDegree = 0;
    23         Used = white;
    24         Cyclic = false;
    25         Type = Undetermined;
     16  leftatom = NULL;
     17  rightatom = NULL;
     18  previous = NULL;
     19  next = NULL;
     20  nr = -1;
     21  HydrogenBond = 0;
     22  BondDegree = 0;
     23  Used = white;
     24  Cyclic = false;
     25  Type = Undetermined;
    2626};
    2727
     
    3434bond::bond(atom *left, atom *right, int degree=1, int number=0)
    3535{
    36         leftatom = left;
    37         rightatom = right;
    38         previous = NULL;
    39         next = NULL;
    40         HydrogenBond = 0;
    41         if ((left != NULL) && (right != NULL)) {
    42                 if ((left->type != NULL) && (left->type->Z == 1))
    43                         HydrogenBond++;
    44                 if ((right->type != NULL) && (right->type->Z == 1))
    45                         HydrogenBond++;
    46         }
    47         BondDegree = degree;
    48         nr = number;
    49         Used = white;
    50         Cyclic = false;
     36  leftatom = left;
     37  rightatom = right;
     38  previous = NULL;
     39  next = NULL;
     40  HydrogenBond = 0;
     41  if ((left != NULL) && (right != NULL)) {
     42    if ((left->type != NULL) && (left->type->Z == 1))
     43      HydrogenBond++;
     44    if ((right->type != NULL) && (right->type->Z == 1))
     45      HydrogenBond++;
     46  }
     47  BondDegree = degree;
     48  nr = number;
     49  Used = white;
     50  Cyclic = false;
    5151};
    5252bond::bond(atom *left, atom *right)
    5353{
    54         leftatom = left;
    55         rightatom = right;
    56         previous = NULL;
    57         next = NULL;
    58         HydrogenBond = 0;
    59         if ((left != NULL) && (right != NULL)) {
    60                 if ((left->type != NULL) && (left->type->Z == 1))
    61                         HydrogenBond++;
    62                 if ((right->type != NULL) && (right->type->Z == 1))
    63                         HydrogenBond++;
    64         }
    65         BondDegree = 1;
    66         nr = 0;
    67         Used = white;
    68         Cyclic = false;
     54  leftatom = left;
     55  rightatom = right;
     56  previous = NULL;
     57  next = NULL;
     58  HydrogenBond = 0;
     59  if ((left != NULL) && (right != NULL)) {
     60    if ((left->type != NULL) && (left->type->Z == 1))
     61      HydrogenBond++;
     62    if ((right->type != NULL) && (right->type->Z == 1))
     63      HydrogenBond++;
     64  }
     65  BondDegree = 1;
     66  nr = 0;
     67  Used = white;
     68  Cyclic = false;
    6969};
    7070
     
    7373bond::~bond()
    7474{
    75         // remove this node from the list structure
    76         if (previous != NULL) {
    77                 previous->next = next;
    78         }
    79         if (next != NULL) {
    80                 next->previous = previous;
    81         }
     75  // remove this node from the list structure
     76  if (previous != NULL) {
     77    previous->next = next;
     78  }
     79  if (next != NULL) {
     80    next->previous = previous;
     81  }
    8282};
    8383
    84 ostream & operator << (ostream &ost, bond &b)
     84ostream & operator << (ostream &ost, const bond &b)
    8585{
    86         ost << "[" << b.leftatom->Name << " <" << b.BondDegree << "(H" << b.HydrogenBond << ")>" << b.rightatom->Name << "]";
    87         return ost;
     86  ost << "[" << b.leftatom->Name << " <" << b.BondDegree << "(H" << b.HydrogenBond << ")>" << b.rightatom->Name << "]";
     87  return ost;
    8888};
    8989
     
    9494atom * bond::GetOtherAtom(atom *Atom) const
    9595{
    96         if(leftatom == Atom)
    97                 return rightatom;
    98         if(rightatom == Atom)
    99                 return leftatom;
    100         return NULL;
     96  if(leftatom == Atom)
     97    return rightatom;
     98  if(rightatom == Atom)
     99    return leftatom;
     100  cerr << "Bond " << *this << " does not contain atom " << *Atom << "!" << endl;
     101  return NULL;
    101102};
    102103
     
    107108bond * bond::GetFirstBond()
    108109{
    109         return GetFirst(this);
     110  return GetFirst(this);
    110111};
    111112
     
    116117bond * bond::GetLastBond()
    117118{
    118         return GetLast(this);
     119  return GetLast(this);
    119120};
    120121
     
    124125enum Shading bond::IsUsed()
    125126{
    126         return Used;
     127  return Used;
    127128};
    128129
     
    133134bool bond::Contains(const atom *ptr)
    134135{
    135         return ((leftatom == ptr) || (rightatom == ptr));
     136  return ((leftatom == ptr) || (rightatom == ptr));
    136137};
    137138
     
    142143bool bond::Contains(const int number)
    143144{
    144         return ((leftatom->nr == number) || (rightatom->nr == number));
     145  return ((leftatom->nr == number) || (rightatom->nr == number));
    145146};
    146147
     
    149150 */
    150151bool bond::MarkUsed(enum Shading color) {
    151         if (Used == black) {
    152                 cerr << "ERROR: Bond " << this << " was already marked black!." << endl;
    153                 return false;
    154         } else {
    155                 Used = color;
    156                 return true;
    157         }
     152  if (Used == black) {
     153    cerr << "ERROR: Bond " << this << " was already marked black!." << endl;
     154    return false;
     155  } else {
     156    Used = color;
     157    return true;
     158  }
    158159};
    159160
     
    162163 */
    163164void bond::ResetUsed() {
    164         Used = white;
     165  Used = white;
    165166};
Note: See TracChangeset for help on using the changeset viewer.