Mercurial > hg > orthanc-wsi
changeset 384:63936f094eaa
merge
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 07 Apr 2025 18:41:34 +0200 |
parents | 30959cb91e89 (diff) 50cb2a69655f (current diff) |
children | 87701a7be3f4 |
files | Framework/Inputs/DicomPyramidInstance.cpp Framework/Inputs/DicomPyramidLevel.cpp |
diffstat | 5 files changed, 60 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Inputs/DicomPyramid.cpp Mon Apr 07 18:08:06 2025 +0200 +++ b/Framework/Inputs/DicomPyramid.cpp Mon Apr 07 18:41:34 2025 +0200 @@ -24,6 +24,7 @@ #include "../PrecompiledHeadersWSI.h" #include "DicomPyramid.h" +#include "../ImageToolbox.h" #include "../DicomToolbox.h" #include <Compatibility.h> @@ -191,6 +192,8 @@ for (size_t i = 0; i < instances_.size(); i++) { + assert(instances_[i] != NULL); + if (i == 0 || instances_[i - 1]->GetTotalWidth() != instances_[i]->GetTotalWidth()) { @@ -201,6 +204,8 @@ assert(levels_.back() != NULL); levels_.back()->AddInstance(*instances_[i]); } + + instances_[i]->SetLevel(levels_.size() - 1); } } @@ -276,7 +281,30 @@ bool DicomPyramid::LookupImagedVolumeSize(double& width, double& height) const { - CheckLevel(0); - return levels_[0]->LookupImagedVolumeSize(width, height, seriesId_); + bool found = false; + + for (size_t i = 0; i < instances_.size(); i++) + { + assert(instances_[i] != NULL); + + if (instances_[i]->IsLevel(0) == 0 && // Only consider the finest level + instances_[i]->HasImagedVolumeSize()) + { + if (!found) + { + found = true; + width = instances_[i]->GetImagedVolumeWidth(); + height = instances_[i]->GetImagedVolumeHeight(); + } + else if (!ImageToolbox::IsNear(width, instances_[i]->GetImagedVolumeWidth()) || + !ImageToolbox::IsNear(height, instances_[i]->GetImagedVolumeHeight())) + { + LOG(WARNING) << "Inconsistency of imaged volume width/height in series: " << seriesId_; + return false; + } + } + } + + return found; } }
--- a/Framework/Inputs/DicomPyramidInstance.cpp Mon Apr 07 18:08:06 2025 +0200 +++ b/Framework/Inputs/DicomPyramidInstance.cpp Mon Apr 07 18:41:34 2025 +0200 @@ -309,7 +309,9 @@ backgroundBlue_(0), hasImagedVolumeSize_(false), imagedVolumeWidth_(0), - imagedVolumeHeight_(0) + imagedVolumeHeight_(0), + hasLevel_(false), + level_(0) { if (useCache) { @@ -574,4 +576,25 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); } } + + + void DicomPyramidInstance::SetLevel(unsigned int level) + { + if (hasLevel_) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); + } + else + { + level_ = level; + hasLevel_ = true; + } + } + + + bool DicomPyramidInstance::IsLevel(unsigned int level) const + { + return (hasLevel_ && + level_ == level); + } }
--- a/Framework/Inputs/DicomPyramidInstance.h Mon Apr 07 18:08:06 2025 +0200 +++ b/Framework/Inputs/DicomPyramidInstance.h Mon Apr 07 18:41:34 2025 +0200 @@ -54,6 +54,8 @@ bool hasImagedVolumeSize_; double imagedVolumeWidth_; double imagedVolumeHeight_; + bool hasLevel_; + unsigned int level_; void Load(OrthancStone::IOrthancConnection& orthanc, const std::string& instanceId); @@ -137,5 +139,9 @@ double GetImagedVolumeWidth() const; double GetImagedVolumeHeight() const; + + void SetLevel(unsigned int level); + + bool IsLevel(unsigned int level) const; }; }
--- a/Framework/Inputs/DicomPyramidLevel.cpp Mon Apr 07 18:08:06 2025 +0200 +++ b/Framework/Inputs/DicomPyramidLevel.cpp Mon Apr 07 18:41:34 2025 +0200 @@ -24,8 +24,6 @@ #include "../PrecompiledHeadersWSI.h" #include "DicomPyramidLevel.h" -#include "../ImageToolbox.h" - #include <Logging.h> #include <OrthancException.h> @@ -173,35 +171,4 @@ return false; } } - - - bool DicomPyramidLevel::LookupImagedVolumeSize(double& width, - double& height, - const std::string& seriesId) const - { - bool found = false; - - for (size_t i = 0; i < tiles_.size(); i++) - { - assert(tiles_[i].instance_ != NULL); - - if (tiles_[i].instance_->HasImagedVolumeSize()) - { - if (!found) - { - found = true; - width = tiles_[i].instance_->GetImagedVolumeWidth(); - height = tiles_[i].instance_->GetImagedVolumeHeight(); - } - else if (!ImageToolbox::IsNear(width, tiles_[i].instance_->GetImagedVolumeWidth()) || - !ImageToolbox::IsNear(height, tiles_[i].instance_->GetImagedVolumeHeight())) - { - LOG(WARNING) << "Inconsistency of imaged volume width/height in series: " << seriesId; - return false; - } - } - } - - return found; - } }
--- a/Framework/Inputs/DicomPyramidLevel.h Mon Apr 07 18:08:06 2025 +0200 +++ b/Framework/Inputs/DicomPyramidLevel.h Mon Apr 07 18:41:34 2025 +0200 @@ -93,9 +93,5 @@ OrthancStone::IOrthancConnection& orthanc, unsigned int tileX, unsigned int tileY) const; - - bool LookupImagedVolumeSize(double& width, - double& height, - const std::string& seriesId) const; }; }