6 |
|
* redistribute this software in source and binary code form, provided |
7 |
|
* that the following conditions are met: |
8 |
|
* |
9 |
< |
* 1. Acknowledgement of the program authors must be made in any |
10 |
< |
* publication of scientific results based in part on use of the |
11 |
< |
* program. An acceptable form of acknowledgement is citation of |
12 |
< |
* the article in which the program was described (Matthew |
13 |
< |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
< |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
< |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
< |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
< |
* |
18 |
< |
* 2. Redistributions of source code must retain the above copyright |
9 |
> |
* 1. Redistributions of source code must retain the above copyright |
10 |
|
* notice, this list of conditions and the following disclaimer. |
11 |
|
* |
12 |
< |
* 3. Redistributions in binary form must reproduce the above copyright |
12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
|
* notice, this list of conditions and the following disclaimer in the |
14 |
|
* documentation and/or other materials provided with the |
15 |
|
* distribution. |
28 |
|
* arising out of the use of or inability to use software, even if the |
29 |
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
* such damages. |
31 |
+ |
* |
32 |
+ |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
+ |
* research, please cite the appropriate papers when you publish your |
34 |
+ |
* work. Good starting points are: |
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, 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/BitSet.hpp" |
46 |
> |
#include "selection/SelectionSet.hpp" |
47 |
|
#include "primitives/StuntDouble.hpp" |
48 |
< |
namespace oopse { |
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 |
< |
class SimInfo; |
50 |
< |
/** |
51 |
< |
* @class SelectionManager SelectionManager.hpp "selection/SelectionManager.hpp" |
52 |
< |
* @brief |
53 |
< |
*/ |
54 |
< |
class SelectionManager { |
55 |
< |
public: |
56 |
< |
SelectionManager(SimInfo* info); |
54 |
> |
namespace OpenMD { |
55 |
|
|
56 |
< |
void addSelection(StuntDouble* sd) { |
57 |
< |
bsSelection_.setBitOn(sd->getGlobalIndex()); |
58 |
< |
} |
59 |
< |
|
62 |
< |
void addSelectionSet(const BitSet& bs) { |
63 |
< |
bsSelection_ |= bs; |
64 |
< |
} |
56 |
> |
class SimInfo; |
57 |
> |
class SelectionManager { |
58 |
> |
public: |
59 |
> |
SelectionManager(SimInfo* info); |
60 |
|
|
61 |
< |
void setSelection(StuntDouble* sd) { |
62 |
< |
bsSelection_.clearAll(); |
63 |
< |
bsSelection_.setBitOn(sd->getGlobalIndex()); |
64 |
< |
} |
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 setSelectionSet(const BitSet& bs) { |
81 |
< |
bsSelection_ = bs; |
82 |
< |
} |
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 |
< |
void toggleSelection(StuntDouble* sd) { |
100 |
< |
bsSelection_.flip(sd->getGlobalIndex()); |
101 |
< |
} |
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 toggleSelection() { |
106 |
< |
bsSelection_.flip(); |
107 |
< |
} |
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 |
> |
ss_.bitsets_[STUNTDOUBLE].clearAll(); |
175 |
> |
ss_.bitsets_[STUNTDOUBLE].setBitOn(sd->getGlobalIndex()); |
176 |
> |
} |
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 |
> |
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 |
> |
for (int i = 0; i < N_SELECTIONTYPES; i++) |
219 |
> |
ss_.bitsets_[i].flip(); |
220 |
> |
} |
221 |
|
|
222 |
< |
void selectAll() { |
223 |
< |
bsSelection_.setAll(); |
224 |
< |
} |
222 |
> |
void selectAll() { |
223 |
> |
for (int i = 0; i < N_SELECTIONTYPES; i++) |
224 |
> |
ss_.bitsets_[i].setAll(); |
225 |
> |
} |
226 |
|
|
227 |
< |
void clearSelection() { |
228 |
< |
bsSelection_.clearAll(); |
229 |
< |
} |
227 |
> |
void clearSelection() { |
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()); |
234 |
< |
} |
232 |
> |
void clearSelection(StuntDouble* sd) { |
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()]; |
253 |
< |
} |
251 |
> |
bool isSelected(StuntDouble* sd) { |
252 |
> |
return ss_.bitsets_[STUNTDOUBLE][sd->getGlobalIndex()]; |
253 |
> |
} |
254 |
> |
bool isSelected(Bond* b) { |
255 |
> |
return ss_.bitsets_[BOND][b->getGlobalIndex()]; |
256 |
> |
} |
257 |
> |
bool isSelected(Bend* b) { |
258 |
> |
return ss_.bitsets_[BEND][b->getGlobalIndex()]; |
259 |
> |
} |
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 |
|
|
270 |
< |
bool isEmpty() { |
271 |
< |
return bsSelection_.none(); |
272 |
< |
} |
270 |
> |
StuntDouble* beginSelected(int& i); |
271 |
> |
StuntDouble* nextSelected(int& i); |
272 |
> |
StuntDouble* beginUnselected(int& i); |
273 |
> |
StuntDouble* nextUnSelected(int& i); |
274 |
|
|
275 |
< |
int getSelectionCount() { |
276 |
< |
return bsSelection_.countBits(); |
277 |
< |
} |
275 |
> |
Bond* beginSelectedBond(int& i); |
276 |
> |
Bond* nextSelectedBond(int& i); |
277 |
> |
Bond* beginUnselectedBond(int& i); |
278 |
> |
Bond* nextUnSelectedBond(int& i); |
279 |
|
|
280 |
< |
BitSet getSelectionSet() { |
281 |
< |
return bsSelection_; |
282 |
< |
} |
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 |
< |
StuntDouble* beginSelected(int& i); |
291 |
< |
StuntDouble* nextSelected(int& i); |
290 |
> |
Inversion* beginSelectedInversion(int& i); |
291 |
> |
Inversion* nextSelectedInversion(int& i); |
292 |
> |
Inversion* beginUnselectedInversion(int& i); |
293 |
> |
Inversion* nextUnSelectedInversion(int& i); |
294 |
|
|
295 |
< |
StuntDouble* beginUnselected(int& i); |
296 |
< |
StuntDouble* nextUnSelected(int& i); |
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_; |
302 |
< |
return *this; |
303 |
< |
} |
300 |
> |
SelectionManager& operator&= (const SelectionManager &sman) { |
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_; |
308 |
< |
return *this; |
309 |
< |
} |
306 |
> |
SelectionManager& operator|= (const SelectionManager &sman) { |
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_; |
314 |
< |
return *this; |
315 |
< |
} |
312 |
> |
SelectionManager& operator^= (const SelectionManager &sman) { |
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_; |
320 |
< |
return *this; |
321 |
< |
} |
318 |
> |
SelectionManager& operator-= (const SelectionManager &sman) { |
319 |
> |
for (int i = 0; i < N_SELECTIONTYPES; i++) |
320 |
> |
ss_.bitsets_[i] -= sman.ss_.bitsets_[i]; |
321 |
> |
return *this; |
322 |
> |
} |
323 |
|
|
324 |
< |
friend SelectionManager operator| (const SelectionManager& sman1, const SelectionManager& sman2); |
325 |
< |
friend SelectionManager operator& (const SelectionManager& sman1, const SelectionManager& sman2); |
326 |
< |
friend SelectionManager operator^ (const SelectionManager& sman1, const SelectionManager& sman2); |
327 |
< |
friend SelectionManager operator-(const SelectionManager& sman1, const SelectionManager& sman2); |
324 |
> |
friend SelectionManager operator| (const SelectionManager& sman1, const SelectionManager& sman2); |
325 |
> |
friend SelectionManager operator& (const SelectionManager& sman1, const SelectionManager& sman2); |
326 |
> |
friend SelectionManager operator^ (const SelectionManager& sman1, const SelectionManager& sman2); |
327 |
> |
friend SelectionManager operator-(const SelectionManager& sman1, const SelectionManager& sman2); |
328 |
|
|
329 |
< |
private: |
330 |
< |
SimInfo* info_; |
331 |
< |
BitSet bsSelection_; |
332 |
< |
std::vector<StuntDouble*> stuntdoubles_; |
333 |
< |
}; |
329 |
> |
private: |
330 |
> |
SimInfo* info_; |
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 |
|
} |
342 |
|
#endif |