comparison OrthancServer/Internals/StoreScp.cpp @ 291:4d7469f72a0b

embedding of dicom dictionaries
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Dec 2012 15:15:48 +0100
parents 0186ac92810c
children 4d5f0857ec9c
comparison
equal deleted inserted replaced
290:b3322636b06d 291:4d7469f72a0b
54 const char* distantAET; 54 const char* distantAET;
55 const char* modality; 55 const char* modality;
56 const char* affectedSOPInstanceUID; 56 const char* affectedSOPInstanceUID;
57 uint32_t messageID; 57 uint32_t messageID;
58 }; 58 };
59
60
61 static int SaveToMemoryBuffer(DcmDataset* dataSet,
62 std::vector<uint8_t>& buffer)
63 {
64 // Determine the transfer syntax which shall be used to write the
65 // information to the file. We always switch to the Little Endian
66 // syntax, with explicit length.
67
68 // http://support.dcmtk.org/docs/dcxfer_8h-source.html
69 E_TransferSyntax xfer = EXS_LittleEndianExplicit;
70 E_EncodingType encodingType = /*opt_sequenceType*/ EET_ExplicitLength;
71
72 uint32_t s = dataSet->getLength(xfer, encodingType);
73
74 buffer.resize(s);
75 DcmOutputBufferStream ob(&buffer[0], s);
76
77 dataSet->transferInit();
78
79 #if DCMTK_VERSION_NUMBER >= 360
80 OFCondition c = dataSet->write(ob, xfer, encodingType, NULL,
81 /*opt_groupLength*/ EGL_recalcGL,
82 /*opt_paddingType*/ EPD_withoutPadding);
83 #else
84 OFCondition c = dataSet->write(ob, xfer, encodingType, NULL);
85 #endif
86
87 dataSet->transferEnd();
88 if (c.good())
89 {
90 return 0;
91 }
92 else
93 {
94 buffer.clear();
95 return -1;
96 }
97
98 #if 0
99 OFCondition cond = cbdata->dcmff->saveFile(fileName.c_str(), xfer,
100 encodingType,
101 /*opt_groupLength*/ EGL_recalcGL,
102 /*opt_paddingType*/ EPD_withoutPadding,
103 OFstatic_cast(Uint32, /*opt_filepad*/ 0),
104 OFstatic_cast(Uint32, /*opt_itempad*/ 0),
105 (opt_useMetaheader) ? EWM_fileformat : EWM_dataset);
106 #endif
107 }
108 59
109 60
110 static void 61 static void
111 storeScpCallback( 62 storeScpCallback(
112 void *callbackData, 63 void *callbackData,
157 // is present and the options opt_bitPreserving and opt_ignore are not set. 108 // is present and the options opt_bitPreserving and opt_ignore are not set.
158 if ((imageDataSet != NULL) && (*imageDataSet != NULL)) 109 if ((imageDataSet != NULL) && (*imageDataSet != NULL))
159 { 110 {
160 DicomMap summary; 111 DicomMap summary;
161 Json::Value dicomJson; 112 Json::Value dicomJson;
162 std::vector<uint8_t> buffer; 113 std::string buffer;
163 114
164 try 115 try
165 { 116 {
166 FromDcmtkBridge::Convert(summary, **imageDataSet); 117 FromDcmtkBridge::Convert(summary, **imageDataSet);
167 FromDcmtkBridge::ToJson(dicomJson, **imageDataSet); 118 FromDcmtkBridge::ToJson(dicomJson, **imageDataSet);
168 119
169 if (SaveToMemoryBuffer(*imageDataSet, buffer) < 0) 120 if (FromDcmtkBridge::SaveToMemoryBuffer(buffer, *imageDataSet) < 0)
170 { 121 {
171 LOG(ERROR) << "cannot write DICOM file to memory"; 122 LOG(ERROR) << "cannot write DICOM file to memory";
172 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; 123 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources;
173 } 124 }
174 } 125 }