# HG changeset patch # User Sebastien Jodogne # Date 1783321493 -7200 # Node ID 8274f812ed788352ad5b649a67ee4b39cbb50579 # Parent eeb1737c4fac798ad8d024d2bef43f80168cf154 added support for OV VR in FromDcmtkBridge::ApplyVisitorToLeaf() diff -r eeb1737c4fac -r 8274f812ed78 NEWS --- a/NEWS Sat Jul 04 13:30:22 2026 +0200 +++ b/NEWS Mon Jul 06 09:04:53 2026 +0200 @@ -27,7 +27,6 @@ - When Orthanc was requested to return a private tag in a C-Find query, Orthanc was actually not returning the resources that did not contain the private tag although it was not used as a filter in the query. - REST API -------- @@ -51,7 +50,6 @@ "orthanc_jobs_total_success" and "orthanc_jobs_total_failed" that are now considering all the jobs that have run since Orthanc started. - Plugin SDK ---------- @@ -62,7 +60,7 @@ Maintenance ----------- -* Added internal support for OV, SV, and UV value representations +* Added support for OV, SV, and UV value representations * Added support for multiple values in AT value representation * Fix resubmit/pause/cancel and reloading of OrthancPeerStore and DicomModalityStore jobs (bug introduced in 1.12.10) diff -r eeb1737c4fac -r 8274f812ed78 OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp --- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Sat Jul 04 13:30:22 2026 +0200 +++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Mon Jul 06 09:04:53 2026 +0200 @@ -738,12 +738,32 @@ return size_; } + DicomTag GetTag(uint64_t index) const + { + assert(valid_); + return DicomTag(content_[2 * index], content_[2 * index + 1]); + } + virtual void ReadValue(std::string& value, uint64_t index) const ORTHANC_OVERRIDE { - assert(valid_); - DicomTag tag(content_[2 * index], content_[2 * index + 1]); - value = tag.Format(); + value = GetTag(index).Format(); + } + + void ReadArrayOfAttributes(std::vector& target) const + { + if (valid_) + { + target.reserve(size_); + for (uint64_t i = 0; i < size_; i++) + { + target.push_back(GetTag(i)); + } + } + else + { + throw OrthancException(ErrorCode_BadFileFormat); + } } }; @@ -798,6 +818,22 @@ assert(valid_); value = boost::lexical_cast(content_[index]); } + + void ReadArrayOfDoubles(std::vector& target) const + { + if (valid_) + { + target.resize(size_); + for (uint64_t i = 0; i < size_; i++) + { + target[i] = content_[i]; + } + } + else + { + throw OrthancException(ErrorCode_BadFileFormat); + } + } }; @@ -814,10 +850,13 @@ valid_(false) { /** - * OD stores a binary array of 64-bit IEEE doubles. Similar to OF, - * getVM() returns 1 for OD. We must use getFloat64Array() to access - * the raw double buffer. - * The resulting string is formatted as in ApplyDcmtkToCTypeConverter(). + * OD stores a binary array of 64-bit IEEE doubles. Unlike FD + * where getVM() returns the count of values, for OD getVM() + * returns 1 (the entire binary blob is considered one + * "value"). But similar to OF, getVM() returns 1 for OD. We + * must use getFloat64Array() to access the raw double buffer. + * The resulting string is formatted as in + * ApplyDcmtkToCTypeConverter(). **/ DcmFloatingPointDouble& e = dynamic_cast(element); @@ -851,6 +890,22 @@ assert(valid_); value = boost::lexical_cast(content_[index]); } + + void ReadArrayOfDoubles(std::vector& target) const + { + if (valid_) + { + target.resize(size_); + for (uint64_t i = 0; i < size_; i++) + { + target[i] = content_[i]; + } + } + else + { + throw OrthancException(ErrorCode_BadFileFormat); + } + } }; #endif @@ -905,6 +960,22 @@ assert(valid_); value = boost::lexical_cast(content_[index]); } + + void ReadArrayOfIntegers(std::vector& target) const + { + if (valid_) + { + target.resize(size_); + for (uint64_t i = 0; i < size_; i++) + { + target[i] = content_[i]; + } + } + else + { + throw OrthancException(ErrorCode_BadFileFormat); + } + } }; #endif @@ -953,6 +1024,35 @@ assert(valid_); value = boost::lexical_cast(content_[index]); } + + void ReadArrayOfIntegers(std::vector& target) const + { + if (valid_) + { + bool truncated = false; + target.resize(size_); + + for (uint64_t i = 0; i < size_; i++) + { + target[i] = static_cast(content_[i]); + + if (static_cast(target[i]) != content_[i]) + { + truncated = true; + target[i] = std::numeric_limits::max(); + } + } + + if (truncated) + { + LOG(WARNING) << "An OV element contains a value that is too large and was truncated"; + } + } + else + { + throw OrthancException(ErrorCode_BadFileFormat); + } + } }; #endif } @@ -3701,33 +3801,9 @@ case EVR_OF: // other float - binary array of 32-bit floats (new in Orthanc 1.12.11) { - /** - * OF stores a binary array of 32-bit IEEE floats. Unlike FL where getVM() - * returns the count of values, for OF getVM() returns 1 (the entire binary - * blob is considered one "value"). We must use getFloat32Array() to access - * the raw float buffer, then iterate over all values. - **/ - DcmFloatingPointSingle& content = dynamic_cast(element); - + ValueRepresentationReader_OF reader(element); std::vector values; - - Float32* floatArray = NULL; - if (content.getFloat32Array(floatArray).good() && floatArray != NULL) - { - if (element.getLength() % sizeof(Float32) != 0) - { - throw OrthancException(ErrorCode_BadFileFormat); - } - - const unsigned long numFloats = static_cast(element.getLength() / sizeof(Float32)); - values.reserve(numFloats); - - for (unsigned long i = 0; i < numFloats; i++) - { - values.push_back(static_cast(floatArray[i])); - } - } - + reader.ReadArrayOfDoubles(values); action = visitor.VisitDoubles(parentTags, parentIndexes, tag, vr, values); break; } @@ -3735,33 +3811,9 @@ #if DCMTK_VERSION_NUMBER >= 361 case EVR_OD: // other double - binary array of 64-bit floats (new in Orthanc 1.12.11) { - /** - * OD stores a binary array of 64-bit IEEE doubles. Unlike FD where getVM() - * returns the count of values, for OD getVM() returns 1 (the entire binary - * blob is considered one "value"). We must use getFloat64Array() to access - * the raw double buffer, then iterate over all values. - **/ - DcmFloatingPointDouble& content = dynamic_cast(element); - + ValueRepresentationReader_OD reader(element); std::vector values; - - Float64* doubleArray = NULL; - if (content.getFloat64Array(doubleArray).good() && doubleArray != NULL) - { - if (element.getLength() % sizeof(Float64) != 0) - { - throw OrthancException(ErrorCode_BadFileFormat); - } - - const unsigned long numDoubles = static_cast(element.getLength() / sizeof(Float64)); - values.reserve(numDoubles); - - for (unsigned long i = 0; i < numDoubles; i++) - { - values.push_back(doubleArray[i]); - } - } - + reader.ReadArrayOfDoubles(values); action = visitor.VisitDoubles(parentTags, parentIndexes, tag, vr, values); break; } @@ -3770,33 +3822,20 @@ #if DCMTK_VERSION_NUMBER >= 362 case EVR_OL: // other long - binary array of 32-bit unsigned integers (new in Orthanc 1.12.11) { - /** - * OL stores a binary array of 32-bit unsigned integers. Like OF/OD, - * getVM() returns 1 for OL (the entire binary blob is one "value"). - * We must use getUint32Array() to access the raw buffer, then iterate - * over all values based on element length. - **/ - DcmUnsignedLong& content = dynamic_cast(element); - + ValueRepresentationReader_OL reader(element); std::vector values; - - Uint32* uint32Array = NULL; - if (content.getUint32Array(uint32Array).good() && uint32Array != NULL) - { - if (element.getLength() % sizeof(Uint32) != 0) - { - throw OrthancException(ErrorCode_BadFileFormat); - } - - const unsigned long numValues = static_cast(element.getLength() / sizeof(Uint32)); - values.reserve(numValues); - - for (unsigned long i = 0; i < numValues; i++) - { - values.push_back(static_cast(uint32Array[i])); - } - } - + reader.ReadArrayOfIntegers(values); + action = visitor.VisitIntegers(parentTags, parentIndexes, tag, vr, values); + break; + } +#endif + +#if DCMTK_VERSION_NUMBER >= 365 + case EVR_OV: // other very long - binary array of 64-bit unsigned integers (new in Orthanc 1.12.12) + { + ValueRepresentationReader_OV reader(element); + std::vector values; + reader.ReadArrayOfIntegers(values); action = visitor.VisitIntegers(parentTags, parentIndexes, tag, vr, values); break; } @@ -3809,22 +3848,12 @@ case EVR_AT: { - DcmAttributeTag& content = dynamic_cast(element); - + assert(vr == ValueRepresentation_AttributeTag); + + ValueRepresentationReader_AT reader(element); std::vector values; - values.reserve(content.getVM()); - - for (unsigned long i = 0; i < content.getVM(); i++) - { - DcmTagKey f; - if (content.getTagVal(f, i).good()) - { - DicomTag t(f.getGroup(), f.getElement()); - values.push_back(t); - } - } - - assert(vr == ValueRepresentation_AttributeTag); + reader.ReadArrayOfAttributes(values); + action = visitor.VisitAttributes(parentTags, parentIndexes, tag, values); break; } diff -r eeb1737c4fac -r 8274f812ed78 OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp --- a/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Sat Jul 04 13:30:22 2026 +0200 +++ b/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Mon Jul 06 09:04:53 2026 +0200 @@ -2011,6 +2011,10 @@ { // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.2.3.html +#if DCMTK_VERSION_NUMBER >= 365 + FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7056, 0x1000), ValueRepresentation_OtherVeryLong, "Tag1", 1, 1, ""); +#endif + ParsedDicomFile dicom(false); dicom.ReplacePlainString(DicomTag(0x0040, 0x0241), "AE"); dicom.ReplacePlainString(DicomTag(0x0010, 0x1010), "AS"); @@ -2044,6 +2048,10 @@ dicom.ReplacePlainString(DicomTag(0x0008, 0x0301), "17"); // US dicom.ReplacePlainString(DicomTag(0x0040, 0x0031), "UT"); +#if DCMTK_VERSION_NUMBER >= 365 + dicom.ReplacePlainString(DicomTag(0x7056, 0x1000), "-17"); // OV +#endif + DicomWebJsonVisitor visitor; dicom.Apply(visitor); @@ -2170,13 +2178,23 @@ ASSERT_EQ("UT", visitor.GetResult() ["00400031"]["vr"].asString()); ASSERT_EQ("UT", visitor.GetResult() ["00400031"]["Value"][0].asString()); +#if DCMTK_VERSION_NUMBER >= 365 + ASSERT_EQ("OV", visitor.GetResult() ["70561000"]["vr"].asString()); + ASSERT_EQ(-17, visitor.GetResult() ["70561000"]["Value"][0].asInt()); +#endif + std::string xml; visitor.FormatXml(xml); { DicomMap m; m.FromDicomWeb(visitor.GetResult()); + +#if DCMTK_VERSION_NUMBER >= 365 + ASSERT_EQ(32u, m.GetSize()); +#else ASSERT_EQ(31u, m.GetSize()); +#endif ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0002, 0x0002), false)); ASSERT_EQ("UI", s); ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0040, 0x0241), false)); ASSERT_EQ("AE", s); @@ -2227,6 +2245,10 @@ ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0120), true)); ASSERT_EQ("UR", s); ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0301), true)); ASSERT_EQ("17", s); // US (but tag unknown to DCMTK 3.6.0) #endif + +#if DCMTK_VERSION_NUMBER >= 365 + ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x7056, 0x1000), true)); ASSERT_EQ("-17", s); // OV +#endif } }