# HG changeset patch # User Sebastien Jodogne # Date 1764698525 -3600 # Node ID fc8d9b8acc6b9e5694e600882792ed506822d24e # Parent dee4cce1857a2c176ebe3e18a07c2f1a4f87b1e0 fix SlicesSorter::SelectNormal() diff -r dee4cce1857a -r fc8d9b8acc6b OrthancStone/Sources/Scene2DViewport/MeasureCommands.cpp --- a/OrthancStone/Sources/Scene2DViewport/MeasureCommands.cpp Tue Dec 02 18:43:13 2025 +0100 +++ b/OrthancStone/Sources/Scene2DViewport/MeasureCommands.cpp Tue Dec 02 19:02:05 2025 +0100 @@ -95,8 +95,8 @@ mementoOriginal_(measureTool->CreateMemento()) { std::unique_ptr lock(GetViewportLock()); - GetMeasureTool()->Disable(); - lock->GetController().RemoveMeasureTool(GetMeasureTool()); + measureTool_->Disable(); + lock->GetController().RemoveMeasureTool(measureTool_); } EditMeasureCommand::EditMeasureCommand(boost::shared_ptr measureTool, diff -r dee4cce1857a -r fc8d9b8acc6b OrthancStone/Sources/Toolbox/SlicesSorter.cpp --- a/OrthancStone/Sources/Toolbox/SlicesSorter.cpp Tue Dec 02 18:43:13 2025 +0100 +++ b/OrthancStone/Sources/Toolbox/SlicesSorter.cpp Tue Dec 02 19:02:05 2025 +0100 @@ -188,14 +188,12 @@ } - bool SlicesSorter::SelectNormal(Vector& normal) const + bool SlicesSorter::SelectNormal(Vector& targetNormal) const { std::vector normalCandidates; std::vector normalCount; - bool found = false; - - for (size_t i = 0; !found && i < GetSlicesCount(); i++) + for (size_t i = 0; i < GetSlicesCount(); i++) { const Vector& normal = GetSlice(i).GetGeometry().GetNormal(); @@ -209,31 +207,27 @@ } } - if (add) + if (add && + normalCount.size() <= 2) { - if (normalCount.size() > 2) - { - // To get linear-time complexity in (*). This heuristics - // allows the series to have one single frame that is - // not parallel to the others (such a frame could be a - // generated preview) - found = false; - } - else - { - normalCandidates.push_back(normal); - normalCount.push_back(1); - } + // To get linear-time complexity in (*). This heuristics + // allows the series to have one single frame that is + // not parallel to the others (such a frame could be a + // generated preview) + normalCandidates.push_back(normal); + normalCount.push_back(1); } } + bool found = false; + for (size_t i = 0; !found && i < normalCandidates.size(); i++) { unsigned int count = normalCount[i]; if (count == GetSlicesCount() || count + 1 == GetSlicesCount()) { - normal = normalCandidates[i]; + targetNormal = normalCandidates[i]; found = true; } } diff -r dee4cce1857a -r fc8d9b8acc6b OrthancStone/Sources/Toolbox/SlicesSorter.h --- a/OrthancStone/Sources/Toolbox/SlicesSorter.h Tue Dec 02 18:43:13 2025 +0100 +++ b/OrthancStone/Sources/Toolbox/SlicesSorter.h Tue Dec 02 19:02:05 2025 +0100 @@ -49,7 +49,7 @@ void FilterNormal(const Vector& normal); - bool SelectNormal(Vector& normal) const; + bool SelectNormal(Vector& targetNormal) const; public: SlicesSorter() : hasNormal_(false)