annotate Resources/Graveyard/TestTranscoding.cpp @ 3884:83061cdc7703 transcoding

moving old tests to the graveyard
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 05 May 2020 14:37:29 +0200
parents
children e23026566536
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3884
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #include <dcmtk/dcmdata/dcostrmb.h>
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 #include <dcmtk/dcmdata/dcpixel.h>
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 #include <dcmtk/dcmdata/dcpxitem.h>
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 #include "../Core/DicomParsing/Internals/DicomFrameIndex.h"
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 namespace Orthanc
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 class IParsedDicomImage : public boost::noncopyable
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 public:
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 virtual ~IParsedDicomImage()
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 virtual DicomTransferSyntax GetTransferSyntax() = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 virtual std::string GetSopClassUid() = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 virtual std::string GetSopInstanceUid() = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 virtual unsigned int GetFramesCount() = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 // Can return NULL, for compressed transfer syntaxes
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 virtual ImageAccessor* GetUncompressedFrame(unsigned int frame) = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 virtual void GetCompressedFrame(std::string& target,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 unsigned int frame) = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 virtual void WriteToMemoryBuffer(std::string& target) = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 };
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 class IDicomImageReader : public boost::noncopyable
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 public:
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 virtual ~IDicomImageReader()
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 virtual IParsedDicomImage* Read(const void* data,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 size_t size) = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 virtual IParsedDicomImage* Transcode(const void* data,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 size_t size,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 DicomTransferSyntax syntax,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 bool allowNewSopInstanceUid) = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 };
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 class DcmtkImageReader : public IDicomImageReader
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 private:
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 class Image : public IParsedDicomImage
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 private:
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 std::unique_ptr<DcmFileFormat> dicom_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 std::unique_ptr<DicomFrameIndex> index_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 DicomTransferSyntax transferSyntax_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 std::string sopClassUid_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 std::string sopInstanceUid_;
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 static std::string GetStringTag(DcmDataset& dataset,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 const DcmTagKey& tag)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 const char* value = NULL;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 if (!dataset.findAndGetString(tag, value).good() ||
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 value == NULL)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 throw OrthancException(ErrorCode_BadFileFormat,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 "Missing SOP class/instance UID in DICOM instance");
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 else
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 return std::string(value);
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 public:
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 Image(DcmFileFormat* dicom,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 DicomTransferSyntax syntax) :
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 dicom_(dicom),
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 transferSyntax_(syntax)
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 if (dicom == NULL ||
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 dicom_->getDataset() == NULL)
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 throw OrthancException(ErrorCode_NullPointer);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 DcmDataset& dataset = *dicom_->getDataset();
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 index_.reset(new DicomFrameIndex(dataset));
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 sopClassUid_ = GetStringTag(dataset, DCM_SOPClassUID);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 sopInstanceUid_ = GetStringTag(dataset, DCM_SOPInstanceUID);
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 virtual DicomTransferSyntax GetTransferSyntax() ORTHANC_OVERRIDE
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 return transferSyntax_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 virtual std::string GetSopClassUid() ORTHANC_OVERRIDE
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 return sopClassUid_;
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 virtual std::string GetSopInstanceUid() ORTHANC_OVERRIDE
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 return sopInstanceUid_;
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 virtual unsigned int GetFramesCount() ORTHANC_OVERRIDE
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 return index_->GetFramesCount();
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 }
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 virtual void WriteToMemoryBuffer(std::string& target) ORTHANC_OVERRIDE
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 assert(dicom_.get() != NULL);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 if (!FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, transferSyntax_))
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 throw OrthancException(ErrorCode_InternalError,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 "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
126 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 virtual ImageAccessor* GetUncompressedFrame(unsigned int frame) ORTHANC_OVERRIDE
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 assert(dicom_.get() != 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 return DicomImageDecoder::Decode(*dicom_->getDataset(), frame);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 }
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 virtual void GetCompressedFrame(std::string& target,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 unsigned int frame) ORTHANC_OVERRIDE
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 assert(index_.get() != NULL);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 index_->GetRawFrame(target, frame);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 }
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 unsigned int lossyQuality_;
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 static DicomTransferSyntax DetectTransferSyntax(DcmFileFormat& dicom)
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 if (dicom.getDataset() == NULL)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 throw OrthancException(ErrorCode_InternalError);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 }
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 DcmDataset& dataset = *dicom.getDataset();
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 E_TransferSyntax xfer = dataset.getCurrentXfer();
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 if (xfer == EXS_Unknown)
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 dataset.updateOriginalXfer();
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 xfer = dataset.getCurrentXfer();
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 if (xfer == EXS_Unknown)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 throw OrthancException(ErrorCode_BadFileFormat,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 "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
164 }
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 DicomTransferSyntax syntax;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 if (FromDcmtkBridge::LookupOrthancTransferSyntax(syntax, xfer))
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 return syntax;
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 else
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 throw OrthancException(
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 ErrorCode_BadFileFormat,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 "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
177 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
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 static uint16_t GetBitsStored(DcmFileFormat& dicom)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 if (dicom.getDataset() == NULL)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 throw OrthancException(ErrorCode_InternalError);
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 uint16_t bitsStored;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 if (dicom.getDataset()->findAndGetUint16(DCM_BitsStored, bitsStored).good())
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 return bitsStored;
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 else
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_BadFileFormat,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 "Missing \"Bits Stored\" tag in DICOM instance");
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 }
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 public:
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 DcmtkImageReader() :
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 lossyQuality_(90)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 }
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 void SetLossyQuality(unsigned int quality)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 if (quality <= 0 ||
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 quality > 100)
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 throw OrthancException(ErrorCode_ParameterOutOfRange);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 else
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 lossyQuality_ = quality;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 }
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 unsigned int GetLossyQuality() const
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 return lossyQuality_;
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 virtual IParsedDicomImage* Read(const void* data,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 size_t size)
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 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
229 if (dicom.get() == NULL)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 throw OrthancException(ErrorCode_BadFileFormat);
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 DicomTransferSyntax transferSyntax = DetectTransferSyntax(*dicom);
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 new Image(dicom.release(), transferSyntax);
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 virtual IParsedDicomImage* Transcode(const void* data,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 size_t size,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 DicomTransferSyntax syntax,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 bool allowNewSopInstanceUid)
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 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
245 if (dicom.get() == NULL)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 throw OrthancException(ErrorCode_BadFileFormat);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 }
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 const uint16_t bitsStored = GetBitsStored(*dicom);
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 if (syntax == DetectTransferSyntax(*dicom))
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 // No transcoding is needed
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 return new Image(dicom.release(), syntax);
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 if (syntax == DicomTransferSyntax_LittleEndianImplicit &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_LittleEndianImplicit, NULL))
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 return new Image(dicom.release(), syntax);
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 if (syntax == DicomTransferSyntax_LittleEndianExplicit &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_LittleEndianExplicit, NULL))
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 new Image(dicom.release(), syntax);
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 if (syntax == DicomTransferSyntax_BigEndianExplicit &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_BigEndianExplicit, NULL))
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 return new Image(dicom.release(), syntax);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 }
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 if (syntax == DicomTransferSyntax_DeflatedLittleEndianExplicit &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_DeflatedLittleEndianExplicit, NULL))
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 return new Image(dicom.release(), syntax);
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 #if ORTHANC_ENABLE_JPEG == 1
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 if (syntax == DicomTransferSyntax_JPEGProcess1 &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 allowNewSopInstanceUid &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 bitsStored == 8)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 DJ_RPLossy rpLossy(lossyQuality_);
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 if (FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_JPEGProcess1, &rpLossy))
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 return new Image(dicom.release(), syntax);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 }
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 #endif
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 #if ORTHANC_ENABLE_JPEG == 1
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 if (syntax == DicomTransferSyntax_JPEGProcess2_4 &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 allowNewSopInstanceUid &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 bitsStored <= 12)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 DJ_RPLossy rpLossy(lossyQuality_);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 if (FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_JPEGProcess2_4, &rpLossy))
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 return new Image(dicom.release(), syntax);
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 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 #endif
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 //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
310 return 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 };
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 class IDicomTranscoder1 : public boost::noncopyable
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 public:
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 virtual ~IDicomTranscoder1()
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 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 virtual DcmFileFormat& GetDicom() = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 virtual DicomTransferSyntax GetTransferSyntax() = 0;
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 virtual std::string GetSopClassUid() = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 virtual std::string GetSopInstanceUid() = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 virtual unsigned int GetFramesCount() = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 virtual ImageAccessor* DecodeFrame(unsigned int frame) = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 virtual void GetCompressedFrame(std::string& target,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 unsigned int frame) = 0;
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 // NB: Transcoding can change the value of "GetSopInstanceUid()"
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 // and "GetTransferSyntax()" if lossy compression is applied
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 virtual bool Transcode(std::string& target,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 DicomTransferSyntax syntax,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 bool allowNewSopInstanceUid) = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 virtual void WriteToMemoryBuffer(std::string& target) = 0;
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 class DcmtkTranscoder2 : public IDicomTranscoder1
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 private:
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 std::unique_ptr<DcmFileFormat> dicom_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 std::unique_ptr<DicomFrameIndex> index_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 DicomTransferSyntax transferSyntax_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 std::string sopClassUid_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 std::string sopInstanceUid_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 uint16_t bitsStored_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 unsigned int lossyQuality_;
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 static std::string GetStringTag(DcmDataset& dataset,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 const DcmTagKey& tag)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 const char* value = NULL;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 if (!dataset.findAndGetString(tag, value).good() ||
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 value == NULL)
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 throw OrthancException(ErrorCode_BadFileFormat,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 "Missing SOP class/instance UID in DICOM instance");
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 else
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 return std::string(value);
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 }
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 void Setup(DcmFileFormat* dicom)
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 lossyQuality_ = 90;
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 dicom_.reset(dicom);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 if (dicom == NULL ||
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 dicom_->getDataset() == NULL)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 throw OrthancException(ErrorCode_NullPointer);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 DcmDataset& dataset = *dicom_->getDataset();
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 index_.reset(new DicomFrameIndex(dataset));
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 E_TransferSyntax xfer = dataset.getCurrentXfer();
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 if (xfer == EXS_Unknown)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 dataset.updateOriginalXfer();
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 xfer = dataset.getCurrentXfer();
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 if (xfer == EXS_Unknown)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 throw OrthancException(ErrorCode_BadFileFormat,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 "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
400 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(transferSyntax_, xfer))
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 throw OrthancException(
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 ErrorCode_BadFileFormat,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 "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
408 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 if (!dataset.findAndGetUint16(DCM_BitsStored, bitsStored_).good())
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 \"Bits Stored\" tag 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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 sopClassUid_ = GetStringTag(dataset, DCM_SOPClassUID);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 sopInstanceUid_ = GetStringTag(dataset, DCM_SOPInstanceUID);
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 public:
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 DcmtkTranscoder2(DcmFileFormat* dicom) // Takes ownership
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 Setup(dicom);
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 DcmtkTranscoder2(const void* dicom,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 size_t size)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 Setup(FromDcmtkBridge::LoadFromMemoryBuffer(dicom, size));
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 }
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 void SetLossyQuality(unsigned int quality)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 if (quality <= 0 ||
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 quality > 100)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 throw OrthancException(ErrorCode_ParameterOutOfRange);
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 else
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 lossyQuality_ = quality;
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 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 unsigned int GetLossyQuality() const
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 return lossyQuality_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 }
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 unsigned int GetBitsStored() const
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 return bitsStored_;
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 virtual DcmFileFormat& GetDicom()
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 assert(dicom_ != NULL);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 return *dicom_;
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 virtual DicomTransferSyntax GetTransferSyntax() ORTHANC_OVERRIDE
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 return transferSyntax_;
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 virtual std::string GetSopClassUid() ORTHANC_OVERRIDE
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 return sopClassUid_;
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 virtual std::string GetSopInstanceUid() ORTHANC_OVERRIDE
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 return sopInstanceUid_;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 }
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 virtual unsigned int GetFramesCount() ORTHANC_OVERRIDE
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 return index_->GetFramesCount();
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 virtual void WriteToMemoryBuffer(std::string& target) ORTHANC_OVERRIDE
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 if (!FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_))
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 throw OrthancException(ErrorCode_InternalError,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 "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
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 virtual ImageAccessor* DecodeFrame(unsigned int frame) ORTHANC_OVERRIDE
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 assert(dicom_->getDataset() != NULL);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 return DicomImageDecoder::Decode(*dicom_->getDataset(), frame);
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 virtual void GetCompressedFrame(std::string& target,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 unsigned int frame) ORTHANC_OVERRIDE
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 index_->GetRawFrame(target, frame);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 }
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 virtual bool Transcode(std::string& target,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 DicomTransferSyntax syntax,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 bool allowNewSopInstanceUid) ORTHANC_OVERRIDE
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 assert(dicom_ != NULL &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 dicom_->getDataset() != NULL);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 if (syntax == GetTransferSyntax())
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 printf("NO TRANSCODING\n");
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 // 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
514 WriteToMemoryBuffer(target);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 return true;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 }
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 printf(">> %d\n", bitsStored_);
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 if (syntax == DicomTransferSyntax_LittleEndianImplicit &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 FromDcmtkBridge::Transcode(*dicom_, syntax, NULL) &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax))
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 transferSyntax_ = DicomTransferSyntax_LittleEndianImplicit;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 return true;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 }
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 (syntax == DicomTransferSyntax_LittleEndianExplicit &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529 FromDcmtkBridge::Transcode(*dicom_, syntax, NULL) &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax))
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 transferSyntax_ = DicomTransferSyntax_LittleEndianExplicit;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533 return true;
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 if (syntax == DicomTransferSyntax_BigEndianExplicit &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 FromDcmtkBridge::Transcode(*dicom_, syntax, NULL) &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax))
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 transferSyntax_ = DicomTransferSyntax_BigEndianExplicit;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 return true;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 }
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 if (syntax == DicomTransferSyntax_DeflatedLittleEndianExplicit &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545 FromDcmtkBridge::Transcode(*dicom_, syntax, NULL) &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax))
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 transferSyntax_ = DicomTransferSyntax_DeflatedLittleEndianExplicit;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 return true;
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 #if ORTHANC_ENABLE_JPEG == 1
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 if (syntax == DicomTransferSyntax_JPEGProcess1 &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 allowNewSopInstanceUid &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 GetBitsStored() == 8)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 DJ_RPLossy rpLossy(lossyQuality_);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 if (FromDcmtkBridge::Transcode(*dicom_, syntax, &rpLossy) &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax))
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 transferSyntax_ = DicomTransferSyntax_JPEGProcess1;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563 sopInstanceUid_ = GetStringTag(*dicom_->getDataset(), DCM_SOPInstanceUID);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 return true;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 #endif
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 #if ORTHANC_ENABLE_JPEG == 1
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 if (syntax == DicomTransferSyntax_JPEGProcess2_4 &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571 allowNewSopInstanceUid &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572 GetBitsStored() <= 12)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 DJ_RPLossy rpLossy(lossyQuality_);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 if (FromDcmtkBridge::Transcode(*dicom_, syntax, &rpLossy) &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax))
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578 transferSyntax_ = DicomTransferSyntax_JPEGProcess2_4;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 sopInstanceUid_ = GetStringTag(*dicom_->getDataset(), DCM_SOPInstanceUID);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 return true;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 #endif
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 return false;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 }
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591
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 #include <boost/filesystem.hpp>
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594
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 static void TestFile(const std::string& path)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 static unsigned int count = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 count++;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600
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 printf("** %s\n", path.c_str());
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 std::string s;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 SystemToolbox::ReadFile(s, path);
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 Orthanc::DcmtkTranscoder2 transcoder(s.c_str(), s.size());
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 /*if (transcoder.GetBitsStored() != 8) // TODO
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610 return; */
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 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613 char buf[1024];
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614 sprintf(buf, "/tmp/source-%06d.dcm", count);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 printf(">> %s\n", buf);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 Orthanc::SystemToolbox::WriteFile(s, buf);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617 }
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 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
620 transcoder.GetSopClassUid().c_str(), transcoder.GetSopInstanceUid().c_str(),
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621 transcoder.GetFramesCount(), transcoder.GetTransferSyntax());
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 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
624 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 std::string f;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626 transcoder.GetCompressedFrame(f, i);
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 if (i == 0)
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 char buf[1024];
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
631 sprintf(buf, "/tmp/frame-%06d.raw", count);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 printf(">> %s\n", buf);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633 Orthanc::SystemToolbox::WriteFile(f, buf);
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 std::string t;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 transcoder.WriteToMemoryBuffer(t);
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 Orthanc::DcmtkTranscoder2 transcoder2(t.c_str(), t.size());
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
642 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
643 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
644
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 std::string a = transcoder.GetSopInstanceUid();
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647 DicomTransferSyntax b = transcoder.GetTransferSyntax();
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 DicomTransferSyntax syntax = DicomTransferSyntax_JPEGProcess2_4;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 //DicomTransferSyntax syntax = DicomTransferSyntax_LittleEndianExplicit;
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 std::string t;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653 bool ok = transcoder.Transcode(t, syntax, true);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654 printf("Transcoding: %d\n", ok);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
656 if (ok)
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 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
659 printf("[%s] => [%s]\n", GetTransferSyntaxUid(b),
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
660 GetTransferSyntaxUid(transcoder.GetTransferSyntax()));
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
661
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 char buf[1024];
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
664 sprintf(buf, "/tmp/transcoded-%06d.dcm", count);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665 printf(">> %s\n", buf);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
666 Orthanc::SystemToolbox::WriteFile(t, buf);
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669 Orthanc::DcmtkTranscoder2 transcoder2(t.c_str(), t.size());
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
670 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
671 }
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
674 printf("\n");
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
675 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
676
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677 TEST(Toto, DISABLED_Transcode)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
679 //OFLog::configure(OFLogger::DEBUG_LOG_LEVEL);
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 if (1)
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 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
684
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
685 for (boost::filesystem::directory_iterator it(PATH);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
686 it != boost::filesystem::directory_iterator(); ++it)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
687 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
688 if (boost::filesystem::is_regular_file(it->status()))
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 TestFile(it->path().string());
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
691 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
692 }
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695 if (0)
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 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
698 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
699 }
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 (0)
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 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
704 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
705 }
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 TEST(Toto, DISABLED_Transcode2)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
709 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710 for (int i = 0; i <= DicomTransferSyntax_XML; i++)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712 DicomTransferSyntax a = (DicomTransferSyntax) i;
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 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
715 std::string(GetTransferSyntaxUid(a)) + ".dcm");
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
716 if (Orthanc::SystemToolbox::IsRegularFile(path))
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 printf("\n======= %s\n", GetTransferSyntaxUid(a));
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
719
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 std::string source;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721 Orthanc::SystemToolbox::ReadFile(source, path);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723 DcmtkImageReader reader;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724
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 std::unique_ptr<IParsedDicomImage> image(
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
727 reader.Read(source.c_str(), source.size()));
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
728 ASSERT_TRUE(image.get() != NULL);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
729 ASSERT_EQ(a, image->GetTransferSyntax());
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
730
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731 std::string target;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732 image->WriteToMemoryBuffer(target);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
733 }
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 for (int j = 0; j <= DicomTransferSyntax_XML; j++)
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 DicomTransferSyntax b = (DicomTransferSyntax) j;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
738 //if (a == b) continue;
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 std::unique_ptr<IParsedDicomImage> image(
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
741 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
742 if (image.get() != NULL)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
744 printf("[%s] -> [%s]\n", GetTransferSyntaxUid(a), GetTransferSyntaxUid(b));
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 std::string target;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747 image->WriteToMemoryBuffer(target);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
749 char buf[1024];
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 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
751
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752 SystemToolbox::WriteFile(target, buf);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754 else if (a != DicomTransferSyntax_JPEG2000 &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755 a != DicomTransferSyntax_JPEG2000LosslessOnly)
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 ASSERT_TRUE(b != DicomTransferSyntax_LittleEndianImplicit &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758 b != DicomTransferSyntax_LittleEndianExplicit &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
759 b != DicomTransferSyntax_BigEndianExplicit &&
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
760 b != DicomTransferSyntax_DeflatedLittleEndianExplicit);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761 }
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 }
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 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
766
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 #include "../Core/DicomNetworking/DicomAssociation.h"
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
769 #include "../Core/DicomNetworking/DicomControlUserConnection.h"
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
770 #include "../Core/DicomNetworking/DicomStoreUserConnection.h"
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
771
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
772 TEST(Toto, DISABLED_DicomAssociation)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
773 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
774 DicomAssociationParameters params;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
775 params.SetLocalApplicationEntityTitle("ORTHANC");
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
776 params.SetRemoteApplicationEntityTitle("PACS");
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
777 params.SetRemotePort(2001);
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 #if 0
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
780 DicomAssociation assoc;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781 assoc.ProposeGenericPresentationContext(UID_StorageCommitmentPushModelSOPClass);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
782 assoc.ProposeGenericPresentationContext(UID_VerificationSOPClass);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
783 assoc.ProposePresentationContext(UID_ComputedRadiographyImageStorage,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
784 DicomTransferSyntax_JPEGProcess1);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
785 assoc.ProposePresentationContext(UID_ComputedRadiographyImageStorage,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
786 DicomTransferSyntax_JPEGProcess2_4);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
787 assoc.ProposePresentationContext(UID_ComputedRadiographyImageStorage,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 DicomTransferSyntax_JPEG2000);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
790 assoc.Open(params);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
792 int presID = ASC_findAcceptedPresentationContextID(&assoc.GetDcmtkAssociation(), UID_ComputedRadiographyImageStorage);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
793 printf(">> %d\n", presID);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
794
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
795 std::map<DicomTransferSyntax, uint8_t> pc;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
796 printf(">> %d\n", assoc.LookupAcceptedPresentationContext(pc, UID_ComputedRadiographyImageStorage));
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
797
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
798 for (std::map<DicomTransferSyntax, uint8_t>::const_iterator
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
799 it = pc.begin(); it != pc.end(); ++it)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
801 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
802 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
803 #else
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
804 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
805 DicomControlUserConnection assoc(params);
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 try
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 printf(">> %d\n", assoc.Echo());
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 catch (OrthancException&)
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 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
816 params.SetRemoteApplicationEntityTitle("PACS");
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
817 params.SetRemotePort(2000);
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 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820 DicomControlUserConnection assoc(params);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
821 printf(">> %d\n", assoc.Echo());
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
822 }
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 #endif
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
825 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
826
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
827 static void TestTranscode(DicomStoreUserConnection& scu,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
828 const std::string& sopClassUid,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
829 DicomTransferSyntax transferSyntax)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
830 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
831 std::set<DicomTransferSyntax> accepted;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
832
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833 scu.LookupTranscoding(accepted, sopClassUid, transferSyntax);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834 if (accepted.empty())
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
835 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
836 throw OrthancException(ErrorCode_NetworkProtocol,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
837 "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
838 }
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 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
841 unsigned int count = 0;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
842 for (std::set<DicomTransferSyntax>::const_iterator
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
843 it = accepted.begin(); it != accepted.end(); ++it)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
844 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 LOG(INFO) << "available for transcoding " << (count++) << ": " << sopClassUid
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
846 << " / " << GetTransferSyntaxUid(*it);
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 }
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 if (accepted.find(transferSyntax) != accepted.end())
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 printf("**** OK, without transcoding !! [%s]\n", GetTransferSyntaxUid(transferSyntax));
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 else
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 // Transcoding - only in Orthanc >= 1.7.0
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 const DicomTransferSyntax uncompressed[] = {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
859 DicomTransferSyntax_LittleEndianImplicit, // Default transfer syntax
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
860 DicomTransferSyntax_LittleEndianExplicit,
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
861 DicomTransferSyntax_BigEndianExplicit
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
862 };
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 bool found = false;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
865 for (size_t i = 0; i < 3; i++)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
866 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
867 if (accepted.find(uncompressed[i]) != accepted.end())
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 printf("**** TRANSCODING to %s\n", GetTransferSyntaxUid(uncompressed[i]));
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
870 found = true;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
871 break;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
872 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
873 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
874
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
875 if (!found)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
876 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
877 printf("**** KO KO KO\n");
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
878 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
879 }
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
882
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
883 TEST(Toto, DISABLED_Store)
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 DicomAssociationParameters params;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
886 params.SetLocalApplicationEntityTitle("ORTHANC");
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
887 params.SetRemoteApplicationEntityTitle("STORESCP");
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
888 params.SetRemotePort(2000);
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 DicomStoreUserConnection assoc(params);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
891 assoc.RegisterStorageClass(UID_MRImageStorage, DicomTransferSyntax_JPEGProcess1);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
892 assoc.RegisterStorageClass(UID_MRImageStorage, DicomTransferSyntax_JPEGProcess2_4);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
893 //assoc.RegisterStorageClass(UID_MRImageStorage, DicomTransferSyntax_LittleEndianExplicit);
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 //assoc.SetUncompressedSyntaxesProposed(false); // Necessary for transcoding
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896 assoc.SetCommonClassesProposed(false);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
897 assoc.SetRetiredBigEndianProposed(true);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898 TestTranscode(assoc, UID_MRImageStorage, DicomTransferSyntax_LittleEndianExplicit);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
899 TestTranscode(assoc, UID_MRImageStorage, DicomTransferSyntax_JPEG2000);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
900 TestTranscode(assoc, UID_MRImageStorage, DicomTransferSyntax_JPEG2000);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
901 }
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
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
904 TEST(Toto, DISABLED_Store2)
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
905 {
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
906 DicomAssociationParameters params;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
907 params.SetLocalApplicationEntityTitle("ORTHANC");
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
908 params.SetRemoteApplicationEntityTitle("STORESCP");
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
909 params.SetRemotePort(2000);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
910
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
911 DicomStoreUserConnection assoc(params);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
912 //assoc.SetCommonClassesProposed(false);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
913 assoc.SetRetiredBigEndianProposed(true);
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
914
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
915 std::string s;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
916 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
917
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
918 std::string c, i;
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
919 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
920 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
921 }
83061cdc7703 moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
922