Mercurial > hg > orthanc
annotate OrthancFramework/Resources/Graveyard/TestTranscoding.cpp @ 5159:f5907aecbaed
conditional usage of malloc_trim
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 02 Feb 2023 11:28:35 +0100 |
parents | 43e613a7756b |
children | 0ea402b4d901 |
rev | line source |
---|---|
4120
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
1 /** |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
4120
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
7 * |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
11 * the License, or (at your option) any later version. |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
12 * |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
16 * Lesser General Public License for more details. |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
17 * |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * License along with this program. If not, see |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
21 **/ |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
22 |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
23 |
3885
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
24 bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer, |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
25 DcmFileFormat& dicom, |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
26 DicomTransferSyntax syntax) |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
27 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
28 E_TransferSyntax xfer; |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
29 if (!LookupDcmtkTransferSyntax(xfer, syntax)) |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
30 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
31 return false; |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
32 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
33 else if (!dicom.validateMetaInfo(xfer).good()) |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
34 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
35 throw OrthancException(ErrorCode_InternalError, |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
36 "Cannot setup the transfer syntax to write a DICOM instance"); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
37 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
38 else |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
39 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
40 return SaveToMemoryBufferInternal(buffer, dicom, xfer); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
41 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
42 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
43 |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
44 |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
45 bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer, |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
46 DcmFileFormat& dicom) |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
47 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
48 E_TransferSyntax xfer = dicom.getDataset()->getCurrentXfer(); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
49 if (xfer == EXS_Unknown) |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
50 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
51 throw OrthancException(ErrorCode_InternalError, |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
52 "Cannot write a DICOM instance with unknown transfer syntax"); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
53 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
54 else if (!dicom.validateMetaInfo(xfer).good()) |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
55 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
56 throw OrthancException(ErrorCode_InternalError, |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
57 "Cannot setup the transfer syntax to write a DICOM instance"); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
58 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
59 else |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
60 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
61 return SaveToMemoryBufferInternal(buffer, dicom, xfer); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
62 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
63 } |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
64 |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
65 |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
66 |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
67 |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
68 |
3884
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 #include <dcmtk/dcmdata/dcostrmb.h> |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 #include <dcmtk/dcmdata/dcpixel.h> |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 #include <dcmtk/dcmdata/dcpxitem.h> |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 #include "../Core/DicomParsing/Internals/DicomFrameIndex.h" |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 namespace Orthanc |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 class IParsedDicomImage : public boost::noncopyable |
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 public: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 virtual ~IParsedDicomImage() |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 virtual DicomTransferSyntax GetTransferSyntax() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 virtual std::string GetSopClassUid() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 virtual std::string GetSopInstanceUid() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 virtual unsigned int GetFramesCount() = 0; |
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 // Can return NULL, for compressed transfer syntaxes |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 virtual ImageAccessor* GetUncompressedFrame(unsigned int frame) = 0; |
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 virtual void GetCompressedFrame(std::string& target, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 unsigned int frame) = 0; |
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 virtual void WriteToMemoryBuffer(std::string& target) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 }; |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 class IDicomImageReader : public boost::noncopyable |
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 public: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 virtual ~IDicomImageReader() |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 { |
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 IParsedDicomImage* Read(const void* data, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 size_t size) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 virtual IParsedDicomImage* Transcode(const void* data, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 size_t size, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 DicomTransferSyntax syntax, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 bool allowNewSopInstanceUid) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 }; |
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 class DcmtkImageReader : public IDicomImageReader |
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 private: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 class Image : public IParsedDicomImage |
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 private: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 std::unique_ptr<DcmFileFormat> dicom_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 std::unique_ptr<DicomFrameIndex> index_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 DicomTransferSyntax transferSyntax_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 std::string sopClassUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 std::string sopInstanceUid_; |
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 static std::string GetStringTag(DcmDataset& dataset, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 const DcmTagKey& tag) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 const char* value = NULL; |
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 if (!dataset.findAndGetString(tag, value).good() || |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 value == NULL) |
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 throw OrthancException(ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 "Missing SOP class/instance UID in DICOM instance"); |
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 else |
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 return std::string(value); |
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 } |
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 public: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 Image(DcmFileFormat* dicom, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 DicomTransferSyntax syntax) : |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 dicom_(dicom), |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 transferSyntax_(syntax) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 if (dicom == NULL || |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 dicom_->getDataset() == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 throw OrthancException(ErrorCode_NullPointer); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 DcmDataset& dataset = *dicom_->getDataset(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 index_.reset(new DicomFrameIndex(dataset)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 sopClassUid_ = GetStringTag(dataset, DCM_SOPClassUID); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 sopInstanceUid_ = GetStringTag(dataset, DCM_SOPInstanceUID); |
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 virtual DicomTransferSyntax GetTransferSyntax() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 return transferSyntax_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 } |
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 virtual std::string GetSopClassUid() ORTHANC_OVERRIDE |
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 return sopClassUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 virtual std::string GetSopInstanceUid() ORTHANC_OVERRIDE |
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 return sopInstanceUid_; |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 virtual unsigned int GetFramesCount() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 return index_->GetFramesCount(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 } |
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 virtual void WriteToMemoryBuffer(std::string& target) ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 assert(dicom_.get() != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 if (!FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, transferSyntax_)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 throw OrthancException(ErrorCode_InternalError, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 "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
|
194 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 virtual ImageAccessor* GetUncompressedFrame(unsigned int frame) ORTHANC_OVERRIDE |
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 assert(dicom_.get() != NULL && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 dicom_->getDataset() != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 return DicomImageDecoder::Decode(*dicom_->getDataset(), frame); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 virtual void GetCompressedFrame(std::string& target, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 unsigned int frame) ORTHANC_OVERRIDE |
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 assert(index_.get() != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 index_->GetRawFrame(target, frame); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 }; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 unsigned int lossyQuality_; |
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 static DicomTransferSyntax DetectTransferSyntax(DcmFileFormat& dicom) |
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 if (dicom.getDataset() == NULL) |
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 throw OrthancException(ErrorCode_InternalError); |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 DcmDataset& dataset = *dicom.getDataset(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 E_TransferSyntax xfer = dataset.getCurrentXfer(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 if (xfer == EXS_Unknown) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 dataset.updateOriginalXfer(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 xfer = dataset.getCurrentXfer(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 if (xfer == EXS_Unknown) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 throw OrthancException(ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 "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
|
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 DicomTransferSyntax syntax; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 if (FromDcmtkBridge::LookupOrthancTransferSyntax(syntax, xfer)) |
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 return syntax; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 else |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 throw OrthancException( |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 "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
|
245 } |
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 |
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 static uint16_t GetBitsStored(DcmFileFormat& dicom) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 if (dicom.getDataset() == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 throw OrthancException(ErrorCode_InternalError); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 uint16_t bitsStored; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 if (dicom.getDataset()->findAndGetUint16(DCM_BitsStored, bitsStored).good()) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 return bitsStored; |
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 else |
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 throw OrthancException(ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 "Missing \"Bits Stored\" tag in DICOM instance"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 } |
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 |
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 public: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 DcmtkImageReader() : |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 lossyQuality_(90) |
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 } |
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 void SetLossyQuality(unsigned int quality) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 if (quality <= 0 || |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 quality > 100) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 throw OrthancException(ErrorCode_ParameterOutOfRange); |
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 else |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
283 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 lossyQuality_ = quality; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 } |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 unsigned int GetLossyQuality() const |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
289 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
290 return lossyQuality_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 virtual IParsedDicomImage* Read(const void* data, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 size_t size) |
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 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
|
297 if (dicom.get() == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 throw OrthancException(ErrorCode_BadFileFormat); |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 DicomTransferSyntax transferSyntax = DetectTransferSyntax(*dicom); |
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(), transferSyntax); |
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 virtual IParsedDicomImage* Transcode(const void* data, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 size_t size, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 DicomTransferSyntax syntax, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 bool allowNewSopInstanceUid) |
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 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
|
313 if (dicom.get() == NULL) |
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 throw OrthancException(ErrorCode_BadFileFormat); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 } |
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 const uint16_t bitsStored = GetBitsStored(*dicom); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 if (syntax == DetectTransferSyntax(*dicom)) |
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 // No transcoding is needed |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 return new Image(dicom.release(), syntax); |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 if (syntax == DicomTransferSyntax_LittleEndianImplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_LittleEndianImplicit, NULL)) |
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 return new Image(dicom.release(), syntax); |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 if (syntax == DicomTransferSyntax_LittleEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_LittleEndianExplicit, NULL)) |
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 return new Image(dicom.release(), syntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 } |
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 if (syntax == DicomTransferSyntax_BigEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_BigEndianExplicit, NULL)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 return new Image(dicom.release(), syntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 } |
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 if (syntax == DicomTransferSyntax_DeflatedLittleEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_DeflatedLittleEndianExplicit, NULL)) |
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 return new Image(dicom.release(), syntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
348 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
349 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 #if ORTHANC_ENABLE_JPEG == 1 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 if (syntax == DicomTransferSyntax_JPEGProcess1 && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 allowNewSopInstanceUid && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
353 bitsStored == 8) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
354 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
355 DJ_RPLossy rpLossy(lossyQuality_); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
356 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
357 if (FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_JPEGProcess1, &rpLossy)) |
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 return new Image(dicom.release(), syntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
361 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 #endif |
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 ORTHANC_ENABLE_JPEG == 1 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 if (syntax == DicomTransferSyntax_JPEGProcess2_4 && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 allowNewSopInstanceUid && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 bitsStored <= 12) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
369 DJ_RPLossy rpLossy(lossyQuality_); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 if (FromDcmtkBridge::Transcode(*dicom, DicomTransferSyntax_JPEGProcess2_4, &rpLossy)) |
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 new Image(dicom.release(), syntax); |
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 #endif |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 //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
|
378 return NULL; |
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 }; |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 class IDicomTranscoder1 : public boost::noncopyable |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 public: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 virtual ~IDicomTranscoder1() |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
388 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
389 } |
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 virtual DcmFileFormat& GetDicom() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
392 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 virtual DicomTransferSyntax GetTransferSyntax() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 virtual std::string GetSopClassUid() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 virtual std::string GetSopInstanceUid() = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
398 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 virtual unsigned int GetFramesCount() = 0; |
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 virtual ImageAccessor* DecodeFrame(unsigned int frame) = 0; |
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 virtual void GetCompressedFrame(std::string& target, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 unsigned int frame) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 // NB: Transcoding can change the value of "GetSopInstanceUid()" |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 // and "GetTransferSyntax()" if lossy compression is applied |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 virtual bool Transcode(std::string& target, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 DicomTransferSyntax syntax, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
410 bool allowNewSopInstanceUid) = 0; |
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 virtual void WriteToMemoryBuffer(std::string& target) = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
413 }; |
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 class DcmtkTranscoder2 : public IDicomTranscoder1 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 private: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
419 std::unique_ptr<DcmFileFormat> dicom_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
420 std::unique_ptr<DicomFrameIndex> index_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 DicomTransferSyntax transferSyntax_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
422 std::string sopClassUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 std::string sopInstanceUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 uint16_t bitsStored_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 unsigned int lossyQuality_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
427 static std::string GetStringTag(DcmDataset& dataset, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
428 const DcmTagKey& tag) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
429 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
430 const char* value = NULL; |
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 if (!dataset.findAndGetString(tag, value).good() || |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
433 value == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
434 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 throw OrthancException(ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
436 "Missing SOP class/instance UID in DICOM instance"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
437 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
438 else |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
439 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 return std::string(value); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
441 } |
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 void Setup(DcmFileFormat* dicom) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
445 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
446 lossyQuality_ = 90; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
447 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
448 dicom_.reset(dicom); |
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 if (dicom == NULL || |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
451 dicom_->getDataset() == NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
452 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
453 throw OrthancException(ErrorCode_NullPointer); |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 DcmDataset& dataset = *dicom_->getDataset(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 index_.reset(new DicomFrameIndex(dataset)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
459 E_TransferSyntax xfer = dataset.getCurrentXfer(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
460 if (xfer == EXS_Unknown) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
462 dataset.updateOriginalXfer(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
463 xfer = dataset.getCurrentXfer(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
464 if (xfer == EXS_Unknown) |
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 throw OrthancException(ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
467 "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
|
468 } |
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 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(transferSyntax_, xfer)) |
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 throw OrthancException( |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
474 ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
475 "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
|
476 } |
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 if (!dataset.findAndGetUint16(DCM_BitsStored, bitsStored_).good()) |
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 throw OrthancException(ErrorCode_BadFileFormat, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 "Missing \"Bits Stored\" tag in DICOM instance"); |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 sopClassUid_ = GetStringTag(dataset, DCM_SOPClassUID); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 sopInstanceUid_ = GetStringTag(dataset, DCM_SOPInstanceUID); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
486 } |
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 public: |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
489 DcmtkTranscoder2(DcmFileFormat* dicom) // Takes ownership |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
490 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
491 Setup(dicom); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
492 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
493 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
494 DcmtkTranscoder2(const void* dicom, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
495 size_t size) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
496 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
497 Setup(FromDcmtkBridge::LoadFromMemoryBuffer(dicom, size)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
498 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
499 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
500 void SetLossyQuality(unsigned int quality) |
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 if (quality <= 0 || |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
503 quality > 100) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 throw OrthancException(ErrorCode_ParameterOutOfRange); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 else |
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 lossyQuality_ = quality; |
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 } |
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 unsigned int GetLossyQuality() const |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
514 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
515 return lossyQuality_; |
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 unsigned int GetBitsStored() const |
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 return bitsStored_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
521 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
523 virtual DcmFileFormat& GetDicom() |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
524 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
525 assert(dicom_ != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 return *dicom_; |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
529 virtual DicomTransferSyntax GetTransferSyntax() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
530 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
531 return transferSyntax_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 virtual std::string GetSopClassUid() ORTHANC_OVERRIDE |
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 return sopClassUid_; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 virtual std::string GetSopInstanceUid() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 return sopInstanceUid_; |
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 virtual unsigned int GetFramesCount() ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
546 return index_->GetFramesCount(); |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 virtual void WriteToMemoryBuffer(std::string& target) ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
551 if (!FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
552 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
553 throw OrthancException(ErrorCode_InternalError, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
554 "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
|
555 } |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
558 virtual ImageAccessor* DecodeFrame(unsigned int frame) ORTHANC_OVERRIDE |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
559 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
560 assert(dicom_->getDataset() != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
561 return DicomImageDecoder::Decode(*dicom_->getDataset(), frame); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
562 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
563 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
564 virtual void GetCompressedFrame(std::string& target, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
565 unsigned int frame) ORTHANC_OVERRIDE |
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 index_->GetRawFrame(target, frame); |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
570 virtual bool Transcode(std::string& target, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
571 DicomTransferSyntax syntax, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
572 bool allowNewSopInstanceUid) ORTHANC_OVERRIDE |
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 assert(dicom_ != NULL && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
575 dicom_->getDataset() != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
576 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
577 if (syntax == GetTransferSyntax()) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
578 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
579 printf("NO TRANSCODING\n"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
580 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
581 // 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
|
582 WriteToMemoryBuffer(target); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
583 return true; |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
586 printf(">> %d\n", bitsStored_); |
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 if (syntax == DicomTransferSyntax_LittleEndianImplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
589 FromDcmtkBridge::Transcode(*dicom_, syntax, NULL) && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
590 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax)) |
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 transferSyntax_ = DicomTransferSyntax_LittleEndianImplicit; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
593 return true; |
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 if (syntax == DicomTransferSyntax_LittleEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
597 FromDcmtkBridge::Transcode(*dicom_, syntax, NULL) && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
598 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
599 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
600 transferSyntax_ = DicomTransferSyntax_LittleEndianExplicit; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
601 return true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
602 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
603 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
604 if (syntax == DicomTransferSyntax_BigEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
605 FromDcmtkBridge::Transcode(*dicom_, syntax, NULL) && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
606 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
607 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
608 transferSyntax_ = DicomTransferSyntax_BigEndianExplicit; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
609 return true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
610 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
611 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
612 if (syntax == DicomTransferSyntax_DeflatedLittleEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
613 FromDcmtkBridge::Transcode(*dicom_, syntax, NULL) && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
614 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
615 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
616 transferSyntax_ = DicomTransferSyntax_DeflatedLittleEndianExplicit; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
617 return true; |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
620 #if ORTHANC_ENABLE_JPEG == 1 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
621 if (syntax == DicomTransferSyntax_JPEGProcess1 && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
622 allowNewSopInstanceUid && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
623 GetBitsStored() == 8) |
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 DJ_RPLossy rpLossy(lossyQuality_); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
626 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
627 if (FromDcmtkBridge::Transcode(*dicom_, syntax, &rpLossy) && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
628 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax)) |
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 transferSyntax_ = DicomTransferSyntax_JPEGProcess1; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
631 sopInstanceUid_ = GetStringTag(*dicom_->getDataset(), DCM_SOPInstanceUID); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
632 return true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
633 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
634 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
635 #endif |
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 #if ORTHANC_ENABLE_JPEG == 1 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
638 if (syntax == DicomTransferSyntax_JPEGProcess2_4 && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
639 allowNewSopInstanceUid && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
640 GetBitsStored() <= 12) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
641 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
642 DJ_RPLossy rpLossy(lossyQuality_); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
643 if (FromDcmtkBridge::Transcode(*dicom_, syntax, &rpLossy) && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
644 FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_, syntax)) |
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 transferSyntax_ = DicomTransferSyntax_JPEGProcess2_4; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
647 sopInstanceUid_ = GetStringTag(*dicom_->getDataset(), DCM_SOPInstanceUID); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
648 return true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
649 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
650 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
651 #endif |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
652 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
653 return false; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
654 } |
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 } |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
659 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
660 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
661 #include <boost/filesystem.hpp> |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
662 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
663 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
664 static void TestFile(const std::string& path) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
665 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
666 static unsigned int count = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
667 count++; |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
670 printf("** %s\n", path.c_str()); |
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 std::string s; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
673 SystemToolbox::ReadFile(s, path); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
674 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
675 Orthanc::DcmtkTranscoder2 transcoder(s.c_str(), s.size()); |
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 /*if (transcoder.GetBitsStored() != 8) // TODO |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
678 return; */ |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
679 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
680 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
681 char buf[1024]; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
682 sprintf(buf, "/tmp/source-%06d.dcm", count); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
683 printf(">> %s\n", buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
684 Orthanc::SystemToolbox::WriteFile(s, buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
685 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
686 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
687 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
|
688 transcoder.GetSopClassUid().c_str(), transcoder.GetSopInstanceUid().c_str(), |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
689 transcoder.GetFramesCount(), transcoder.GetTransferSyntax()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
690 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
691 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
|
692 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
693 std::string f; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
694 transcoder.GetCompressedFrame(f, i); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
695 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
696 if (i == 0) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
697 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
698 char buf[1024]; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
699 sprintf(buf, "/tmp/frame-%06d.raw", count); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
700 printf(">> %s\n", buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
701 Orthanc::SystemToolbox::WriteFile(f, buf); |
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 } |
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 std::string t; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
707 transcoder.WriteToMemoryBuffer(t); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
708 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
709 Orthanc::DcmtkTranscoder2 transcoder2(t.c_str(), t.size()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
710 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
|
711 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
712 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
713 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
714 std::string a = transcoder.GetSopInstanceUid(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
715 DicomTransferSyntax b = transcoder.GetTransferSyntax(); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
716 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
717 DicomTransferSyntax syntax = DicomTransferSyntax_JPEGProcess2_4; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
718 //DicomTransferSyntax syntax = DicomTransferSyntax_LittleEndianExplicit; |
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 t; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
721 bool ok = transcoder.Transcode(t, syntax, true); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
722 printf("Transcoding: %d\n", ok); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
723 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
724 if (ok) |
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 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
|
727 printf("[%s] => [%s]\n", GetTransferSyntaxUid(b), |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
728 GetTransferSyntaxUid(transcoder.GetTransferSyntax())); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
729 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
730 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
731 char buf[1024]; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
732 sprintf(buf, "/tmp/transcoded-%06d.dcm", count); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
733 printf(">> %s\n", buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
734 Orthanc::SystemToolbox::WriteFile(t, buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
735 } |
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 Orthanc::DcmtkTranscoder2 transcoder2(t.c_str(), t.size()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
738 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
|
739 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
740 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
741 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
742 printf("\n"); |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
745 TEST(Toto, DISABLED_Transcode) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
746 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
747 //OFLog::configure(OFLogger::DEBUG_LOG_LEVEL); |
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 if (1) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
750 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
751 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
|
752 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
753 for (boost::filesystem::directory_iterator it(PATH); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
754 it != boost::filesystem::directory_iterator(); ++it) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
755 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
756 if (boost::filesystem::is_regular_file(it->status())) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
757 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
758 TestFile(it->path().string()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
759 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
760 } |
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 if (0) |
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 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
|
766 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
|
767 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
768 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
769 if (0) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
770 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
771 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
|
772 } |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
775 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
776 TEST(Toto, DISABLED_Transcode2) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
777 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
778 for (int i = 0; i <= DicomTransferSyntax_XML; i++) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
779 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
780 DicomTransferSyntax a = (DicomTransferSyntax) i; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
781 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
782 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
|
783 std::string(GetTransferSyntaxUid(a)) + ".dcm"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
784 if (Orthanc::SystemToolbox::IsRegularFile(path)) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
785 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
786 printf("\n======= %s\n", GetTransferSyntaxUid(a)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
787 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
788 std::string source; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
789 Orthanc::SystemToolbox::ReadFile(source, path); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
790 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
791 DcmtkImageReader reader; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
792 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
793 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
794 std::unique_ptr<IParsedDicomImage> image( |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
795 reader.Read(source.c_str(), source.size())); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
796 ASSERT_TRUE(image.get() != NULL); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
797 ASSERT_EQ(a, image->GetTransferSyntax()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
798 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
799 std::string target; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
800 image->WriteToMemoryBuffer(target); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
801 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
802 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
803 for (int j = 0; j <= DicomTransferSyntax_XML; j++) |
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 DicomTransferSyntax b = (DicomTransferSyntax) j; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
806 //if (a == b) continue; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
807 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
808 std::unique_ptr<IParsedDicomImage> image( |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
809 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
|
810 if (image.get() != NULL) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
811 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
812 printf("[%s] -> [%s]\n", GetTransferSyntaxUid(a), GetTransferSyntaxUid(b)); |
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 std::string target; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
815 image->WriteToMemoryBuffer(target); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
816 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
817 char buf[1024]; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
818 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
|
819 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
820 SystemToolbox::WriteFile(target, buf); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
821 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
822 else if (a != DicomTransferSyntax_JPEG2000 && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
823 a != DicomTransferSyntax_JPEG2000LosslessOnly) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
824 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
825 ASSERT_TRUE(b != DicomTransferSyntax_LittleEndianImplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
826 b != DicomTransferSyntax_LittleEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
827 b != DicomTransferSyntax_BigEndianExplicit && |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
828 b != DicomTransferSyntax_DeflatedLittleEndianExplicit); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
829 } |
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 } |
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 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
834 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
835 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
836 #include "../Core/DicomNetworking/DicomAssociation.h" |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
837 #include "../Core/DicomNetworking/DicomControlUserConnection.h" |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
838 #include "../Core/DicomNetworking/DicomStoreUserConnection.h" |
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 TEST(Toto, DISABLED_DicomAssociation) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
841 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
842 DicomAssociationParameters params; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
843 params.SetLocalApplicationEntityTitle("ORTHANC"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
844 params.SetRemoteApplicationEntityTitle("PACS"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
845 params.SetRemotePort(2001); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
846 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
847 #if 0 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
848 DicomAssociation assoc; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
849 assoc.ProposeGenericPresentationContext(UID_StorageCommitmentPushModelSOPClass); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
850 assoc.ProposeGenericPresentationContext(UID_VerificationSOPClass); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
851 assoc.ProposePresentationContext(UID_ComputedRadiographyImageStorage, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
852 DicomTransferSyntax_JPEGProcess1); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
853 assoc.ProposePresentationContext(UID_ComputedRadiographyImageStorage, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
854 DicomTransferSyntax_JPEGProcess2_4); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
855 assoc.ProposePresentationContext(UID_ComputedRadiographyImageStorage, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
856 DicomTransferSyntax_JPEG2000); |
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 assoc.Open(params); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
859 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
860 int presID = ASC_findAcceptedPresentationContextID(&assoc.GetDcmtkAssociation(), UID_ComputedRadiographyImageStorage); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
861 printf(">> %d\n", presID); |
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 std::map<DicomTransferSyntax, uint8_t> pc; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
864 printf(">> %d\n", assoc.LookupAcceptedPresentationContext(pc, UID_ComputedRadiographyImageStorage)); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
865 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
866 for (std::map<DicomTransferSyntax, uint8_t>::const_iterator |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
867 it = pc.begin(); it != pc.end(); ++it) |
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("[%s] => %d\n", GetTransferSyntaxUid(it->first), it->second); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
870 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
871 #else |
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 DicomControlUserConnection assoc(params); |
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 try |
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(">> %d\n", assoc.Echo()); |
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 catch (OrthancException&) |
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 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
884 params.SetRemoteApplicationEntityTitle("PACS"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
885 params.SetRemotePort(2000); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
886 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
887 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
888 DicomControlUserConnection assoc(params); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
889 printf(">> %d\n", assoc.Echo()); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
890 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
891 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
892 #endif |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
893 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
894 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
895 static void TestTranscode(DicomStoreUserConnection& scu, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
896 const std::string& sopClassUid, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
897 DicomTransferSyntax transferSyntax) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
898 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
899 std::set<DicomTransferSyntax> accepted; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
900 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
901 scu.LookupTranscoding(accepted, sopClassUid, transferSyntax); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
902 if (accepted.empty()) |
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 throw OrthancException(ErrorCode_NetworkProtocol, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
905 "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
|
906 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
907 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
908 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
909 unsigned int count = 0; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
910 for (std::set<DicomTransferSyntax>::const_iterator |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
911 it = accepted.begin(); it != accepted.end(); ++it) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
912 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
913 LOG(INFO) << "available for transcoding " << (count++) << ": " << sopClassUid |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
914 << " / " << GetTransferSyntaxUid(*it); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
915 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
916 } |
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 if (accepted.find(transferSyntax) != accepted.end()) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
919 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
920 printf("**** OK, without transcoding !! [%s]\n", GetTransferSyntaxUid(transferSyntax)); |
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 else |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
923 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
924 // Transcoding - only in Orthanc >= 1.7.0 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
925 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
926 const DicomTransferSyntax uncompressed[] = { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
927 DicomTransferSyntax_LittleEndianImplicit, // Default transfer syntax |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
928 DicomTransferSyntax_LittleEndianExplicit, |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
929 DicomTransferSyntax_BigEndianExplicit |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
930 }; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
931 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
932 bool found = false; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
933 for (size_t i = 0; i < 3; i++) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
934 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
935 if (accepted.find(uncompressed[i]) != accepted.end()) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
936 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
937 printf("**** TRANSCODING to %s\n", GetTransferSyntaxUid(uncompressed[i])); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
938 found = true; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
939 break; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
940 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
941 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
942 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
943 if (!found) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
944 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
945 printf("**** KO KO KO\n"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
946 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
947 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
948 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
949 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
950 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
951 TEST(Toto, DISABLED_Store) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
952 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
953 DicomAssociationParameters params; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
954 params.SetLocalApplicationEntityTitle("ORTHANC"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
955 params.SetRemoteApplicationEntityTitle("STORESCP"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
956 params.SetRemotePort(2000); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
957 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
958 DicomStoreUserConnection assoc(params); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
959 assoc.RegisterStorageClass(UID_MRImageStorage, DicomTransferSyntax_JPEGProcess1); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
960 assoc.RegisterStorageClass(UID_MRImageStorage, DicomTransferSyntax_JPEGProcess2_4); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
961 //assoc.RegisterStorageClass(UID_MRImageStorage, DicomTransferSyntax_LittleEndianExplicit); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
962 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
963 //assoc.SetUncompressedSyntaxesProposed(false); // Necessary for transcoding |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
964 assoc.SetCommonClassesProposed(false); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
965 assoc.SetRetiredBigEndianProposed(true); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
966 TestTranscode(assoc, UID_MRImageStorage, DicomTransferSyntax_LittleEndianExplicit); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
967 TestTranscode(assoc, UID_MRImageStorage, DicomTransferSyntax_JPEG2000); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
968 TestTranscode(assoc, UID_MRImageStorage, DicomTransferSyntax_JPEG2000); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
969 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
970 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
971 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
972 TEST(Toto, DISABLED_Store2) |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
973 { |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
974 DicomAssociationParameters params; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
975 params.SetLocalApplicationEntityTitle("ORTHANC"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
976 params.SetRemoteApplicationEntityTitle("STORESCP"); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
977 params.SetRemotePort(2000); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
978 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
979 DicomStoreUserConnection assoc(params); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
980 //assoc.SetCommonClassesProposed(false); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
981 assoc.SetRetiredBigEndianProposed(true); |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
982 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
983 std::string s; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
984 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
|
985 |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
986 std::string c, i; |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
987 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
|
988 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
|
989 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
990 |