Mercurial > hg > orthanc
changeset 1840:859224214616
simplification of the sample plugin
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 30 Nov 2015 10:34:04 +0100 |
parents | 7f68b04c79e8 |
children | 5d8134e54c03 |
files | Plugins/Engine/OrthancPlugins.cpp 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 Plugins/Samples/GdcmDecoder/Plugin.cpp |
diffstat | 7 files changed, 9 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/Engine/OrthancPlugins.cpp Fri Nov 27 18:17:31 2015 +0100 +++ b/Plugins/Engine/OrthancPlugins.cpp Mon Nov 30 10:34:04 2015 +0100 @@ -2285,10 +2285,8 @@ { return reinterpret_cast<ImageAccessor*>(pluginImage); } - else - { - LOG(WARNING) << "The custom image decoder cannot handle an image, trying with the built-in decoder"; - } + + LOG(WARNING) << "The custom image decoder cannot handle an image, trying with the built-in decoder"; } }
--- a/Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp Fri Nov 27 18:17:31 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp Mon Nov 30 10:34:04 2015 +0100 @@ -77,13 +77,13 @@ md5_ == md5) { // This is the same image: Reuse the previous decoding - return new OrthancImageWrapper(context, *decoder_, frameIndex); + return new OrthancImageWrapper(context, decoder_->Decode(context, frameIndex)); } } // This is not the same image std::auto_ptr<GdcmImageDecoder> decoder(new GdcmImageDecoder(dicom, size)); - std::auto_ptr<OrthancImageWrapper> image(new OrthancImageWrapper(context, *decoder, frameIndex)); + std::auto_ptr<OrthancImageWrapper> image(new OrthancImageWrapper(context, decoder->Decode(context, frameIndex))); { // Cache the newly created decoder for further use
--- a/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.cpp Fri Nov 27 18:17:31 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.cpp Mon Nov 30 10:34:04 2015 +0100 @@ -222,30 +222,6 @@ } - 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 18:17:31 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.h Mon Nov 30 10:34:04 2015 +0100 @@ -45,14 +45,6 @@ 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 18:17:31 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp Mon Nov 30 10:34:04 2015 +0100 @@ -28,11 +28,7 @@ OrthancPluginPixelFormat format, uint32_t width, uint32_t height) : - context_(context), - slope_(1), - intercept_(0), - rowPixelSpacing_(1), - columnPixelSpacing_(1) + context_(context) { image_ = OrthancPluginCreateImage(context_, format, width, height); if (image_ == NULL) @@ -43,14 +39,9 @@ OrthancImageWrapper::OrthancImageWrapper(OrthancPluginContext* context, - GdcmImageDecoder& decoder, - unsigned int frameIndex) : + OrthancPluginImage* image) : context_(context), - image_(decoder.Decode(context, frameIndex)), - slope_(decoder.GetSlope()), - intercept_(decoder.GetIntercept()), - rowPixelSpacing_(decoder.GetRowPixelSpacing()), - columnPixelSpacing_(decoder.GetColumnPixelSpacing()) + image_(image) { }
--- a/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.h Fri Nov 27 18:17:31 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.h Mon Nov 30 10:34:04 2015 +0100 @@ -31,10 +31,6 @@ private: OrthancPluginContext* context_; OrthancPluginImage* image_; - double slope_; - double intercept_; - double rowPixelSpacing_; - double columnPixelSpacing_; public: OrthancImageWrapper(OrthancPluginContext* context, @@ -43,8 +39,7 @@ uint32_t height); OrthancImageWrapper(OrthancPluginContext* context, - GdcmImageDecoder& decoder, - unsigned int frameIndex); + OrthancPluginImage* image); // Takes ownership ~OrthancImageWrapper(); @@ -64,25 +59,5 @@ OrthancPluginPixelFormat GetFormat(); char* GetBuffer(); - - double GetSlope() const - { - return slope_; - } - - double GetIntercept() const - { - return intercept_; - } - - double GetRowPixelSpacing() const - { - return rowPixelSpacing_; - } - - double GetColumnPixelSpacing() const - { - return columnPixelSpacing_; - } }; }
--- a/Plugins/Samples/GdcmDecoder/Plugin.cpp Fri Nov 27 18:17:31 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/Plugin.cpp Mon Nov 30 10:34:04 2015 +0100 @@ -39,7 +39,7 @@ #if 0 // Do not use the cache OrthancPlugins::GdcmImageDecoder decoder(dicom, size); - image.reset(new OrthancPlugins::OrthancImageWrapper(context_, decoder, frameIndex)); + image.reset(new OrthancPlugins::OrthancImageWrapper(context_, decoder.Decode(context_, frameIndex))); #else image.reset(cache_.Decode(context_, dicom, size, frameIndex)); #endif