diff --git a/modules/mol/alg/pymod/structure_analysis.py b/modules/mol/alg/pymod/structure_analysis.py index dbbc1d9df707d04c0e89e89f753ad9ed449c2292..a9f600bca0a16ea181e2f9780c085208d7b8a7d6 100644 --- a/modules/mol/alg/pymod/structure_analysis.py +++ b/modules/mol/alg/pymod/structure_analysis.py @@ -13,7 +13,7 @@ def GetFrameFromEntity(eh): Input: eh : EntityHandle """ - return ost.mol.CreateCoordFrame(eh.GetAtomPosList()) + return ost.mol.CreateCoordFrame(eh.GetAtomPosList(ordered_by_index=True)) def GetDistanceBetwCenterOfMass(sele1,sele2): """ diff --git a/modules/mol/base/pymod/export_entity.cc b/modules/mol/base/pymod/export_entity.cc index 0373b2590e3ea66f3067b2ae0234df9891783fbb..6d56e7db13fb7e7e32baed55a474636d28b24d7b 100644 --- a/modules/mol/base/pymod/export_entity.cc +++ b/modules/mol/base/pymod/export_entity.cc @@ -155,7 +155,7 @@ void export_Entity() .def("GetMass", &EntityHandle::GetMass) .def("GetCenterOfMass", &EntityHandle::GetCenterOfMass) .def("GetCenterOfAtoms", &EntityHandle::GetCenterOfAtoms) - .def("GetAtomPosList", &EntityHandle::GetAtomPosList) + .def("GetAtomPosList", &EntityHandle::GetAtomPosList, arg("ordered_by_index")=false) .def("GetGeometricCenter", geom_center<EntityHandle>) .add_property("geometric_center", geom_center<EntityHandle>) diff --git a/modules/mol/base/src/entity_handle.cc b/modules/mol/base/src/entity_handle.cc index eaa348914fec1595be83283c10358cc81df7ea0c..36afa61b34a90251942104963feac606133a5dca 100644 --- a/modules/mol/base/src/entity_handle.cc +++ b/modules/mol/base/src/entity_handle.cc @@ -408,16 +408,23 @@ AtomHandleList EntityHandle::GetAtomList() const return atoms; } -geom::Vec3List EntityHandle::GetAtomPosList() const { +bool less_index(const mol::AtomHandle& a1, const mol::AtomHandle& a2) +{ + return a1.GetIndex()<a2.GetIndex(); +} + +geom::Vec3List EntityHandle::GetAtomPosList(bool ordered_by_index) const { this->CheckValidity(); geom::Vec3List atom_pos_list; atom_pos_list.reserve(this->GetAtomCount()); AtomHandleList atom_list=this->GetAtomList(); + if (ordered_by_index){ + std::sort(atom_list.begin(),atom_list.end(),less_index); + } for (AtomHandleList::const_iterator a=atom_list.begin(), e=atom_list.end(); a!=e; ++a) { atom_pos_list.push_back(a->GetPos()); } return atom_pos_list; - //return Impl()->GetAtomPosList(); } EntityHandle EntityHandle::GetHandle() const diff --git a/modules/mol/base/src/entity_handle.hh b/modules/mol/base/src/entity_handle.hh index 63a2bc6be27c10908072c5ea72ff6106e315d541..d165a997d5d177563add08c78db2544e3b4d8200 100644 --- a/modules/mol/base/src/entity_handle.hh +++ b/modules/mol/base/src/entity_handle.hh @@ -291,7 +291,7 @@ public: AtomHandleList GetAtomList() const; /// \brief get complete list of atom positions - geom::Vec3List GetAtomPosList() const; + geom::Vec3List GetAtomPosList(bool ordered_by_index = false) const; /// \brief Get editor for external coordinate system to manipulate atom /// positions