| 45 |  | #include "brains/SimInfo.hpp" | 
| 46 |  | namespace OpenMD { | 
| 47 |  | SelectionManager::SelectionManager(SimInfo* info) : info_(info){ | 
| 48 | + | nObjects_.push_back(info_->getNGlobalAtoms()+info_->getNGlobalRigidBodies()); | 
| 49 | + | nObjects_.push_back(info_->getNGlobalBonds()); | 
| 50 | + | nObjects_.push_back(info_->getNGlobalBends()); | 
| 51 | + | nObjects_.push_back(info_->getNGlobalTorsions()); | 
| 52 | + | nObjects_.push_back(info_->getNGlobalInversions()); | 
| 53 |  |  | 
| 54 | < | int nStuntDoubles = info_->getNGlobalAtoms() + info_->getNGlobalRigidBodies(); | 
| 55 | < |  | 
| 56 | < | bsSelection_.resize(nStuntDoubles); | 
| 57 | < | stuntdoubles_.resize(nStuntDoubles, NULL); | 
| 54 | > | stuntdoubles_.resize(nObjects_[STUNTDOUBLE]); | 
| 55 | > | bonds_.resize(nObjects_[BOND]); | 
| 56 | > | bends_.resize(nObjects_[BEND]); | 
| 57 | > | torsions_.resize(nObjects_[TORSION]); | 
| 58 | > | inversions_.resize(nObjects_[INVERSION]); | 
| 59 |  |  | 
| 60 |  | SimInfo::MoleculeIterator mi; | 
| 55 | – | Molecule* mol; | 
| 61 |  | Molecule::AtomIterator ai; | 
| 57 | – | Atom* atom; | 
| 62 |  | Molecule::RigidBodyIterator rbIter; | 
| 63 | + | Molecule::BondIterator bondIter; | 
| 64 | + | Molecule::BendIterator bendIter; | 
| 65 | + | Molecule::TorsionIterator torsionIter; | 
| 66 | + | Molecule::InversionIterator inversionIter; | 
| 67 | + |  | 
| 68 | + | Molecule* mol; | 
| 69 | + | Atom* atom; | 
| 70 |  | RigidBody* rb; | 
| 71 | < |  | 
| 71 | > | Bond* bond; | 
| 72 | > | Bend* bend; | 
| 73 | > | Torsion* torsion; | 
| 74 | > | Inversion* inversion; | 
| 75 | > |  | 
| 76 |  | for (mol = info_->beginMolecule(mi); mol != NULL; | 
| 77 |  | mol = info_->nextMolecule(mi)) { | 
| 78 | < |  | 
| 78 | > |  | 
| 79 |  | for(atom = mol->beginAtom(ai); atom != NULL; | 
| 80 |  | atom = mol->nextAtom(ai)) { | 
| 81 |  | stuntdoubles_[atom->getGlobalIndex()] = atom; | 
| 82 | < | } | 
| 68 | < |  | 
| 82 | > | } | 
| 83 |  | for (rb = mol->beginRigidBody(rbIter); rb != NULL; | 
| 84 |  | rb = mol->nextRigidBody(rbIter)) { | 
| 85 |  | stuntdoubles_[rb->getGlobalIndex()] = rb; | 
| 86 |  | } | 
| 87 | + | for (bond = mol->beginBond(bondIter); bond != NULL; | 
| 88 | + | bond = mol->nextBond(bondIter)) { | 
| 89 | + | bonds_[bond->getGlobalIndex()] = bond; | 
| 90 | + | } | 
| 91 | + | for (bend = mol->beginBend(bendIter); bend != NULL; | 
| 92 | + | bend = mol->nextBend(bendIter)) { | 
| 93 | + | bends_[bend->getGlobalIndex()] = bend; | 
| 94 | + | } | 
| 95 | + | for (torsion = mol->beginTorsion(torsionIter); torsion != NULL; | 
| 96 | + | torsion = mol->nextTorsion(torsionIter)) { | 
| 97 | + | torsions_[torsion->getGlobalIndex()] = torsion; | 
| 98 | + | } | 
| 99 | + | for (inversion = mol->beginInversion(inversionIter); inversion != NULL; | 
| 100 | + | inversion = mol->nextInversion(inversionIter)) { | 
| 101 | + | inversions_[inversion->getGlobalIndex()] = inversion; | 
| 102 | + | } | 
| 103 |  | } | 
| 104 |  | } | 
| 105 |  |  | 
| 106 |  | StuntDouble* SelectionManager::beginSelected(int& i) { | 
| 107 | < | i = bsSelection_.firstOnBit(); | 
| 107 | > | i = ss_.bitsets_[STUNTDOUBLE].firstOnBit(); | 
| 108 |  | return i == -1 ? NULL : stuntdoubles_[i]; | 
| 109 |  | } | 
| 110 |  |  | 
| 111 |  | StuntDouble* SelectionManager::nextSelected(int& i) { | 
| 112 | < | i = bsSelection_.nextOnBit(i); | 
| 112 | > | i = ss_.bitsets_[STUNTDOUBLE].nextOnBit(i); | 
| 113 |  | return i == -1 ? NULL : stuntdoubles_[i]; | 
| 114 |  | } | 
| 115 |  |  | 
| 116 |  | StuntDouble* SelectionManager::beginUnselected(int& i){ | 
| 117 | < | i = bsSelection_.firstOffBit(); | 
| 117 | > | i = ss_.bitsets_[STUNTDOUBLE].firstOffBit(); | 
| 118 |  | return i == -1 ? NULL : stuntdoubles_[i]; | 
| 119 |  | } | 
| 120 |  |  | 
| 121 |  | StuntDouble* SelectionManager::nextUnSelected(int& i) { | 
| 122 | < | i = bsSelection_.nextOffBit(i); | 
| 122 | > | i = ss_.bitsets_[STUNTDOUBLE].nextOffBit(i); | 
| 123 |  | return i == -1 ? NULL : stuntdoubles_[i]; | 
| 124 |  | } | 
| 125 |  |  | 
| 126 | + | Bond* SelectionManager::beginSelectedBond(int& i) { | 
| 127 | + | i = ss_.bitsets_[BOND].firstOnBit(); | 
| 128 | + | return i == -1 ? NULL : bonds_[i]; | 
| 129 | + | } | 
| 130 | + |  | 
| 131 | + | Bond* SelectionManager::nextSelectedBond(int& i) { | 
| 132 | + | i = ss_.bitsets_[BOND].nextOnBit(i); | 
| 133 | + | return i == -1 ? NULL : bonds_[i]; | 
| 134 | + | } | 
| 135 | + |  | 
| 136 | + | Bond* SelectionManager::beginUnselectedBond(int& i){ | 
| 137 | + | i = ss_.bitsets_[BOND].firstOffBit(); | 
| 138 | + | return i == -1 ? NULL : bonds_[i]; | 
| 139 | + | } | 
| 140 | + |  | 
| 141 | + | Bond* SelectionManager::nextUnSelectedBond(int& i) { | 
| 142 | + | i = ss_.bitsets_[BOND].nextOffBit(i); | 
| 143 | + | return i == -1 ? NULL : bonds_[i]; | 
| 144 | + | } | 
| 145 | + |  | 
| 146 | + | Bend* SelectionManager::beginSelectedBend(int& i) { | 
| 147 | + | i = ss_.bitsets_[BEND].firstOnBit(); | 
| 148 | + | return i == -1 ? NULL : bends_[i]; | 
| 149 | + | } | 
| 150 | + |  | 
| 151 | + | Bend* SelectionManager::nextSelectedBend(int& i) { | 
| 152 | + | i = ss_.bitsets_[BEND].nextOnBit(i); | 
| 153 | + | return i == -1 ? NULL : bends_[i]; | 
| 154 | + | } | 
| 155 | + |  | 
| 156 | + | Bend* SelectionManager::beginUnselectedBend(int& i){ | 
| 157 | + | i = ss_.bitsets_[BEND].firstOffBit(); | 
| 158 | + | return i == -1 ? NULL : bends_[i]; | 
| 159 | + | } | 
| 160 | + |  | 
| 161 | + | Bend* SelectionManager::nextUnSelectedBend(int& i) { | 
| 162 | + | i = ss_.bitsets_[BEND].nextOffBit(i); | 
| 163 | + | return i == -1 ? NULL : bends_[i]; | 
| 164 | + | } | 
| 165 | + |  | 
| 166 | + | Torsion* SelectionManager::beginSelectedTorsion(int& i) { | 
| 167 | + | i = ss_.bitsets_[TORSION].firstOnBit(); | 
| 168 | + | return i == -1 ? NULL : torsions_[i]; | 
| 169 | + | } | 
| 170 | + |  | 
| 171 | + | Torsion* SelectionManager::nextSelectedTorsion(int& i) { | 
| 172 | + | i = ss_.bitsets_[TORSION].nextOnBit(i); | 
| 173 | + | return i == -1 ? NULL : torsions_[i]; | 
| 174 | + | } | 
| 175 | + |  | 
| 176 | + | Torsion* SelectionManager::beginUnselectedTorsion(int& i){ | 
| 177 | + | i = ss_.bitsets_[TORSION].firstOffBit(); | 
| 178 | + | return i == -1 ? NULL : torsions_[i]; | 
| 179 | + | } | 
| 180 | + |  | 
| 181 | + | Torsion* SelectionManager::nextUnSelectedTorsion(int& i) { | 
| 182 | + | i = ss_.bitsets_[TORSION].nextOffBit(i); | 
| 183 | + | return i == -1 ? NULL : torsions_[i]; | 
| 184 | + | } | 
| 185 | + |  | 
| 186 | + | Inversion* SelectionManager::beginSelectedInversion(int& i) { | 
| 187 | + | i = ss_.bitsets_[INVERSION].firstOnBit(); | 
| 188 | + | return i == -1 ? NULL : inversions_[i]; | 
| 189 | + | } | 
| 190 | + |  | 
| 191 | + | Inversion* SelectionManager::nextSelectedInversion(int& i) { | 
| 192 | + | i = ss_.bitsets_[INVERSION].nextOnBit(i); | 
| 193 | + | return i == -1 ? NULL : inversions_[i]; | 
| 194 | + | } | 
| 195 | + |  | 
| 196 | + | Inversion* SelectionManager::beginUnselectedInversion(int& i){ | 
| 197 | + | i = ss_.bitsets_[INVERSION].firstOffBit(); | 
| 198 | + | return i == -1 ? NULL : inversions_[i]; | 
| 199 | + | } | 
| 200 | + |  | 
| 201 | + | Inversion* SelectionManager::nextUnSelectedInversion(int& i) { | 
| 202 | + | i = ss_.bitsets_[INVERSION].nextOffBit(i); | 
| 203 | + | return i == -1 ? NULL : inversions_[i]; | 
| 204 | + | } | 
| 205 | + |  | 
| 206 |  | SelectionManager operator| (const SelectionManager& sman1, | 
| 207 |  | const SelectionManager& sman2) { | 
| 208 |  | SelectionManager result(sman1); |