Mercurial > hg > orthanc
comparison Core/DicomParsing/FromDcmtkBridge.cpp @ 3872:b40dfa6dc8da transcoding
working on a simpler abstraction for transcoding
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 Apr 2020 14:39:28 +0200 |
parents | 890af7156f19 |
children | f23ab7829a8d |
comparison
equal
deleted
inserted
replaced
3871:5797d184de67 | 3872:b40dfa6dc8da |
---|---|
1204 throw OrthancException(ErrorCode_ParameterOutOfRange); | 1204 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1205 } | 1205 } |
1206 } | 1206 } |
1207 | 1207 |
1208 | 1208 |
1209 | 1209 |
1210 static bool SaveToMemoryBufferInternal(std::string& buffer, | 1210 static bool SaveToMemoryBufferInternal(std::string& buffer, |
1211 DcmFileFormat& dicom, | 1211 DcmFileFormat& dicom, |
1212 E_TransferSyntax xfer) | 1212 E_TransferSyntax xfer) |
1213 { | 1213 { |
1214 E_EncodingType encodingType = /*opt_sequenceType*/ EET_ExplicitLength; | 1214 E_EncodingType encodingType = /*opt_sequenceType*/ EET_ExplicitLength; |
1252 } | 1252 } |
1253 } | 1253 } |
1254 | 1254 |
1255 | 1255 |
1256 bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer, | 1256 bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer, |
1257 DcmFileFormat& dicom, | |
1258 DicomTransferSyntax syntax) | |
1259 { | |
1260 E_TransferSyntax xfer; | |
1261 if (!LookupDcmtkTransferSyntax(xfer, syntax)) | |
1262 { | |
1263 return false; | |
1264 } | |
1265 else if (!dicom.validateMetaInfo(xfer).good()) | |
1266 { | |
1267 throw OrthancException(ErrorCode_InternalError, | |
1268 "Cannot setup the transfer syntax to write a DICOM instance"); | |
1269 } | |
1270 else | |
1271 { | |
1272 return SaveToMemoryBufferInternal(buffer, dicom, xfer); | |
1273 } | |
1274 } | |
1275 | |
1276 | |
1277 bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer, | |
1257 DcmDataset& dataSet) | 1278 DcmDataset& dataSet) |
1258 { | 1279 { |
1259 // Determine the transfer syntax which shall be used to write the | 1280 // Determine the transfer syntax which shall be used to write the |
1260 // information to the file. If not possible, switch to the Little | 1281 // information to the file. If not possible, switch to the Little |
1261 // Endian syntax, with explicit length. | 1282 // Endian syntax, with explicit length. |
1305 return SaveToMemoryBufferInternal(buffer, dicom, xfer); | 1326 return SaveToMemoryBufferInternal(buffer, dicom, xfer); |
1306 } | 1327 } |
1307 } | 1328 } |
1308 | 1329 |
1309 | 1330 |
1310 bool FromDcmtkBridge::Transcode(std::string& buffer, | 1331 bool FromDcmtkBridge::Transcode(DcmFileFormat& dicom, |
1311 DcmFileFormat& dicom, | |
1312 DicomTransferSyntax syntax, | 1332 DicomTransferSyntax syntax, |
1313 const DcmRepresentationParameter* representation) | 1333 const DcmRepresentationParameter* representation) |
1314 { | 1334 { |
1315 E_TransferSyntax xfer; | 1335 E_TransferSyntax xfer; |
1316 if (!LookupDcmtkTransferSyntax(xfer, syntax)) | 1336 if (!LookupDcmtkTransferSyntax(xfer, syntax)) |
1323 !dicom.getDataset()->canWriteXfer(xfer) || | 1343 !dicom.getDataset()->canWriteXfer(xfer) || |
1324 !dicom.validateMetaInfo(xfer, EWM_updateMeta).good()) | 1344 !dicom.validateMetaInfo(xfer, EWM_updateMeta).good()) |
1325 { | 1345 { |
1326 return false; | 1346 return false; |
1327 } | 1347 } |
1328 | 1348 else |
1329 dicom.removeInvalidGroups(); | 1349 { |
1330 | 1350 dicom.removeInvalidGroups(); |
1331 return SaveToMemoryBufferInternal(buffer, dicom, xfer); | 1351 return true; |
1352 } | |
1332 } | 1353 } |
1333 } | 1354 } |
1334 | 1355 |
1335 | 1356 |
1336 ValueRepresentation FromDcmtkBridge::LookupValueRepresentation(const DicomTag& tag) | 1357 ValueRepresentation FromDcmtkBridge::LookupValueRepresentation(const DicomTag& tag) |