Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp @ 5657:dedbf019a707
Improved parsing of multiple numerical values in DICOM tags
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 06 Jun 2024 17:55:13 +0200 |
parents | f7adfb22e20e |
children |
comparison
equal
deleted
inserted
replaced
5655:65a509cac161 | 5657:dedbf019a707 |
---|---|
1976 * Numerical types | 1976 * Numerical types |
1977 **/ | 1977 **/ |
1978 | 1978 |
1979 case EVR_SL: // signed long | 1979 case EVR_SL: // signed long |
1980 { | 1980 { |
1981 ok = element.putSint32(boost::lexical_cast<Sint32>(*decoded)).good(); | 1981 if (decoded->find('\\') != std::string::npos) |
1982 { | |
1983 ok = element.putString(decoded->c_str()).good(); | |
1984 } | |
1985 else | |
1986 { | |
1987 ok = element.putSint32(boost::lexical_cast<Sint32>(*decoded)).good(); | |
1988 } | |
1982 break; | 1989 break; |
1983 } | 1990 } |
1984 | 1991 |
1985 case EVR_SS: // signed short | 1992 case EVR_SS: // signed short |
1986 { | 1993 { |
1987 ok = element.putSint16(boost::lexical_cast<Sint16>(*decoded)).good(); | 1994 if (decoded->find('\\') != std::string::npos) |
1995 { | |
1996 ok = element.putString(decoded->c_str()).good(); | |
1997 } | |
1998 else | |
1999 { | |
2000 ok = element.putSint16(boost::lexical_cast<Sint16>(*decoded)).good(); | |
2001 } | |
1988 break; | 2002 break; |
1989 } | 2003 } |
1990 | 2004 |
1991 case EVR_UL: // unsigned long | 2005 case EVR_UL: // unsigned long |
1992 #if DCMTK_VERSION_NUMBER >= 362 | 2006 #if DCMTK_VERSION_NUMBER >= 362 |
2021 break; | 2035 break; |
2022 } | 2036 } |
2023 | 2037 |
2024 case EVR_US: // unsigned short | 2038 case EVR_US: // unsigned short |
2025 { | 2039 { |
2026 ok = element.putUint16(boost::lexical_cast<Uint16>(*decoded)).good(); | 2040 if (decoded->find('\\') != std::string::npos) |
2041 { | |
2042 ok = element.putString(decoded->c_str()).good(); | |
2043 } | |
2044 else | |
2045 { | |
2046 ok = element.putUint16(boost::lexical_cast<Uint16>(*decoded)).good(); | |
2047 } | |
2027 break; | 2048 break; |
2028 } | 2049 } |
2029 | 2050 |
2030 case EVR_FL: // float single-precision | 2051 case EVR_FL: // float single-precision |
2031 case EVR_OF: // other float (requires byte swapping) | 2052 case EVR_OF: // other float (requires byte swapping) |
2032 { | 2053 { |
2033 ok = element.putFloat32(boost::lexical_cast<float>(*decoded)).good(); | 2054 if (decoded->find('\\') != std::string::npos) |
2055 { | |
2056 ok = element.putString(decoded->c_str()).good(); | |
2057 } | |
2058 else | |
2059 { | |
2060 ok = element.putFloat32(boost::lexical_cast<float>(*decoded)).good(); | |
2061 } | |
2034 break; | 2062 break; |
2035 } | 2063 } |
2036 | 2064 |
2037 case EVR_FD: // float double-precision | 2065 case EVR_FD: // float double-precision |
2038 #if DCMTK_VERSION_NUMBER >= 361 | 2066 #if DCMTK_VERSION_NUMBER >= 361 |
2039 case EVR_OD: // other double (requires byte-swapping) | 2067 case EVR_OD: // other double (requires byte-swapping) |
2040 #endif | 2068 #endif |
2041 { | 2069 { |
2042 ok = element.putFloat64(boost::lexical_cast<double>(*decoded)).good(); | 2070 if (decoded->find('\\') != std::string::npos) |
2071 { | |
2072 ok = element.putString(decoded->c_str()).good(); | |
2073 } | |
2074 else | |
2075 { | |
2076 ok = element.putFloat64(boost::lexical_cast<double>(*decoded)).good(); | |
2077 } | |
2043 break; | 2078 break; |
2044 } | 2079 } |
2045 | 2080 |
2046 | 2081 |
2047 /** | 2082 /** |