# HG changeset patch # User Sebastien Jodogne # Date 1558444804 -7200 # Node ID be3671662eecfd74079001d96a758b9afa7bdb99 # Parent 717eabfa749addf9b42a30ffbe21544aa240e1ad moved FitWindowingToRange() from ImageBuffer3D to RenderStyle diff -r 717eabfa749a -r be3671662eec Framework/Deprecated/Layers/RenderStyle.cpp --- a/Framework/Deprecated/Layers/RenderStyle.cpp Tue May 21 14:27:52 2019 +0200 +++ b/Framework/Deprecated/Layers/RenderStyle.cpp Tue May 21 15:20:04 2019 +0200 @@ -21,6 +21,9 @@ #include "RenderStyle.h" +#include "../../Volumes/ImageBuffer3D.h" +#include "../Toolbox/DicomFrameConverter.h" + #include namespace Deprecated @@ -70,4 +73,34 @@ drawColor_[1] = green; drawColor_[2] = blue; } + + + bool RenderStyle::FitRange(const OrthancStone::ImageBuffer3D& image, + const DicomFrameConverter& converter) + { + float minValue, maxValue; + + windowing_ = OrthancStone::ImageWindowing_Custom; + + if (image.GetRange(minValue, maxValue)) + { + // casting the narrower type to wider before calling the + operator + // will prevent overflowing (this is why the cast to double is only + // done on the first operand) + customWindowCenter_ = static_cast( + converter.Apply((static_cast(minValue) + maxValue) / 2.0)); + + customWindowWidth_ = static_cast( + converter.Apply(static_cast(maxValue) - minValue)); + + if (customWindowWidth_ > 1) + { + return true; + } + } + + customWindowCenter_ = 128.0; + customWindowWidth_ = 256.0; + return false; + } } diff -r 717eabfa749a -r be3671662eec Framework/Deprecated/Layers/RenderStyle.h --- a/Framework/Deprecated/Layers/RenderStyle.h Tue May 21 14:27:52 2019 +0200 +++ b/Framework/Deprecated/Layers/RenderStyle.h Tue May 21 15:20:04 2019 +0200 @@ -22,6 +22,8 @@ #pragma once #include "../../StoneEnumerations.h" +#include "../../Volumes/ImageBuffer3D.h" +#include "../Toolbox/DicomFrameConverter.h" #include @@ -54,5 +56,8 @@ void SetColor(uint8_t red, uint8_t green, uint8_t blue); + + bool FitRange(const OrthancStone::ImageBuffer3D& image, + const DicomFrameConverter& converter); }; } diff -r 717eabfa749a -r be3671662eec Framework/Volumes/ImageBuffer3D.cpp --- a/Framework/Volumes/ImageBuffer3D.cpp Tue May 21 14:27:52 2019 +0200 +++ b/Framework/Volumes/ImageBuffer3D.cpp Tue May 21 15:20:04 2019 +0200 @@ -258,35 +258,6 @@ } - bool ImageBuffer3D::FitWindowingToRange(Deprecated::RenderStyle& style, - const Deprecated::DicomFrameConverter& converter) const - { - if (hasRange_) - { - style.windowing_ = ImageWindowing_Custom; - - // casting the narrower type to wider before calling the + operator - // will prevent overflowing (this is why the cast to double is only - // done on the first operand) - style.customWindowCenter_ = static_cast( - converter.Apply((static_cast(minValue_) + maxValue_) / 2.0)); - - style.customWindowWidth_ = static_cast( - converter.Apply(static_cast(maxValue_) - minValue_)); - - if (style.customWindowWidth_ > 1) - { - return true; - } - } - - style.windowing_ = ImageWindowing_Custom; - style.customWindowCenter_ = 128.0; - style.customWindowWidth_ = 256.0; - return false; - } - - ImageBuffer3D::SliceReader::SliceReader(const ImageBuffer3D& that, VolumeProjection projection, unsigned int slice) diff -r 717eabfa749a -r be3671662eec Framework/Volumes/ImageBuffer3D.h --- a/Framework/Volumes/ImageBuffer3D.h Tue May 21 14:27:52 2019 +0200 +++ b/Framework/Volumes/ImageBuffer3D.h Tue May 21 15:20:04 2019 +0200 @@ -21,8 +21,6 @@ #pragma once -#include "../Deprecated/Layers/RenderStyle.h" -#include "../Deprecated/Toolbox/DicomFrameConverter.h" #include "../StoneEnumerations.h" #include "../Toolbox/ParallelSlices.h" #include "../Toolbox/VolumeImageGeometry.h" @@ -121,9 +119,6 @@ bool GetRange(float& minValue, float& maxValue) const; - bool FitWindowingToRange(Deprecated::RenderStyle& style, - const Deprecated::DicomFrameConverter& converter) const; - uint8_t GetVoxelGrayscale8Unchecked(unsigned int x, unsigned int y, unsigned int z) const