Mercurial > hg > orthanc
comparison OrthancServer/FromDcmtkBridge.cpp @ 661:d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 05 Nov 2013 17:41:25 +0100 |
parents | 08eca5d86aad |
children | aa5ca7a2166f |
comparison
equal
deleted
inserted
replaced
660:f0232774b913 | 661:d233b5090105 |
---|---|
96 #include <dcmtk/dcmdata/dcdicent.h> | 96 #include <dcmtk/dcmdata/dcdicent.h> |
97 #include <dcmtk/dcmdata/dcdict.h> | 97 #include <dcmtk/dcmdata/dcdict.h> |
98 #include <dcmtk/dcmdata/dcfilefo.h> | 98 #include <dcmtk/dcmdata/dcfilefo.h> |
99 #include <dcmtk/dcmdata/dcistrmb.h> | 99 #include <dcmtk/dcmdata/dcistrmb.h> |
100 #include <dcmtk/dcmdata/dcuid.h> | 100 #include <dcmtk/dcmdata/dcuid.h> |
101 #include <dcmtk/dcmdata/dcmetinf.h> | |
101 | 102 |
102 #include <dcmtk/dcmdata/dcvrae.h> | 103 #include <dcmtk/dcmdata/dcvrae.h> |
103 #include <dcmtk/dcmdata/dcvras.h> | 104 #include <dcmtk/dcmdata/dcvras.h> |
104 #include <dcmtk/dcmdata/dcvrcs.h> | 105 #include <dcmtk/dcmdata/dcvrcs.h> |
105 #include <dcmtk/dcmdata/dcvrda.h> | 106 #include <dcmtk/dcmdata/dcvrda.h> |
1552 // Determine the transfer syntax which shall be used to write the | 1553 // Determine the transfer syntax which shall be used to write the |
1553 // information to the file. We always switch to the Little Endian | 1554 // information to the file. We always switch to the Little Endian |
1554 // syntax, with explicit length. | 1555 // syntax, with explicit length. |
1555 | 1556 |
1556 // http://support.dcmtk.org/docs/dcxfer_8h-source.html | 1557 // http://support.dcmtk.org/docs/dcxfer_8h-source.html |
1557 E_TransferSyntax xfer = EXS_LittleEndianExplicit; | 1558 |
1559 | |
1560 /** | |
1561 * Note that up to Orthanc 0.7.1 (inclusive), the | |
1562 * "EXS_LittleEndianExplicit" was always used to save the DICOM | |
1563 * dataset into memory. We now keep the original transfer syntax | |
1564 * (if available). | |
1565 **/ | |
1566 E_TransferSyntax xfer = dataSet->getOriginalXfer(); | |
1567 if (xfer == EXS_Unknown) | |
1568 { | |
1569 // No information about the original transfer syntax: This is | |
1570 // most probably a DICOM dataset that was read from memory. | |
1571 xfer = EXS_LittleEndianExplicit; | |
1572 } | |
1573 | |
1558 E_EncodingType encodingType = /*opt_sequenceType*/ EET_ExplicitLength; | 1574 E_EncodingType encodingType = /*opt_sequenceType*/ EET_ExplicitLength; |
1559 | 1575 |
1560 uint32_t s = dataSet->getLength(xfer, encodingType); | 1576 // Create the meta-header information |
1561 | 1577 DcmFileFormat ff(dataSet); |
1578 ff.validateMetaInfo(xfer); | |
1579 | |
1580 // Create a memory buffer with the proper size | |
1581 uint32_t s = ff.calcElementLength(xfer, encodingType); | |
1562 buffer.resize(s); | 1582 buffer.resize(s); |
1563 DcmOutputBufferStream ob(&buffer[0], s); | 1583 DcmOutputBufferStream ob(&buffer[0], s); |
1564 | 1584 |
1565 dataSet->transferInit(); | 1585 // Fill the memory buffer with the meta-header and the dataset |
1566 | 1586 ff.transferInit(); |
1567 #if DCMTK_VERSION_NUMBER >= 360 | 1587 OFCondition c = ff.write(ob, xfer, encodingType, NULL, |
1568 OFCondition c = dataSet->write(ob, xfer, encodingType, NULL, | 1588 /*opt_groupLength*/ EGL_recalcGL, |
1569 /*opt_groupLength*/ EGL_recalcGL, | 1589 /*opt_paddingType*/ EPD_withoutPadding); |
1570 /*opt_paddingType*/ EPD_withoutPadding); | 1590 ff.transferEnd(); |
1571 #else | 1591 |
1572 OFCondition c = dataSet->write(ob, xfer, encodingType, NULL); | 1592 // Handle errors |
1573 #endif | |
1574 | |
1575 dataSet->transferEnd(); | |
1576 if (c.good()) | 1593 if (c.good()) |
1577 { | 1594 { |
1578 return true; | 1595 return true; |
1579 } | 1596 } |
1580 else | 1597 else |
1581 { | 1598 { |
1582 buffer.clear(); | 1599 buffer.clear(); |
1583 return false; | 1600 return false; |
1584 } | 1601 } |
1585 | |
1586 #if 0 | |
1587 OFCondition cond = cbdata->dcmff->saveFile(fileName.c_str(), xfer, | |
1588 encodingType, | |
1589 /*opt_groupLength*/ EGL_recalcGL, | |
1590 /*opt_paddingType*/ EPD_withoutPadding, | |
1591 OFstatic_cast(Uint32, /*opt_filepad*/ 0), | |
1592 OFstatic_cast(Uint32, /*opt_itempad*/ 0), | |
1593 (opt_useMetaheader) ? EWM_fileformat : EWM_dataset); | |
1594 #endif | |
1595 } | 1602 } |
1596 } | 1603 } |