Mercurial > hg > orthanc-stone
diff Framework/Toolbox/SlicesSorter.cpp @ 1015:24fecc02bfb1
SlicesSorter::AreAllSlicesDistinct()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 24 Sep 2019 11:16:25 +0200 |
parents | a7351ad54960 |
children | 34ee7204fde3 2d8ab34c8c91 |
line wrap: on
line diff
--- a/Framework/Toolbox/SlicesSorter.cpp Mon Sep 23 15:19:04 2019 +0200 +++ b/Framework/Toolbox/SlicesSorter.cpp Tue Sep 24 11:16:25 2019 +0200 @@ -326,4 +326,32 @@ return spacingZ; } + + + bool SlicesSorter::AreAllSlicesDistinct() const + { + if (GetSlicesCount() <= 1) + { + return true; + } + else + { + const OrthancStone::CoordinateSystem3D& reference = GetSliceGeometry(0); + double previousPosition = reference.ProjectAlongNormal(GetSliceGeometry(0).GetOrigin()); + + for (size_t i = 1; i < GetSlicesCount(); i++) + { + double position = reference.ProjectAlongNormal(GetSliceGeometry(i).GetOrigin()); + + if (OrthancStone::LinearAlgebra::IsNear(position, previousPosition, 0.001 /* tolerance expressed in mm */)) + { + return false; + } + + previousPosition = position; + } + + return true; + } + } }