From 542653d3497dbeae6fb2353b85025403ac1295ee Mon Sep 17 00:00:00 2001
From: Niklaus Johner <nij2003@med.cornell.edu>
Date: Thu, 17 May 2012 19:37:27 -0400
Subject: [PATCH] Added EntityHandle::GetAtomPosList This function returns a
 geom::Vec3List containing the positions of all the atoms in the entity.

---
 modules/mol/base/pymod/export_entity.cc  | 1 +
 modules/mol/base/src/entity_handle.cc    | 5 +++++
 modules/mol/base/src/entity_handle.hh    | 3 +++
 modules/mol/base/src/impl/entity_impl.cc | 9 +++++++++
 modules/mol/base/src/impl/entity_impl.hh | 2 +-
 5 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/modules/mol/base/pymod/export_entity.cc b/modules/mol/base/pymod/export_entity.cc
index c46f07284..6fda49c79 100644
--- a/modules/mol/base/pymod/export_entity.cc
+++ b/modules/mol/base/pymod/export_entity.cc
@@ -147,6 +147,7 @@ void export_Entity()
     .def("GetMass", &EntityHandle::GetMass)
     .def("GetCenterOfMass", &EntityHandle::GetCenterOfMass)
     .def("GetCenterOfAtoms", &EntityHandle::GetCenterOfAtoms)
+    .def("GetAtomPosList", &EntityHandle::GetAtomPosList)
     .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 e975132ea..63145be7e 100644
--- a/modules/mol/base/src/entity_handle.cc
+++ b/modules/mol/base/src/entity_handle.cc
@@ -362,6 +362,11 @@ AtomHandleList EntityHandle::GetAtomList() const
   return atoms;
 }
 
+geom::Vec3List EntityHandle::GetAtomPosList() const {
+  this->CheckValidity();
+  return Impl()->GetAtomPosList();
+}
+  
 EntityHandle EntityHandle::GetHandle() const
 {
   return *this;
diff --git a/modules/mol/base/src/entity_handle.hh b/modules/mol/base/src/entity_handle.hh
index 0fcadee77..67b2a847e 100644
--- a/modules/mol/base/src/entity_handle.hh
+++ b/modules/mol/base/src/entity_handle.hh
@@ -280,6 +280,9 @@ public:
   /// \sa #AtomsBegin, #AtomsEnd
   AtomHandleList GetAtomList() const;
   
+  /// \brief get complete list of atom positions
+  geom::Vec3List GetAtomPosList() const;
+  
   /// \brief Get editor for external coordinate system to manipulate atom 
   ///     positions
   /// \sa editors
diff --git a/modules/mol/base/src/impl/entity_impl.cc b/modules/mol/base/src/impl/entity_impl.cc
index daf9c7c1f..f2fbd6d81 100644
--- a/modules/mol/base/src/impl/entity_impl.cc
+++ b/modules/mol/base/src/impl/entity_impl.cc
@@ -307,6 +307,15 @@ geom::Vec3 EntityImpl::GetCenterOfMass() const {
   return center;
 }
 
+geom::Vec3List EntityImpl::GetAtomPosList() const {
+  geom::Vec3List atom_pos_list;
+  atom_pos_list.reserve(this->GetAtomCount());
+  for(AtomImplMap::const_iterator it = atom_map_.begin();it!=atom_map_.end();++it) {
+    atom_pos_list.push_back(it->second->TransformedPos());
+  }
+  return atom_pos_list;
+}
+  
 Real EntityImpl::GetMass() const {
   double mass=0.0;
   for (ChainImplList::const_iterator i=chain_list_.begin(), 
diff --git a/modules/mol/base/src/impl/entity_impl.hh b/modules/mol/base/src/impl/entity_impl.hh
index dd88fb325..8d8e53017 100644
--- a/modules/mol/base/src/impl/entity_impl.hh
+++ b/modules/mol/base/src/impl/entity_impl.hh
@@ -93,7 +93,7 @@ public:
   Real GetMass() const;
   geom::Vec3 GetCenterOfMass() const;
   geom::Vec3 GetCenterOfAtoms() const;
-  
+  geom::Vec3List GetAtomPosList() const;
   /// \brief returns the axis-aligned bounding box of the entity
   geom::AlignedCuboid GetBounds() const;
   
-- 
GitLab