# HG changeset patch # User Sebastien Jodogne # Date 1623315254 -7200 # Node ID ead3b81f4541cafb3ff31efdd148b85daefa66e5 # Parent 177ad026d2194ca55fbdfb14d399d4e700bf45e9 added DicomPath::SetPrefixIndex() diff -r 177ad026d219 -r ead3b81f4541 OrthancFramework/Sources/DicomFormat/DicomPath.cpp --- a/OrthancFramework/Sources/DicomFormat/DicomPath.cpp Thu Jun 10 10:09:54 2021 +0200 +++ b/OrthancFramework/Sources/DicomFormat/DicomPath.cpp Thu Jun 10 10:54:14 2021 +0200 @@ -63,6 +63,13 @@ } + void DicomPath::PrefixItem::SetIndex(size_t index) + { + isUniversal_ = false; + index_ = index; + } + + DicomTag DicomPath::ParseTag(const std::string& token) { DicomTag tag(0,0); @@ -189,6 +196,20 @@ } + void DicomPath::SetPrefixIndex(size_t level, + size_t index) + { + if (level >= prefix_.size()) + { + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + else + { + prefix_[level].SetIndex(index); + } + } + + std::string DicomPath::Format() const { std::string s; diff -r 177ad026d219 -r ead3b81f4541 OrthancFramework/Sources/DicomFormat/DicomPath.h --- a/OrthancFramework/Sources/DicomFormat/DicomPath.h Thu Jun 10 10:09:54 2021 +0200 +++ b/OrthancFramework/Sources/DicomFormat/DicomPath.h Thu Jun 10 10:54:14 2021 +0200 @@ -66,6 +66,8 @@ } size_t GetIndex() const; + + void SetIndex(size_t index); }; std::vector prefix_; @@ -135,6 +137,11 @@ bool HasUniversal() const; + // This method is used for an optimization in Stone + // (cf. "DicomStructureSet.cpp") + void SetPrefixIndex(size_t level, + size_t index); + std::string Format() const; static DicomPath Parse(const std::string& s); diff -r 177ad026d219 -r ead3b81f4541 OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp --- a/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Thu Jun 10 10:09:54 2021 +0200 +++ b/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Thu Jun 10 10:54:14 2021 +0200 @@ -2352,6 +2352,10 @@ ASSERT_EQ(DICOM_TAG_PATIENT_NAME, path.GetFinalTag()); ASSERT_EQ("(0010,0020)[42].(0010,0010)", path.Format()); + ASSERT_THROW(path.SetPrefixIndex(1, 44), OrthancException); + path.SetPrefixIndex(0, 44); + ASSERT_EQ("(0010,0020)[44].(0010,0010)", path.Format()); + ASSERT_THROW(DicomPath::Parse("nope"), OrthancException); ASSERT_THROW(DicomPath::Parse("(0010,0010)[.PatientID"), OrthancException); ASSERT_THROW(DicomPath::Parse("(0010,0010)[].PatientID"), OrthancException);