Mercurial > hg > orthanc
annotate OrthancCppClient/Instance.cpp @ 509:e7841864c97c
StableResourcesMonitor
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 16 Aug 2013 14:23:54 +0200 |
parents | 0cd977e94479 |
children | 7f7a2d174acb |
rev | line source |
---|---|
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Belgium |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * License, or (at your option) any later version. |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * In addition, as a special exception, the copyright holders of this |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * program give permission to link the code of its release with the |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * that use the same license as the "OpenSSL" library), and distribute |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * the linked executables. You must obey the GNU General Public License |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * in all respects for all of the code used other than "OpenSSL". If you |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * modify file(s) with this exception, you may extend this exception to |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * your version of the file(s), but you are not obligated to do so. If |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * you do not wish to do so, delete this exception statement from your |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * version. If you delete this exception statement from all source files |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * in the program, then also delete it here. |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * This program is distributed in the hope that it will be useful, but |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * WITHOUT ANY WARRANTY; without even the implied warranty of |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * General Public License for more details. |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * You should have received a copy of the GNU General Public License |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 **/ |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 #include "Instance.h" |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #include "OrthancConnection.h" |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 #include "../Core/OrthancException.h" |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 #include <boost/lexical_cast.hpp> |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 namespace OrthancClient |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 void Instance::DownloadImage() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 if (reader_.get() == NULL) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 const char* suffix; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 switch (mode_) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 case Orthanc::ImageExtractionMode_Preview: |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 suffix = "preview"; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 break; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 case Orthanc::ImageExtractionMode_UInt8: |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 suffix = "image-uint8"; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 break; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 case Orthanc::ImageExtractionMode_UInt16: |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 suffix = "image-uint16"; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 break; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 case Orthanc::ImageExtractionMode_Int16: |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 suffix = "image-int16"; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 break; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 default: |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 Orthanc::HttpClient client(connection_.GetHttpClient()); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 client.SetUrl(connection_.GetOrthancUrl() + "/instances/" + id_ + "/" + suffix); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 std::string png; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 if (!client.Apply(png)) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 reader_.reset(new Orthanc::PngReader); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 reader_->ReadFromMemory(png); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 Instance::Instance(const OrthancConnection& connection, |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 const std::string& id) : |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 connection_(connection), |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 id_(id), |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 mode_(Orthanc::ImageExtractionMode_Int16) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 Orthanc::HttpClient client(connection_.GetHttpClient()); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 client.SetUrl(connection_.GetOrthancUrl() + "/instances/" + id_ + "/simplified-tags"); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 Json::Value v; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 if (!client.Apply(tags_)) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 std::string Instance::GetTagAsString(const char* tag) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 if (tags_.isMember(tag)) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 return tags_[tag].asString(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 else |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 float Instance::GetTagAsFloat(const char* tag) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 std::string value = GetTagAsString(tag); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 try |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 return boost::lexical_cast<float>(value); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 catch (boost::bad_lexical_cast) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 int Instance::GetTagAsInt(const char* tag) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 std::string value = GetTagAsString(tag); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 try |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 return boost::lexical_cast<int>(value); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 catch (boost::bad_lexical_cast) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 unsigned int Instance::GetWidth() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 DownloadImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 return reader_->GetWidth(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 unsigned int Instance::GetHeight() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 DownloadImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 return reader_->GetHeight(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 unsigned int Instance::GetPitch() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 DownloadImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 return reader_->GetPitch(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 Orthanc::PixelFormat Instance::GetPixelFormat() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 DownloadImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 return reader_->GetFormat(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 const void* Instance::GetBuffer() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 DownloadImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 return reader_->GetBuffer(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 const void* Instance::GetBuffer(unsigned int y) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 DownloadImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 return reader_->GetBuffer(y); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 void Instance::DiscardImage() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 reader_.reset(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 void Instance::SetImageExtractionMode(Orthanc::ImageExtractionMode mode) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 if (mode_ == mode) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 return; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 DiscardImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 mode_ = mode; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 void Instance::SplitVectorOfFloats(std::vector<float>& target, |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 const char* tag) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 const std::string value = GetTagAsString(tag); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 target.clear(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 try |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 std::string tmp; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 for (size_t i = 0; i < value.size(); i++) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 if (value[i] == '\\') |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 target.push_back(boost::lexical_cast<float>(tmp)); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 tmp.clear(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 else |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 tmp.push_back(value[i]); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 target.push_back(boost::lexical_cast<float>(tmp)); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 catch (boost::bad_lexical_cast) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 // Unable to parse the Image Orientation Patient. |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 } |