Mercurial > hg > orthanc
comparison OrthancServer/DicomInstanceToStore.cpp @ 1788:6a2d507ef064 worklists
getting rid of opaque data structures
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 18 Nov 2015 16:11:28 +0100 |
parents | a001f6226c7c |
children | bdfae6e17d23 |
comparison
equal
deleted
inserted
replaced
1787:1b1d5470233f | 1788:6a2d507ef064 |
---|---|
39 #include <dcmtk/dcmdata/dcfilefo.h> | 39 #include <dcmtk/dcmdata/dcfilefo.h> |
40 | 40 |
41 | 41 |
42 namespace Orthanc | 42 namespace Orthanc |
43 { | 43 { |
44 static DcmDataset& GetDataset(ParsedDicomFile& file) | |
45 { | |
46 return *reinterpret_cast<DcmFileFormat*>(file.GetDcmtkObject())->getDataset(); | |
47 } | |
48 | |
49 | |
50 void DicomInstanceToStore::AddMetadata(ResourceType level, | 44 void DicomInstanceToStore::AddMetadata(ResourceType level, |
51 MetadataType metadata, | 45 MetadataType metadata, |
52 const std::string& value) | 46 const std::string& value) |
53 { | 47 { |
54 metadata_[std::make_pair(level, metadata)] = value; | 48 metadata_[std::make_pair(level, metadata)] = value; |
73 } | 67 } |
74 else | 68 else |
75 { | 69 { |
76 // Serialize the parsed DICOM file | 70 // Serialize the parsed DICOM file |
77 buffer_.Allocate(); | 71 buffer_.Allocate(); |
78 if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer_.GetContent(), GetDataset(parsed_.GetContent()))) | 72 if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer_.GetContent(), |
73 *parsed_.GetContent().GetDcmtkObject().getDataset())) | |
79 { | 74 { |
80 LOG(ERROR) << "Unable to serialize a DICOM file to a memory buffer"; | 75 LOG(ERROR) << "Unable to serialize a DICOM file to a memory buffer"; |
81 throw OrthancException(ErrorCode_InternalError); | 76 throw OrthancException(ErrorCode_InternalError); |
82 } | 77 } |
83 } | 78 } |
101 // At this point, we have parsed the DICOM file | 96 // At this point, we have parsed the DICOM file |
102 | 97 |
103 if (!summary_.HasContent()) | 98 if (!summary_.HasContent()) |
104 { | 99 { |
105 summary_.Allocate(); | 100 summary_.Allocate(); |
106 FromDcmtkBridge::Convert(summary_.GetContent(), GetDataset(parsed_.GetContent())); | 101 FromDcmtkBridge::Convert(summary_.GetContent(), |
102 *parsed_.GetContent().GetDcmtkObject().getDataset()); | |
107 } | 103 } |
108 | 104 |
109 if (!json_.HasContent()) | 105 if (!json_.HasContent()) |
110 { | 106 { |
111 json_.Allocate(); | 107 json_.Allocate(); |
112 FromDcmtkBridge::ToJson(json_.GetContent(), GetDataset(parsed_.GetContent()), | 108 FromDcmtkBridge::ToJson(json_.GetContent(), |
109 *parsed_.GetContent().GetDcmtkObject().getDataset(), | |
113 DicomToJsonFormat_Full, | 110 DicomToJsonFormat_Full, |
114 DicomToJsonFlags_Default, | 111 DicomToJsonFlags_Default, |
115 256 /* max string length */); | 112 256 /* max string length */); |
116 } | 113 } |
117 } | 114 } |