Conformer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #ifndef _RD_CONFORMER_H
00007 #define _RD_CONFORMER_H
00008
00009 #include <Geometry/point.h>
00010 #include <RDGeneral/types.h>
00011 #include <boost/smart_ptr.hpp>
00012
00013 namespace RDKit {
00014 class ROMol;
00015
00016
00017 class ConformerException : public std::exception {
00018 public:
00019
00020 ConformerException(const char *msg) : _msg(msg) {};
00021
00022 ConformerException(const std::string msg) : _msg(msg) {};
00023
00024 const char *message () const { return _msg.c_str(); };
00025 ~ConformerException () throw () {};
00026 private:
00027 std::string _msg;
00028 };
00029
00030
00031
00032
00033
00034
00035
00036
00037 class Conformer {
00038 public:
00039
00040 friend class ROMol;
00041
00042
00043 Conformer() : df_is3D(true), d_id(0), dp_mol(NULL) {
00044 d_positions.clear();
00045 };
00046
00047
00048 Conformer(unsigned int numAtoms) : df_is3D(true), d_id(0), dp_mol(NULL) {
00049 if(numAtoms){
00050 d_positions.resize(numAtoms, RDGeom::Point3D(0.0, 0.0, 0.0));
00051 } else {
00052 d_positions.resize(0);
00053 d_positions.clear();
00054 }
00055 };
00056
00057
00058 Conformer(const Conformer &other);
00059
00060
00061 ~Conformer() {};
00062
00063
00064
00065 void resize(unsigned int size) {
00066 d_positions.resize(size);
00067 }
00068
00069
00070 void reserve(unsigned int size) {
00071 d_positions.reserve(size);
00072 }
00073
00074
00075 ROMol &getOwningMol() const {return *dp_mol;}
00076
00077
00078 const RDGeom::POINT3D_VECT &getPositions() const;
00079
00080
00081 RDGeom::POINT3D_VECT &getPositions();
00082
00083
00084 const RDGeom::Point3D &getAtomPos(unsigned int atomId) const;
00085
00086
00087 RDGeom::Point3D &getAtomPos(unsigned int atomId);
00088
00089
00090 inline void setAtomPos(unsigned int atomId, const RDGeom::Point3D &position) {
00091
00092 if (atomId >= d_positions.size()) {
00093 d_positions.resize(atomId+1, RDGeom::Point3D(0.0, 0.0, 0.0));
00094 }
00095 d_positions[atomId] = position;
00096 }
00097
00098
00099 inline unsigned int getId() const {return d_id;}
00100
00101
00102 inline void setId(unsigned int id) {
00103 d_id = id;
00104 }
00105
00106
00107 inline unsigned int getNumAtoms() const {
00108 return d_positions.size();
00109 }
00110
00111 inline bool is3D() const {
00112 return df_is3D;
00113 }
00114 inline void set3D(bool v) {
00115 df_is3D=v;
00116 }
00117 protected:
00118
00119 void setOwningMol(ROMol *mol);
00120
00121
00122 void setOwningMol(ROMol &mol);
00123
00124 private:
00125 bool df_is3D;
00126 unsigned int d_id;
00127 ROMol *dp_mol;
00128 RDGeom::POINT3D_VECT d_positions;
00129 };
00130
00131 typedef boost::shared_ptr<Conformer> CONFORMER_SPTR;
00132 }
00133
00134 #endif