| 35 |
|
* |
| 36 |
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
| 37 |
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
| 38 |
< |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
| 39 |
< |
* [4] Vardeman & Gezelter, in progress (2009). |
| 38 |
> |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |
| 39 |
> |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
| 40 |
> |
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
| 41 |
|
*/ |
| 42 |
|
|
| 43 |
|
#ifndef SELECTION_SELECTIONMANAGER_HPP |
| 44 |
|
#define SELECTION_SELECTIONMANAGER_HPP |
| 45 |
|
|
| 46 |
< |
#include "utils/OpenMDBitSet.hpp" |
| 46 |
> |
#include "selection/SelectionSet.hpp" |
| 47 |
|
#include "primitives/StuntDouble.hpp" |
| 48 |
+ |
#include "primitives/Bond.hpp" |
| 49 |
+ |
#include "primitives/Bend.hpp" |
| 50 |
+ |
#include "primitives/Torsion.hpp" |
| 51 |
+ |
#include "primitives/Inversion.hpp" |
| 52 |
+ |
#include "primitives/Molecule.hpp" |
| 53 |
+ |
|
| 54 |
|
namespace OpenMD { |
| 55 |
|
|
| 56 |
|
class SimInfo; |
| 50 |
– |
/** |
| 51 |
– |
* @class SelectionManager SelectionManager.hpp "selection/SelectionManager.hpp" |
| 52 |
– |
* @brief |
| 53 |
– |
*/ |
| 57 |
|
class SelectionManager { |
| 58 |
|
public: |
| 59 |
|
SelectionManager(SimInfo* info); |
| 60 |
|
|
| 61 |
< |
void addSelection(StuntDouble* sd) { |
| 62 |
< |
bsSelection_.setBitOn(sd->getGlobalIndex()); |
| 61 |
> |
void addSelection(StuntDouble* sd) { |
| 62 |
> |
ss_.bitsets_[STUNTDOUBLE].setBitOn(sd->getGlobalIndex()); |
| 63 |
|
} |
| 64 |
+ |
void addSelection(Bond* b) { |
| 65 |
+ |
ss_.bitsets_[BOND].setBitOn(b->getGlobalIndex()); |
| 66 |
+ |
} |
| 67 |
+ |
void addSelection(Bend* b) { |
| 68 |
+ |
ss_.bitsets_[BEND].setBitOn(b->getGlobalIndex()); |
| 69 |
+ |
} |
| 70 |
+ |
void addSelection(Torsion* t) { |
| 71 |
+ |
ss_.bitsets_[TORSION].setBitOn(t->getGlobalIndex()); |
| 72 |
+ |
} |
| 73 |
+ |
void addSelection(Inversion* i) { |
| 74 |
+ |
ss_.bitsets_[INVERSION].setBitOn(i->getGlobalIndex()); |
| 75 |
+ |
} |
| 76 |
+ |
void addSelection(Molecule* m) { |
| 77 |
+ |
ss_.bitsets_[MOLECULE].setBitOn(m->getGlobalIndex()); |
| 78 |
+ |
} |
| 79 |
|
|
| 80 |
< |
void addSelectionSet(const OpenMDBitSet& bs) { |
| 81 |
< |
bsSelection_ |= bs; |
| 80 |
> |
void addSelectionSet(const SelectionSet& bs) { |
| 81 |
> |
ss_.bitsets_[STUNTDOUBLE] |= bs.bitsets_[STUNTDOUBLE]; |
| 82 |
|
} |
| 83 |
+ |
void addBondSelectionSet(const SelectionSet& bs) { |
| 84 |
+ |
ss_.bitsets_[BOND] |= bs.bitsets_[BOND]; |
| 85 |
+ |
} |
| 86 |
+ |
void addBendSelectionSet(const SelectionSet& bs) { |
| 87 |
+ |
ss_.bitsets_[BEND] |= bs.bitsets_[BEND]; |
| 88 |
+ |
} |
| 89 |
+ |
void addTorsionSelectionSet(const SelectionSet& bs) { |
| 90 |
+ |
ss_.bitsets_[TORSION] |= bs.bitsets_[TORSION]; |
| 91 |
+ |
} |
| 92 |
+ |
void addInversionSelectionSet(const SelectionSet& bs) { |
| 93 |
+ |
ss_.bitsets_[INVERSION] |= bs.bitsets_[INVERSION]; |
| 94 |
+ |
} |
| 95 |
+ |
void addMoleculeSelectionSet(const SelectionSet& bs) { |
| 96 |
+ |
ss_.bitsets_[MOLECULE] |= bs.bitsets_[MOLECULE]; |
| 97 |
+ |
} |
| 98 |
|
|
| 99 |
+ |
bool isEmpty() { |
| 100 |
+ |
return ss_.bitsets_[STUNTDOUBLE].none() && ss_.bitsets_[BOND].none() |
| 101 |
+ |
&& ss_.bitsets_[BEND].none() && ss_.bitsets_[TORSION].none() |
| 102 |
+ |
&& ss_.bitsets_[INVERSION].none() && ss_.bitsets_[MOLECULE].none(); |
| 103 |
+ |
} |
| 104 |
+ |
|
| 105 |
+ |
void setSelectionSet(const SelectionSet& bs) { |
| 106 |
+ |
for (int i = 0; i < N_SELECTIONTYPES; i++) |
| 107 |
+ |
ss_.bitsets_[i] = bs.bitsets_[i]; |
| 108 |
+ |
} |
| 109 |
+ |
|
| 110 |
+ |
//void setSelectionSet(const SelectionSet& bs) { |
| 111 |
+ |
// ss_.bitsets_[STUNTDOUBLE] = bs.bitsets_[]; |
| 112 |
+ |
//} |
| 113 |
+ |
void setBondSelectionSet(const SelectionSet& bs) { |
| 114 |
+ |
ss_.bitsets_[BOND] = bs.bitsets_[BOND]; |
| 115 |
+ |
} |
| 116 |
+ |
void setBendSelectionSet(const SelectionSet& bs) { |
| 117 |
+ |
ss_.bitsets_[BEND] = bs.bitsets_[BEND]; |
| 118 |
+ |
} |
| 119 |
+ |
void setTorsionSelectionSet(const SelectionSet& bs) { |
| 120 |
+ |
ss_.bitsets_[TORSION] = bs.bitsets_[TORSION]; |
| 121 |
+ |
} |
| 122 |
+ |
void setInversionSelectionSet(const SelectionSet& bs) { |
| 123 |
+ |
ss_.bitsets_[INVERSION] = bs.bitsets_[INVERSION]; |
| 124 |
+ |
} |
| 125 |
+ |
void setMoleculeSelectionSet(const SelectionSet& bs) { |
| 126 |
+ |
ss_.bitsets_[MOLECULE] = bs.bitsets_[MOLECULE]; |
| 127 |
+ |
} |
| 128 |
+ |
|
| 129 |
+ |
std::vector<int> getSelectionCounts() { |
| 130 |
+ |
std::vector<int> counts(N_SELECTIONTYPES,0); |
| 131 |
+ |
for (int i = 0; i < N_SELECTIONTYPES; i++) { |
| 132 |
+ |
counts[i] = ss_.bitsets_[i].countBits(); |
| 133 |
+ |
} |
| 134 |
+ |
return counts; |
| 135 |
+ |
} |
| 136 |
+ |
|
| 137 |
+ |
int getSelectionCount() { |
| 138 |
+ |
return ss_.bitsets_[STUNTDOUBLE].countBits(); |
| 139 |
+ |
} |
| 140 |
+ |
int getBondSelectionCount() { |
| 141 |
+ |
return ss_.bitsets_[BOND].countBits(); |
| 142 |
+ |
} |
| 143 |
+ |
int getBendSelectionCount() { |
| 144 |
+ |
return ss_.bitsets_[BEND].countBits(); |
| 145 |
+ |
} |
| 146 |
+ |
int getTorsionSelectionCount() { |
| 147 |
+ |
return ss_.bitsets_[TORSION].countBits(); |
| 148 |
+ |
} |
| 149 |
+ |
int getInversionSelectionCount() { |
| 150 |
+ |
return ss_.bitsets_[INVERSION].countBits(); |
| 151 |
+ |
} |
| 152 |
+ |
int getMoleculeSelectionCount() { |
| 153 |
+ |
return ss_.bitsets_[MOLECULE].countBits(); |
| 154 |
+ |
} |
| 155 |
+ |
|
| 156 |
+ |
SelectionSet getSelectionSet() { |
| 157 |
+ |
return ss_; |
| 158 |
+ |
} |
| 159 |
+ |
/* SelectionSet getBondSelectionSet() { |
| 160 |
+ |
return ss_.bitsets_[BOND]; |
| 161 |
+ |
} |
| 162 |
+ |
SelectionSet getBendSelectionSet() { |
| 163 |
+ |
return ss_.bitsets_[BEND]; |
| 164 |
+ |
} |
| 165 |
+ |
SelectionSet getTorsionSelectionSet() { |
| 166 |
+ |
return ss_.bitsets_[TORSION]; |
| 167 |
+ |
} |
| 168 |
+ |
SelectionSet getInversionSelectionSet() { |
| 169 |
+ |
return ss_.bitsets_[INVERSION]; |
| 170 |
+ |
} |
| 171 |
+ |
*/ |
| 172 |
+ |
|
| 173 |
|
void setSelection(StuntDouble* sd) { |
| 174 |
< |
bsSelection_.clearAll(); |
| 175 |
< |
bsSelection_.setBitOn(sd->getGlobalIndex()); |
| 174 |
> |
ss_.bitsets_[STUNTDOUBLE].clearAll(); |
| 175 |
> |
ss_.bitsets_[STUNTDOUBLE].setBitOn(sd->getGlobalIndex()); |
| 176 |
|
} |
| 177 |
< |
|
| 178 |
< |
void setSelectionSet(const OpenMDBitSet& bs) { |
| 179 |
< |
bsSelection_ = bs; |
| 177 |
> |
void setSelection(Bond* b) { |
| 178 |
> |
ss_.bitsets_[BOND].clearAll(); |
| 179 |
> |
ss_.bitsets_[BOND].setBitOn(b->getGlobalIndex()); |
| 180 |
|
} |
| 181 |
+ |
void setSelection(Bend* b) { |
| 182 |
+ |
ss_.bitsets_[BEND].clearAll(); |
| 183 |
+ |
ss_.bitsets_[BEND].setBitOn(b->getGlobalIndex()); |
| 184 |
+ |
} |
| 185 |
+ |
void setSelection(Torsion* t) { |
| 186 |
+ |
ss_.bitsets_[TORSION].clearAll(); |
| 187 |
+ |
ss_.bitsets_[TORSION].setBitOn(t->getGlobalIndex()); |
| 188 |
+ |
} |
| 189 |
+ |
void setSelection(Inversion* i) { |
| 190 |
+ |
ss_.bitsets_[INVERSION].clearAll(); |
| 191 |
+ |
ss_.bitsets_[INVERSION].setBitOn(i->getGlobalIndex()); |
| 192 |
+ |
} |
| 193 |
+ |
void setSelection(Molecule* m) { |
| 194 |
+ |
ss_.bitsets_[MOLECULE].clearAll(); |
| 195 |
+ |
ss_.bitsets_[MOLECULE].setBitOn(m->getGlobalIndex()); |
| 196 |
+ |
} |
| 197 |
|
|
| 198 |
|
void toggleSelection(StuntDouble* sd) { |
| 199 |
< |
bsSelection_.flip(sd->getGlobalIndex()); |
| 199 |
> |
ss_.bitsets_[STUNTDOUBLE].flip(sd->getGlobalIndex()); |
| 200 |
|
} |
| 201 |
+ |
void toggleSelection(Bond* b) { |
| 202 |
+ |
ss_.bitsets_[BOND].flip(b->getGlobalIndex()); |
| 203 |
+ |
} |
| 204 |
+ |
void toggleSelection(Bend* b) { |
| 205 |
+ |
ss_.bitsets_[BEND].flip(b->getGlobalIndex()); |
| 206 |
+ |
} |
| 207 |
+ |
void toggleSelection(Torsion* t) { |
| 208 |
+ |
ss_.bitsets_[TORSION].flip(t->getGlobalIndex()); |
| 209 |
+ |
} |
| 210 |
+ |
void toggleSelection(Inversion* i) { |
| 211 |
+ |
ss_.bitsets_[INVERSION].flip(i->getGlobalIndex()); |
| 212 |
+ |
} |
| 213 |
+ |
void toggleSelection(Molecule* m) { |
| 214 |
+ |
ss_.bitsets_[MOLECULE].flip(m->getGlobalIndex()); |
| 215 |
+ |
} |
| 216 |
|
|
| 217 |
|
void toggleSelection() { |
| 218 |
< |
bsSelection_.flip(); |
| 218 |
> |
for (int i = 0; i < N_SELECTIONTYPES; i++) |
| 219 |
> |
ss_.bitsets_[i].flip(); |
| 220 |
|
} |
| 221 |
|
|
| 222 |
|
void selectAll() { |
| 223 |
< |
bsSelection_.setAll(); |
| 223 |
> |
for (int i = 0; i < N_SELECTIONTYPES; i++) |
| 224 |
> |
ss_.bitsets_[i].setAll(); |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
void clearSelection() { |
| 228 |
< |
bsSelection_.clearAll(); |
| 228 |
> |
for (int i = 0; i < N_SELECTIONTYPES; i++) |
| 229 |
> |
ss_.bitsets_[i].clearAll(); |
| 230 |
|
} |
| 231 |
|
|
| 232 |
|
void clearSelection(StuntDouble* sd) { |
| 233 |
< |
bsSelection_.setBitOff(sd->getGlobalIndex()); |
| 233 |
> |
ss_.bitsets_[STUNTDOUBLE].setBitOff(sd->getGlobalIndex()); |
| 234 |
|
} |
| 235 |
+ |
void clearSelection(Bond* b) { |
| 236 |
+ |
ss_.bitsets_[BOND].setBitOff(b->getGlobalIndex()); |
| 237 |
+ |
} |
| 238 |
+ |
void clearSelection(Bend* b) { |
| 239 |
+ |
ss_.bitsets_[BEND].setBitOff(b->getGlobalIndex()); |
| 240 |
+ |
} |
| 241 |
+ |
void clearSelection(Torsion* t) { |
| 242 |
+ |
ss_.bitsets_[TORSION].setBitOff(t->getGlobalIndex()); |
| 243 |
+ |
} |
| 244 |
+ |
void clearSelection(Inversion* i) { |
| 245 |
+ |
ss_.bitsets_[INVERSION].setBitOff(i->getGlobalIndex()); |
| 246 |
+ |
} |
| 247 |
+ |
void clearSelection(Molecule* m) { |
| 248 |
+ |
ss_.bitsets_[MOLECULE].setBitOff(m->getGlobalIndex()); |
| 249 |
+ |
} |
| 250 |
|
|
| 251 |
|
bool isSelected(StuntDouble* sd) { |
| 252 |
< |
return bsSelection_[sd->getGlobalIndex()]; |
| 252 |
> |
return ss_.bitsets_[STUNTDOUBLE][sd->getGlobalIndex()]; |
| 253 |
|
} |
| 254 |
< |
|
| 255 |
< |
bool isEmpty() { |
| 100 |
< |
return bsSelection_.none(); |
| 254 |
> |
bool isSelected(Bond* b) { |
| 255 |
> |
return ss_.bitsets_[BOND][b->getGlobalIndex()]; |
| 256 |
|
} |
| 257 |
< |
|
| 258 |
< |
int getSelectionCount() { |
| 104 |
< |
return bsSelection_.countBits(); |
| 257 |
> |
bool isSelected(Bend* b) { |
| 258 |
> |
return ss_.bitsets_[BEND][b->getGlobalIndex()]; |
| 259 |
|
} |
| 260 |
< |
|
| 261 |
< |
OpenMDBitSet getSelectionSet() { |
| 108 |
< |
return bsSelection_; |
| 260 |
> |
bool isSelected(Torsion* t) { |
| 261 |
> |
return ss_.bitsets_[TORSION][t->getGlobalIndex()]; |
| 262 |
|
} |
| 263 |
+ |
bool isSelected(Inversion* i) { |
| 264 |
+ |
return ss_.bitsets_[INVERSION][i->getGlobalIndex()]; |
| 265 |
+ |
} |
| 266 |
+ |
bool isSelected(Molecule* m) { |
| 267 |
+ |
return ss_.bitsets_[MOLECULE][m->getGlobalIndex()]; |
| 268 |
+ |
} |
| 269 |
|
|
| 111 |
– |
|
| 270 |
|
StuntDouble* beginSelected(int& i); |
| 271 |
|
StuntDouble* nextSelected(int& i); |
| 114 |
– |
|
| 272 |
|
StuntDouble* beginUnselected(int& i); |
| 273 |
|
StuntDouble* nextUnSelected(int& i); |
| 274 |
|
|
| 275 |
+ |
Bond* beginSelectedBond(int& i); |
| 276 |
+ |
Bond* nextSelectedBond(int& i); |
| 277 |
+ |
Bond* beginUnselectedBond(int& i); |
| 278 |
+ |
Bond* nextUnSelectedBond(int& i); |
| 279 |
+ |
|
| 280 |
+ |
Bend* beginSelectedBend(int& i); |
| 281 |
+ |
Bend* nextSelectedBend(int& i); |
| 282 |
+ |
Bend* beginUnselectedBend(int& i); |
| 283 |
+ |
Bend* nextUnSelectedBend(int& i); |
| 284 |
+ |
|
| 285 |
+ |
Torsion* beginSelectedTorsion(int& i); |
| 286 |
+ |
Torsion* nextSelectedTorsion(int& i); |
| 287 |
+ |
Torsion* beginUnselectedTorsion(int& i); |
| 288 |
+ |
Torsion* nextUnSelectedTorsion(int& i); |
| 289 |
+ |
|
| 290 |
+ |
Inversion* beginSelectedInversion(int& i); |
| 291 |
+ |
Inversion* nextSelectedInversion(int& i); |
| 292 |
+ |
Inversion* beginUnselectedInversion(int& i); |
| 293 |
+ |
Inversion* nextUnSelectedInversion(int& i); |
| 294 |
+ |
|
| 295 |
+ |
Molecule* beginSelectedMolecule(int& i); |
| 296 |
+ |
Molecule* nextSelectedMolecule(int& i); |
| 297 |
+ |
Molecule* beginUnselectedMolecule(int& i); |
| 298 |
+ |
Molecule* nextUnSelectedMolecule(int& i); |
| 299 |
+ |
|
| 300 |
|
SelectionManager& operator&= (const SelectionManager &sman) { |
| 301 |
< |
bsSelection_ &= sman.bsSelection_; |
| 301 |
> |
for (int i = 0; i < N_SELECTIONTYPES; i++) |
| 302 |
> |
ss_.bitsets_[i] &= sman.ss_.bitsets_[i]; |
| 303 |
|
return *this; |
| 304 |
|
} |
| 305 |
|
|
| 306 |
|
SelectionManager& operator|= (const SelectionManager &sman) { |
| 307 |
< |
bsSelection_ |= sman.bsSelection_; |
| 307 |
> |
for (int i = 0; i < N_SELECTIONTYPES; i++) |
| 308 |
> |
ss_.bitsets_[i] |= sman.ss_.bitsets_[i]; |
| 309 |
|
return *this; |
| 310 |
|
} |
| 311 |
|
|
| 312 |
|
SelectionManager& operator^= (const SelectionManager &sman) { |
| 313 |
< |
bsSelection_ ^= sman.bsSelection_; |
| 313 |
> |
for (int i = 0; i < N_SELECTIONTYPES; i++) |
| 314 |
> |
ss_.bitsets_[i] ^= sman.ss_.bitsets_[i]; |
| 315 |
|
return *this; |
| 316 |
|
} |
| 317 |
|
|
| 318 |
|
SelectionManager& operator-= (const SelectionManager &sman) { |
| 319 |
< |
bsSelection_ -= sman.bsSelection_; |
| 319 |
> |
for (int i = 0; i < N_SELECTIONTYPES; i++) |
| 320 |
> |
ss_.bitsets_[i] -= sman.ss_.bitsets_[i]; |
| 321 |
|
return *this; |
| 322 |
|
} |
| 323 |
|
|
| 328 |
|
|
| 329 |
|
private: |
| 330 |
|
SimInfo* info_; |
| 331 |
< |
OpenMDBitSet bsSelection_; |
| 331 |
> |
SelectionSet ss_; |
| 332 |
> |
std::vector<int> nObjects_; |
| 333 |
|
std::vector<StuntDouble*> stuntdoubles_; |
| 334 |
+ |
std::vector<Bond*> bonds_; |
| 335 |
+ |
std::vector<Bend*> bends_; |
| 336 |
+ |
std::vector<Torsion*> torsions_; |
| 337 |
+ |
std::vector<Inversion*> inversions_; |
| 338 |
+ |
std::vector<Molecule*> molecules_; |
| 339 |
|
}; |
| 340 |
|
|
| 341 |
|
} |