Mercurial > hg > orthanc-client
comparison CppClient/Series.h @ 5:798076adf9e9
rename
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 02 Jun 2015 10:11:34 +0200 |
parents | OrthancCppClient/Series.h@d5027f9f676a |
children | c584c25a74fd |
comparison
equal
deleted
inserted
replaced
4:2e999f3e84b4 | 5:798076adf9e9 |
---|---|
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 "Instance.h" | |
36 | |
37 #include "ArrayFilledByThreads.h" | |
38 #include "ThreadedCommandProcessor.h" | |
39 | |
40 namespace OrthancClient | |
41 { | |
42 /** | |
43 * {summary}{Connection to a series stored in %Orthanc.} | |
44 * {description}{This class encapsulates a connection to a series | |
45 * from a remote instance of %Orthanc.} | |
46 **/ | |
47 class LAAW_API Series : | |
48 public Orthanc::IDynamicObject, | |
49 private Orthanc::ArrayFilledByThreads::IFiller | |
50 { | |
51 private: | |
52 enum Status3DImage | |
53 { | |
54 Status3DImage_NotTested, | |
55 Status3DImage_True, | |
56 Status3DImage_False | |
57 }; | |
58 | |
59 const OrthancConnection& connection_; | |
60 std::string id_, url_; | |
61 Json::Value series_; | |
62 Orthanc::ArrayFilledByThreads instances_; | |
63 Status3DImage status_; | |
64 | |
65 float voxelSizeX_; | |
66 float voxelSizeY_; | |
67 float voxelSizeZ_; | |
68 float sliceThickness_; | |
69 | |
70 void Check3DImage(); | |
71 | |
72 bool Is3DImageInternal(); | |
73 | |
74 void ReadSeries(); | |
75 | |
76 virtual size_t GetFillerSize() | |
77 { | |
78 return series_["Instances"].size(); | |
79 } | |
80 | |
81 virtual Orthanc::IDynamicObject* GetFillerItem(size_t index); | |
82 | |
83 void Load3DImageInternal(void* target, | |
84 Orthanc::PixelFormat format, | |
85 size_t lineStride, | |
86 size_t stackStride, | |
87 Orthanc::ThreadedCommandProcessor::IListener* listener); | |
88 | |
89 public: | |
90 /** | |
91 * {summary}{Create a connection to some series.} | |
92 * {param}{connection The remote instance of %Orthanc.} | |
93 * {param}{id The %Orthanc identifier of the series.} | |
94 **/ | |
95 Series(const OrthancConnection& connection, | |
96 const char* id); | |
97 | |
98 /** | |
99 * {summary}{Reload the instances of this series.} | |
100 * {description}{This method will reload the list of the instances of this series. Pay attention to the fact that the instances that have been previously returned by GetInstance() will be invalidated.} | |
101 **/ | |
102 void Reload() | |
103 { | |
104 instances_.Reload(); | |
105 } | |
106 | |
107 /** | |
108 * {summary}{Return the number of instances for this series.} | |
109 * {returns}{The number of instances.} | |
110 **/ | |
111 uint32_t GetInstanceCount(); | |
112 | |
113 /** | |
114 * {summary}{Get some instance of this series.} | |
115 * {description}{This method will return an object that contains information about some instance. The instances are indexed by a number between 0 (inclusive) and the result of GetInstanceCount() (exclusive).} | |
116 * {param}{index The index of the instance of interest.} | |
117 * {returns}{The instance.} | |
118 **/ | |
119 Instance& GetInstance(uint32_t index); | |
120 | |
121 /** | |
122 * {summary}{Get the %Orthanc identifier of this series.} | |
123 * {returns}{The identifier.} | |
124 **/ | |
125 const char* GetId() const | |
126 { | |
127 return id_.c_str(); | |
128 } | |
129 | |
130 /** | |
131 * {summary}{Returns the URL to this series.} | |
132 * {returns}{The URL.} | |
133 **/ | |
134 const char* GetUrl() const | |
135 { | |
136 return url_.c_str(); | |
137 } | |
138 | |
139 | |
140 /** | |
141 * {summary}{Get the value of one of the main DICOM tags for this series.} | |
142 * {param}{tag The name of the tag of interest ("Modality", "Manufacturer", "SeriesDate", "SeriesDescription", "SeriesInstanceUID"...).} | |
143 * {param}{defaultValue The default value to be returned if this tag does not exist.} | |
144 * {returns}{The value of the tag.} | |
145 **/ | |
146 const char* GetMainDicomTag(const char* tag, | |
147 const char* defaultValue) const; | |
148 | |
149 /** | |
150 * {summary}{Test whether this series encodes a 3D image that can be downloaded from %Orthanc.} | |
151 * {returns}{"true" if and only if this is a 3D image.} | |
152 **/ | |
153 bool Is3DImage(); | |
154 | |
155 /** | |
156 * {summary}{Get the width of the 3D image.} | |
157 * {description}{Get the width of the 3D image (i.e. along the X-axis). This call is only valid if this series corresponds to a 3D image.} | |
158 * {returns}{The width.} | |
159 **/ | |
160 uint32_t GetWidth(); | |
161 | |
162 /** | |
163 * {summary}{Get the height of the 3D image.} | |
164 * {description}{Get the height of the 3D image (i.e. along the Y-axis). This call is only valid if this series corresponds to a 3D image.} | |
165 * {returns}{The height.} | |
166 **/ | |
167 uint32_t GetHeight(); | |
168 | |
169 /** | |
170 * {summary}{Get the physical size of a voxel along the X-axis.} | |
171 * {description}{Get the physical size of a voxel along the X-axis. This call is only valid if this series corresponds to a 3D image.} | |
172 * {returns}{The voxel size.} | |
173 **/ | |
174 float GetVoxelSizeX(); | |
175 | |
176 /** | |
177 * {summary}{Get the physical size of a voxel along the Y-axis.} | |
178 * {description}{Get the physical size of a voxel along the Y-axis. This call is only valid if this series corresponds to a 3D image.} | |
179 * {returns}{The voxel size.} | |
180 **/ | |
181 float GetVoxelSizeY(); | |
182 | |
183 /** | |
184 * {summary}{Get the physical size of a voxel along the Z-axis.} | |
185 * {description}{Get the physical size of a voxel along the Z-axis. This call is only valid if this series corresponds to a 3D image.} | |
186 * {returns}{The voxel size.} | |
187 **/ | |
188 float GetVoxelSizeZ(); | |
189 | |
190 /** | |
191 * {summary}{Get the slice thickness.} | |
192 * {description}{Get the slice thickness. This call is only valid if this series corresponds to a 3D image.} | |
193 * {returns}{The slice thickness.} | |
194 **/ | |
195 float GetSliceThickness(); | |
196 | |
197 LAAW_API_INTERNAL void Load3DImage(void* target, | |
198 Orthanc::PixelFormat format, | |
199 int64_t lineStride, | |
200 int64_t stackStride, | |
201 Orthanc::ThreadedCommandProcessor::IListener& listener) | |
202 { | |
203 Load3DImageInternal(target, format, static_cast<size_t>(lineStride), | |
204 static_cast<size_t>(stackStride), &listener); | |
205 } | |
206 | |
207 /** | |
208 * {summary}{Load the 3D image into a memory buffer.} | |
209 * {description}{Load the 3D image into a memory buffer. This call is only valid if this series corresponds to a 3D image. The "target" buffer must be wide enough to store all the voxels of the image.} | |
210 * {param}{target The target memory buffer.} | |
211 * {param}{format The memory layout of the voxels.} | |
212 * {param}{lineStride The number of bytes between two lines in the target memory buffer.} | |
213 * {param}{stackStride The number of bytes between two 2D slices in the target memory buffer.} | |
214 **/ | |
215 void Load3DImage(void* target, | |
216 Orthanc::PixelFormat format, | |
217 int64_t lineStride, | |
218 int64_t stackStride) | |
219 { | |
220 Load3DImageInternal(target, format, static_cast<size_t>(lineStride), | |
221 static_cast<size_t>(stackStride), NULL); | |
222 } | |
223 | |
224 /** | |
225 * {summary}{Load the 3D image into a memory buffer.} | |
226 * {description}{Load the 3D image into a memory buffer. This call is only valid if this series corresponds to a 3D image. The "target" buffer must be wide enough to store all the voxels of the image. This method will also update a progress indicator to monitor the loading of the image.} | |
227 * {param}{target The target memory buffer.} | |
228 * {param}{format The memory layout of the voxels.} | |
229 * {param}{lineStride The number of bytes between two lines in the target memory buffer.} | |
230 * {param}{stackStride The number of bytes between two 2D slices in the target memory buffer.} | |
231 * {param}{progress A pointer to a floating-point number that is continuously updated by the download threads to reflect the percentage of completion (between 0 and 1). This value can be read from a separate thread.} | |
232 **/ | |
233 void Load3DImage(void* target, | |
234 Orthanc::PixelFormat format, | |
235 int64_t lineStride, | |
236 int64_t stackStride, | |
237 float* progress); | |
238 }; | |
239 } |