Mercurial > hg > orthanc
annotate Resources/Graveyard/TestTranscoding.cpp @ 4111:994d4da97dea more-changes
closing more-changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 13:07:03 +0200 |
parents | e23026566536 |
children |
rev | line source |
---|---|
3885
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
1 bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer, |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
2 DcmFileFormat& dicom, |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
3 DicomTransferSyntax syntax) |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
4 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
5 E_TransferSyntax xfer; |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
6 if (!LookupDcmtkTransferSyntax(xfer, syntax)) |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
7 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
8 return false; |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
9 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
10 else if (!dicom.validateMetaInfo(xfer).good()) |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
11 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
12 throw OrthancException(ErrorCode_InternalError, |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
13 "Cannot setup the transfer syntax to write a DICOM instance"); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
14 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
15 else |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
16 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
17 return SaveToMemoryBufferInternal(buffer, dicom, xfer); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
18 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
19 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
20 |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
21 |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
22 bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer, |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
23 DcmFileFormat& dicom) |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
24 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
25 E_TransferSyntax xfer = dicom.getDataset()->getCurrentXfer(); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
26 if (xfer == EXS_Unknown) |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
27 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
28 throw OrthancException(ErrorCode_InternalError, |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
29 "Cannot write a DICOM instance with unknown transfer syntax"); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
30 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
31 else if (!dicom.validateMetaInfo(xfer).good()) |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
32 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
33 throw OrthancException(ErrorCode_InternalError, |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
34 "Cannot setup the transfer syntax to write a DICOM instance"); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
35 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
36 else |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
37 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
38 return SaveToMemoryBufferInternal(buffer, dicom, xfer); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
39 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
40 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
41 |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
42 |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
43 |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
44 |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
45 |
3884
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 #include <dcmtk/dcmdata/dcostrmb.h> |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 #include <dcmtk/dcmdata/dcpixel.h> |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 #include <dcmtk/dcmdata/dcpxitem.h> |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 #include "../Core/DicomParsing/Internals/DicomFrameIndex.h" |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 namespace Orthanc |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 class IParsedDicomImage : public boost::noncopyable |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 public: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 virtual ~IParsedDicomImage() |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 virtual DicomTransferSyntax GetTransferSyntax() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 virtual std::string GetSopClassUid() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 virtual std::string GetSopInstanceUid() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 virtual unsigned int GetFramesCount() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 // Can return NULL, for compressed transfer syntaxes |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 virtual ImageAccessor* GetUncompressedFrame(unsigned int frame) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 virtual void GetCompressedFrame(std::string& target, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 unsigned int frame) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 virtual void WriteToMemoryBuffer(std::string& target) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 }; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 class IDicomImageReader : public boost::noncopyable |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 public: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 virtual ~IDicomImageReader() |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 virtual IParsedDicomImage* Read(const void* data, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 size_t size) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 virtual IParsedDicomImage* Transcode(const void* data, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 size_t size, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 DicomTransferSyntax syntax, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 bool allowNewSopInstanceUid) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 }; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 class DcmtkImageReader : public IDicomImageReader |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 private: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 class Image : public IParsedDicomImage |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 private: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 std::unique_ptr<DcmFileFormat> dicom_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 std::unique_ptr<DicomFrameIndex> index_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 DicomTransferSyntax transferSyntax_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 std::string sopClassUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 std::string sopInstanceUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 static std::string GetStringTag(DcmDataset& dataset, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 const DcmTagKey& tag) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 const char* value = NULL; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 if (!dataset.findAndGetString(tag, value).good() || |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 value == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 throw OrthancException(ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 "Missing SOP class/instance UID in DICOM instance"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 else |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 return std::string(value); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 public: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 Image(DcmFileFormat* dicom, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 DicomTransferSyntax syntax) : |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 dicom_(dicom), |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 transferSyntax_(syntax) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 if (dicom == NULL || |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 dicom_->getDataset() == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 throw OrthancException(ErrorCode_NullPointer); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 DcmDataset& dataset = *dicom_->getDataset(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 index_.reset(new DicomFrameIndex(dataset)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 sopClassUid_ = GetStringTag(dataset, DCM_SOPClassUID); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 sopInstanceUid_ = GetStringTag(dataset, DCM_SOPInstanceUID); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 virtual DicomTransferSyntax GetTransferSyntax() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 return transferSyntax_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 virtual std::string GetSopClassUid() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 return sopClassUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 virtual std::string GetSopInstanceUid() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 return sopInstanceUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 virtual unsigned int GetFramesCount() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 return index_->GetFramesCount(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 virtual void WriteToMemoryBuffer(std::string& target) ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 assert(dicom_.get() != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 if (!FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, transferSyntax_)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 throw OrthancException(ErrorCode_InternalError, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 "Cannot write the DICOM instance to a memory buffer"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 virtual ImageAccessor* GetUncompressedFrame(unsigned int frame) ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 assert(dicom_.get() != NULL && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 dicom_->getDataset() != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 return DicomImageDecoder::Decode(*dicom_->getDataset(), frame); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 virtual void GetCompressedFrame(std::string& target, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 unsigned int frame) ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 assert(index_.get() != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 index_->GetRawFrame(target, frame); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 }; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 unsigned int lossyQuality_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 static DicomTransferSyntax DetectTransferSyntax(DcmFileFormat& dicom) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 if (dicom.getDataset() == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 throw OrthancException(ErrorCode_InternalError); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 DcmDataset& dataset = *dicom.getDataset(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 E_TransferSyntax xfer = dataset.getCurrentXfer(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 if (xfer == EXS_Unknown) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 dataset.updateOriginalXfer(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 xfer = dataset.getCurrentXfer(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 if (xfer == EXS_Unknown) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 throw OrthancException(ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 "Cannot determine the transfer syntax of the DICOM instance"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 DicomTransferSyntax syntax; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 if (FromDcmtkBridge::LookupOrthancTransferSyntax(syntax, xfer)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 return syntax; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 else |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 throw OrthancException( |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 "Unsupported transfer syntax: " + boost::lexical_cast<std::string>(xfer)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 static uint16_t GetBitsStored(DcmFileFormat& dicom) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 if (dicom.getDataset() == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 throw OrthancException(ErrorCode_InternalError); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 uint16_t bitsStored; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 if (dicom.getDataset()->findAndGetUint16(DCM_BitsStored, bitsStored).good()) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 return bitsStored; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 else |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 throw OrthancException(ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 "Missing \"Bits Stored\" tag in DICOM instance"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 public: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 DcmtkImageReader() : |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 lossyQuality_(90) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 void SetLossyQuality(unsigned int quality) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 if (quality <= 0 || |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 quality > 100) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 throw OrthancException(ErrorCode_ParameterOutOfRange); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 else |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 lossyQuality_ = quality; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 unsigned int GetLossyQuality() const |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 return lossyQuality_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 virtual IParsedDicomImage* Read(const void* data, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 size_t size) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 std::unique_ptr<DcmFileFormat> dicom(FromDcmtkBridge::LoadFromMemoryBuffer(data, size)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 if (dicom.get() == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 throw OrthancException(ErrorCode_BadFileFormat); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 DicomTransferSyntax transferSyntax = DetectTransferSyntax(*dicom); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 return new Image(dicom.release(), transferSyntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
282 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
283 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 virtual IParsedDicomImage* Transcode(const void* data, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 size_t size, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
286 DicomTransferSyntax syntax, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
287 bool allowNewSopInstanceUid) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
289 std::unique_ptr<DcmFileFormat> dicom(FromDcmtkBridge::LoadFromMemoryBuffer(data, size)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
290 if (dicom.get() == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 throw OrthancException(ErrorCode_BadFileFormat); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 const uint16_t bitsStored = GetBitsStored(*dicom); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
296 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
297 if (syntax == DetectTransferSyntax(*dicom)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 // No transcoding is needed |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 return new Image(dicom.release(), syntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 if (syntax == DicomTransferSyntax_LittleEndianImplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_LittleEndianImplicit, NULL)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 return new Image(dicom.release(), syntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 if (syntax == DicomTransferSyntax_LittleEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_LittleEndianExplicit, NULL)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 return new Image(dicom.release(), syntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
313 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
314 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
315 if (syntax == DicomTransferSyntax_BigEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_BigEndianExplicit, NULL)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
317 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 return new Image(dicom.release(), syntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
321 if (syntax == DicomTransferSyntax_DeflatedLittleEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_DeflatedLittleEndianExplicit, NULL)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 return new Image(dicom.release(), syntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 #if ORTHANC_ENABLE_JPEG == 1 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 if (syntax == DicomTransferSyntax_JPEGProcess1 && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
329 allowNewSopInstanceUid && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 bitsStored == 8) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 DJ_RPLossy rpLossy(lossyQuality_); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 if (FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_JPEGProcess1, &rpLossy)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 return new Image(dicom.release(), syntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
338 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 #endif |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 #if ORTHANC_ENABLE_JPEG == 1 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 if (syntax == DicomTransferSyntax_JPEGProcess2_4 && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 allowNewSopInstanceUid && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 bitsStored <= 12) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 DJ_RPLossy rpLossy(lossyQuality_); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
347 if (FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_JPEGProcess2_4, &rpLossy)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
348 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
349 return new Image(dicom.release(), syntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 #endif |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
353 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
354 //LOG(INFO) << "Unable to transcode DICOM image using the built-in reader"; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
355 return NULL; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
356 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
357 }; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
358 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
359 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
361 class IDicomTranscoder1 : public boost::noncopyable |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 public: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 virtual ~IDicomTranscoder1() |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 virtual DcmFileFormat& GetDicom() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
369 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 virtual DicomTransferSyntax GetTransferSyntax() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
371 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 virtual std::string GetSopClassUid() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 virtual std::string GetSopInstanceUid() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 virtual unsigned int GetFramesCount() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 virtual ImageAccessor* DecodeFrame(unsigned int frame) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 virtual void GetCompressedFrame(std::string& target, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 unsigned int frame) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
382 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 // NB: Transcoding can change the value of "GetSopInstanceUid()" |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 // and "GetTransferSyntax()" if lossy compression is applied |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 virtual bool Transcode(std::string& target, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 DicomTransferSyntax syntax, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 bool allowNewSopInstanceUid) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
388 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
389 virtual void WriteToMemoryBuffer(std::string& target) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
390 }; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
392 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 class DcmtkTranscoder2 : public IDicomTranscoder1 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 private: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 std::unique_ptr<DcmFileFormat> dicom_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 std::unique_ptr<DicomFrameIndex> index_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
398 DicomTransferSyntax transferSyntax_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 std::string sopClassUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 std::string sopInstanceUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 uint16_t bitsStored_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 unsigned int lossyQuality_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 static std::string GetStringTag(DcmDataset& dataset, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 const DcmTagKey& tag) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 const char* value = NULL; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 if (!dataset.findAndGetString(tag, value).good() || |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
410 value == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
412 throw OrthancException(ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
413 "Missing SOP class/instance UID in DICOM instance"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
414 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
415 else |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 return std::string(value); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
419 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
420 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 void Setup(DcmFileFormat* dicom) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
422 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 lossyQuality_ = 90; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 dicom_.reset(dicom); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
427 if (dicom == NULL || |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
428 dicom_->getDataset() == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
429 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
430 throw OrthancException(ErrorCode_NullPointer); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
431 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
432 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
433 DcmDataset& dataset = *dicom_->getDataset(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
434 index_.reset(new DicomFrameIndex(dataset)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
436 E_TransferSyntax xfer = dataset.getCurrentXfer(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
437 if (xfer == EXS_Unknown) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
438 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
439 dataset.updateOriginalXfer(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 xfer = dataset.getCurrentXfer(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
441 if (xfer == EXS_Unknown) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
442 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
443 throw OrthancException(ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
444 "Cannot determine the transfer syntax of the DICOM instance"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
445 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
446 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
447 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
448 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(transferSyntax_, xfer)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
449 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
450 throw OrthancException( |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
451 ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
452 "Unsupported transfer syntax: " + boost::lexical_cast<std::string>(xfer)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
453 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
454 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
455 if (!dataset.findAndGetUint16(DCM_BitsStored, bitsStored_).good()) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 throw OrthancException(ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 "Missing \"Bits Stored\" tag in DICOM instance"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
459 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
460 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 sopClassUid_ = GetStringTag(dataset, DCM_SOPClassUID); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
462 sopInstanceUid_ = GetStringTag(dataset, DCM_SOPInstanceUID); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
463 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
464 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
465 public: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
466 DcmtkTranscoder2(DcmFileFormat* dicom) // Takes ownership |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
467 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
468 Setup(dicom); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
469 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
470 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
471 DcmtkTranscoder2(const void* dicom, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
472 size_t size) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
473 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
474 Setup(FromDcmtkBridge::LoadFromMemoryBuffer(dicom, size)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
475 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
476 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
477 void SetLossyQuality(unsigned int quality) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
478 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 if (quality <= 0 || |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 quality > 100) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
482 throw OrthancException(ErrorCode_ParameterOutOfRange); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
483 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 else |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
486 lossyQuality_ = quality; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
487 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
488 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
489 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
490 unsigned int GetLossyQuality() const |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
491 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
492 return lossyQuality_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
493 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
494 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
495 unsigned int GetBitsStored() const |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
496 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
497 return bitsStored_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
498 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
499 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
500 virtual DcmFileFormat& GetDicom() |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
501 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
502 assert(dicom_ != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
503 return *dicom_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 virtual DicomTransferSyntax GetTransferSyntax() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
508 return transferSyntax_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
509 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
510 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
511 virtual std::string GetSopClassUid() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
512 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
513 return sopClassUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
514 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
515 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
516 virtual std::string GetSopInstanceUid() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
517 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
518 return sopInstanceUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
519 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
520 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
521 virtual unsigned int GetFramesCount() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
523 return index_->GetFramesCount(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
524 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
525 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 virtual void WriteToMemoryBuffer(std::string& target) ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
527 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
528 if (!FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
529 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
530 throw OrthancException(ErrorCode_InternalError, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
531 "Cannot write the DICOM instance to a memory buffer"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 virtual ImageAccessor* DecodeFrame(unsigned int frame) ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 assert(dicom_->getDataset() != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 return DicomImageDecoder::Decode(*dicom_->getDataset(), frame); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 virtual void GetCompressedFrame(std::string& target, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 unsigned int frame) ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
543 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
544 index_->GetRawFrame(target, frame); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
546 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
547 virtual bool Transcode(std::string& target, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
548 DicomTransferSyntax syntax, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 bool allowNewSopInstanceUid) ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
551 assert(dicom_ != NULL && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
552 dicom_->getDataset() != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
553 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
554 if (syntax == GetTransferSyntax()) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
555 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
556 printf("NO TRANSCODING\n"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
557 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
558 // No change in the transfer syntax => simply serialize the current dataset |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
559 WriteToMemoryBuffer(target); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
560 return true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
561 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
562 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
563 printf(">> %d\n", bitsStored_); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
564 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
565 if (syntax == DicomTransferSyntax_LittleEndianImplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
566 FromDcmtkBridge::Transcode(*dicom_, syntax, NULL) && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
567 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
568 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
569 transferSyntax_ = DicomTransferSyntax_LittleEndianImplicit; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
570 return true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
571 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
572 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
573 if (syntax == DicomTransferSyntax_LittleEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
574 FromDcmtkBridge::Transcode(*dicom_, syntax, NULL) && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
575 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
576 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
577 transferSyntax_ = DicomTransferSyntax_LittleEndianExplicit; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
578 return true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
579 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
580 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
581 if (syntax == DicomTransferSyntax_BigEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
582 FromDcmtkBridge::Transcode(*dicom_, syntax, NULL) && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
583 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
584 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
585 transferSyntax_ = DicomTransferSyntax_BigEndianExplicit; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
586 return true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
587 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
588 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
589 if (syntax == DicomTransferSyntax_DeflatedLittleEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
590 FromDcmtkBridge::Transcode(*dicom_, syntax, NULL) && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
591 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
592 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
593 transferSyntax_ = DicomTransferSyntax_DeflatedLittleEndianExplicit; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
594 return true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
595 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
596 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
597 #if ORTHANC_ENABLE_JPEG == 1 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
598 if (syntax == DicomTransferSyntax_JPEGProcess1 && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
599 allowNewSopInstanceUid && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
600 GetBitsStored() == 8) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
601 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
602 DJ_RPLossy rpLossy(lossyQuality_); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
603 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
604 if (FromDcmtkBridge::Transcode(*dicom_, syntax, &rpLossy) && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
605 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
606 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
607 transferSyntax_ = DicomTransferSyntax_JPEGProcess1; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
608 sopInstanceUid_ = GetStringTag(*dicom_->getDataset(), DCM_SOPInstanceUID); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
609 return true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
610 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
611 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
612 #endif |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
613 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
614 #if ORTHANC_ENABLE_JPEG == 1 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
615 if (syntax == DicomTransferSyntax_JPEGProcess2_4 && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
616 allowNewSopInstanceUid && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
617 GetBitsStored() <= 12) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
618 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
619 DJ_RPLossy rpLossy(lossyQuality_); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
620 if (FromDcmtkBridge::Transcode(*dicom_, syntax, &rpLossy) && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
621 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
622 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
623 transferSyntax_ = DicomTransferSyntax_JPEGProcess2_4; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
624 sopInstanceUid_ = GetStringTag(*dicom_->getDataset(), DCM_SOPInstanceUID); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
625 return true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
626 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
627 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
628 #endif |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
629 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
630 return false; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
631 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
632 }; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
633 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
634 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
635 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
636 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
637 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
638 #include <boost/filesystem.hpp> |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
639 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
640 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
641 static void TestFile(const std::string& path) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
642 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
643 static unsigned int count = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
644 count++; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
645 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
646 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
647 printf("** %s\n", path.c_str()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
648 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
649 std::string s; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
650 SystemToolbox::ReadFile(s, path); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
651 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
652 Orthanc::DcmtkTranscoder2 transcoder(s.c_str(), s.size()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
653 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
654 /*if (transcoder.GetBitsStored() != 8) // TODO |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
655 return; */ |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
656 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
657 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
658 char buf[1024]; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
659 sprintf(buf, "/tmp/source-%06d.dcm", count); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
660 printf(">> %s\n", buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
661 Orthanc::SystemToolbox::WriteFile(s, buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
662 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
663 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
664 printf("[%s] [%s] [%s] %d %d\n", GetTransferSyntaxUid(transcoder.GetTransferSyntax()), |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
665 transcoder.GetSopClassUid().c_str(), transcoder.GetSopInstanceUid().c_str(), |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
666 transcoder.GetFramesCount(), transcoder.GetTransferSyntax()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
667 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
668 for (size_t i = 0; i < transcoder.GetFramesCount(); i++) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
669 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
670 std::string f; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
671 transcoder.GetCompressedFrame(f, i); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
672 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
673 if (i == 0) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
674 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
675 char buf[1024]; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
676 sprintf(buf, "/tmp/frame-%06d.raw", count); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
677 printf(">> %s\n", buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
678 Orthanc::SystemToolbox::WriteFile(f, buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
679 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
680 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
681 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
682 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
683 std::string t; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
684 transcoder.WriteToMemoryBuffer(t); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
685 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
686 Orthanc::DcmtkTranscoder2 transcoder2(t.c_str(), t.size()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
687 printf(">> %d %d ; %lu bytes\n", transcoder.GetTransferSyntax(), transcoder2.GetTransferSyntax(), t.size()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
688 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
689 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
690 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
691 std::string a = transcoder.GetSopInstanceUid(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
692 DicomTransferSyntax b = transcoder.GetTransferSyntax(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
693 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
694 DicomTransferSyntax syntax = DicomTransferSyntax_JPEGProcess2_4; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
695 //DicomTransferSyntax syntax = DicomTransferSyntax_LittleEndianExplicit; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
696 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
697 std::string t; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
698 bool ok = transcoder.Transcode(t, syntax, true); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
699 printf("Transcoding: %d\n", ok); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
700 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
701 if (ok) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
702 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
703 printf("[%s] => [%s]\n", a.c_str(), transcoder.GetSopInstanceUid().c_str()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
704 printf("[%s] => [%s]\n", GetTransferSyntaxUid(b), |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
705 GetTransferSyntaxUid(transcoder.GetTransferSyntax())); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
706 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
707 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
708 char buf[1024]; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
709 sprintf(buf, "/tmp/transcoded-%06d.dcm", count); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
710 printf(">> %s\n", buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
711 Orthanc::SystemToolbox::WriteFile(t, buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
712 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
713 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
714 Orthanc::DcmtkTranscoder2 transcoder2(t.c_str(), t.size()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
715 printf(" => transcoded transfer syntax %d ; %lu bytes\n", transcoder2.GetTransferSyntax(), t.size()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
716 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
717 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
718 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
719 printf("\n"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
720 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
721 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
722 TEST(Toto, DISABLED_Transcode) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
723 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
724 //OFLog::configure(OFLogger::DEBUG_LOG_LEVEL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
725 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
726 if (1) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
727 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
728 const char* const PATH = "/home/jodogne/Subversion/orthanc-tests/Database/TransferSyntaxes"; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
729 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
730 for (boost::filesystem::directory_iterator it(PATH); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
731 it != boost::filesystem::directory_iterator(); ++it) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
732 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
733 if (boost::filesystem::is_regular_file(it->status())) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
734 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
735 TestFile(it->path().string()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
736 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
737 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
738 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
739 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
740 if (0) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
741 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
742 TestFile("/home/jodogne/Subversion/orthanc-tests/Database/Multiframe.dcm"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
743 TestFile("/home/jodogne/Subversion/orthanc-tests/Database/Issue44/Monochrome1-Jpeg.dcm"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
744 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
745 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
746 if (0) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
747 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
748 TestFile("/home/jodogne/Subversion/orthanc-tests/Database/TransferSyntaxes/1.2.840.10008.1.2.1.dcm"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
749 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
750 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
751 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
752 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
753 TEST(Toto, DISABLED_Transcode2) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
754 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
755 for (int i = 0; i <= DicomTransferSyntax_XML; i++) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
756 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
757 DicomTransferSyntax a = (DicomTransferSyntax) i; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
758 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
759 std::string path = ("/home/jodogne/Subversion/orthanc-tests/Database/TransferSyntaxes/" + |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
760 std::string(GetTransferSyntaxUid(a)) + ".dcm"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
761 if (Orthanc::SystemToolbox::IsRegularFile(path)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
762 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
763 printf("\n======= %s\n", GetTransferSyntaxUid(a)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
764 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
765 std::string source; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
766 Orthanc::SystemToolbox::ReadFile(source, path); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
767 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
768 DcmtkImageReader reader; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
769 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
770 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
771 std::unique_ptr<IParsedDicomImage> image( |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
772 reader.Read(source.c_str(), source.size())); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
773 ASSERT_TRUE(image.get() != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
774 ASSERT_EQ(a, image->GetTransferSyntax()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
775 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
776 std::string target; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
777 image->WriteToMemoryBuffer(target); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
778 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
779 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
780 for (int j = 0; j <= DicomTransferSyntax_XML; j++) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
781 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
782 DicomTransferSyntax b = (DicomTransferSyntax) j; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
783 //if (a == b) continue; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
784 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
785 std::unique_ptr<IParsedDicomImage> image( |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
786 reader.Transcode(source.c_str(), source.size(), b, true)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
787 if (image.get() != NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
788 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
789 printf("[%s] -> [%s]\n", GetTransferSyntaxUid(a), GetTransferSyntaxUid(b)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
790 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
791 std::string target; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
792 image->WriteToMemoryBuffer(target); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
793 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
794 char buf[1024]; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
795 sprintf(buf, "/tmp/%s-%s.dcm", GetTransferSyntaxUid(a), GetTransferSyntaxUid(b)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
796 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
797 SystemToolbox::WriteFile(target, buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
798 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
799 else if (a != DicomTransferSyntax_JPEG2000 && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
800 a != DicomTransferSyntax_JPEG2000LosslessOnly) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
801 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
802 ASSERT_TRUE(b != DicomTransferSyntax_LittleEndianImplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
803 b != DicomTransferSyntax_LittleEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
804 b != DicomTransferSyntax_BigEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
805 b != DicomTransferSyntax_DeflatedLittleEndianExplicit); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
806 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
807 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
808 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
809 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
810 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
811 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
812 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
813 #include "../Core/DicomNetworking/DicomAssociation.h" |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
814 #include "../Core/DicomNetworking/DicomControlUserConnection.h" |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
815 #include "../Core/DicomNetworking/DicomStoreUserConnection.h" |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
816 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
817 TEST(Toto, DISABLED_DicomAssociation) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
818 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
819 DicomAssociationParameters params; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
820 params.SetLocalApplicationEntityTitle("ORTHANC"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
821 params.SetRemoteApplicationEntityTitle("PACS"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
822 params.SetRemotePort(2001); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
823 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
824 #if 0 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
825 DicomAssociation assoc; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
826 assoc.ProposeGenericPresentationContext(UID_StorageCommitmentPushModelSOPClass); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
827 assoc.ProposeGenericPresentationContext(UID_VerificationSOPClass); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
828 assoc.ProposePresentationContext(UID_ComputedRadiographyImageStorage, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
829 DicomTransferSyntax_JPEGProcess1); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
830 assoc.ProposePresentationContext(UID_ComputedRadiographyImageStorage, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
831 DicomTransferSyntax_JPEGProcess2_4); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
832 assoc.ProposePresentationContext(UID_ComputedRadiographyImageStorage, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
833 DicomTransferSyntax_JPEG2000); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
834 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
835 assoc.Open(params); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
836 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
837 int presID = ASC_findAcceptedPresentationContextID(&assoc.GetDcmtkAssociation(), UID_ComputedRadiographyImageStorage); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
838 printf(">> %d\n", presID); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
839 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
840 std::map<DicomTransferSyntax, uint8_t> pc; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
841 printf(">> %d\n", assoc.LookupAcceptedPresentationContext(pc, UID_ComputedRadiographyImageStorage)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
842 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
843 for (std::map<DicomTransferSyntax, uint8_t>::const_iterator |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
844 it = pc.begin(); it != pc.end(); ++it) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
845 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
846 printf("[%s] => %d\n", GetTransferSyntaxUid(it->first), it->second); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
847 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
848 #else |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
849 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
850 DicomControlUserConnection assoc(params); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
851 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
852 try |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
853 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
854 printf(">> %d\n", assoc.Echo()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
855 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
856 catch (OrthancException&) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
857 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
858 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
859 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
860 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
861 params.SetRemoteApplicationEntityTitle("PACS"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
862 params.SetRemotePort(2000); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
863 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
864 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
865 DicomControlUserConnection assoc(params); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
866 printf(">> %d\n", assoc.Echo()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
867 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
868 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
869 #endif |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
870 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
871 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
872 static void TestTranscode(DicomStoreUserConnection& scu, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
873 const std::string& sopClassUid, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
874 DicomTransferSyntax transferSyntax) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
875 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
876 std::set<DicomTransferSyntax> accepted; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
877 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
878 scu.LookupTranscoding(accepted, sopClassUid, transferSyntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
879 if (accepted.empty()) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
880 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
881 throw OrthancException(ErrorCode_NetworkProtocol, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
882 "The SOP class is not supported by the remote modality"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
883 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
884 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
885 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
886 unsigned int count = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
887 for (std::set<DicomTransferSyntax>::const_iterator |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
888 it = accepted.begin(); it != accepted.end(); ++it) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
889 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
890 LOG(INFO) << "available for transcoding " << (count++) << ": " << sopClassUid |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
891 << " / " << GetTransferSyntaxUid(*it); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
892 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
893 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
894 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
895 if (accepted.find(transferSyntax) != accepted.end()) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
896 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
897 printf("**** OK, without transcoding !! [%s]\n", GetTransferSyntaxUid(transferSyntax)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
898 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
899 else |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
900 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
901 // Transcoding - only in Orthanc >= 1.7.0 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
902 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
903 const DicomTransferSyntax uncompressed[] = { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
904 DicomTransferSyntax_LittleEndianImplicit, // Default transfer syntax |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
905 DicomTransferSyntax_LittleEndianExplicit, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
906 DicomTransferSyntax_BigEndianExplicit |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
907 }; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
908 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
909 bool found = false; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
910 for (size_t i = 0; i < 3; i++) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
911 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
912 if (accepted.find(uncompressed[i]) != accepted.end()) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
913 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
914 printf("**** TRANSCODING to %s\n", GetTransferSyntaxUid(uncompressed[i])); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
915 found = true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
916 break; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
917 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
918 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
919 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
920 if (!found) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
921 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
922 printf("**** KO KO KO\n"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
923 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
924 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
925 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
926 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
927 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
928 TEST(Toto, DISABLED_Store) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
929 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
930 DicomAssociationParameters params; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
931 params.SetLocalApplicationEntityTitle("ORTHANC"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
932 params.SetRemoteApplicationEntityTitle("STORESCP"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
933 params.SetRemotePort(2000); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
934 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
935 DicomStoreUserConnection assoc(params); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
936 assoc.RegisterStorageClass(UID_MRImageStorage, DicomTransferSyntax_JPEGProcess1); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
937 assoc.RegisterStorageClass(UID_MRImageStorage, DicomTransferSyntax_JPEGProcess2_4); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
938 //assoc.RegisterStorageClass(UID_MRImageStorage, DicomTransferSyntax_LittleEndianExplicit); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
939 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
940 //assoc.SetUncompressedSyntaxesProposed(false); // Necessary for transcoding |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
941 assoc.SetCommonClassesProposed(false); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
942 assoc.SetRetiredBigEndianProposed(true); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
943 TestTranscode(assoc, UID_MRImageStorage, DicomTransferSyntax_LittleEndianExplicit); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
944 TestTranscode(assoc, UID_MRImageStorage, DicomTransferSyntax_JPEG2000); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
945 TestTranscode(assoc, UID_MRImageStorage, DicomTransferSyntax_JPEG2000); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
946 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
947 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
948 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
949 TEST(Toto, DISABLED_Store2) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
950 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
951 DicomAssociationParameters params; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
952 params.SetLocalApplicationEntityTitle("ORTHANC"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
953 params.SetRemoteApplicationEntityTitle("STORESCP"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
954 params.SetRemotePort(2000); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
955 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
956 DicomStoreUserConnection assoc(params); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
957 //assoc.SetCommonClassesProposed(false); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
958 assoc.SetRetiredBigEndianProposed(true); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
959 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
960 std::string s; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
961 Orthanc::SystemToolbox::ReadFile(s, "/tmp/i/" + std::string(GetTransferSyntaxUid(DicomTransferSyntax_BigEndianExplicit)) +".dcm"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
962 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
963 std::string c, i; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
964 assoc.Store(c, i, s.c_str(), s.size()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
965 printf("[%s] [%s]\n", c.c_str(), i.c_str()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
966 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
967 |