# HG changeset patch # User Sebastien Jodogne # Date 1448885812 -3600 # Node ID 697ae8d0e287eebaadd8a395ae075d19b88760d0 # Parent 5d8134e54c033d44ad7f1f8a31d23c2156f8e9da better handling of ordered-slices diff -r 5d8134e54c03 -r 697ae8d0e287 OrthancServer/SliceOrdering.cpp --- 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::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::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; } diff -r 5d8134e54c03 -r 697ae8d0e287 Plugins/Engine/OrthancPlugins.cpp --- 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(parameters); - *(p.resultBuffer) = reinterpret_cast(p.image)->GetBuffer(); + const ImageAccessor& image = reinterpret_cast(p.image); + + if (image.IsReadOnly()) + { + throw OrthancException(ErrorCode_ReadOnly); + } + + *(p.resultBuffer) = image.GetBuffer(); return true; } diff -r 5d8134e54c03 -r 697ae8d0e287 Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp --- 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"); + } }