changeset 187:a12ca0f4aaaa wasm

ImageBuffer3D::GetCoordinates
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 15 Mar 2018 17:45:48 +0100
parents fac46066b933
children 45b03b04a777
files Framework/Volumes/ImageBuffer3D.cpp Framework/Volumes/ImageBuffer3D.h Framework/Volumes/VolumeReslicer.cpp
diffstat 3 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Volumes/ImageBuffer3D.cpp	Thu Mar 15 16:11:45 2018 +0100
+++ b/Framework/Volumes/ImageBuffer3D.cpp	Thu Mar 15 17:45:48 2018 +0100
@@ -462,4 +462,22 @@
     const void* p = image_.GetConstRow(y + height_ * (depth_ - 1 - z));
     return reinterpret_cast<const uint16_t*>(p) [x];
   }
+
+
+  Vector ImageBuffer3D::GetCoordinates(float x,
+                                       float y,
+                                       float z) const
+  {
+    Vector ps = GetVoxelDimensions(OrthancStone::VolumeProjection_Axial);
+
+    const CoordinateSystem3D& axial = GetAxialGeometry();
+    
+    Vector origin = (axial.MapSliceToWorldCoordinates(-0.5 * ps[0], -0.5 * ps[1]) -
+                     0.5 * ps[2] * axial.GetNormal());
+
+    return (origin +
+            axial.GetAxisX() * ps[0] * x * static_cast<double>(GetWidth()) +
+            axial.GetAxisY() * ps[1] * y * static_cast<double>(GetHeight()) +
+            axial.GetNormal() * ps[2] * z * static_cast<double>(GetDepth()));
+  }
 }
--- a/Framework/Volumes/ImageBuffer3D.h	Thu Mar 15 16:11:45 2018 +0100
+++ b/Framework/Volumes/ImageBuffer3D.h	Thu Mar 15 17:45:48 2018 +0100
@@ -158,6 +158,12 @@
                                  unsigned int y,
                                  unsigned int z) const;
 
+    // Get the 3D position of a point in the volume, where x, y and z
+    // lie in the [0;1] range
+    Vector GetCoordinates(float x,
+                          float y,
+                          float z) const;
+
 
     class SliceReader : public boost::noncopyable
     {
--- a/Framework/Volumes/VolumeReslicer.cpp	Thu Mar 15 16:11:45 2018 +0100
+++ b/Framework/Volumes/VolumeReslicer.cpp	Thu Mar 15 17:45:48 2018 +0100
@@ -30,8 +30,6 @@
 
 #include <boost/math/special_functions/round.hpp>
 
-#include <stdio.h>
-
 namespace OrthancStone
 {
   // Anonymous namespace to avoid clashes between compilation modules