# HG changeset patch # User Sebastien Jodogne # Date 1623319624 -7200 # Node ID 126522623e20868fbb1da546ac2399a21fb05c49 # Parent 3c0996f028a12a4acdb2e800da5b4c11c0167397 replaced OrthancStone::DicomPath by new class Orthanc::DicomPath from orthanc framework diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Resources/CMake/OrthancStoneConfiguration.cmake --- a/OrthancStone/Resources/CMake/OrthancStoneConfiguration.cmake Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Resources/CMake/OrthancStoneConfiguration.cmake Thu Jun 10 12:07:04 2021 +0200 @@ -206,7 +206,6 @@ list(APPEND ORTHANC_STONE_SOURCES ${ORTHANC_STONE_ROOT}/Toolbox/OrthancDatasets/DicomDatasetReader.cpp - ${ORTHANC_STONE_ROOT}/Toolbox/OrthancDatasets/DicomPath.cpp ${ORTHANC_STONE_ROOT}/Toolbox/OrthancDatasets/FullOrthancDataset.cpp ${ORTHANC_STONE_ROOT}/Toolbox/OrthancDatasets/IOrthancConnection.cpp diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/CoordinateSystem3D.cpp --- a/OrthancStone/Sources/Toolbox/CoordinateSystem3D.cpp Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/CoordinateSystem3D.cpp Thu Jun 10 12:07:04 2021 +0200 @@ -138,8 +138,8 @@ { std::string a, b; - if (dicom.GetStringValue(a, DicomPath(Orthanc::DICOM_TAG_IMAGE_POSITION_PATIENT)) && - dicom.GetStringValue(b, DicomPath(Orthanc::DICOM_TAG_IMAGE_ORIENTATION_PATIENT))) + if (dicom.GetStringValue(a, Orthanc::DicomPath(Orthanc::DICOM_TAG_IMAGE_POSITION_PATIENT)) && + dicom.GetStringValue(b, Orthanc::DicomPath(Orthanc::DICOM_TAG_IMAGE_ORIENTATION_PATIENT))) { Setup(a, b); } diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/DicomStructure2.cpp --- a/OrthancStone/Sources/Toolbox/DicomStructure2.cpp Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/DicomStructure2.cpp Thu Jun 10 12:07:04 2021 +0200 @@ -26,6 +26,8 @@ #include "GeometryToolbox.h" #include "DisjointDataSet.h" +#include + namespace OrthancStone { // see header diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/DicomStructurePolygon2.cpp --- a/OrthancStone/Sources/Toolbox/DicomStructurePolygon2.cpp Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/DicomStructurePolygon2.cpp Thu Jun 10 12:07:04 2021 +0200 @@ -25,6 +25,8 @@ #include "../Toolbox/LinearAlgebra.h" +#include + namespace OrthancStone { void DicomStructurePolygon2::ComputeDependentProperties() diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/DicomStructurePolygon2.h --- a/OrthancStone/Sources/Toolbox/DicomStructurePolygon2.h Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/DicomStructurePolygon2.h Thu Jun 10 12:07:04 2021 +0200 @@ -30,7 +30,7 @@ #include "../Scene2D/Color.h" #include "../StoneException.h" -#include +#include "OrthancDatasets/FullOrthancDataset.h" #include #include diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/DicomStructureSet.cpp --- a/OrthancStone/Sources/Toolbox/DicomStructureSet.cpp Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/DicomStructureSet.cpp Thu Jun 10 12:07:04 2021 +0200 @@ -170,8 +170,8 @@ static bool FastParseVector(Vector& target, - const IDicomDataset& dataset, - const DicomPath& tag) + const IDicomDataset& dataset, + const Orthanc::DicomPath& tag) { std::string value; return (dataset.GetStringValue(value, tag) && @@ -481,10 +481,10 @@ DicomDatasetReader reader(tags); size_t count, tmp; - if (!tags.GetSequenceSize(count, DicomPath(DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE)) || - !tags.GetSequenceSize(tmp, DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE)) || + if (!tags.GetSequenceSize(count, Orthanc::DicomPath(DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE)) || + !tags.GetSequenceSize(tmp, Orthanc::DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE)) || tmp != count || - !tags.GetSequenceSize(tmp, DicomPath(DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE)) || + !tags.GetSequenceSize(tmp, Orthanc::DicomPath(DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE)) || tmp != count) { throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); @@ -494,18 +494,18 @@ for (size_t i = 0; i < count; i++) { structures_[i].interpretation_ = reader.GetStringValue - (DicomPath(DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE, i, - DICOM_TAG_RT_ROI_INTERPRETED_TYPE), + (Orthanc::DicomPath(DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE, i, + DICOM_TAG_RT_ROI_INTERPRETED_TYPE), "No interpretation"); structures_[i].name_ = reader.GetStringValue - (DicomPath(DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE, i, - DICOM_TAG_ROI_NAME), + (Orthanc::DicomPath(DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE, i, + DICOM_TAG_ROI_NAME), "No name"); Vector color; - if (FastParseVector(color, tags, DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, - DICOM_TAG_ROI_DISPLAY_COLOR)) && + if (FastParseVector(color, tags, Orthanc::DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, + DICOM_TAG_ROI_DISPLAY_COLOR)) && color.size() == 3) { structures_[i].red_ = ConvertColor(color[0]); @@ -520,8 +520,8 @@ } size_t countSlices; - if (!tags.GetSequenceSize(countSlices, DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, - DICOM_TAG_CONTOUR_SEQUENCE))) + if (!tags.GetSequenceSize(countSlices, Orthanc::DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, + DICOM_TAG_CONTOUR_SEQUENCE))) { countSlices = 0; } @@ -533,28 +533,32 @@ << static_cast(structures_[i].green_) << "," << static_cast(structures_[i].blue_) << ")"; - // These temporary variables avoid allocating many vectors in the loop below - DicomPath countPointsPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, - DICOM_TAG_CONTOUR_SEQUENCE, 0, - DICOM_TAG_NUMBER_OF_CONTOUR_POINTS); + /** + * These temporary variables avoid allocating many vectors in + * the loop below (indeed, "Orthanc::DicomPath" handles a + * "std::vector") + **/ + Orthanc::DicomPath countPointsPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, + DICOM_TAG_CONTOUR_SEQUENCE, 0, + DICOM_TAG_NUMBER_OF_CONTOUR_POINTS); - DicomPath geometricTypePath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, - DICOM_TAG_CONTOUR_SEQUENCE, 0, - DICOM_TAG_CONTOUR_GEOMETRIC_TYPE); + Orthanc::DicomPath geometricTypePath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, + DICOM_TAG_CONTOUR_SEQUENCE, 0, + DICOM_TAG_CONTOUR_GEOMETRIC_TYPE); - DicomPath imageSequencePath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, - DICOM_TAG_CONTOUR_SEQUENCE, 0, - DICOM_TAG_CONTOUR_IMAGE_SEQUENCE); + Orthanc::DicomPath imageSequencePath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, + DICOM_TAG_CONTOUR_SEQUENCE, 0, + DICOM_TAG_CONTOUR_IMAGE_SEQUENCE); // (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155) - DicomPath referencedInstancePath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, - DICOM_TAG_CONTOUR_SEQUENCE, 0, - DICOM_TAG_CONTOUR_IMAGE_SEQUENCE, 0, - DICOM_TAG_REFERENCED_SOP_INSTANCE_UID); + Orthanc::DicomPath referencedInstancePath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, + DICOM_TAG_CONTOUR_SEQUENCE, 0, + DICOM_TAG_CONTOUR_IMAGE_SEQUENCE, 0, + DICOM_TAG_REFERENCED_SOP_INSTANCE_UID); - DicomPath contourDataPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, - DICOM_TAG_CONTOUR_SEQUENCE, 0, - DICOM_TAG_CONTOUR_DATA); + Orthanc::DicomPath contourDataPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, + DICOM_TAG_CONTOUR_SEQUENCE, 0, + DICOM_TAG_CONTOUR_DATA); for (size_t j = 0; j < countSlices; j++) { diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/DicomStructureSet2.cpp --- a/OrthancStone/Sources/Toolbox/DicomStructureSet2.cpp Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/DicomStructureSet2.cpp Thu Jun 10 12:07:04 2021 +0200 @@ -31,23 +31,24 @@ #include #include -#include -#include +#include "DicomStructure2.h" +#include "GenericToolbox.h" +#include "OrthancDatasets/DicomDatasetReader.h" namespace OrthancStone { - static const OrthancPlugins::DicomTag DICOM_TAG_CONTOUR_GEOMETRIC_TYPE(0x3006, 0x0042); - static const OrthancPlugins::DicomTag DICOM_TAG_CONTOUR_IMAGE_SEQUENCE(0x3006, 0x0016); - static const OrthancPlugins::DicomTag DICOM_TAG_CONTOUR_SEQUENCE(0x3006, 0x0040); - static const OrthancPlugins::DicomTag DICOM_TAG_CONTOUR_DATA(0x3006, 0x0050); - static const OrthancPlugins::DicomTag DICOM_TAG_NUMBER_OF_CONTOUR_POINTS(0x3006, 0x0046); - static const OrthancPlugins::DicomTag DICOM_TAG_REFERENCED_SOP_INSTANCE_UID(0x0008, 0x1155); - static const OrthancPlugins::DicomTag DICOM_TAG_ROI_CONTOUR_SEQUENCE(0x3006, 0x0039); - static const OrthancPlugins::DicomTag DICOM_TAG_ROI_DISPLAY_COLOR(0x3006, 0x002a); - static const OrthancPlugins::DicomTag DICOM_TAG_ROI_NAME(0x3006, 0x0026); - static const OrthancPlugins::DicomTag DICOM_TAG_RT_ROI_INTERPRETED_TYPE(0x3006, 0x00a4); - static const OrthancPlugins::DicomTag DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE(0x3006, 0x0080); - static const OrthancPlugins::DicomTag DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE(0x3006, 0x0020); + static const Orthanc::DicomTag DICOM_TAG_CONTOUR_GEOMETRIC_TYPE(0x3006, 0x0042); + static const Orthanc::DicomTag DICOM_TAG_CONTOUR_IMAGE_SEQUENCE(0x3006, 0x0016); + static const Orthanc::DicomTag DICOM_TAG_CONTOUR_SEQUENCE(0x3006, 0x0040); + static const Orthanc::DicomTag DICOM_TAG_CONTOUR_DATA(0x3006, 0x0050); + static const Orthanc::DicomTag DICOM_TAG_NUMBER_OF_CONTOUR_POINTS(0x3006, 0x0046); + static const Orthanc::DicomTag DICOM_TAG_REFERENCED_SOP_INSTANCE_UID(0x0008, 0x1155); + static const Orthanc::DicomTag DICOM_TAG_ROI_CONTOUR_SEQUENCE(0x3006, 0x0039); + static const Orthanc::DicomTag DICOM_TAG_ROI_DISPLAY_COLOR(0x3006, 0x002a); + static const Orthanc::DicomTag DICOM_TAG_ROI_NAME(0x3006, 0x0026); + static const Orthanc::DicomTag DICOM_TAG_RT_ROI_INTERPRETED_TYPE(0x3006, 0x00a4); + static const Orthanc::DicomTag DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE(0x3006, 0x0080); + static const Orthanc::DicomTag DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE(0x3006, 0x0020); static inline uint8_t ConvertAndClipToByte(double v) { @@ -66,21 +67,21 @@ } static bool ReadDicomToVector(Vector& target, - const OrthancPlugins::IDicomDataset& dataset, - const OrthancPlugins::DicomPath& tag) + const IDicomDataset& dataset, + const Orthanc::DicomPath& tag) { std::string value; return (dataset.GetStringValue(value, tag) && - GenericToolbox::FastParseVector(target, value)); + GenericToolbox::FastParseVector(target, value)); } - void DicomPathToString(std::string& s, const OrthancPlugins::DicomPath& dicomPath) + void DicomPathToString(std::string& s, const Orthanc::DicomPath& dicomPath) { std::stringstream tmp; for (size_t i = 0; i < dicomPath.GetPrefixLength(); ++i) { - OrthancPlugins::DicomTag tag = dicomPath.GetPrefixTag(i); + Orthanc::DicomTag tag = dicomPath.GetPrefixTag(i); // We use this other object to be able to use GetMainTagsName // and Format @@ -88,13 +89,13 @@ size_t index = dicomPath.GetPrefixIndex(i); tmp << tag2.GetMainTagsName() << " (" << tag2.Format() << ") [" << index << "] / "; } - const OrthancPlugins::DicomTag& tag = dicomPath.GetFinalTag(); + const Orthanc::DicomTag& tag = dicomPath.GetFinalTag(); Orthanc::DicomTag tag2(tag.GetGroup(), tag.GetElement()); tmp << tag2.GetMainTagsName() << " (" << tag2.Format() << ")"; s = tmp.str(); } - std::ostream& operator<<(std::ostream& s, const OrthancPlugins::DicomPath& dicomPath) + std::ostream& operator<<(std::ostream& s, const Orthanc::DicomPath& dicomPath) { std::string tmp; DicomPathToString(tmp, dicomPath); @@ -114,7 +115,7 @@ } - void DicomStructureSet2::SetContents(const OrthancPlugins::FullOrthancDataset& tags) + void DicomStructureSet2::SetContents(const FullOrthancDataset& tags) { FillStructuresFromDataset(tags); ComputeDependentProperties(); @@ -128,9 +129,9 @@ } } - void DicomStructureSet2::FillStructuresFromDataset(const OrthancPlugins::FullOrthancDataset& tags) + void DicomStructureSet2::FillStructuresFromDataset(const FullOrthancDataset& tags) { - OrthancPlugins::DicomDatasetReader reader(tags); + DicomDatasetReader reader(tags); // a few sanity checks size_t count = 0, tmp = 0; @@ -138,11 +139,11 @@ // DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE (0x3006, 0x0080); // DICOM_TAG_ROI_CONTOUR_SEQUENCE (0x3006, 0x0039); // DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE (0x3006, 0x0020); - if (!tags.GetSequenceSize(count, DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE) || - !tags.GetSequenceSize(tmp, DICOM_TAG_ROI_CONTOUR_SEQUENCE) || - tmp != count || - !tags.GetSequenceSize(tmp, DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE) || - tmp != count) + if (!tags.GetSequenceSize(count, Orthanc::DicomPath(DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE)) || + !tags.GetSequenceSize(tmp, Orthanc::DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE)) || + tmp != count || + !tags.GetSequenceSize(tmp, Orthanc::DicomPath(DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE)) || + tmp != count) { throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); } @@ -157,21 +158,21 @@ { // (0x3006, 0x0080)[i]/(0x3006, 0x00a4) structures_[i].interpretation_ = reader.GetStringValue - (OrthancPlugins::DicomPath(DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE, i, - DICOM_TAG_RT_ROI_INTERPRETED_TYPE), - "No interpretation"); + (Orthanc::DicomPath(DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE, i, + DICOM_TAG_RT_ROI_INTERPRETED_TYPE), + "No interpretation"); // (0x3006, 0x0020)[i]/(0x3006, 0x0026) structures_[i].name_ = reader.GetStringValue - (OrthancPlugins::DicomPath(DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE, i, - DICOM_TAG_ROI_NAME), - "No name"); + (Orthanc::DicomPath(DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE, i, + DICOM_TAG_ROI_NAME), + "No name"); Vector color; // (0x3006, 0x0039)[i]/(0x3006, 0x002a) - if (ReadDicomToVector(color, tags, OrthancPlugins::DicomPath( - DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_ROI_DISPLAY_COLOR)) - && color.size() == 3) + if (ReadDicomToVector(color, tags, Orthanc::DicomPath( + DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_ROI_DISPLAY_COLOR)) + && color.size() == 3) { structures_[i].red_ = ConvertAndClipToByte(color[0]); structures_[i].green_ = ConvertAndClipToByte(color[1]); @@ -187,46 +188,46 @@ size_t countSlices; // DICOM_TAG_ROI_CONTOUR_SEQUENCE (0x3006, 0x0039); // DICOM_TAG_CONTOUR_SEQUENCE (0x3006, 0x0040); - if (!tags.GetSequenceSize(countSlices, OrthancPlugins::DicomPath( - DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_CONTOUR_SEQUENCE))) + if (!tags.GetSequenceSize(countSlices, Orthanc::DicomPath( + DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_CONTOUR_SEQUENCE))) { LOG(WARNING) << "DicomStructureSet2::SetContents | structure \"" << structures_[i].name_ << "\" has no slices!"; countSlices = 0; } LOG(INFO) << "New RT structure: \"" << structures_[i].name_ - << "\" with interpretation \"" << structures_[i].interpretation_ - << "\" containing " << countSlices << " slices (color: " - << static_cast(structures_[i].red_) << "," + << "\" with interpretation \"" << structures_[i].interpretation_ + << "\" containing " << countSlices << " slices (color: " + << static_cast(structures_[i].red_) << "," << static_cast(structures_[i].green_) << "," << static_cast(structures_[i].blue_) << ")"; // These temporary variables avoid allocating many vectors in the loop below // (0x3006, 0x0039)[i]/(0x3006, 0x0040)[0]/(0x3006, 0x0046) - OrthancPlugins::DicomPath countPointsPath( + Orthanc::DicomPath countPointsPath( DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_CONTOUR_SEQUENCE, 0, DICOM_TAG_NUMBER_OF_CONTOUR_POINTS); - OrthancPlugins::DicomPath geometricTypePath( + Orthanc::DicomPath geometricTypePath( DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_CONTOUR_SEQUENCE, 0, DICOM_TAG_CONTOUR_GEOMETRIC_TYPE); - OrthancPlugins::DicomPath imageSequencePath( + Orthanc::DicomPath imageSequencePath( DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_CONTOUR_SEQUENCE, 0, DICOM_TAG_CONTOUR_IMAGE_SEQUENCE); // (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155) - OrthancPlugins::DicomPath referencedInstancePath( + Orthanc::DicomPath referencedInstancePath( DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_CONTOUR_SEQUENCE, 0, DICOM_TAG_CONTOUR_IMAGE_SEQUENCE, 0, DICOM_TAG_REFERENCED_SOP_INSTANCE_UID); - OrthancPlugins::DicomPath contourDataPath( + Orthanc::DicomPath contourDataPath( DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_CONTOUR_SEQUENCE, 0, DICOM_TAG_CONTOUR_DATA); @@ -272,7 +273,7 @@ Vector points; if (!GenericToolbox::FastParseVector(points, slicesData) || - points.size() != 3 * countPoints) + points.size() != 3 * countPoints) { throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); } diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/DicomStructureSet2.h --- a/OrthancStone/Sources/Toolbox/DicomStructureSet2.h Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/DicomStructureSet2.h Thu Jun 10 12:07:04 2021 +0200 @@ -23,12 +23,11 @@ #ifdef BGO_ENABLE_DICOMSTRUCTURESETLOADER2 +#include "../Scene2D/Color.h" +#include "CoordinateSystem3D.h" #include "DicomStructure2.h" -#include "CoordinateSystem3D.h" #include "Extent2D.h" -#include "../Scene2D/Color.h" - -#include +#include "OrthancDatasets/FullOrthancDataset.h" #include @@ -40,7 +39,7 @@ DicomStructureSet2(); ~DicomStructureSet2(); - void SetContents(const OrthancPlugins::FullOrthancDataset& tags); + void SetContents(const FullOrthancDataset& tags); size_t GetStructuresCount() const { @@ -56,7 +55,7 @@ } /** Internal use only */ - void FillStructuresFromDataset(const OrthancPlugins::FullOrthancDataset& tags); + void FillStructuresFromDataset(const FullOrthancDataset& tags); /** Internal use only */ void ComputeDependentProperties(); diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/OrthancDatasets/DicomDatasetReader.cpp --- a/OrthancStone/Sources/Toolbox/OrthancDatasets/DicomDatasetReader.cpp Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/OrthancDatasets/DicomDatasetReader.cpp Thu Jun 10 12:07:04 2021 +0200 @@ -35,7 +35,7 @@ } - std::string DicomDatasetReader::GetStringValue(const DicomPath& path, + std::string DicomDatasetReader::GetStringValue(const Orthanc::DicomPath& path, const std::string& defaultValue) const { std::string s; @@ -50,7 +50,7 @@ } - std::string DicomDatasetReader::GetMandatoryStringValue(const DicomPath& path) const + std::string DicomDatasetReader::GetMandatoryStringValue(const Orthanc::DicomPath& path) const { std::string s; if (dataset_.GetStringValue(s, path)) @@ -67,7 +67,7 @@ template static bool GetValueInternal(T& target, const IDicomDataset& dataset, - const DicomPath& path) + const Orthanc::DicomPath& path) { try { @@ -91,14 +91,14 @@ bool DicomDatasetReader::GetIntegerValue(int& target, - const DicomPath& path) const + const Orthanc::DicomPath& path) const { return GetValueInternal(target, dataset_, path); } bool DicomDatasetReader::GetUnsignedIntegerValue(unsigned int& target, - const DicomPath& path) const + const Orthanc::DicomPath& path) const { int value; @@ -119,14 +119,14 @@ bool DicomDatasetReader::GetFloatValue(float& target, - const DicomPath& path) const + const Orthanc::DicomPath& path) const { return GetValueInternal(target, dataset_, path); } bool DicomDatasetReader::GetDoubleValue(double& target, - const DicomPath& path) const + const Orthanc::DicomPath& path) const { return GetValueInternal(target, dataset_, path); } diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/OrthancDatasets/DicomDatasetReader.h --- a/OrthancStone/Sources/Toolbox/OrthancDatasets/DicomDatasetReader.h Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/OrthancDatasets/DicomDatasetReader.h Thu Jun 10 12:07:04 2021 +0200 @@ -42,21 +42,21 @@ return dataset_; } - std::string GetStringValue(const DicomPath& path, + std::string GetStringValue(const Orthanc::DicomPath& path, const std::string& defaultValue) const; - std::string GetMandatoryStringValue(const DicomPath& path) const; + std::string GetMandatoryStringValue(const Orthanc::DicomPath& path) const; bool GetIntegerValue(int& target, - const DicomPath& path) const; + const Orthanc::DicomPath& path) const; bool GetUnsignedIntegerValue(unsigned int& target, - const DicomPath& path) const; + const Orthanc::DicomPath& path) const; bool GetFloatValue(float& target, - const DicomPath& path) const; + const Orthanc::DicomPath& path) const; bool GetDoubleValue(double& target, - const DicomPath& path) const; + const Orthanc::DicomPath& path) const; }; } diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/OrthancDatasets/DicomPath.cpp --- a/OrthancStone/Sources/Toolbox/OrthancDatasets/DicomPath.cpp Mon Jun 07 18:47:10 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -/** - * Stone of Orthanc - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017-2021 Osimis S.A., Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program. If not, see - * . - **/ - - -#include "DicomPath.h" - -#include - -#include - -namespace OrthancStone -{ - const DicomPath::Prefix& DicomPath::GetPrefixItem(size_t depth) const - { - if (depth >= prefix_.size()) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); - } - else - { - return prefix_[depth]; - } - } - - - DicomPath::Prefix& DicomPath::GetPrefixItem(size_t depth) - { - if (depth >= prefix_.size()) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); - } - else - { - return prefix_[depth]; - } - } - - - DicomPath::DicomPath(const Orthanc::DicomTag& sequence, - size_t index, - const Orthanc::DicomTag& tag) : - finalTag_(tag) - { - AddToPrefix(sequence, index); - } - - - DicomPath::DicomPath(const Orthanc::DicomTag& sequence1, - size_t index1, - const Orthanc::DicomTag& sequence2, - size_t index2, - const Orthanc::DicomTag& tag) : - finalTag_(tag) - { - AddToPrefix(sequence1, index1); - AddToPrefix(sequence2, index2); - } - - - DicomPath::DicomPath(const Orthanc::DicomTag& sequence1, - size_t index1, - const Orthanc::DicomTag& sequence2, - size_t index2, - const Orthanc::DicomTag& sequence3, - size_t index3, - const Orthanc::DicomTag& tag) : - finalTag_(tag) - { - AddToPrefix(sequence1, index1); - AddToPrefix(sequence2, index2); - AddToPrefix(sequence3, index3); - } - - - static std::string FormatHexadecimal(const Orthanc::DicomTag& tag) - { - char buf[16]; - sprintf(buf, "(%04x,%04x)", tag.GetGroup(), tag.GetElement()); - return buf; - } - - - std::string DicomPath::Format() const - { - std::string s; - - for (size_t i = 0; i < GetPrefixLength(); i++) - { - s += (FormatHexadecimal(GetPrefixTag(i)) + " / " + - boost::lexical_cast(i) + " / "); - } - - return s + FormatHexadecimal(GetFinalTag()); - } -} diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/OrthancDatasets/DicomPath.h --- a/OrthancStone/Sources/Toolbox/OrthancDatasets/DicomPath.h Mon Jun 07 18:47:10 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/** - * Stone of Orthanc - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017-2021 Osimis S.A., Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program. If not, see - * . - **/ - - -#pragma once - -#include - -#include -#include - -namespace OrthancStone -{ - class DicomPath - { - private: - typedef std::pair Prefix; - - std::vector prefix_; - Orthanc::DicomTag finalTag_; - - const Prefix& GetPrefixItem(size_t depth) const; - - Prefix& GetPrefixItem(size_t depth); - - public: - explicit DicomPath(const Orthanc::DicomTag& finalTag) : - finalTag_(finalTag) - { - } - - DicomPath(const Orthanc::DicomTag& sequence, - size_t index, - const Orthanc::DicomTag& tag); - - DicomPath(const Orthanc::DicomTag& sequence1, - size_t index1, - const Orthanc::DicomTag& sequence2, - size_t index2, - const Orthanc::DicomTag& tag); - - DicomPath(const Orthanc::DicomTag& sequence1, - size_t index1, - const Orthanc::DicomTag& sequence2, - size_t index2, - const Orthanc::DicomTag& sequence3, - size_t index3, - const Orthanc::DicomTag& tag); - - void AddToPrefix(const Orthanc::DicomTag& tag, - size_t position) - { - prefix_.push_back(std::make_pair(tag, position)); - } - - size_t GetPrefixLength() const - { - return prefix_.size(); - } - - Orthanc::DicomTag GetPrefixTag(size_t depth) const - { - return GetPrefixItem(depth).first; - } - - size_t GetPrefixIndex(size_t depth) const - { - return GetPrefixItem(depth).second; - } - - void SetPrefixIndex(size_t depth, - size_t value) - { - GetPrefixItem(depth).second = value; - } - - const Orthanc::DicomTag& GetFinalTag() const - { - return finalTag_; - } - - void SetFinalTag(const Orthanc::DicomTag& tag) - { - finalTag_ = tag; - } - - std::string Format() const; - }; -} diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/OrthancDatasets/FullOrthancDataset.cpp --- a/OrthancStone/Sources/Toolbox/OrthancDatasets/FullOrthancDataset.cpp Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/OrthancDatasets/FullOrthancDataset.cpp Thu Jun 10 12:07:04 2021 +0200 @@ -102,7 +102,7 @@ } - const Json::Value* FullOrthancDataset::LookupPath(const DicomPath& path) const + const Json::Value* FullOrthancDataset::LookupPath(const Orthanc::DicomPath& path) const { const Json::Value* content = &root_; @@ -171,7 +171,7 @@ bool FullOrthancDataset::GetStringValue(std::string& result, - const DicomPath& path) const + const Orthanc::DicomPath& path) const { const Json::Value* value = LookupPath(path); @@ -187,7 +187,7 @@ bool FullOrthancDataset::GetSequenceSize(size_t& size, - const DicomPath& path) const + const Orthanc::DicomPath& path) const { const Json::Value* sequence = LookupPath(path); diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/OrthancDatasets/FullOrthancDataset.h --- a/OrthancStone/Sources/Toolbox/OrthancDatasets/FullOrthancDataset.h Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/OrthancDatasets/FullOrthancDataset.h Thu Jun 10 12:07:04 2021 +0200 @@ -36,7 +36,7 @@ private: Json::Value root_; - const Json::Value* LookupPath(const DicomPath& path) const; + const Json::Value* LookupPath(const Orthanc::DicomPath& path) const; void CheckRoot() const; @@ -52,10 +52,10 @@ explicit FullOrthancDataset(const Json::Value& root); virtual bool GetStringValue(std::string& result, - const DicomPath& path) const ORTHANC_OVERRIDE; + const Orthanc::DicomPath& path) const ORTHANC_OVERRIDE; virtual bool GetSequenceSize(size_t& size, - const DicomPath& path) const ORTHANC_OVERRIDE; + const Orthanc::DicomPath& path) const ORTHANC_OVERRIDE; FullOrthancDataset* Clone() const { diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/OrthancDatasets/IDicomDataset.h --- a/OrthancStone/Sources/Toolbox/OrthancDatasets/IDicomDataset.h Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/OrthancDatasets/IDicomDataset.h Thu Jun 10 12:07:04 2021 +0200 @@ -22,7 +22,7 @@ #pragma once -#include "DicomPath.h" +#include // From Orthanc framework #include #include @@ -37,9 +37,9 @@ } virtual bool GetStringValue(std::string& result, - const DicomPath& path) const = 0; + const Orthanc::DicomPath& path) const = 0; virtual bool GetSequenceSize(size_t& size, - const DicomPath& path) const = 0; + const Orthanc::DicomPath& path) const = 0; }; } diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/OrthancDatasets/IOrthancConnection.h --- a/OrthancStone/Sources/Toolbox/OrthancDatasets/IOrthancConnection.h Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/OrthancDatasets/IOrthancConnection.h Thu Jun 10 12:07:04 2021 +0200 @@ -22,8 +22,6 @@ #pragma once -#include "DicomPath.h" - #include #include #include diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/OrthancDatasets/SimplifiedOrthancDataset.cpp --- a/OrthancStone/Sources/Toolbox/OrthancDatasets/SimplifiedOrthancDataset.cpp Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/OrthancDatasets/SimplifiedOrthancDataset.cpp Thu Jun 10 12:07:04 2021 +0200 @@ -27,7 +27,7 @@ namespace OrthancStone { - const Json::Value* SimplifiedOrthancDataset::LookupPath(const DicomPath& path) const + const Json::Value* SimplifiedOrthancDataset::LookupPath(const Orthanc::DicomPath& path) const { const Json::Value* content = &root_; @@ -105,7 +105,7 @@ bool SimplifiedOrthancDataset::GetStringValue(std::string& result, - const DicomPath& path) const + const Orthanc::DicomPath& path) const { const Json::Value* value = LookupPath(path); @@ -126,7 +126,7 @@ bool SimplifiedOrthancDataset::GetSequenceSize(size_t& size, - const DicomPath& path) const + const Orthanc::DicomPath& path) const { const Json::Value* sequence = LookupPath(path); diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/OrthancDatasets/SimplifiedOrthancDataset.h --- a/OrthancStone/Sources/Toolbox/OrthancDatasets/SimplifiedOrthancDataset.h Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/OrthancDatasets/SimplifiedOrthancDataset.h Thu Jun 10 12:07:04 2021 +0200 @@ -42,7 +42,7 @@ private: Json::Value root_; - const Json::Value* LookupPath(const DicomPath& path) const; + const Json::Value* LookupPath(const Orthanc::DicomPath& path) const; void CheckRoot() const; @@ -53,9 +53,9 @@ explicit SimplifiedOrthancDataset(const std::string& content); virtual bool GetStringValue(std::string& result, - const DicomPath& path) const ORTHANC_OVERRIDE; + const Orthanc::DicomPath& path) const ORTHANC_OVERRIDE; virtual bool GetSequenceSize(size_t& size, - const DicomPath& path) const ORTHANC_OVERRIDE; + const Orthanc::DicomPath& path) const ORTHANC_OVERRIDE; }; } diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/ParsedDicomDataset.cpp --- a/OrthancStone/Sources/Toolbox/ParsedDicomDataset.cpp Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/ParsedDicomDataset.cpp Thu Jun 10 12:07:04 2021 +0200 @@ -27,7 +27,7 @@ namespace OrthancStone { static DcmItem* LookupPath(Orthanc::ParsedDicomFile& dicom, - const DicomPath& path) + const Orthanc::DicomPath& path) { DcmItem* node = dicom.GetDcmtkObject().getDataset(); @@ -61,7 +61,7 @@ bool ParsedDicomDataset::GetStringValue(std::string& result, - const DicomPath& path) const + const Orthanc::DicomPath& path) const { DcmItem* node = LookupPath(dicom_, path); @@ -83,7 +83,7 @@ bool ParsedDicomDataset::GetSequenceSize(size_t& size, - const DicomPath& path) const + const Orthanc::DicomPath& path) const { DcmItem* node = LookupPath(dicom_, path); diff -r 3c0996f028a1 -r 126522623e20 OrthancStone/Sources/Toolbox/ParsedDicomDataset.h --- a/OrthancStone/Sources/Toolbox/ParsedDicomDataset.h Mon Jun 07 18:47:10 2021 +0200 +++ b/OrthancStone/Sources/Toolbox/ParsedDicomDataset.h Thu Jun 10 12:07:04 2021 +0200 @@ -41,9 +41,9 @@ } virtual bool GetStringValue(std::string& result, - const DicomPath& path) const ORTHANC_OVERRIDE; + const Orthanc::DicomPath& path) const ORTHANC_OVERRIDE; virtual bool GetSequenceSize(size_t& size, - const DicomPath& path) const ORTHANC_OVERRIDE; + const Orthanc::DicomPath& path) const ORTHANC_OVERRIDE; }; } diff -r 3c0996f028a1 -r 126522623e20 TODO --- a/TODO Mon Jun 07 18:47:10 2021 +0200 +++ b/TODO Thu Jun 10 12:07:04 2021 +0200 @@ -31,9 +31,6 @@ * Replace "ParsedDicomCache" by "Orthanc::ParsedDicomCache" (new in Orthanc framework 1.9.0) -* Replace "DicomPath" by "Orthanc::DicomPath" (new in Orthanc - framework 1.9.4) - -------- Wishlist diff -r 3c0996f028a1 -r 126522623e20 UnitTestsSources/TestStructureSet.cpp --- a/UnitTestsSources/TestStructureSet.cpp Mon Jun 07 18:47:10 2021 +0200 +++ b/UnitTestsSources/TestStructureSet.cpp Thu Jun 10 12:07:04 2021 +0200 @@ -4270,7 +4270,7 @@ #ifdef BGO_ENABLE_DICOMSTRUCTURESETLOADER2 static void CheckGroundTruth( - const std::vector& structures, + const std::vector& structures, const size_t structureIndex, const size_t sliceIndex, std::vector groundTruth) @@ -4305,7 +4305,10 @@ { DicomStructureSet2 structureSet; - OrthancPlugins::FullOrthancDataset dicom(GetTestJson()); + Json::Value test; + Orthanc::Toolbox::ReadJson(test, k_rtStruct_json00); + + FullOrthancDataset dicom(test); //loader.content_.reset(new DicomStructureSet(dicom)); structureSet.Clear(); @@ -5363,14 +5366,16 @@ #ifdef BGO_ENABLE_DICOMSTRUCTURESETLOADER2 +#include + TEST(StructureSet, ReadFromJsonPart2) { DicomStructureSet2 structureSet; std::string jsonText; - SystemToolbox::ReadFile(jsonText, "72c773ac-5059f2c4-2e6a9120-4fd4bca1-45701661.json"); + Orthanc::SystemToolbox::ReadFile(jsonText, "72c773ac-5059f2c4-2e6a9120-4fd4bca1-45701661.json"); - OrthancPlugins::FullOrthancDataset dicom(jsonText); + FullOrthancDataset dicom(jsonText); //loader.content_.reset(new DicomStructureSet(dicom)); structureSet.Clear();