diff --git a/modules/mol/base/pymod/export_bond.cc b/modules/mol/base/pymod/export_bond.cc index 8537b2a13c71cd3a7cd58b715ed64976af922032..e22adf98e8e26d4abfcf0ecdf1a63bce746f0107 100644 --- a/modules/mol/base/pymod/export_bond.cc +++ b/modules/mol/base/pymod/export_bond.cc @@ -41,6 +41,8 @@ void export_Bond() make_function(&BondHandle::GetFirst)) .add_property("second", make_function(&BondHandle::GetSecond)) + .add_property("other", + make_function(&BondHandle::GetOther)) .add_property("length", &BondHandle::GetLength) .add_property("bond_order", @@ -48,6 +50,7 @@ void export_Bond() &BondHandle::SetBondOrder) .def("GetFirst", &BondHandle::GetFirst) .def("GetSecond",&BondHandle::GetSecond) + .def("GetOther",&BondHandle::GetOther) .def("GetLength",&BondHandle::GetLength) .def("GetBondOrder",&BondHandle::GetBondOrder) .def("SetBondOrder",&BondHandle::SetBondOrder) diff --git a/modules/mol/base/src/bond_handle.cc b/modules/mol/base/src/bond_handle.cc index 901a1ab4da12d196a2769c3576efca2fdf45612e..995f4d1431bdaae238943689660fc802cb4ceba8 100644 --- a/modules/mol/base/src/bond_handle.cc +++ b/modules/mol/base/src/bond_handle.cc @@ -64,6 +64,20 @@ AtomHandle BondHandle::GetSecond() const return nrvo; } +AtomHandle BondHandle::GetOther(const AtomHandle& a) const +{ + this->CheckValidity(); + if(a.IsValid()) { + if(a.Impl()==impl_->GetFirst()) { + return GetSecond(); + } else { + return GetFirst(); + } + } + AtomHandle nrvo(impl_->GetFirst()); + return nrvo; +} + geom::Vec3 BondHandle::GetPos() const { this->CheckValidity(); diff --git a/modules/mol/base/src/bond_handle.hh b/modules/mol/base/src/bond_handle.hh index ca3fc92f6eab0569d099930616583d79e8ddd507..b23ca06792604dc2af606e5fecc183edc72c729f 100644 --- a/modules/mol/base/src/bond_handle.hh +++ b/modules/mol/base/src/bond_handle.hh @@ -73,6 +73,11 @@ public: /// \brief get second atom /// In python also available as the property second AtomHandle GetSecond() const; + + /// \brief get other atom + /// Returns one of the two atoms that does not match the given one. + /// In python also available as the property other + AtomHandle GetOther(const AtomHandle& a) const; //@} /// \brief return midpoint between the two atoms (transformed coordinates)