Debian Codegraph @

avogadro/qtgui/hydrogentools.h

raw
1 /******************************************************************************
2 This source file is part of the MoleQueue project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #ifndef AVOGADRO_QTGUI_HYDROGENTOOLS_H
7 #define AVOGADRO_QTGUI_HYDROGENTOOLS_H
8
9 #include "avogadroqtguiexport.h"
10
11 #include <avogadro/core/vector.h>
12 #include <avogadro/qtgui/rwmolecule.h>
13
14 #include <vector>
15
16 namespace Avogadro {
17 namespace QtGui {
18 class RWAtom;
19 class RWMolecule;
20
21 class AVOGADROQTGUI_EXPORT HydrogenTools
22 {
23 public:
24 /**
25 * Remove all hydrogen atoms from @a molecule.
26 */
27 static void removeAllHydrogens(RWMolecule& molecule);
28
29 /**
30 * Enum values that control the adjustHydrogen function's behavior.
31 */
32 enum Adjustment
33 {
34 /** Only add hydrogens to underbonded atoms. */
35 Add = 0,
36 /** Only remove hydrogens from overbonded atoms. */
37 Remove,
38 /** Add hydrogens to underbonded atoms and remove hydrogens from
39 * overbonded atoms. */
40 AddAndRemove
41 };
42
43 /**
44 * Add/remove hydrogens on @a molecule to satisfy valency.
45 */
46 static void adjustHydrogens(RWMolecule& molecule,
47 Adjustment adjustment = AddAndRemove);
48
49 /**
50 * Add/remove hydrogens on @a atom to satisfy valency.
51 */
52 static void adjustHydrogens(RWAtom& atom,
53 Adjustment adjustment = AddAndRemove);
54
55 /**
56 * @return The number of bonds that need to be added or removed from
57 * @a atom to satisfy valency. A positive number indicates the number of
58 * bonds to add, a negative number indicates the number of bonds that need to
59 * be removed.
60 */
61 static int valencyAdjustment(const RWAtom& atom);
62
63 /**
64 * Obtain the indices of hydrogens that can be removed from @a atom.
65 * @param atom The atom from which to prune hydrogens.
66 * @param numberOfHydrogens The maximum number of hydrogens to prune.
67 * @param indices A vector that will be appended with the indices of the
68 * hydrogens to remove.
69 * @return The number of hydrogen indices appended to @a indices.
70 * @note This function modifies neither @a atom nor its parent molecule. It
71 * only pushes the indices of hydrogens to remove to the end of @a indices.
72 */
73 static int extraHydrogenIndices(const RWAtom& atom, int numberOfHydrogens,
74 std::vector<size_t>& indices);
75
76 /**
77 * Generate positions for @a numberOfHydrogens hydrogens bonded to @a atom.
78 * @param positions Vector of positions that will be appended with @a
79 * numberOfHydrogens hydrogen locations.
80 * @note There is nothing intelligent going on here. The new positions are
81 * randomly oriented and have a length that is the sum of @a atom's and
82 * hydrogen's covalent radii. Effort is made to prevent overlap with other
83 * bonded atoms, but this is not guaranteed.
84 */
85 static void generateNewHydrogenPositions(const RWAtom& atom,
86 int numberOfHydrogens,
87 std::vector<Vector3>& positions);
88
89 private:
90 HydrogenTools(); // Not implemented
91 ~HydrogenTools(); // Not implemented
92 };
93
94 } // namespace QtGui
95 } // namespace Avogadro
96
97 #endif // AVOGADRO_QTGUI_HYDROGENTOOLS_H