Mercurial > hg > orthanc
changeset 1842:697ae8d0e287
better handling of ordered-slices
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 30 Nov 2015 13:16:52 +0100 |
parents | 5d8134e54c03 |
children | d10a8164da5f |
files | OrthancServer/SliceOrdering.cpp Plugins/Engine/OrthancPlugins.cpp Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp |
diffstat | 3 files changed, 28 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/SliceOrdering.cpp Mon Nov 30 12:05:55 2015 +0100 +++ b/OrthancServer/SliceOrdering.cpp Mon Nov 30 13:16:52 2015 +0100 @@ -276,21 +276,24 @@ PositionComparator comparator(normal_); std::sort(instances_.begin(), instances_.end(), comparator); - float a = instances_.front()->ComputeRelativePosition(normal_); - float b = instances_.back()->ComputeRelativePosition(normal_); - - if (std::fabs(b - a) <= 10.0f * std::numeric_limits<float>::epsilon()) + float a = instances_[0]->ComputeRelativePosition(normal_); + for (size_t i = 1; i < instances_.size(); i++) { - // Not enough difference between the minimum and maximum - // positions along the normal of the volume - return false; + float b = instances_[i]->ComputeRelativePosition(normal_); + + if (std::fabs(b - a) <= 10.0f * std::numeric_limits<float>::epsilon()) + { + // Not enough space between two slices along the normal of the volume + printf("Not enough space\n"); + return false; + } + + a = b; } - else - { - // This is a 3D volume - isVolume_ = true; - return true; - } + + // This is a 3D volume + isVolume_ = true; + return true; }
--- a/Plugins/Engine/OrthancPlugins.cpp Mon Nov 30 12:05:55 2015 +0100 +++ b/Plugins/Engine/OrthancPlugins.cpp Mon Nov 30 13:16:52 2015 +0100 @@ -1964,7 +1964,14 @@ case _OrthancPluginService_GetImageBuffer: { const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters); - *(p.resultBuffer) = reinterpret_cast<const ImageAccessor*>(p.image)->GetBuffer(); + const ImageAccessor& image = reinterpret_cast<const ImageAccessor&>(p.image); + + if (image.IsReadOnly()) + { + throw OrthancException(ErrorCode_ReadOnly); + } + + *(p.resultBuffer) = image.GetBuffer(); return true; }
--- a/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp Mon Nov 30 12:05:55 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp Mon Nov 30 13:16:52 2015 +0100 @@ -43,6 +43,10 @@ context_(context), image_(image) { + if (image_ == NULL) + { + throw std::runtime_error("Invalid image returned by the core of Orthanc"); + } }