Mercurial > hg > orthanc
comparison Core/DicomParsing/DcmtkTranscoder.cpp @ 3907:1555feda39e2 transcoding
substituting IDicomTranscoder::TranscodeToParsed() by refactored implementation
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 08 May 2020 11:24:34 +0200 |
parents | f0dd5ded8927 |
children | 6762a97deabc |
comparison
equal
deleted
inserted
replaced
3906:f0dd5ded8927 | 3907:1555feda39e2 |
---|---|
127 lossyQuality_ = quality; | 127 lossyQuality_ = quality; |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 DcmFileFormat* DcmtkTranscoder::TranscodeToParsed(bool& hasSopInstanceUidChanged /* out */, | |
133 const void* buffer, | |
134 size_t size, | |
135 const std::set<DicomTransferSyntax>& allowedSyntaxes, | |
136 bool allowNewSopInstanceUid) | |
137 { | |
138 std::unique_ptr<DcmFileFormat> dicom(FromDcmtkBridge::LoadFromMemoryBuffer(buffer, size)); | |
139 | |
140 if (dicom.get() == NULL) | |
141 { | |
142 throw OrthancException(ErrorCode_InternalError); | |
143 } | |
144 | |
145 if (InplaceTranscode(hasSopInstanceUidChanged, *dicom, allowedSyntaxes, allowNewSopInstanceUid)) | |
146 { | |
147 return dicom.release(); | |
148 } | |
149 else | |
150 { | |
151 return NULL; | |
152 } | |
153 } | |
154 | |
155 | |
156 bool DcmtkTranscoder::InplaceTranscode(bool& hasSopInstanceUidChanged /* out */, | 132 bool DcmtkTranscoder::InplaceTranscode(bool& hasSopInstanceUidChanged /* out */, |
157 DcmFileFormat& dicom, | 133 DcmFileFormat& dicom, |
158 const std::set<DicomTransferSyntax>& allowedSyntaxes, | 134 const std::set<DicomTransferSyntax>& allowedSyntaxes, |
159 bool allowNewSopInstanceUid) | 135 bool allowNewSopInstanceUid) |
160 { | 136 { |
319 const void* buffer, | 295 const void* buffer, |
320 size_t size, | 296 size_t size, |
321 const std::set<DicomTransferSyntax>& allowedSyntaxes, | 297 const std::set<DicomTransferSyntax>& allowedSyntaxes, |
322 bool allowNewSopInstanceUid) | 298 bool allowNewSopInstanceUid) |
323 { | 299 { |
324 std::unique_ptr<DcmFileFormat> transcoded( | 300 std::unique_ptr<DcmFileFormat> dicom(FromDcmtkBridge::LoadFromMemoryBuffer(buffer, size)); |
325 TranscodeToParsed(hasSopInstanceUidChanged, buffer, size, allowedSyntaxes, allowNewSopInstanceUid)); | 301 if (dicom.get() == NULL) |
302 { | |
303 throw OrthancException(ErrorCode_BadFileFormat); | |
304 } | |
305 | |
306 std::unique_ptr<TranscodedDicom> transcoded( | |
307 TranscodeToParsed(*dicom, buffer, size, allowedSyntaxes, allowNewSopInstanceUid)); | |
326 | 308 |
327 if (transcoded.get() == NULL) | 309 if (transcoded.get() == NULL) |
328 { | 310 { |
329 return false; | 311 return false; |
330 } | 312 } |
331 else | 313 else |
332 { | 314 { |
333 if (transcoded->getDataset() == NULL) | 315 if (transcoded->GetDicom().getDataset() == NULL) |
334 { | 316 { |
335 throw OrthancException(ErrorCode_InternalError); | 317 throw OrthancException(ErrorCode_InternalError); |
336 } | 318 } |
337 | 319 |
338 FromDcmtkBridge::SaveToMemoryBuffer(target, *transcoded->getDataset()); | 320 FromDcmtkBridge::SaveToMemoryBuffer(target, *transcoded->GetDicom().getDataset()); |
339 return true; | 321 return true; |
340 } | 322 } |
341 } | 323 } |
342 | 324 |
343 | 325 |
413 return false; | 395 return false; |
414 } | 396 } |
415 } | 397 } |
416 | 398 |
417 | 399 |
418 IDicomTranscoder::TranscodedDicom* DcmtkTranscoder::TranscodeToParsed2( | 400 IDicomTranscoder::TranscodedDicom* DcmtkTranscoder::TranscodeToParsed( |
419 DcmFileFormat& dicom /* in, possibly modified */, | 401 DcmFileFormat& dicom /* in, possibly modified */, |
420 const void* buffer /* in, same DICOM file as "dicom" */, | 402 const void* buffer /* in, same DICOM file as "dicom" */, |
421 size_t size, | 403 size_t size, |
422 const std::set<DicomTransferSyntax>& allowedSyntaxes, | 404 const std::set<DicomTransferSyntax>& allowedSyntaxes, |
423 bool allowNewSopInstanceUid) | 405 bool allowNewSopInstanceUid) |