changeset 139:22628d37ef5c wasm

ImageBuffer3D::GetPixelGrayscale16
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 16 Jan 2018 17:44:16 +0100
parents 77c4fef7f4a5
children 2115530d3703
files Framework/Volumes/ImageBuffer3D.cpp Framework/Volumes/ImageBuffer3D.h
diffstat 2 files changed, 36 insertions(+), 4 deletions(-) [+]
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];
+  }
+
 }
--- a/Framework/Volumes/ImageBuffer3D.h	Tue Jan 16 13:47:54 2018 +0100
+++ b/Framework/Volumes/ImageBuffer3D.h	Tue Jan 16 17:44:16 2018 +0100
@@ -69,11 +69,16 @@
     // depth == 0)
     void SetAxialGeometry(const CoordinateSystem3D& geometry);
 
+    const CoordinateSystem3D& GetAxialGeometry() const
+    {
+      return axialGeometry_;
+    }
+
     void SetVoxelDimensions(double x,
                             double y,
                             double z);
 
-    Vector GetVoxelDimensions(VolumeProjection projection);
+    Vector GetVoxelDimensions(VolumeProjection projection) const;
 
     void GetSliceSize(unsigned int& width,
                       unsigned int& height,
@@ -99,7 +104,7 @@
       return format_;
     }
 
-    ParallelSlices* GetGeometry(VolumeProjection projection);
+    ParallelSlices* GetGeometry(VolumeProjection projection) const;
     
     uint64_t GetEstimatedMemorySize() const;
 
@@ -109,6 +114,10 @@
     bool FitWindowingToRange(RenderStyle& style,
                              const DicomFrameConverter& converter) const;
 
+    uint16_t GetPixelGrayscale16(unsigned int x,
+                                 unsigned int y,
+                                 unsigned int z) const;
+
 
     class SliceReader : public boost::noncopyable
     {