diff Framework/Volumes/ImageBuffer3D.cpp @ 139:22628d37ef5c wasm

ImageBuffer3D::GetPixelGrayscale16
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 16 Jan 2018 17:44:16 +0100
parents e2fe9352f240
children 88bca952cb17
line wrap: on
line diff
--- a/Framework/Volumes/ImageBuffer3D.cpp	Tue Jan 16 13:47:54 2018 +0100
+++ b/Framework/Volumes/ImageBuffer3D.cpp	Tue Jan 16 17:44:16 2018 +0100
@@ -158,7 +158,7 @@
   }
 
 
-  Vector ImageBuffer3D::GetVoxelDimensions(VolumeProjection projection)
+  Vector ImageBuffer3D::GetVoxelDimensions(VolumeProjection projection) const
   {
     Vector result;
     switch (projection)
@@ -210,7 +210,7 @@
   }
 
 
-  ParallelSlices* ImageBuffer3D::GetGeometry(VolumeProjection projection)
+  ParallelSlices* ImageBuffer3D::GetGeometry(VolumeProjection projection) const
   {
     std::auto_ptr<ParallelSlices> result(new ParallelSlices);
 
@@ -420,4 +420,27 @@
         throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);          
     }
   }
+
+
+  uint16_t ImageBuffer3D::GetPixelGrayscale16(unsigned int x,
+                                              unsigned int y,
+                                              unsigned int z) const
+  {
+    if (format_ != Orthanc::PixelFormat_Grayscale16)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
+    }
+
+    if (x >= width_ ||
+        y >= height_ ||
+        z >= depth_)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+    }
+
+    const void* p = image_.GetConstRow(y + height_ * (depth_ - 1 - z));
+
+    return reinterpret_cast<const uint16_t*>(p) [x];
+  }
+
 }