# HG changeset patch # User am@osimis.io # Date 1525254647 -7200 # Node ID ea63d9f9037731f38541f48cf70a753370054d30 # Parent 7853c9a6760580cf4003a40bcbefe697c9018f67 /tags now returns multiple numerical values in a \ separated string diff -r 7853c9a67605 -r ea63d9f90377 Core/DicomParsing/FromDcmtkBridge.cpp --- a/Core/DicomParsing/FromDcmtkBridge.cpp Thu Apr 19 16:26:17 2018 +0200 +++ b/Core/DicomParsing/FromDcmtkBridge.cpp Wed May 02 11:50:47 2018 +0200 @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -198,6 +199,56 @@ return &dictionary_; } }; + + +#define DCMTK_TO_CTYPE_CONVERTER(converter, cType, dcmtkType, getter) \ + \ + struct converter \ + { \ + typedef cType CType; \ + \ + static bool Apply(CType& result, \ + DcmElement& element, \ + size_t i) \ + { \ + return dynamic_cast(element).getter(result, i).good(); \ + } \ + }; + +DCMTK_TO_CTYPE_CONVERTER(DcmtkToSint32Converter, Sint32, DcmSignedLong, getSint32) +DCMTK_TO_CTYPE_CONVERTER(DcmtkToSint16Converter, Sint16, DcmSignedShort, getSint16) +DCMTK_TO_CTYPE_CONVERTER(DcmtkToUint32Converter, Uint32, DcmUnsignedLong, getUint32) +DCMTK_TO_CTYPE_CONVERTER(DcmtkToUint16Converter, Uint16, DcmUnsignedShort, getUint16) +DCMTK_TO_CTYPE_CONVERTER(DcmtkToFloat32Converter, Float32, DcmFloatingPointSingle, getFloat32) +DCMTK_TO_CTYPE_CONVERTER(DcmtkToFloat64Converter, Float64, DcmFloatingPointDouble, getFloat64) + + + template + static DicomValue* ApplyDcmtkToCTypeConverter(DcmElement& element) + { + F f; + typename F::CType value; + + if (element.getLength() > sizeof(typename F::CType) + && (element.getLength() % sizeof(typename F::CType)) == 0) + { + size_t count = element.getLength() / sizeof(typename F::CType); + std::vector strings; + for (size_t i = 0; i < count; i++) { + if (f.Apply(value, element, i)) { + strings.push_back(boost::lexical_cast(value)); + } + } + return new DicomValue(boost::algorithm::join(strings, "\\"), false); + } + else if (f.Apply(value, element, 0)) { + return new DicomValue(boost::lexical_cast(value), false); + } + else { + return new DicomValue; + } + } + } @@ -572,56 +623,32 @@ case EVR_SL: // signed long { - Sint32 f; - if (dynamic_cast(element).getSint32(f).good()) - return new DicomValue(boost::lexical_cast(f), false); - else - return new DicomValue; + return ApplyDcmtkToCTypeConverter(element); } case EVR_SS: // signed short { - Sint16 f; - if (dynamic_cast(element).getSint16(f).good()) - return new DicomValue(boost::lexical_cast(f), false); - else - return new DicomValue; + return ApplyDcmtkToCTypeConverter(element); } case EVR_UL: // unsigned long { - Uint32 f; - if (dynamic_cast(element).getUint32(f).good()) - return new DicomValue(boost::lexical_cast(f), false); - else - return new DicomValue; + return ApplyDcmtkToCTypeConverter(element); } case EVR_US: // unsigned short { - Uint16 f; - if (dynamic_cast(element).getUint16(f).good()) - return new DicomValue(boost::lexical_cast(f), false); - else - return new DicomValue; + return ApplyDcmtkToCTypeConverter(element); } case EVR_FL: // float single-precision { - Float32 f; - if (dynamic_cast(element).getFloat32(f).good()) - return new DicomValue(boost::lexical_cast(f), false); - else - return new DicomValue; + return ApplyDcmtkToCTypeConverter(element); } case EVR_FD: // float double-precision { - Float64 f; - if (dynamic_cast(element).getFloat64(f).good()) - return new DicomValue(boost::lexical_cast(f), false); - else - return new DicomValue; + return ApplyDcmtkToCTypeConverter(element); } diff -r 7853c9a67605 -r ea63d9f90377 NEWS --- a/NEWS Thu Apr 19 16:26:17 2018 +0200 +++ b/NEWS Wed May 02 11:50:47 2018 +0200 @@ -1,6 +1,13 @@ Pending changes in the mainline =============================== +REST API +-------- +* ".../tags" URI was returning only the first value of DicomTags containing + multiple numerical value. It now returns all values in a string separated + by \\ (i.e.: "1\\2\\3"). Note that, for data already in Orthanc, you'll need + to reconstruct the data by sending a POST request to the ".../reconstruct" URI. + This change triggered an update of ORTHANC_API_VERSION from 1.0 to 1.1 Version 1.3.2 (2018-04-18) ========================== diff -r 7853c9a67605 -r ea63d9f90377 Resources/CMake/OrthancFrameworkParameters.cmake --- a/Resources/CMake/OrthancFrameworkParameters.cmake Thu Apr 19 16:26:17 2018 +0200 +++ b/Resources/CMake/OrthancFrameworkParameters.cmake Wed May 02 11:50:47 2018 +0200 @@ -17,7 +17,7 @@ # Version of the Orthanc API, can be retrieved from "/system" URI in # order to check whether new URI endpoints are available even if using # the mainline version of Orthanc -set(ORTHANC_API_VERSION "1.0") +set(ORTHANC_API_VERSION "1.1") #####################################################################