# HG changeset patch # User Sebastien Jodogne # Date 1448876044 -3600 # Node ID 8592242146166182038af4f82bd0c7fc9c3c222e # Parent 7f68b04c79e8aca6563e135b834e2bc8b3e13974 simplification of the sample plugin diff -r 7f68b04c79e8 -r 859224214616 Plugins/Engine/OrthancPlugins.cpp --- 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(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"; } } diff -r 7f68b04c79e8 -r 859224214616 Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp --- 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 decoder(new GdcmImageDecoder(dicom, size)); - std::auto_ptr image(new OrthancImageWrapper(context, *decoder, frameIndex)); + std::auto_ptr image(new OrthancImageWrapper(context, decoder->Decode(context, frameIndex))); { // Cache the newly created decoder for further use diff -r 7f68b04c79e8 -r 859224214616 Plugins/Samples/GdcmDecoder/GdcmImageDecoder.cpp --- 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) diff -r 7f68b04c79e8 -r 859224214616 Plugins/Samples/GdcmDecoder/GdcmImageDecoder.h --- 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, diff -r 7f68b04c79e8 -r 859224214616 Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp --- 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) { } diff -r 7f68b04c79e8 -r 859224214616 Plugins/Samples/GdcmDecoder/OrthancImageWrapper.h --- 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_; - } }; } diff -r 7f68b04c79e8 -r 859224214616 Plugins/Samples/GdcmDecoder/Plugin.cpp --- 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