From dcb5cc6895c68beab9252799c5fe188bcba315b5 Mon Sep 17 00:00:00 2001
From: Niklaus Johner <nij2003@med.cornell.edu>
Date: Fri, 23 Mar 2012 15:35:45 -0400
Subject: [PATCH] changed mol.alg.CalculateAgreementWithDensityMap to
 mol.alg.CalculateAverageAgreementWithDensityMap and adapted its output
 accordingly

---
 modules/mol/alg/pymod/export_structure_analysis.cc | 2 +-
 modules/mol/alg/src/structure_analysis.cc          | 4 ++--
 modules/mol/alg/src/structure_analysis.hh          | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/mol/alg/pymod/export_structure_analysis.cc b/modules/mol/alg/pymod/export_structure_analysis.cc
index dc60e67b9..4a07ad568 100644
--- a/modules/mol/alg/pymod/export_structure_analysis.cc
+++ b/modules/mol/alg/pymod/export_structure_analysis.cc
@@ -27,6 +27,6 @@ using namespace ost::mol::alg;
 void export_StructureAnalysis()
 {
   def("GetPosListFromView",&GetPosListFromView, (arg("view")));
-  def("CalculateAgreementWithDensityMap",&CalculateAgreementWithDensityMap,(arg("pos_list"),arg("density_map")));
+  def("CalculateAverageAgreementWithDensityMap",&CalculateAverageAgreementWithDensityMap,(arg("pos_list"),arg("density_map")));
   def("WrapEntityInPeriodicCell",&WrapEntityInPeriodicCell,(arg("Entity"),arg("cell_center"),arg("nasis_vec")));
 }
\ No newline at end of file
diff --git a/modules/mol/alg/src/structure_analysis.cc b/modules/mol/alg/src/structure_analysis.cc
index bef3588e3..f4d4a50ba 100644
--- a/modules/mol/alg/src/structure_analysis.cc
+++ b/modules/mol/alg/src/structure_analysis.cc
@@ -39,7 +39,7 @@ geom::Vec3List GetPosListFromView(const EntityView& view){
   return vl;
 }    
   
-Real CalculateAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map){
+Real CalculateAverageAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map){
   Real sum,v;
   sum=0;
   CheckHandleValidity(density_map);
@@ -48,7 +48,7 @@ Real CalculateAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle&
     v=density_map.GetReal(p);
     sum=sum+v;
   }
-  return sum;
+  return sum/float(vl.size());
 }
  
 void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec){
diff --git a/modules/mol/alg/src/structure_analysis.hh b/modules/mol/alg/src/structure_analysis.hh
index c3f1f8596..529357037 100644
--- a/modules/mol/alg/src/structure_analysis.hh
+++ b/modules/mol/alg/src/structure_analysis.hh
@@ -32,7 +32,7 @@
 
 namespace ost { namespace mol { namespace alg {
   geom::Vec3List DLLEXPORT_OST_MOL_ALG GetPosListFromView(const EntityView& view);
-  Real DLLEXPORT_OST_MOL_ALG CalculateAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map);
+  Real DLLEXPORT_OST_MOL_ALG CalculateAverageAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map);
   void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec);
 }}}//ns
 #endif
-- 
GitLab