# HG changeset patch # User Alain Mazy # Date 1588847020 -7200 # Node ID 104e27133ebd5114ce18531aab4cc4994c30d7fd # Parent a4c0ae644fe5cedeefaa589d9adf97436e45fcbf '/ordered-slices': reverted the change introduced in 1.5.8 and go-back to 1.5.7 behaviour diff -r a4c0ae644fe5 -r 104e27133ebd NEWS --- a/NEWS Thu May 07 11:40:54 2020 +0200 +++ b/NEWS Thu May 07 12:23:40 2020 +0200 @@ -11,6 +11,9 @@ - added "Timeout" parameter to every DICOM operation - "/queries/.../answers/../retrieve": "TargetAet" not mandatory anymore (defaults to the local AET) +* Changes: + - "/ordered-slices": reverted the change introduced in 1.5.8 and go-back + to 1.5.7 behaviour. Maintenance ----------- diff -r a4c0ae644fe5 -r 104e27133ebd OrthancServer/SliceOrdering.cpp --- a/OrthancServer/SliceOrdering.cpp Thu May 07 11:40:54 2020 +0200 +++ b/OrthancServer/SliceOrdering.cpp Thu May 07 12:23:40 2020 +0200 @@ -320,7 +320,6 @@ if (instances_.size() <= 1) { // One single instance: It is sorted by default - sortedInstances_ = instances_; return true; } @@ -329,32 +328,25 @@ return false; } - sortedInstances_.clear(); - - // consider only the instances with a position and correctly oriented (if they have a normal) for (size_t i = 0; i < instances_.size(); i++) { assert(instances_[i] != NULL); - if (instances_[i]->HasPosition() && - (!instances_[i]->HasNormal() || - IsParallelOrOpposite(instances_[i]->GetNormal(), normal_))) + + if (!instances_[i]->HasPosition() || + (instances_[i]->HasNormal() && + !IsParallelOrOpposite(instances_[i]->GetNormal(), normal_))) { - sortedInstances_.push_back(instances_[i]); + return false; } } - if (sortedInstances_.size() == 0) - { - return false; - } + PositionComparator comparator(normal_); + std::sort(instances_.begin(), instances_.end(), comparator); - PositionComparator comparator(normal_); - std::sort(sortedInstances_.begin(), sortedInstances_.end(), comparator); - - float a = sortedInstances_[0]->ComputeRelativePosition(normal_); - for (size_t i = 1; i < sortedInstances_.size(); i++) + float a = instances_[0]->ComputeRelativePosition(normal_); + for (size_t i = 1; i < instances_.size(); i++) { - float b = sortedInstances_[i]->ComputeRelativePosition(normal_); + float b = instances_[i]->ComputeRelativePosition(normal_); if (std::fabs(b - a) <= 10.0f * std::numeric_limits::epsilon()) { @@ -376,38 +368,27 @@ if (instances_.size() <= 1) { // One single instance: It is sorted by default - sortedInstances_ = instances_; return true; } - sortedInstances_.clear(); - - // consider only the instances with an index for (size_t i = 0; i < instances_.size(); i++) { assert(instances_[i] != NULL); - if (instances_[i]->HasIndexInSeries()) + if (!instances_[i]->HasIndexInSeries()) { - sortedInstances_.push_back(instances_[i]); + return false; } } - if (sortedInstances_.size() == 0) // if we were not able to sort instances because none of them had an index, return all instances in a "random" order - { - sortedInstances_ = instances_; - } - else + std::sort(instances_.begin(), instances_.end(), IndexInSeriesComparator); + + for (size_t i = 1; i < instances_.size(); i++) { - std::sort(sortedInstances_.begin(), sortedInstances_.end(), IndexInSeriesComparator); - - for (size_t i = 1; i < sortedInstances_.size(); i++) + if (instances_[i - 1]->GetIndexInSeries() == instances_[i]->GetIndexInSeries()) { - if (sortedInstances_[i - 1]->GetIndexInSeries() == sortedInstances_[i]->GetIndexInSeries()) - { - // The current "IndexInSeries" occurs 2 times: Not a proper ordering - LOG(WARNING) << "This series contains 2 slices with the same index, trying to display it anyway"; - break; - } + // The current "IndexInSeries" occurs 2 times: Not a proper ordering + LOG(WARNING) << "This series contains 2 slices with the same index, trying to display it anyway"; + break; } } @@ -446,28 +427,28 @@ } - const std::string& SliceOrdering::GetSortedInstanceId(size_t index) const + const std::string& SliceOrdering::GetInstanceId(size_t index) const { - if (index >= sortedInstances_.size()) + if (index >= instances_.size()) { throw OrthancException(ErrorCode_ParameterOutOfRange); } else { - return sortedInstances_[index]->GetIdentifier(); + return instances_[index]->GetIdentifier(); } } - unsigned int SliceOrdering::GetSortedInstanceFramesCount(size_t index) const + unsigned int SliceOrdering::GetFramesCount(size_t index) const { - if (index >= sortedInstances_.size()) + if (index >= instances_.size()) { throw OrthancException(ErrorCode_ParameterOutOfRange); } else { - return sortedInstances_[index]->GetFramesCount(); + return instances_[index]->GetFramesCount(); } } @@ -478,9 +459,9 @@ result["Type"] = (isVolume_ ? "Volume" : "Sequence"); Json::Value tmp = Json::arrayValue; - for (size_t i = 0; i < GetSortedInstancesCount(); i++) + for (size_t i = 0; i < GetInstancesCount(); i++) { - tmp.append(GetBasePath(ResourceType_Instance, GetSortedInstanceId(i)) + "/file"); + tmp.append(GetBasePath(ResourceType_Instance, GetInstanceId(i)) + "/file"); } result["Dicom"] = tmp; @@ -488,18 +469,18 @@ Json::Value slicesShort = Json::arrayValue; tmp.clear(); - for (size_t i = 0; i < GetSortedInstancesCount(); i++) + for (size_t i = 0; i < GetInstancesCount(); i++) { - std::string base = GetBasePath(ResourceType_Instance, GetSortedInstanceId(i)); - for (size_t j = 0; j < GetSortedInstanceFramesCount(i); j++) + std::string base = GetBasePath(ResourceType_Instance, GetInstanceId(i)); + for (size_t j = 0; j < GetFramesCount(i); j++) { tmp.append(base + "/frames/" + boost::lexical_cast(j)); } Json::Value tmp2 = Json::arrayValue; - tmp2.append(GetSortedInstanceId(i)); + tmp2.append(GetInstanceId(i)); tmp2.append(0); - tmp2.append(GetSortedInstanceFramesCount(i)); + tmp2.append(GetFramesCount(i)); slicesShort.append(tmp2); } diff -r a4c0ae644fe5 -r 104e27133ebd OrthancServer/SliceOrdering.h --- a/OrthancServer/SliceOrdering.h Thu May 07 11:40:54 2020 +0200 +++ b/OrthancServer/SliceOrdering.h Thu May 07 12:23:40 2020 +0200 @@ -51,8 +51,7 @@ std::string seriesId_; bool hasNormal_; Vector normal_; - std::vector instances_; // this vector owns the instances - std::vector sortedInstances_; // this vectore references the instances of instances_ + std::vector instances_; bool isVolume_; static bool ComputeNormal(Vector& normal, @@ -78,14 +77,14 @@ ~SliceOrdering(); - size_t GetSortedInstancesCount() const + size_t GetInstancesCount() const { - return sortedInstances_.size(); + return instances_.size(); } - const std::string& GetSortedInstanceId(size_t index) const; + const std::string& GetInstanceId(size_t index) const; - unsigned int GetSortedInstanceFramesCount(size_t index) const; + unsigned int GetFramesCount(size_t index) const; void Format(Json::Value& result) const; };