Skip to content
Snippets Groups Projects
Commit 501e9f06 authored by Niklaus Johner's avatar Niklaus Johner Committed by Marco Biasini
Browse files

Fixed atom ordering in the GetFrameFromEntity() function

in the structure_analysis.py module.

This is used to make functions written at the CoordFrame level
accesible to analyze both entities and trajectories.
parent 6f9d2142
Branches
Tags
No related merge requests found
...@@ -13,7 +13,7 @@ def GetFrameFromEntity(eh): ...@@ -13,7 +13,7 @@ def GetFrameFromEntity(eh):
Input: Input:
eh : EntityHandle eh : EntityHandle
""" """
return ost.mol.CreateCoordFrame(eh.GetAtomPosList()) return ost.mol.CreateCoordFrame(eh.GetAtomPosList(ordered_by_index=True))
def GetDistanceBetwCenterOfMass(sele1,sele2): def GetDistanceBetwCenterOfMass(sele1,sele2):
""" """
......
...@@ -155,7 +155,7 @@ void export_Entity() ...@@ -155,7 +155,7 @@ void export_Entity()
.def("GetMass", &EntityHandle::GetMass) .def("GetMass", &EntityHandle::GetMass)
.def("GetCenterOfMass", &EntityHandle::GetCenterOfMass) .def("GetCenterOfMass", &EntityHandle::GetCenterOfMass)
.def("GetCenterOfAtoms", &EntityHandle::GetCenterOfAtoms) .def("GetCenterOfAtoms", &EntityHandle::GetCenterOfAtoms)
.def("GetAtomPosList", &EntityHandle::GetAtomPosList) .def("GetAtomPosList", &EntityHandle::GetAtomPosList, arg("ordered_by_index")=false)
.def("GetGeometricCenter", geom_center<EntityHandle>) .def("GetGeometricCenter", geom_center<EntityHandle>)
.add_property("geometric_center", geom_center<EntityHandle>) .add_property("geometric_center", geom_center<EntityHandle>)
......
...@@ -402,16 +402,23 @@ AtomHandleList EntityHandle::GetAtomList() const ...@@ -402,16 +402,23 @@ AtomHandleList EntityHandle::GetAtomList() const
return atoms; 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(); this->CheckValidity();
geom::Vec3List atom_pos_list; geom::Vec3List atom_pos_list;
atom_pos_list.reserve(this->GetAtomCount()); atom_pos_list.reserve(this->GetAtomCount());
AtomHandleList atom_list=this->GetAtomList(); 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) { for (AtomHandleList::const_iterator a=atom_list.begin(), e=atom_list.end(); a!=e; ++a) {
atom_pos_list.push_back(a->GetPos()); atom_pos_list.push_back(a->GetPos());
} }
return atom_pos_list; return atom_pos_list;
//return Impl()->GetAtomPosList();
} }
EntityHandle EntityHandle::GetHandle() const EntityHandle EntityHandle::GetHandle() const
......
...@@ -289,7 +289,7 @@ public: ...@@ -289,7 +289,7 @@ public:
AtomHandleList GetAtomList() const; AtomHandleList GetAtomList() const;
/// \brief get complete list of atom positions /// \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 /// \brief Get editor for external coordinate system to manipulate atom
/// positions /// positions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment