Mercurial > hg > orthanc
annotate OrthancCppClient/Instance.cpp @ 522:81cb140941a5 laaw
compiling the dll
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 19 Jul 2013 16:41:48 +0200 |
parents | 50d9660f960c |
children | eaca3d38b2aa |
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 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 #include <boost/lexical_cast.hpp> |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 namespace OrthancClient |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 void Instance::DownloadImage() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 if (reader_.get() == NULL) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 const char* suffix; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 switch (mode_) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 case Orthanc::ImageExtractionMode_Preview: |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 suffix = "preview"; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 break; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 case Orthanc::ImageExtractionMode_UInt8: |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 suffix = "image-uint8"; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 break; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 case Orthanc::ImageExtractionMode_UInt16: |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 suffix = "image-uint16"; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 break; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 case Orthanc::ImageExtractionMode_Int16: |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 suffix = "image-int16"; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 break; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 default: |
504 | 65 throw OrthancClientException(Orthanc::ErrorCode_NotImplemented); |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 } |
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 Orthanc::HttpClient client(connection_.GetHttpClient()); |
496
7f7a2d174acb
preparing Laaw packaging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
479
diff
changeset
|
69 client.SetUrl(std::string(connection_.GetOrthancUrl()) + "/instances/" + id_ + "/" + suffix); |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 std::string png; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 if (!client.Apply(png)) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 { |
504 | 74 throw OrthancClientException(Orthanc::ErrorCode_NotImplemented); |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 } |
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 reader_.reset(new Orthanc::PngReader); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 reader_->ReadFromMemory(png); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 } |
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 Instance::Instance(const OrthancConnection& connection, |
496
7f7a2d174acb
preparing Laaw packaging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
479
diff
changeset
|
83 const char* id) : |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 connection_(connection), |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 id_(id), |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 mode_(Orthanc::ImageExtractionMode_Int16) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 Orthanc::HttpClient client(connection_.GetHttpClient()); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
496
7f7a2d174acb
preparing Laaw packaging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
479
diff
changeset
|
90 client.SetUrl(std::string(connection_.GetOrthancUrl()) + "/instances/" + id_ + "/simplified-tags"); |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 Json::Value v; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 if (!client.Apply(tags_)) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 { |
504 | 94 throw OrthancClientException(Orthanc::ErrorCode_NetworkProtocol); |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 } |
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 |
500 | 98 const char* Instance::GetTagAsString(const char* tag) const |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 if (tags_.isMember(tag)) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 { |
500 | 102 return tags_[tag].asCString(); |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 else |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 { |
504 | 106 throw OrthancClientException(Orthanc::ErrorCode_InexistentItem); |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 } |
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 |
500 | 110 float Instance::GetTagAsFloat(const char* tag) const |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 std::string value = GetTagAsString(tag); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 try |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 return boost::lexical_cast<float>(value); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 catch (boost::bad_lexical_cast) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 { |
504 | 120 throw OrthancClientException(Orthanc::ErrorCode_BadFileFormat); |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 } |
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 |
500 | 124 int Instance::GetTagAsInt(const char* tag) const |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 std::string value = GetTagAsString(tag); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 try |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 return boost::lexical_cast<int>(value); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 catch (boost::bad_lexical_cast) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 { |
504 | 134 throw OrthancClientException(Orthanc::ErrorCode_BadFileFormat); |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 } |
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 unsigned int Instance::GetWidth() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 DownloadImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 return reader_->GetWidth(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 } |
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 unsigned int Instance::GetHeight() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 DownloadImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 return reader_->GetHeight(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 } |
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 unsigned int Instance::GetPitch() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 DownloadImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 return reader_->GetPitch(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 } |
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 Orthanc::PixelFormat Instance::GetPixelFormat() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 DownloadImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 return reader_->GetFormat(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 } |
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 const void* Instance::GetBuffer() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 DownloadImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 return reader_->GetBuffer(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 } |
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 const void* Instance::GetBuffer(unsigned int y) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 DownloadImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 return reader_->GetBuffer(y); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 } |
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 void Instance::DiscardImage() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 reader_.reset(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 } |
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 void Instance::SetImageExtractionMode(Orthanc::ImageExtractionMode mode) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 if (mode_ == mode) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 return; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 } |
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 DiscardImage(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 mode_ = mode; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 } |
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 void Instance::SplitVectorOfFloats(std::vector<float>& target, |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 const char* tag) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 const std::string value = GetTagAsString(tag); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 target.clear(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 try |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 std::string tmp; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 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
|
203 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 if (value[i] == '\\') |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 target.push_back(boost::lexical_cast<float>(tmp)); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 tmp.clear(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 else |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 tmp.push_back(value[i]); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 } |
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 target.push_back(boost::lexical_cast<float>(tmp)); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 catch (boost::bad_lexical_cast) |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 // Unable to parse the Image Orientation Patient. |
504 | 220 throw OrthancClientException(Orthanc::ErrorCode_BadFileFormat); |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 } |
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 } |