From 6086791ded73048820f26a6cb70f52ea6250fee3 Mon Sep 17 00:00:00 2001
From: Ansgar Philippsen <ansgar.philippsen@gmail.com>
Date: Tue, 19 Jun 2012 11:32:45 -0400
Subject: [PATCH] fixed img.alg.FractionalShift ignoring absolute origin; some
 more img py exports

---
 modules/img/alg/src/fractional_shift.cc       | 7 ++++++-
 modules/img/base/pymod/export_image_handle.cc | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/modules/img/alg/src/fractional_shift.cc b/modules/img/alg/src/fractional_shift.cc
index b7545a523..1d10dac29 100644
--- a/modules/img/alg/src/fractional_shift.cc
+++ b/modules/img/alg/src/fractional_shift.cc
@@ -56,7 +56,10 @@ Vec3 FractionalShift::GetShift() const
 
 void FractionalShift::Visit(ImageHandle& ih)
 {  
+  Vec3 ao=ih.GetAbsoluteOrigin();
+
   bool spatialflag=false;
+
   if(ih.GetDomain()==SPATIAL){
     spatialflag=true;
     ih.ApplyIP(FFT());
@@ -72,10 +75,12 @@ void FractionalShift::Visit(ImageHandle& ih)
   for(ExtentIterator it=ih.GetIterator();!it.AtEnd();++it) {
     ih.SetComplex(it,ih.GetComplex(it)*std::polar<Real>(1.0,-Dot(phaseshift,Point(it).ToVec3())));
   }
+
   if(spatialflag){
-    //back FFT
     ih.ApplyIP(FFT());
   }
+  // update spatial origin
+  ih.SetAbsoluteOrigin(ao-shift_);
 }
 
 }}}//ns
diff --git a/modules/img/base/pymod/export_image_handle.cc b/modules/img/base/pymod/export_image_handle.cc
index bbfdd713c..ff8197f31 100644
--- a/modules/img/base/pymod/export_image_handle.cc
+++ b/modules/img/base/pymod/export_image_handle.cc
@@ -205,9 +205,11 @@ void export_ImageHandle()
     .def("SetComplex",&ImageHandle::SetComplex, args("point","value"))
     .def("SetSpatialOrigin",&ImageHandle::SetSpatialOrigin)
     .def("GetSpatialOrigin",&ImageHandle::GetSpatialOrigin)
+    .add_property("spatial_origin",&ImageHandle::GetSpatialOrigin,&ImageHandle::SetSpatialOrigin)
     .def("CenterSpatialOrigin",&ImageHandle::CenterSpatialOrigin)
     .def("SetAbsoluteOrigin",&ImageHandle::SetAbsoluteOrigin)
     .def("GetAbsoluteOrigin",&ImageHandle::GetAbsoluteOrigin)
+    .add_property("absolute_origin",&ImageHandle::GetAbsoluteOrigin,&ImageHandle::SetAbsoluteOrigin)
     .def("IndexToCoord",&ImageHandle::IndexToCoord)
     .def("CoordToIndex",&ImageHandle::CoordToIndex)
     .def("FractionalIndexToCoord",&ImageHandle::FractionalIndexToCoord)
@@ -296,7 +298,9 @@ void export_ConstImageHandle()
     .def("Apply",apply_cmodip)
     .def("Apply",apply_cmodop)
     .def("GetSpatialOrigin",&ConstImageHandle::GetSpatialOrigin)
+    .add_property("spatial_origin",&ImageHandle::GetSpatialOrigin)
     .def("GetAbsoluteOrigin",&ConstImageHandle::GetAbsoluteOrigin)
+    .add_property("absolute_origin",&ImageHandle::GetAbsoluteOrigin)
     .def("IndexToCoord",&ConstImageHandle::IndexToCoord)
     .def("CoordToIndex",&ConstImageHandle::CoordToIndex)
     .def("FractionalIndexToCoord",&ConstImageHandle::FractionalIndexToCoord)
-- 
GitLab