Mercurial > hg > orthanc-client
comparison OrthancCppClient/Instance.h @ 0:ebc1e38ef615
initial commit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 01 Jun 2015 09:47:32 +0200 |
parents | |
children | d5027f9f676a |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ebc1e38ef615 |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
22 * | |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
33 #pragma once | |
34 | |
35 #include <string> | |
36 #include <json/value.h> | |
37 | |
38 #include "OrthancClientException.h" | |
39 #include "../Core/IDynamicObject.h" | |
40 #include "../Core/ImageFormats/PngReader.h" | |
41 | |
42 namespace OrthancClient | |
43 { | |
44 class OrthancConnection; | |
45 | |
46 /** | |
47 * {summary}{Connection to an instance stored in %Orthanc.} | |
48 * {description}{This class encapsulates a connection to an image instance | |
49 * from a remote instance of %Orthanc.} | |
50 **/ | |
51 class LAAW_API Instance : public Orthanc::IDynamicObject | |
52 { | |
53 private: | |
54 const OrthancConnection& connection_; | |
55 std::string id_; | |
56 Json::Value tags_; | |
57 std::auto_ptr<Orthanc::PngReader> reader_; | |
58 Orthanc::ImageExtractionMode mode_; | |
59 std::auto_ptr<std::string> dicom_; | |
60 std::string content_; | |
61 | |
62 void DownloadImage(); | |
63 | |
64 void DownloadDicom(); | |
65 | |
66 public: | |
67 /** | |
68 * {summary}{Create a connection to some image instance.} | |
69 * {param}{connection The remote instance of %Orthanc.} | |
70 * {param}{id The %Orthanc identifier of the image instance.} | |
71 **/ | |
72 Instance(const OrthancConnection& connection, | |
73 const char* id); | |
74 | |
75 | |
76 /** | |
77 * {summary}{Get the %Orthanc identifier of this identifier.} | |
78 * {returns}{The identifier.} | |
79 **/ | |
80 const char* GetId() const | |
81 { | |
82 return id_.c_str(); | |
83 } | |
84 | |
85 | |
86 /** | |
87 * {summary}{Set the extraction mode for the 2D image corresponding to this instance.} | |
88 * {param}{mode The extraction mode.} | |
89 **/ | |
90 void SetImageExtractionMode(Orthanc::ImageExtractionMode mode); | |
91 | |
92 /** | |
93 * {summary}{Get the extraction mode for the 2D image corresponding to this instance.} | |
94 * {returns}{The extraction mode.} | |
95 **/ | |
96 Orthanc::ImageExtractionMode GetImageExtractionMode() const | |
97 { | |
98 return mode_; | |
99 } | |
100 | |
101 | |
102 /** | |
103 * {summary}{Get the string value of some DICOM tag of this instance.} | |
104 * {param}{tag The name of the tag of interest.} | |
105 * {returns}{The value of the tag.} | |
106 **/ | |
107 const char* GetTagAsString(const char* tag) const; | |
108 | |
109 /** | |
110 * {summary}{Get the floating point value that is stored in some DICOM tag of this instance.} | |
111 * {param}{tag The name of the tag of interest.} | |
112 * {returns}{The value of the tag.} | |
113 **/ | |
114 float GetTagAsFloat(const char* tag) const; | |
115 | |
116 /** | |
117 * {summary}{Get the integer value that is stored in some DICOM tag of this instance.} | |
118 * {param}{tag The name of the tag of interest.} | |
119 * {returns}{The value of the tag.} | |
120 **/ | |
121 int32_t GetTagAsInt(const char* tag) const; | |
122 | |
123 | |
124 /** | |
125 * {summary}{Get the width of the 2D image.} | |
126 * {description}{Get the width of the 2D image that is encoded by this DICOM instance.} | |
127 * {returns}{The width.} | |
128 **/ | |
129 uint32_t GetWidth(); | |
130 | |
131 /** | |
132 * {summary}{Get the height of the 2D image.} | |
133 * {description}{Get the height of the 2D image that is encoded by this DICOM instance.} | |
134 * {returns}{The height.} | |
135 **/ | |
136 uint32_t GetHeight(); | |
137 | |
138 /** | |
139 * {summary}{Get the number of bytes between two lines of the image (pitch).} | |
140 * {description}{Get the number of bytes between two lines of the image in the memory buffer returned by GetBuffer(). This value depends on the extraction mode for the image.} | |
141 * {returns}{The pitch.} | |
142 **/ | |
143 uint32_t GetPitch(); | |
144 | |
145 /** | |
146 * {summary}{Get the format of the pixels of the 2D image.} | |
147 * {description}{Return the memory layout that is used for the 2D image that is encoded by this DICOM instance. This value depends on the extraction mode for the image.} | |
148 * {returns}{The pixel format.} | |
149 **/ | |
150 Orthanc::PixelFormat GetPixelFormat(); | |
151 | |
152 /** | |
153 * {summary}{Access the memory buffer in which the raw pixels of the 2D image are stored.} | |
154 * {returns}{A pointer to the memory buffer.} | |
155 **/ | |
156 const void* GetBuffer(); | |
157 | |
158 /** | |
159 * {summary}{Access the memory buffer in which the raw pixels of some line of the 2D image are stored.} | |
160 * {param}{y The line of interest.} | |
161 * {returns}{A pointer to the memory buffer.} | |
162 **/ | |
163 const void* GetBuffer(uint32_t y); | |
164 | |
165 /** | |
166 * {summary}{Get the size of the DICOM file corresponding to this instance.} | |
167 * {returns}{The file size.} | |
168 **/ | |
169 const uint64_t GetDicomSize(); | |
170 | |
171 /** | |
172 * {summary}{Get a pointer to the content of the DICOM file corresponding to this instance.} | |
173 * {returns}{The DICOM file.} | |
174 **/ | |
175 const void* GetDicom(); | |
176 | |
177 /** | |
178 * {summary}{Discard the downloaded 2D image, so as to make room in memory.} | |
179 **/ | |
180 void DiscardImage(); | |
181 | |
182 /** | |
183 * {summary}{Discard the downloaded DICOM file, so as to make room in memory.} | |
184 **/ | |
185 void DiscardDicom(); | |
186 | |
187 LAAW_API_INTERNAL void SplitVectorOfFloats(std::vector<float>& target, | |
188 const char* tag); | |
189 | |
190 /** | |
191 * {summary}{Load a raw tag from the DICOM file.} | |
192 * {param}{path The path to the tag of interest (e.g. "0020-000d").} | |
193 **/ | |
194 void LoadTagContent(const char* path); | |
195 | |
196 /** | |
197 * {summary}{Return the value of the raw tag that was loaded by LoadContent.} | |
198 * {returns}{The tag value.} | |
199 **/ | |
200 const char* GetLoadedTagContent() const; | |
201 }; | |
202 } |