Changes in src/bond.cpp [6ac7ee:ce5ac3]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/bond.cpp
r6ac7ee rce5ac3 14 14 bond::bond() 15 15 { 16 17 18 19 20 21 22 23 24 25 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; 26 26 }; 27 27 … … 34 34 bond::bond(atom *left, atom *right, int degree=1, int number=0) 35 35 { 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 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; 51 51 }; 52 52 bond::bond(atom *left, atom *right) 53 53 { 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 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; 69 69 }; 70 70 … … 73 73 bond::~bond() 74 74 { 75 76 77 78 79 80 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 } 82 82 }; 83 83 84 ostream & operator << (ostream &ost, bond &b)84 ostream & operator << (ostream &ost, const bond &b) 85 85 { 86 87 86 ost << "[" << b.leftatom->Name << " <" << b.BondDegree << "(H" << b.HydrogenBond << ")>" << b.rightatom->Name << "]"; 87 return ost; 88 88 }; 89 89 … … 94 94 atom * bond::GetOtherAtom(atom *Atom) const 95 95 { 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; 101 102 }; 102 103 … … 107 108 bond * bond::GetFirstBond() 108 109 { 109 110 return GetFirst(this); 110 111 }; 111 112 … … 116 117 bond * bond::GetLastBond() 117 118 { 118 119 return GetLast(this); 119 120 }; 120 121 … … 124 125 enum Shading bond::IsUsed() 125 126 { 126 127 return Used; 127 128 }; 128 129 … … 133 134 bool bond::Contains(const atom *ptr) 134 135 { 135 136 return ((leftatom == ptr) || (rightatom == ptr)); 136 137 }; 137 138 … … 142 143 bool bond::Contains(const int number) 143 144 { 144 145 return ((leftatom->nr == number) || (rightatom->nr == number)); 145 146 }; 146 147 … … 149 150 */ 150 151 bool bond::MarkUsed(enum Shading color) { 151 152 153 154 155 156 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 } 158 159 }; 159 160 … … 162 163 */ 163 164 void bond::ResetUsed() { 164 165 Used = white; 165 166 };
Note:
See TracChangeset
for help on using the changeset viewer.