OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
connector_impl.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_CONNECTOR_IMPL_HH
20 #define OST_CONNECTOR_IMPL_HH
21 
22 #include <boost/enable_shared_from_this.hpp>
23 
24 #include <ost/geom/geom.hh>
25 
30 
31 #include <ost/generic_property.hh>
32 
33 namespace ost { namespace mol { namespace impl {
34 
36  public boost::enable_shared_from_this<ConnectorImpl> {
37 public:
38  ConnectorImpl(const EntityImplPtr& e, const AtomImplPtr& first,
39  const AtomImplPtr& second, Real l, Real t, Real p, unsigned char bond_order);
41 
42  AtomImplPtr GetFirst() const {return first_.lock();}
43  AtomImplPtr GetSecond() const {return second_.lock();}
44 
45  geom::Vec3 GetPos() const;
46  geom::Vec3 GetOriginalPos() const;
47 
48  Real GetLength() const;
49  void SetLength(Real l) {len_=l;}
50 
51  // Tests whether this connector is connecting atoms a and b.
52  bool IsConnectorOf(const AtomImplPtr& a, const AtomImplPtr& b) const;
53 
54 
55 
56  // reverse order of atoms, does not affect angles!
57  void Switch();
58 
59  void Apply(EntityVisitor& v);
60 
61  geom::Vec3 GetDir() const {
62  return local_rot_*geom::Vec3(0, 0, 1);
63  }
64 
65  void SetDirAndLength(const geom::Vec3& dir);
66 
67  void SetDir(const geom::Vec3& dir);
68 
69  const geom::Mat3& GetLocalRot() const { return local_rot_; }
70 
71  void SetBondOrder(unsigned char bo) { bond_order_ = bo; }
72 
73  unsigned char GetBondOrder() const { return bond_order_; }
74 
75 private:
76  AtomImplW first_,second_;
77  Real len_;
78  unsigned char bond_order_;
79  // rotation matrix that brings a vector from the local coordinates of the
80  // first to the local coordinate system of the second atom.
81  geom::Mat3 local_rot_;
82 };
83 
84 }}} // ns
85 
86 #endif
unsigned char GetBondOrder() const
geom::Vec3 GetOriginalPos() const
float Real
Definition: base.hh:44
boost::weak_ptr< AtomImpl > AtomImplW
Definition: atom_impl_fw.hh:40
const geom::Mat3 & GetLocalRot() const
EntityVisitor interface.
boost::shared_ptr< AtomImpl > AtomImplPtr
Definition: atom_impl_fw.hh:33
boost::shared_ptr< EntityImpl > EntityImplPtr
bool IsConnectorOf(const AtomImplPtr &a, const AtomImplPtr &b) const
ConnectorImpl(const EntityImplPtr &e, const AtomImplPtr &first, const AtomImplPtr &second, Real l, Real t, Real p, unsigned char bond_order)
Three dimensional vector class, using Real precision.
Definition: vec3.hh:43
AtomImplPtr GetSecond() const
void SetDirAndLength(const geom::Vec3 &dir)
geom::Vec3 GetDir() const
void SetDir(const geom::Vec3 &dir)
AtomImplPtr GetFirst() const
void Apply(EntityVisitor &v)
base class for the implementation
void SetBondOrder(unsigned char bo)
geom::Vec3 GetPos() const