Mercurial > hg > orthanc
changeset 1836:2faa2abbf311
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 27 Nov 2015 17:40:25 +0100 |
parents | 323dd6402933 |
children | fbc5522023aa |
files | Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp Plugins/Samples/GdcmDecoder/GdcmImageDecoder.cpp Plugins/Samples/GdcmDecoder/GdcmImageDecoder.h Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp Plugins/Samples/GdcmDecoder/OrthancImageWrapper.h |
diffstat | 5 files changed, 60 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp Fri Nov 27 12:54:54 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp Fri Nov 27 17:40:25 2015 +0100 @@ -83,7 +83,7 @@ // This is not the same image std::auto_ptr<GdcmImageDecoder> decoder(new GdcmImageDecoder(dicom, size)); - OrthancImageWrapper image(context, decoder->Decode(context, frameIndex)); + OrthancImageWrapper image(context, *decoder, frameIndex); { // Cache the newly created decoder for further use
--- a/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.cpp Fri Nov 27 12:54:54 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.cpp Fri Nov 27 17:40:25 2015 +0100 @@ -222,6 +222,30 @@ } + double GdcmImageDecoder::GetSlope() const + { + return pimpl_->GetImage().GetSlope(); + } + + + double GdcmImageDecoder::GetIntercept() const + { + return pimpl_->GetImage().GetIntercept(); + } + + + double GdcmImageDecoder::GetColumnPixelSpacing() const + { + return pimpl_->GetImage().GetSpacing(1); + } + + + double GdcmImageDecoder::GetRowPixelSpacing() const + { + return pimpl_->GetImage().GetSpacing(0); + } + + size_t GdcmImageDecoder::GetBytesPerPixel(OrthancPluginPixelFormat format) { switch (format)
--- a/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.h Fri Nov 27 12:54:54 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.h Fri Nov 27 17:40:25 2015 +0100 @@ -45,6 +45,14 @@ unsigned int GetFramesCount() const; + double GetSlope() const; + + double GetIntercept() const; + + double GetColumnPixelSpacing() const; + + double GetRowPixelSpacing() const; + static size_t GetBytesPerPixel(OrthancPluginPixelFormat format); OrthancPluginImage* Decode(OrthancPluginContext* context,
--- a/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp Fri Nov 27 12:54:54 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp Fri Nov 27 17:40:25 2015 +0100 @@ -28,7 +28,11 @@ OrthancPluginPixelFormat format, uint32_t width, uint32_t height) : - context_(context) + context_(context), + slope_(1), + intercept_(0), + rowPixelSpacing_(1), + columnPixelSpacing_(1) { image_ = OrthancPluginCreateImage(context_, format, width, height); if (image_ == NULL) @@ -38,6 +42,20 @@ } + OrthancImageWrapper::OrthancImageWrapper(OrthancPluginContext* context, + GdcmImageDecoder& decoder, + unsigned int frameIndex) : + context_(context), + image_(decoder.Decode(context, frameIndex)), + slope_(decoder.GetSlope()), + intercept_(decoder.GetIntercept()), + rowPixelSpacing_(decoder.GetRowPixelSpacing()), + columnPixelSpacing_(decoder.GetColumnPixelSpacing()) + { + } + + + OrthancImageWrapper::~OrthancImageWrapper() { if (image_ != NULL)
--- a/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.h Fri Nov 27 12:54:54 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.h Fri Nov 27 17:40:25 2015 +0100 @@ -22,6 +22,8 @@ #include <orthanc/OrthancCPlugin.h> +#include "GdcmImageDecoder.h" + namespace OrthancPlugins { class OrthancImageWrapper @@ -29,6 +31,10 @@ private: OrthancPluginContext* context_; OrthancPluginImage* image_; + double slope_; + double intercept_; + double rowPixelSpacing_; + double columnPixelSpacing_; public: OrthancImageWrapper(OrthancPluginContext* context, @@ -36,13 +42,9 @@ uint32_t width, uint32_t height); - // Takes the ownership OrthancImageWrapper(OrthancPluginContext* context, - OrthancPluginImage* image) : - context_(context), - image_(image) - { - } + GdcmImageDecoder& decoder, + unsigned int frameIndex); ~OrthancImageWrapper();