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