comparison Core/DicomParsing/FromDcmtkBridge.cpp @ 2662:47d812308d63 jobs

serialization of DicomModification
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 07 Jun 2018 17:47:41 +0200
parents ea63d9f90377
children ab0fd5923c1d
comparison
equal deleted inserted replaced
2660:27b7884512be 2662:47d812308d63
104 #endif 104 #endif
105 105
106 106
107 namespace Orthanc 107 namespace Orthanc
108 { 108 {
109 static inline uint16_t GetCharValue(char c)
110 {
111 if (c >= '0' && c <= '9')
112 return c - '0';
113 else if (c >= 'a' && c <= 'f')
114 return c - 'a' + 10;
115 else if (c >= 'A' && c <= 'F')
116 return c - 'A' + 10;
117 else
118 return 0;
119 }
120
121 static inline uint16_t GetTagValue(const char* c)
122 {
123 return ((GetCharValue(c[0]) << 12) +
124 (GetCharValue(c[1]) << 8) +
125 (GetCharValue(c[2]) << 4) +
126 GetCharValue(c[3]));
127 }
128
129
130 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 109 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1
131 static void LoadEmbeddedDictionary(DcmDataDictionary& dictionary, 110 static void LoadEmbeddedDictionary(DcmDataDictionary& dictionary,
132 EmbeddedResources::FileResourceId resource) 111 EmbeddedResources::FileResourceId resource)
133 { 112 {
134 std::string content; 113 std::string content;
1059 1038
1060 1039
1061 1040
1062 DicomTag FromDcmtkBridge::ParseTag(const char* name) 1041 DicomTag FromDcmtkBridge::ParseTag(const char* name)
1063 { 1042 {
1064 if (strlen(name) == 9 && 1043 DicomTag parsed(0, 0);
1065 isxdigit(name[0]) && 1044 if (DicomTag::ParseHexadecimal(parsed, name))
1066 isxdigit(name[1]) && 1045 {
1067 isxdigit(name[2]) && 1046 return parsed;
1068 isxdigit(name[3]) &&
1069 (name[4] == '-' || name[4] == ',') &&
1070 isxdigit(name[5]) &&
1071 isxdigit(name[6]) &&
1072 isxdigit(name[7]) &&
1073 isxdigit(name[8]))
1074 {
1075 uint16_t group = GetTagValue(name);
1076 uint16_t element = GetTagValue(name + 5);
1077 return DicomTag(group, element);
1078 }
1079
1080 if (strlen(name) == 8 &&
1081 isxdigit(name[0]) &&
1082 isxdigit(name[1]) &&
1083 isxdigit(name[2]) &&
1084 isxdigit(name[3]) &&
1085 isxdigit(name[4]) &&
1086 isxdigit(name[5]) &&
1087 isxdigit(name[6]) &&
1088 isxdigit(name[7]))
1089 {
1090 uint16_t group = GetTagValue(name);
1091 uint16_t element = GetTagValue(name + 4);
1092 return DicomTag(group, element);
1093 } 1047 }
1094 1048
1095 #if 0 1049 #if 0
1096 const DcmDataDictionary& dict = dcmDataDict.rdlock(); 1050 const DcmDataDictionary& dict = dcmDataDict.rdlock();
1097 const DcmDictEntry* entry = dict.findEntry(name); 1051 const DcmDictEntry* entry = dict.findEntry(name);