ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/selection/SelectionManager.hpp
(Generate patch)

Comparing trunk/src/selection/SelectionManager.hpp (file contents):
Revision 1801 by gezelter, Mon Oct 1 18:21:15 2012 UTC vs.
Revision 1953 by gezelter, Thu Dec 5 18:19:26 2013 UTC

# Line 35 | Line 35
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).          
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   */
# Line 43 | Line 43
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 +
53   namespace OpenMD {
54  
55    class SimInfo;
# Line 53 | Line 58 | namespace OpenMD {
58      SelectionManager(SimInfo* info);
59  
60      void addSelection(StuntDouble* sd) {
61 <      bsSelection_.setBitOn(sd->getGlobalIndex());
61 >      
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          
77 <    void addSelectionSet(const OpenMDBitSet& bs) {
78 <      bsSelection_ |= bs;
77 >    void addSelectionSet(const SelectionSet& bs) {
78 >      ss_.bitsets_[STUNTDOUBLE] |= bs.bitsets_[STUNTDOUBLE];
79      }
80 +    void addBondSelectionSet(const SelectionSet& bs) {
81 +      ss_.bitsets_[BOND] |= bs.bitsets_[BOND];
82 +    }
83 +    void addBendSelectionSet(const SelectionSet& bs) {
84 +      ss_.bitsets_[BEND] |= bs.bitsets_[BEND];
85 +    }
86 +    void addTorsionSelectionSet(const SelectionSet& bs) {
87 +      ss_.bitsets_[TORSION] |= bs.bitsets_[TORSION];
88 +    }
89 +    void addInversionSelectionSet(const SelectionSet& bs) {
90 +      ss_.bitsets_[INVERSION] |= bs.bitsets_[INVERSION];
91 +    }
92  
93 +    bool isEmpty() {
94 +      return ss_.bitsets_[STUNTDOUBLE].none() && ss_.bitsets_[BOND].none()
95 +        && ss_.bitsets_[BEND].none()  && ss_.bitsets_[TORSION].none()
96 +        && ss_.bitsets_[INVERSION].none();
97 +    }
98 +
99 +    void setSelectionSet(const SelectionSet& bs) {
100 +      for (int i = 0; i < N_SELECTIONTYPES; i++)
101 +        ss_.bitsets_[i] = bs.bitsets_[i];
102 +    }
103 +
104 +    //void setSelectionSet(const SelectionSet& bs) {
105 +    //  ss_.bitsets_[STUNTDOUBLE] = bs.bitsets_[];          
106 +    //}
107 +    void setBondSelectionSet(const SelectionSet& bs) {
108 +      ss_.bitsets_[BOND] = bs.bitsets_[BOND];          
109 +    }
110 +    void setBendSelectionSet(const SelectionSet& bs) {
111 +      ss_.bitsets_[BEND] = bs.bitsets_[BEND];          
112 +    }
113 +    void setTorsionSelectionSet(const SelectionSet& bs) {
114 +      ss_.bitsets_[TORSION] = bs.bitsets_[TORSION];          
115 +    }
116 +    void setInversionSelectionSet(const SelectionSet& bs) {
117 +      ss_.bitsets_[INVERSION] = bs.bitsets_[INVERSION];          
118 +    }
119 +
120 +    std::vector<int> getSelectionCounts() {
121 +      std::vector<int> counts(N_SELECTIONTYPES,0);
122 +      for (int i = 0; i < N_SELECTIONTYPES; i++) {
123 +        counts[i] = ss_.bitsets_[i].countBits();
124 +      }
125 +      return counts;
126 +    }
127 +    
128 +    int getSelectionCount() {
129 +      return ss_.bitsets_[STUNTDOUBLE].countBits();
130 +    }
131 +    int getBondSelectionCount() {
132 +      return ss_.bitsets_[BOND].countBits();
133 +    }
134 +    int getBendSelectionCount() {
135 +      return ss_.bitsets_[BEND].countBits();
136 +    }
137 +    int getTorsionSelectionCount() {
138 +      return ss_.bitsets_[TORSION].countBits();
139 +    }
140 +    int getInversionSelectionCount() {
141 +      return ss_.bitsets_[INVERSION].countBits();
142 +    }
143 +    
144 +    SelectionSet getSelectionSet() {
145 +      return ss_;
146 +    }
147 +    /*    SelectionSet getBondSelectionSet() {
148 +      return ss_.bitsets_[BOND];
149 +    }
150 +    SelectionSet getBendSelectionSet() {
151 +      return ss_.bitsets_[BEND];
152 +    }
153 +    SelectionSet getTorsionSelectionSet() {
154 +      return ss_.bitsets_[TORSION];
155 +    }
156 +    SelectionSet getInversionSelectionSet() {
157 +      return ss_.bitsets_[INVERSION];
158 +    }
159 +    */
160 +
161      void setSelection(StuntDouble* sd) {
162 <      bsSelection_.clearAll();
163 <      bsSelection_.setBitOn(sd->getGlobalIndex());
162 >      ss_.bitsets_[STUNTDOUBLE].clearAll();
163 >      ss_.bitsets_[STUNTDOUBLE].setBitOn(sd->getGlobalIndex());
164      }
165 <        
166 <    void setSelectionSet(const OpenMDBitSet& bs) {
167 <      bsSelection_ = bs;          
165 >    void setSelection(Bond* b) {
166 >      ss_.bitsets_[BOND].clearAll();
167 >      ss_.bitsets_[BOND].setBitOn(b->getGlobalIndex());
168      }
169 +    void setSelection(Bend* b) {
170 +      ss_.bitsets_[BEND].clearAll();
171 +      ss_.bitsets_[BEND].setBitOn(b->getGlobalIndex());
172 +    }
173 +    void setSelection(Torsion* t) {
174 +      ss_.bitsets_[TORSION].clearAll();
175 +      ss_.bitsets_[TORSION].setBitOn(t->getGlobalIndex());
176 +    }
177 +    void setSelection(Inversion* i) {
178 +      ss_.bitsets_[INVERSION].clearAll();
179 +      ss_.bitsets_[INVERSION].setBitOn(i->getGlobalIndex());
180 +    }
181  
182      void toggleSelection(StuntDouble* sd) {
183 <      bsSelection_.flip(sd->getGlobalIndex());
183 >      ss_.bitsets_[STUNTDOUBLE].flip(sd->getGlobalIndex());
184      }
185 +    void toggleSelection(Bond* b) {
186 +      ss_.bitsets_[BOND].flip(b->getGlobalIndex());
187 +    }
188 +    void toggleSelection(Bend* b) {
189 +      ss_.bitsets_[BEND].flip(b->getGlobalIndex());
190 +    }
191 +    void toggleSelection(Torsion* t) {
192 +      ss_.bitsets_[TORSION].flip(t->getGlobalIndex());
193 +    }
194 +    void toggleSelection(Inversion* i) {
195 +      ss_.bitsets_[INVERSION].flip(i->getGlobalIndex());
196 +    }
197  
198      void toggleSelection() {
199 <      bsSelection_.flip();
199 >      for (int i = 0; i < N_SELECTIONTYPES; i++)
200 >        ss_.bitsets_[i].flip();
201      }
202          
203      void selectAll() {
204 <      bsSelection_.setAll();                
204 >      for (int i = 0; i < N_SELECTIONTYPES; i++)
205 >        ss_.bitsets_[i].setAll();
206      }
207  
208      void clearSelection() {
209 <      bsSelection_.clearAll();
209 >      for (int i = 0; i < N_SELECTIONTYPES; i++)
210 >        ss_.bitsets_[i].clearAll();
211      }
212  
213      void clearSelection(StuntDouble* sd) {
214 <      bsSelection_.setBitOff(sd->getGlobalIndex());
214 >      ss_.bitsets_[STUNTDOUBLE].setBitOff(sd->getGlobalIndex());
215      }
216 +    void clearSelection(Bond* b) {
217 +      ss_.bitsets_[BOND].setBitOff(b->getGlobalIndex());
218 +    }
219 +    void clearSelection(Bend* b) {
220 +      ss_.bitsets_[BEND].setBitOff(b->getGlobalIndex());
221 +    }
222 +    void clearSelection(Torsion* t) {
223 +      ss_.bitsets_[TORSION].setBitOff(t->getGlobalIndex());
224 +    }
225 +    void clearSelection(Inversion* i) {
226 +      ss_.bitsets_[INVERSION].setBitOff(i->getGlobalIndex());
227 +    }
228  
229      bool isSelected(StuntDouble* sd) {
230 <      return bsSelection_[sd->getGlobalIndex()];
230 >      return ss_.bitsets_[STUNTDOUBLE][sd->getGlobalIndex()];
231      }
232 <
233 <    bool isEmpty() {
97 <      return bsSelection_.none();
232 >    bool isSelected(Bond* b) {
233 >      return ss_.bitsets_[BOND][b->getGlobalIndex()];
234      }
235 <
236 <    int getSelectionCount() {
101 <      return bsSelection_.countBits();
235 >    bool isSelected(Bend* b) {
236 >      return ss_.bitsets_[BEND][b->getGlobalIndex()];
237      }
238 <
239 <    OpenMDBitSet getSelectionSet() {
105 <      return bsSelection_;
238 >    bool isSelected(Torsion* t) {
239 >      return ss_.bitsets_[TORSION][t->getGlobalIndex()];
240      }
241 +    bool isSelected(Inversion* i) {
242 +      return ss_.bitsets_[INVERSION][i->getGlobalIndex()];
243 +    }
244  
108
245      StuntDouble* beginSelected(int& i);
246      StuntDouble* nextSelected(int& i);
111
247      StuntDouble* beginUnselected(int& i);
248      StuntDouble* nextUnSelected(int& i);
249  
250 +    Bond* beginSelectedBond(int& i);
251 +    Bond* nextSelectedBond(int& i);
252 +    Bond* beginUnselectedBond(int& i);
253 +    Bond* nextUnSelectedBond(int& i);
254 +
255 +    Bend* beginSelectedBend(int& i);
256 +    Bend* nextSelectedBend(int& i);
257 +    Bend* beginUnselectedBend(int& i);
258 +    Bend* nextUnSelectedBend(int& i);
259 +
260 +    Torsion* beginSelectedTorsion(int& i);
261 +    Torsion* nextSelectedTorsion(int& i);
262 +    Torsion* beginUnselectedTorsion(int& i);
263 +    Torsion* nextUnSelectedTorsion(int& i);
264 +
265 +    Inversion* beginSelectedInversion(int& i);
266 +    Inversion* nextSelectedInversion(int& i);
267 +    Inversion* beginUnselectedInversion(int& i);
268 +    Inversion* nextUnSelectedInversion(int& i);
269 +
270      SelectionManager& operator&= (const SelectionManager &sman) {
271 <      bsSelection_ &= sman.bsSelection_;
271 >      for (int i = 0; i < N_SELECTIONTYPES; i++)
272 >        ss_.bitsets_[i] &= sman.ss_.bitsets_[i];
273        return *this;
274      }
275          
276      SelectionManager& operator|= (const SelectionManager &sman) {
277 <      bsSelection_ |= sman.bsSelection_;
277 >      for (int i = 0; i < N_SELECTIONTYPES; i++)
278 >        ss_.bitsets_[i] |= sman.ss_.bitsets_[i];
279        return *this;
280      }
281          
282      SelectionManager& operator^= (const SelectionManager &sman) {
283 <      bsSelection_ ^= sman.bsSelection_;
283 >      for (int i = 0; i < N_SELECTIONTYPES; i++)
284 >        ss_.bitsets_[i] ^= sman.ss_.bitsets_[i];
285        return *this;
286      }
287  
288      SelectionManager& operator-= (const SelectionManager &sman) {
289 <      bsSelection_ -= sman.bsSelection_;
289 >      for (int i = 0; i < N_SELECTIONTYPES; i++)
290 >        ss_.bitsets_[i] -= sman.ss_.bitsets_[i];
291        return *this;
292      }
293          
# Line 139 | Line 298 | namespace OpenMD {
298          
299    private:
300      SimInfo* info_;
301 <    OpenMDBitSet bsSelection_;
301 >    SelectionSet ss_;
302 >    std::vector<int> nObjects_;
303      std::vector<StuntDouble*> stuntdoubles_;
304 +    std::vector<Bond*> bonds_;
305 +    std::vector<Bend*> bends_;
306 +    std::vector<Torsion*> torsions_;
307 +    std::vector<Inversion*> inversions_;
308    };
309  
310   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines