Class Avogadro::QtGui::HydrogenTools

class Avogadro::QtGui::HydrogenTools

Public Types

enum Adjustment

Enum values that control the adjustHydrogen function’s behavior.

Values:

enumerator Add

Only add hydrogens to underbonded atoms.

enumerator Remove

Only remove hydrogens from overbonded atoms.

enumerator AddAndRemove

Add hydrogens to underbonded atoms and remove hydrogens from overbonded atoms.

Public Static Functions

static void removeAllHydrogens(RWMolecule &molecule)

Remove all hydrogen atoms from molecule.

static void adjustHydrogens(RWMolecule &molecule, Adjustment adjustment = AddAndRemove)

Add/remove hydrogens on molecule to satisfy valency.

static void adjustHydrogens(RWAtom &atom, Adjustment adjustment = AddAndRemove)

Add/remove hydrogens on atom to satisfy valency.

static int valencyAdjustment(const RWAtom &atom)
Returns

The number of bonds that need to be added or removed from atom to satisfy valency. A positive number indicates the number of bonds to add, a negative number indicates the number of bonds that need to be removed.

static int extraHydrogenIndices(const RWAtom &atom, int numberOfHydrogens, std::vector<size_t> &indices)

Obtain the indices of hydrogens that can be removed from atom.

Note

This function modifies neither atom nor its parent molecule. It only pushes the indices of hydrogens to remove to the end of indices.

Parameters
  • atom – The atom from which to prune hydrogens.

  • numberOfHydrogens – The maximum number of hydrogens to prune.

  • indices – A vector that will be appended with the indices of the hydrogens to remove.

Returns

The number of hydrogen indices appended to indices.

static void generateNewHydrogenPositions(const RWAtom &atom, int numberOfHydrogens, std::vector<Vector3> &positions)

Generate positions for numberOfHydrogens hydrogens bonded to atom.

Note

There is nothing intelligent going on here. The new positions are randomly oriented and have a length that is the sum of atom’s and hydrogen’s covalent radii. Effort is made to prevent overlap with other bonded atoms, but this is not guaranteed.

Parameters

positions – Vector of positions that will be appended with numberOfHydrogens hydrogen locations.

static Core::AtomHybridization perceiveHybridization(const RWAtom &atom)

Perceive the geometry / hybridization bonded to atom. Ideally, the client should cache the hybridization number by calling setHybridization() later

static Vector3 generateNewBondVector(const RWAtom &atom, std::vector<Vector3> &currentVectors, Core::AtomHybridization hybridization)

Generate a new bond vector (unit length)