changeset 4689:ead3b81f4541

added DicomPath::SetPrefixIndex()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 10 Jun 2021 10:54:14 +0200
parents 177ad026d219
children 13efc0967cea
files OrthancFramework/Sources/DicomFormat/DicomPath.cpp OrthancFramework/Sources/DicomFormat/DicomPath.h OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp
diffstat 3 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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<PrefixItem>  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);
--- 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);