Gromacs
2026.0-dev-20241121-c76fa1e
|
Helper to encapsulate logic for looping over input selections.
This class provides two-dimensional iteration:
This class isn't perferctly self-contained and requires the caller to know some of the internals to use it properly, but it serves its purpose for this single analysis tool by simplifying the loops. Some methods have also been tailored to allow the caller to use it a bit more easily.
Public Member Functions | |
AnglePositionIterator (const SelectionList &selections, int posCountPerValue) | |
Creates an iterator to loop over input selection positions. More... | |
void | nextGroup () |
Advances the iterator to the next group of angles. | |
void | nextValue () |
Advances the iterator to the next angle in the current group. | |
bool | hasValue () const |
Returns whether this iterator represents any values. More... | |
bool | hasSingleValue () const |
Returns whether the current selection only contains a single value. More... | |
bool | isDynamic () const |
Returns whether the current selection is dynamic. | |
bool | allValuesConsistentlySelected () const |
Returns whether positions in the current value are either all selected or all unselected. | |
bool | currentValuesSelected () const |
Returns whether positions in the current value are selected. More... | |
const Selection & | currentSelection () const |
Returns the currently active selection. | |
SelectionPosition | currentPosition (int i) const |
Returns the i th position for the current value. | |
void | getCurrentPositions (rvec x[]) const |
Extracts all coordinates corresponding to the current value. More... | |
|
inline |
Creates an iterator to loop over input selection positions.
[in] | selections | List of selections. |
[in] | posCountPerValue | Number of selection positions that constitute a single value for the iteration. |
If selections
is empty, and/or posCountPerValue
is zero, the iterator can still be advanced and hasValue()/hasSingleValue() called, but values cannot be accessed.
|
inline |
Returns whether positions in the current value are selected.
Only works reliably if allValuesConsistentlySelected() returns true
.
|
inline |
Extracts all coordinates corresponding to the current value.
[out] | x | Array to which the positions are extracted. |
x
should contain at minimum the number of positions per value passed to the constructor.
|
inline |
Returns whether the current selection only contains a single value.
Returns false
if hasValue() returns false, which allows cutting some corners in consistency checks.
|
inline |
Returns whether this iterator represents any values.
If the return value is false
, only nextGroup(), nextValue() and hasSingleValue() are allowed to be called.