Mercurial > hg > orthanc-stone
changeset 648:1088d4c4d78c
cont
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 13 May 2019 17:19:04 +0200 |
parents | 6af3099ed8da |
children | 6646957eff7f |
files | Framework/Toolbox/OrthancSlicesLoader.cpp Framework/Toolbox/Slice.h Framework/Toolbox/SlicesSorter.cpp Framework/Toolbox/SlicesSorter.h Samples/Sdl/Loader.cpp |
diffstat | 5 files changed, 50 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Toolbox/OrthancSlicesLoader.cpp Mon May 13 17:03:46 2019 +0200 +++ b/Framework/Toolbox/OrthancSlicesLoader.cpp Mon May 13 17:19:04 2019 +0200 @@ -191,19 +191,7 @@ void OrthancSlicesLoader::SortAndFinalizeSlices() { - bool ok = false; - - if (slices_.GetSlicesCount() > 0) - { - Vector normal; - if (slices_.SelectNormal(normal)) - { - slices_.FilterNormal(normal); - slices_.SetNormal(normal); - slices_.Sort(); - ok = true; - } - } + bool ok = slices_.Sort(); state_ = State_GeometryReady;
--- a/Framework/Toolbox/Slice.h Mon May 13 17:03:46 2019 +0200 +++ b/Framework/Toolbox/Slice.h Mon May 13 17:19:04 2019 +0200 @@ -29,7 +29,9 @@ namespace OrthancStone { - class Slice : public Orthanc::IDynamicObject + // TODO - Remove this class + class Slice : + public Orthanc::IDynamicObject /* to be used as a payload of SlicesSorter */ { private: enum Type
--- a/Framework/Toolbox/SlicesSorter.cpp Mon May 13 17:03:46 2019 +0200 +++ b/Framework/Toolbox/SlicesSorter.cpp Mon May 13 17:19:04 2019 +0200 @@ -148,7 +148,7 @@ } - void SlicesSorter::Sort() + void SlicesSorter::SortInternal() { if (!hasNormal_) { @@ -237,6 +237,24 @@ } + bool SlicesSorter::Sort() + { + if (GetSlicesCount() > 0) + { + Vector normal; + if (SelectNormal(normal)) + { + FilterNormal(normal); + SetNormal(normal); + SortInternal(); + return true; + } + } + + return false; + } + + bool SlicesSorter::LookupClosestSlice(size_t& index, double& distance, const CoordinateSystem3D& slice) const
--- a/Framework/Toolbox/SlicesSorter.h Mon May 13 17:03:46 2019 +0200 +++ b/Framework/Toolbox/SlicesSorter.h Mon May 13 17:19:04 2019 +0200 @@ -41,6 +41,14 @@ const SliceWithDepth& GetSlice(size_t i) const; + void SetNormal(const Vector& normal); + + void SortInternal(); + + void FilterNormal(const Vector& normal); + + bool SelectNormal(Vector& normal) const; + public: SlicesSorter() : hasNormal_(false) { @@ -71,15 +79,9 @@ bool HasSlicePayload(size_t i) const; const Orthanc::IDynamicObject& GetSlicePayload(size_t i) const; - - void SetNormal(const Vector& normal); + + bool Sort(); - void Sort(); - - void FilterNormal(const Vector& normal); - - bool SelectNormal(Vector& normal) const; - bool LookupClosestSlice(size_t& index, double& distance, const CoordinateSystem3D& slice) const;
--- a/Samples/Sdl/Loader.cpp Mon May 13 17:03:46 2019 +0200 +++ b/Samples/Sdl/Loader.cpp Mon May 13 17:19:04 2019 +0200 @@ -26,6 +26,7 @@ #include "../../Framework/StoneInitialization.h" #include "../../Framework/Toolbox/GeometryToolbox.h" #include "../../Framework/Volumes/ImageBuffer3D.h" +#include "../../Framework/Toolbox/SlicesSorter.h" // From Orthanc framework #include <Core/Compression/GzipCompressor.h> @@ -1138,7 +1139,8 @@ - class DicomInstanceParameters : public boost::noncopyable + class DicomInstanceParameters : + public Orthanc::IDynamicObject /* to be used as a payload of SlicesSorter */ { private: Orthanc::DicomImageInformation imageInformation_; @@ -1374,8 +1376,8 @@ double distance; - return (OrthancStone::CoordinateSystem3D::GetDistance(distance, tmp, plan) && - OrthancStone::LinearAlgebra::IsNear(distance, thickness_ / 2.0)); + return (OrthancStone::CoordinateSystem3D::GetDistance(distance, tmp, plane) && + distance <= thickness_ / 2.0); } bool IsColor() const @@ -1491,9 +1493,19 @@ Orthanc::DicomMap dicom; dicom.FromDicomAsJson(value[instances[i]]); - DicomInstanceParameters instance(dicom); + std::auto_ptr<DicomInstanceParameters> instance(new DicomInstanceParameters(dicom)); + + OrthancStone::CoordinateSystem3D geometry = instance->GetGeometry(); + that_.slices_.AddSlice(geometry, instance.release()); + } + if (!that_.slices_.Sort()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, + "Cannot sort the 3D slices of a DICOM series"); } + + printf("series sorted\n"); } }; @@ -1529,7 +1541,7 @@ bool active_; std::auto_ptr<OrthancStone::ImageBuffer3D> image_; - + OrthancStone::SlicesSorter slices_; public: AxialVolumeOrthancLoader(OrthancStone::IObservable& oracle) :