Mercurial > hg > orthanc-stone
changeset 2252:fc8d9b8acc6b
fix SlicesSorter::SelectNormal()
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Tue, 02 Dec 2025 19:02:05 +0100 |
| parents | dee4cce1857a |
| children | 1c2d1d247afb |
| files | OrthancStone/Sources/Scene2DViewport/MeasureCommands.cpp OrthancStone/Sources/Toolbox/SlicesSorter.cpp OrthancStone/Sources/Toolbox/SlicesSorter.h |
| diffstat | 3 files changed, 16 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- 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<IViewport::ILock> lock(GetViewportLock()); - GetMeasureTool()->Disable(); - lock->GetController().RemoveMeasureTool(GetMeasureTool()); + measureTool_->Disable(); + lock->GetController().RemoveMeasureTool(measureTool_); } EditMeasureCommand::EditMeasureCommand(boost::shared_ptr<MeasureTool> measureTool,
--- 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<Vector> normalCandidates; std::vector<unsigned int> 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; } }
--- 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)
