chemfiles::SelectionThis class allow to select some atoms in a Frame, using a specific selection language.
The selection language is built by combining basic operations. Each basic operation follows the <selector> <operator> <value> structure, where <operator> can be a comparison operator in == != < <= > >=.
Implemented <selector> and associated <value> types are given below:
name: select atoms on their name. <value> must be a string, and only the == and != operators are allowed. Examples: name == C; name != Hw.index: select atoms on their index in the frame. <value> must be an integer. Examples: index == 4; index > 304.mass: select atoms on their mass. <value> must be a number. Examples: mass 4; mass < 2.0.x|y|z: select atoms on their position. must be a number. Examples:x <= 7.3;z != 4.2;y > 2. -vx|vy|vz: select atoms on their velocity. <value> must be a number. Examples: vx <= 7.3; vz != 4.2; vy > 2.
These basic operations can be combined by three logical operators: and, or and not. Parentheses can be used to remove ambiguity when using multiple operators.
`name == H and (x < 45.9 or vz >= 67) and (not index == 67)`
Some selections also accept a short form, where the comparison operator is elided and implicitly ==. These selections are name, index and mass. So name O or index 234 is equivalent to name == O or index == 234.
Two other special operation are the all and none selection, matching respectively all and none of the atoms in the frame.
Public Functions
Selection(const std::string & selection)Create a selection using the given string.
ParserError - if there is a semantic error in the selection
LexerError - if there is a syntaxic error in the selection
evaluate(const Frame & frame) constEvaluate the selection on a given frame. This function returns a vector of size Frame::natoms(), containing true at the index i if the atom at index i matches the selection, and false otherwise.
chemfiles::BoolBecause the standard spacialization std::vector<bool> is optimized for space requirements and hard to work with, chemfiles uses a small wrapper around the bool type, the Bool class.
Public Functions
Bool(bool value)Construct a Bool from a given bool value.
operator!() constNegate this boolean.
operator bool() constConvert this boolean to the bool standard type.