# HG changeset patch # User Sebastien Jodogne # Date 1573911453 -3600 # Node ID 34ee7204fde3523755f1656f98f9ab7bfca339b0 # Parent e265ed3f78438e34b6eb95beb891482e9f0ce6f5 removing IGeometryProvider diff -r e265ed3f7843 -r 34ee7204fde3 Framework/Loaders/OrthancMultiframeVolumeLoader.h --- a/Framework/Loaders/OrthancMultiframeVolumeLoader.h Sat Nov 16 11:26:13 2019 +0100 +++ b/Framework/Loaders/OrthancMultiframeVolumeLoader.h Sat Nov 16 14:37:33 2019 +0100 @@ -30,8 +30,7 @@ { class OrthancMultiframeVolumeLoader : public LoaderStateMachine, - public IObservable, - public IGeometryProvider + public IObservable { private: class LoadRTDoseGeometry; @@ -57,8 +56,8 @@ void SetUncompressedPixelData(const std::string& pixelData); - virtual bool HasGeometry() const ORTHANC_OVERRIDE; - virtual const VolumeImageGeometry& GetImageGeometry() const ORTHANC_OVERRIDE; + bool HasGeometry() const; + const VolumeImageGeometry& GetImageGeometry() const; public: OrthancMultiframeVolumeLoader(boost::shared_ptr volume, diff -r e265ed3f7843 -r 34ee7204fde3 Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp --- a/Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Sat Nov 16 11:26:13 2019 +0100 +++ b/Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Sat Nov 16 14:37:33 2019 +0100 @@ -185,18 +185,27 @@ CheckVolume(); - const double spacingZ = slices.ComputeSpacingBetweenSlices(); - LOG(INFO) << "Computed spacing between slices: " << spacingZ << "mm"; + double spacingZ; + + if (slices.ComputeSpacingBetweenSlices(spacingZ)) + { + LOG(INFO) << "Computed spacing between slices: " << spacingZ << "mm"; - const DicomInstanceParameters& parameters = *slices_[0]; + const DicomInstanceParameters& parameters = *slices_[0]; - geometry_.reset(new VolumeImageGeometry); - geometry_->SetSizeInVoxels(parameters.GetImageInformation().GetWidth(), - parameters.GetImageInformation().GetHeight(), - static_cast(slices.GetSlicesCount())); - geometry_->SetAxialGeometry(slices.GetSliceGeometry(0)); - geometry_->SetVoxelDimensions(parameters.GetPixelSpacingX(), - parameters.GetPixelSpacingY(), spacingZ); + geometry_.reset(new VolumeImageGeometry); + geometry_->SetSizeInVoxels(parameters.GetImageInformation().GetWidth(), + parameters.GetImageInformation().GetHeight(), + static_cast(slices.GetSlicesCount())); + geometry_->SetAxialGeometry(slices.GetSliceGeometry(0)); + geometry_->SetVoxelDimensions(parameters.GetPixelSpacingX(), + parameters.GetPixelSpacingY(), spacingZ); + } + else + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, + "The origins of the slices of a volume image are not regularly spaced"); + } } } diff -r e265ed3f7843 -r 34ee7204fde3 Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h --- a/Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h Sat Nov 16 11:26:13 2019 +0100 +++ b/Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h Sat Nov 16 14:37:33 2019 +0100 @@ -44,8 +44,7 @@ class OrthancSeriesVolumeProgressiveLoader : public ObserverBase, public IObservable, - public IVolumeSlicer, - public IGeometryProvider + public IVolumeSlicer { private: static const unsigned int LOW_QUALITY = 0; @@ -140,7 +139,7 @@ subscribing, for instance if they are created or listening only AFTER the "geometry loaded" message is broadcast */ - bool HasGeometry() const ORTHANC_OVERRIDE + bool HasGeometry() const { return seriesGeometry_.HasGeometry(); } @@ -148,7 +147,7 @@ /** Same remark as HasGeometry */ - const VolumeImageGeometry& GetImageGeometry() const ORTHANC_OVERRIDE + const VolumeImageGeometry& GetImageGeometry() const { return seriesGeometry_.GetImageGeometry(); } diff -r e265ed3f7843 -r 34ee7204fde3 Framework/Toolbox/SlicesSorter.cpp --- a/Framework/Toolbox/SlicesSorter.cpp Sat Nov 16 11:26:13 2019 +0100 +++ b/Framework/Toolbox/SlicesSorter.cpp Sat Nov 16 14:37:33 2019 +0100 @@ -289,13 +289,14 @@ } - double SlicesSorter::ComputeSpacingBetweenSlices() const + bool SlicesSorter::ComputeSpacingBetweenSlices(double& spacing /* out */) const { if (GetSlicesCount() <= 1) { // This is a volume that is empty or that contains one single // slice: Choose a dummy z-dimension for voxels - return 1.0; + spacing = 1.0; + return true; } const OrthancStone::CoordinateSystem3D& reference = GetSliceGeometry(0); @@ -303,28 +304,27 @@ double referencePosition = reference.ProjectAlongNormal(reference.GetOrigin()); double p = reference.ProjectAlongNormal(GetSliceGeometry(1).GetOrigin()); - double spacingZ = p - referencePosition; + spacing = p - referencePosition; - if (spacingZ <= 0) + if (spacing <= 0) { - LOG(ERROR) << "SlicesSorter::ComputeSpacingBetweenSlices(): (spacingZ <= 0)"; + LOG(ERROR) << "SlicesSorter::ComputeSpacingBetweenSlices(): (spacing <= 0)"; throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, "Please call the Sort() method before"); } for (size_t i = 1; i < GetSlicesCount(); i++) { - OrthancStone::Vector p = reference.GetOrigin() + spacingZ * static_cast(i) * reference.GetNormal(); + OrthancStone::Vector p = reference.GetOrigin() + spacing * static_cast(i) * reference.GetNormal(); double d = boost::numeric::ublas::norm_2(p - GetSliceGeometry(i).GetOrigin()); if (!OrthancStone::LinearAlgebra::IsNear(d, 0, 0.001 /* tolerance expressed in mm */)) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, - "The origins of the slices of a volume image are not regularly spaced"); + return false; } } - return spacingZ; + return true; } diff -r e265ed3f7843 -r 34ee7204fde3 Framework/Toolbox/SlicesSorter.h --- a/Framework/Toolbox/SlicesSorter.h Sat Nov 16 11:26:13 2019 +0100 +++ b/Framework/Toolbox/SlicesSorter.h Sat Nov 16 14:37:33 2019 +0100 @@ -91,7 +91,7 @@ const CoordinateSystem3D& slice) const; // WARNING - The slices must have been sorted before calling this method - double ComputeSpacingBetweenSlices() const; + bool ComputeSpacingBetweenSlices(double& spacing /* out */) const; // WARNING - The slices must have been sorted before calling this method bool AreAllSlicesDistinct() const; diff -r e265ed3f7843 -r 34ee7204fde3 Framework/Volumes/DicomVolumeImage.h --- a/Framework/Volumes/DicomVolumeImage.h Sat Nov 16 11:26:13 2019 +0100 +++ b/Framework/Volumes/DicomVolumeImage.h Sat Nov 16 14:37:33 2019 +0100 @@ -28,14 +28,6 @@ namespace OrthancStone { - class IGeometryProvider - { - public: - virtual ~IGeometryProvider() {} - virtual bool HasGeometry() const = 0; - virtual const VolumeImageGeometry& GetImageGeometry() const = 0; - }; - /** This class combines a 3D image buffer, a 3D volume geometry and information about the DICOM parameters of the series.