Chemical Data Processing Library C++ API - Version 1.4.0
Hydrogen3DCoordinatesCalculator.hpp
Go to the documentation of this file.
1 /*
2  * Hydrogen3DCoordinatesCalculator.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_CHEM_HYDROGEN3DCOORDINATESCALCULATOR_HPP
30 #define CDPL_CHEM_HYDROGEN3DCOORDINATESCALCULATOR_HPP
31 
32 #include <cstddef>
33 #include <vector>
34 
35 #include "CDPL/Chem/APIPrefix.hpp"
39 #include "CDPL/Math/Matrix.hpp"
41 #include "CDPL/Util/BitSet.hpp"
42 
43 
44 namespace CDPL
45 {
46 
47  namespace Chem
48  {
49 
50  class MolecularGraph;
51  class Atom;
52 
64  {
65 
66  public:
71 
83  Hydrogen3DCoordinatesCalculator(const MolecularGraph& molgraph, Math::Vector3DArray& coords, bool undef_only = true);
84 
90  void undefinedOnly(bool undef_only);
91 
96  bool undefinedOnly() const;
97 
103 
109 
115 
121 
129  void setup(const MolecularGraph& molgraph);
130 
142  void calculate(const MolecularGraph& molgraph, Math::Vector3DArray& coords, bool init_coords = true);
143 
154  void calculate(Math::Vector3DArray& coords, bool init_coords = true);
155 
156  private:
157  typedef std::vector<std::size_t> AtomIndexList;
158 
159  void assignCoordinates(Math::Vector3DArray&, bool init_coords);
160  void assignDiatomicMolCoords(const Atom&, std::size_t, Math::Vector3DArray&);
161  void assignLinearCoords(const Atom&, std::size_t, std::size_t, Math::Vector3DArray&);
162  void assignTrigonalPlanarCoords(const Atom&, std::size_t, std::size_t, Math::Vector3DArray&);
163  void assignTetrahedralCoords(const Atom&, std::size_t, std::size_t, Math::Vector3DArray&);
164  void assignSquarePlanarCoords(const Atom&, std::size_t, std::size_t, Math::Vector3DArray&);
165  void assignTrigonalBipyramidalCoords(const Atom&, std::size_t, std::size_t, Math::Vector3DArray&);
166  void assignOctahedralCoords(const Atom&, std::size_t, std::size_t, Math::Vector3DArray&);
167  void assignPentagonalBipyramidalCoords(const Atom&, std::size_t, std::size_t, Math::Vector3DArray&);
168  void assignEvenlyDistributedCoords(const Atom&, std::size_t, std::size_t, Math::Vector3DArray&);
169 
170  void assignTemplateCoords(const Atom&, std::size_t, std::size_t,
171  std::size_t, const Math::Vector3D[], const std::size_t*,
173 
174  std::size_t getConnectedAtoms(const Atom&, AtomIndexList&);
175  bool getConnectedAtomWithCoords(std::size_t, const Atom&, std::size_t&) const;
176 
177  double getHydrogenBondLength(const Atom&) const;
178 
179  unsigned int getHybridizationState(const Atom&, std::size_t) const;
180 
181  void buildOrthogonalBasis(const Math::Vector3D&, const Math::Vector3D&,
182  Math::Matrix3D&, bool) const;
183  void getRotationReferenceVector(const Atom&, std::size_t, std::size_t, std::size_t,
185  void getPerpendicularVector(const Math::Vector3D&, Math::Vector3D&) const;
186 
187  typedef std::vector<Math::Vector3D> DynamicPointArray;
188 
189  const MolecularGraph* molGraph;
190  bool undefOnly;
191  Atom3DCoordinatesFunction coordsFunc;
192  AtomPredicate hasCoordsFunc;
193  Util::BitSet defCoordsMask;
194  Util::BitSet savedCoordsMask;
195  AtomIndexList centerAtoms;
196  AtomIndexList conctdAtoms;
197  Math::DMatrix refPoints;
198  Math::DMatrix tmpltPoints;
199  DynamicPointArray genPoints;
201  Util::BitSet usedPosMask;
202  };
203  } // namespace Chem
204 } // namespace CDPL
205 
206 #endif // CDPL_CHEM_HYDROGEN3DCOORDINATESCALCULATOR_HPP
Type declaration of a generic wrapper class for storing user-defined Chem::Atom 3D coordinates functi...
Type declaration of a generic wrapper class for storing user-defined Chem::Atom predicates.
Declaration of type CDPL::Util::BitSet.
Definition of the preprocessor macro CDPL_CHEM_API.
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Implementation of the Kabsch algorithm.
Definition of matrix data types.
Definition of class CDPL::Math::VectorArray.
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:58
Generates 3D coordinates for the hydrogen atoms of a molecular graph from the existing positions of t...
Definition: Hydrogen3DCoordinatesCalculator.hpp:64
const AtomPredicate & getAtom3DCoordinatesCheckFunction() const
Returns the function that was registered to determine whether for a given atom 3D coordinates are ava...
void setAtom3DCoordinatesFunction(const Atom3DCoordinatesFunction &func)
Specifies a function for the retrieval of atom 3D coordinates.
void calculate(const MolecularGraph &molgraph, Math::Vector3DArray &coords, bool init_coords=true)
Calculates 3D coordinates for the hydrogen atoms of the molecular graph molgraph.
const Atom3DCoordinatesFunction & getAtom3DCoordinatesFunction() const
Returns the function that was registered for the retrieval of atom 3D coordinates.
void calculate(Math::Vector3DArray &coords, bool init_coords=true)
Calculates 3D coordinates for the hydrogen atoms of the molecular graph previously specified via setu...
void setup(const MolecularGraph &molgraph)
Initializes the calculator for the molecular graph molgraph.
void setAtom3DCoordinatesCheckFunction(const AtomPredicate &func)
Specifies a function that tells whether 3D coordinates are available for it's argument atom.
Hydrogen3DCoordinatesCalculator(const MolecularGraph &molgraph, Math::Vector3DArray &coords, bool undef_only=true)
Constructs the Hydrogen3DCoordinatesCalculator instance and calculates 3D coordinates for the hydroge...
Hydrogen3DCoordinatesCalculator()
Constructs the Hydrogen3DCoordinatesCalculator instance.
bool undefinedOnly() const
Tells whether already defined hydrogen atom 3D coordinates are recalculated or left unchanged.
void undefinedOnly(bool undef_only)
Allows to specify whether already defined hydrogen atom 3D coordinates have to be recalculated or are...
Abstract base class for data structures that represent chemical structures as molecular graphs.
Definition: MolecularGraph.hpp:60
std::function< bool(const Chem::Atom &)> AtomPredicate
Generic wrapper class used to store a user-defined atom predicate.
Definition: AtomPredicate.hpp:41
std::size_t getConnectedAtoms(AtomType &atom, const MolecularGraph &molgraph, OutputIterator it, AtomType *excl_atom=0)
Writes every neighbor of the atom atom that is connected by a bond belonging to the molecular graph m...
Definition: Chem/AtomFunctions.hpp:1255
CDPL_CHEM_API unsigned int getHybridizationState(const Atom &atom)
Returns the value of the Chem::AtomProperty::HYBRIDIZATION property of the atom atom.
std::function< const Math::Vector3D &(const Chem::Atom &)> Atom3DCoordinatesFunction
Generic wrapper class used to store a user-defined Chem::Atom 3D coordinates function.
Definition: Atom3DCoordinatesFunction.hpp:43
VectorArray< Vector3D > Vector3DArray
Array storing vectors of type Math::Vector3D.
Definition: VectorArray.hpp:87
CVector< double, 3 > Vector3D
Bounded 3 element vector holding floating-point values of type double.
Definition: Vector.hpp:3218
CMatrix< double, 3, 3 > Matrix3D
Bounded 3×3 matrix holding floating-point values of type double.
Definition: Matrix.hpp:3504
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.