Mercurial > hg > orthanc-stone
annotate Samples/Sdl/Loader.cpp @ 731:ac4fe43551a1
merge am-dev -> default
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Tue, 21 May 2019 13:53:57 +0200 |
parents | e63c8b9b7b02 |
children | c3bbb130abc4 |
rev | line source |
---|---|
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 // From Stone |
712 | 22 #include "../../Framework/Loaders/BasicFetchingItemsSorter.h" |
23 #include "../../Framework/Loaders/BasicFetchingStrategy.h" | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
24 #include "../../Framework/Messages/ICallable.h" |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "../../Framework/Messages/IMessage.h" |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
26 #include "../../Framework/Messages/IObservable.h" |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #include "../../Framework/Messages/MessageBroker.h" |
712 | 28 #include "../../Framework/Scene2D/ColorTextureSceneLayer.h" |
29 #include "../../Framework/Scene2D/FloatTextureSceneLayer.h" | |
30 #include "../../Framework/Scene2D/Scene2D.h" | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
31 #include "../../Framework/StoneInitialization.h" |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
32 #include "../../Framework/Toolbox/GeometryToolbox.h" |
683
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
33 #include "../../Framework/Toolbox/SlicesSorter.h" |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
34 #include "../../Framework/Volumes/ImageBuffer3D.h" |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 // From Orthanc framework |
637
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
37 #include <Core/Compression/GzipCompressor.h> |
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
38 #include <Core/Compression/ZlibCompressor.h> |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
39 #include <Core/DicomFormat/DicomArray.h> |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
40 #include <Core/DicomFormat/DicomImageInformation.h> |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
41 #include <Core/HttpClient.h> |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 #include <Core/IDynamicObject.h> |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 #include <Core/Images/Image.h> |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 #include <Core/Images/ImageProcessing.h> |
637
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
45 #include <Core/Images/JpegReader.h> |
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
46 #include <Core/Images/PamReader.h> |
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
47 #include <Core/Images/PngReader.h> |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 #include <Core/Images/PngWriter.h> |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 #include <Core/Logging.h> |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 #include <Core/MultiThreading/SharedMessageQueue.h> |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 #include <Core/OrthancException.h> |
683
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
52 #include <Core/SystemToolbox.h> |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
53 #include <Core/Toolbox.h> |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 #include <json/reader.h> |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 #include <json/value.h> |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 #include <json/writer.h> |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 #include <list> |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 #include <stdio.h> |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 namespace Refactoring |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 class IOracleCommand : public boost::noncopyable |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 public: |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 enum Type |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 { |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
71 Type_OrthancRestApi, |
641 | 72 Type_GetOrthancImage, |
73 Type_GetOrthancWebViewerJpeg | |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 }; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 virtual ~IOracleCommand() |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 virtual Type GetType() const = 0; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 }; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
622
8a3a25f2d42c
uncoupling oracle from context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
619
diff
changeset
|
84 class IMessageEmitter : public boost::noncopyable |
8a3a25f2d42c
uncoupling oracle from context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
619
diff
changeset
|
85 { |
8a3a25f2d42c
uncoupling oracle from context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
619
diff
changeset
|
86 public: |
8a3a25f2d42c
uncoupling oracle from context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
619
diff
changeset
|
87 virtual ~IMessageEmitter() |
8a3a25f2d42c
uncoupling oracle from context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
619
diff
changeset
|
88 { |
8a3a25f2d42c
uncoupling oracle from context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
619
diff
changeset
|
89 } |
8a3a25f2d42c
uncoupling oracle from context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
619
diff
changeset
|
90 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
91 virtual void EmitMessage(const OrthancStone::IObserver& observer, |
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
92 const OrthancStone::IMessage& message) = 0; |
622
8a3a25f2d42c
uncoupling oracle from context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
619
diff
changeset
|
93 }; |
8a3a25f2d42c
uncoupling oracle from context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
619
diff
changeset
|
94 |
8a3a25f2d42c
uncoupling oracle from context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
619
diff
changeset
|
95 |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 class IOracle : public boost::noncopyable |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 public: |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 virtual ~IOracle() |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
103 virtual void Schedule(const OrthancStone::IObserver& receiver, |
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
104 IOracleCommand* command) = 0; // Takes ownership |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 }; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 |
683
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
109 class IVolumeSlicer : public boost::noncopyable |
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
110 { |
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
111 public: |
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
112 virtual ~IVolumeSlicer() |
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
113 { |
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
114 } |
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
115 |
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
116 virtual void SetViewportPlane(const OrthancStone::CoordinateSystem3D& plane) = 0; |
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
117 }; |
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
118 |
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
119 |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 class OracleCommandWithPayload : public IOracleCommand |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 private: |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 std::auto_ptr<Orthanc::IDynamicObject> payload_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 public: |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 void SetPayload(Orthanc::IDynamicObject* payload) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 if (payload == NULL) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 else |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 payload_.reset(payload); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 bool HasPayload() const |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 return (payload_.get() != NULL); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 const Orthanc::IDynamicObject& GetPayload() const |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 if (HasPayload()) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 return *payload_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 else |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 }; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
642
diff
changeset
|
159 class OracleCommandExceptionMessage : public OrthancStone::IMessage |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
160 { |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
642
diff
changeset
|
161 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); |
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
642
diff
changeset
|
162 |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
163 private: |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
164 const IOracleCommand& command_; |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
165 Orthanc::OrthancException exception_; |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
166 |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
167 public: |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
168 OracleCommandExceptionMessage(const IOracleCommand& command, |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
169 const Orthanc::OrthancException& exception) : |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
170 command_(command), |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
171 exception_(exception) |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
172 { |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
173 } |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
174 |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
175 OracleCommandExceptionMessage(const IOracleCommand& command, |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
176 const Orthanc::ErrorCode& error) : |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
177 command_(command), |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
178 exception_(error) |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
179 { |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
180 } |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
181 |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
182 const IOracleCommand& GetCommand() const |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
183 { |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
184 return command_; |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
185 } |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
186 |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
187 const Orthanc::OrthancException& GetException() const |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
188 { |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
189 return exception_; |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
190 } |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
191 }; |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
192 |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
193 |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 typedef std::map<std::string, std::string> HttpHeaders; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
196 class OrthancRestApiCommand : public OracleCommandWithPayload |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 public: |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
642
diff
changeset
|
199 class SuccessMessage : public OrthancStone::OriginMessage<OrthancRestApiCommand> |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 { |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
642
diff
changeset
|
201 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); |
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
642
diff
changeset
|
202 |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 private: |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 HttpHeaders headers_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 std::string answer_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 public: |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
208 SuccessMessage(const OrthancRestApiCommand& command, |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 const HttpHeaders& answerHeaders, |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 std::string& answer /* will be swapped to avoid a memcpy() */) : |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 OriginMessage(command), |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 headers_(answerHeaders), |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 answer_(answer) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 const std::string& GetAnswer() const |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 return answer_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
222 void ParseJsonBody(Json::Value& target) const |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 Json::Reader reader; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 if (!reader.parse(answer_, target)) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 const HttpHeaders& GetAnswerHeaders() const |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 return headers_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 }; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 private: |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 Orthanc::HttpMethod method_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 std::string uri_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 std::string body_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 HttpHeaders headers_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 unsigned int timeout_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 std::auto_ptr< OrthancStone::MessageHandler<SuccessMessage> > successCallback_; |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
246 std::auto_ptr< OrthancStone::MessageHandler<OracleCommandExceptionMessage> > failureCallback_; |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 public: |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
249 OrthancRestApiCommand() : |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 method_(Orthanc::HttpMethod_Get), |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 uri_("/"), |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 timeout_(10) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 virtual Type GetType() const |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 { |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
258 return Type_OrthancRestApi; |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 void SetMethod(Orthanc::HttpMethod method) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 method_ = method; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 void SetUri(const std::string& uri) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 uri_ = uri; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 void SetBody(const std::string& body) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 body_ = body; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 void SetBody(const Json::Value& json) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 Json::FastWriter writer; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 body_ = writer.write(json); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
282 void SetHttpHeaders(const HttpHeaders& headers) |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
283 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
284 headers_ = headers; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
285 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
286 |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
287 void SetHttpHeader(const std::string& key, |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 const std::string& value) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
289 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
290 headers_[key] = value; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 Orthanc::HttpMethod GetMethod() const |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 return method_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
296 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
297 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 const std::string& GetUri() const |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 return uri_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 const std::string& GetBody() const |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 if (method_ == Orthanc::HttpMethod_Post || |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 method_ == Orthanc::HttpMethod_Put) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 return body_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 else |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
313 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
314 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
315 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 const HttpHeaders& GetHttpHeaders() const |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
317 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 return headers_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
321 void SetTimeout(unsigned int seconds) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 timeout_ = seconds; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 unsigned int GetTimeout() const |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 return timeout_; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
329 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 }; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
334 |
641 | 335 class GetOrthancImageCommand : public OracleCommandWithPayload |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
336 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
337 public: |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
642
diff
changeset
|
338 class SuccessMessage : public OrthancStone::OriginMessage<GetOrthancImageCommand> |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
339 { |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
642
diff
changeset
|
340 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); |
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
642
diff
changeset
|
341 |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
342 private: |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
343 std::auto_ptr<Orthanc::ImageAccessor> image_; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
344 Orthanc::MimeType mime_; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
345 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
346 public: |
641 | 347 SuccessMessage(const GetOrthancImageCommand& command, |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
348 Orthanc::ImageAccessor* image, // Takes ownership |
637
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
349 Orthanc::MimeType mime) : |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
350 OriginMessage(command), |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
351 image_(image), |
637
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
352 mime_(mime) |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
353 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
354 if (image == NULL) |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
355 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
356 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
357 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
358 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
359 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
360 const Orthanc::ImageAccessor& GetImage() const |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
361 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
362 return *image_; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
363 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
364 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
365 Orthanc::MimeType GetMimeType() const |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
366 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
367 return mime_; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
368 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
369 }; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
370 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
371 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
372 private: |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
373 std::string uri_; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
374 HttpHeaders headers_; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
375 unsigned int timeout_; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
376 bool hasExpectedFormat_; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
377 Orthanc::PixelFormat expectedFormat_; |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
378 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
379 std::auto_ptr< OrthancStone::MessageHandler<SuccessMessage> > successCallback_; |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
380 std::auto_ptr< OrthancStone::MessageHandler<OracleCommandExceptionMessage> > failureCallback_; |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
381 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
382 public: |
641 | 383 GetOrthancImageCommand() : |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
384 uri_("/"), |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
385 timeout_(10), |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
386 hasExpectedFormat_(false) |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
387 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
388 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
389 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
390 virtual Type GetType() const |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
391 { |
641 | 392 return Type_GetOrthancImage; |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
393 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
394 |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
395 void SetExpectedPixelFormat(Orthanc::PixelFormat format) |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
396 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
397 hasExpectedFormat_ = true; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
398 expectedFormat_ = format; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
399 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
400 |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
401 void SetUri(const std::string& uri) |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
402 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
403 uri_ = uri; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
404 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
405 |
709
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
406 void SetInstanceUri(const std::string& instance, |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
407 Orthanc::PixelFormat pixelFormat) |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
408 { |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
409 uri_ = "/instances/" + instance; |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
410 |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
411 switch (pixelFormat) |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
412 { |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
413 case Orthanc::PixelFormat_RGB24: |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
414 uri_ += "/preview"; |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
415 break; |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
416 |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
417 case Orthanc::PixelFormat_Grayscale16: |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
418 uri_ += "/image-uint16"; |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
419 break; |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
420 |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
421 case Orthanc::PixelFormat_SignedGrayscale16: |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
422 uri_ += "/image-int16"; |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
423 break; |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
424 |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
425 default: |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
426 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
427 } |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
428 } |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
429 |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
430 void SetHttpHeader(const std::string& key, |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
431 const std::string& value) |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
432 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
433 headers_[key] = value; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
434 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
435 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
436 const std::string& GetUri() const |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
437 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
438 return uri_; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
439 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
440 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
441 const HttpHeaders& GetHttpHeaders() const |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
442 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
443 return headers_; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
444 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
445 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
446 void SetTimeout(unsigned int seconds) |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
447 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
448 timeout_ = seconds; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
449 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
450 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
451 unsigned int GetTimeout() const |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
452 { |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
453 return timeout_; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
454 } |
640 | 455 |
456 void ProcessHttpAnswer(IMessageEmitter& emitter, | |
457 const OrthancStone::IObserver& receiver, | |
458 const std::string& answer, | |
459 const HttpHeaders& answerHeaders) const | |
460 { | |
461 Orthanc::MimeType contentType = Orthanc::MimeType_Binary; | |
462 | |
463 for (HttpHeaders::const_iterator it = answerHeaders.begin(); | |
464 it != answerHeaders.end(); ++it) | |
465 { | |
466 std::string s; | |
467 Orthanc::Toolbox::ToLowerCase(s, it->first); | |
468 | |
469 if (s == "content-type") | |
470 { | |
471 contentType = Orthanc::StringToMimeType(it->second); | |
472 break; | |
473 } | |
474 } | |
475 | |
476 std::auto_ptr<Orthanc::ImageAccessor> image; | |
477 | |
478 switch (contentType) | |
479 { | |
480 case Orthanc::MimeType_Png: | |
481 { | |
482 image.reset(new Orthanc::PngReader); | |
483 dynamic_cast<Orthanc::PngReader&>(*image).ReadFromMemory(answer); | |
484 break; | |
485 } | |
486 | |
487 case Orthanc::MimeType_Pam: | |
488 { | |
489 image.reset(new Orthanc::PamReader); | |
490 dynamic_cast<Orthanc::PamReader&>(*image).ReadFromMemory(answer); | |
491 break; | |
492 } | |
493 | |
494 case Orthanc::MimeType_Jpeg: | |
495 { | |
496 image.reset(new Orthanc::JpegReader); | |
497 dynamic_cast<Orthanc::JpegReader&>(*image).ReadFromMemory(answer); | |
498 break; | |
499 } | |
500 | |
501 default: | |
502 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol, | |
503 "Unsupported HTTP Content-Type for an image: " + | |
504 std::string(Orthanc::EnumerationToString(contentType))); | |
505 } | |
506 | |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
507 if (hasExpectedFormat_) |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
508 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
509 if (expectedFormat_ == Orthanc::PixelFormat_SignedGrayscale16 && |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
510 image->GetFormat() == Orthanc::PixelFormat_Grayscale16) |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
511 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
512 image->SetFormat(Orthanc::PixelFormat_SignedGrayscale16); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
513 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
514 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
515 if (expectedFormat_ != image->GetFormat()) |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
516 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
517 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
518 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
519 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
520 |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
521 SuccessMessage message(*this, image.release(), contentType); |
640 | 522 emitter.EmitMessage(receiver, message); |
523 } | |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
524 }; |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
525 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
526 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
527 |
641 | 528 class GetOrthancWebViewerJpegCommand : public OracleCommandWithPayload |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
529 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
530 public: |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
642
diff
changeset
|
531 class SuccessMessage : public OrthancStone::OriginMessage<GetOrthancWebViewerJpegCommand> |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
532 { |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
642
diff
changeset
|
533 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); |
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
642
diff
changeset
|
534 |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
535 private: |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
536 std::auto_ptr<Orthanc::ImageAccessor> image_; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
537 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
538 public: |
641 | 539 SuccessMessage(const GetOrthancWebViewerJpegCommand& command, |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
540 Orthanc::ImageAccessor* image) : // Takes ownership |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
541 OriginMessage(command), |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
542 image_(image) |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
543 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
544 if (image == NULL) |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
545 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
546 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
547 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
548 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
549 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
550 const Orthanc::ImageAccessor& GetImage() const |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
551 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
552 return *image_; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
553 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
554 }; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
555 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
556 private: |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
557 std::string instanceId_; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
558 unsigned int frame_; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
559 unsigned int quality_; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
560 HttpHeaders headers_; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
561 unsigned int timeout_; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
562 Orthanc::PixelFormat expectedFormat_; |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
563 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
564 std::auto_ptr< OrthancStone::MessageHandler<SuccessMessage> > successCallback_; |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
565 std::auto_ptr< OrthancStone::MessageHandler<OracleCommandExceptionMessage> > failureCallback_; |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
566 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
567 public: |
641 | 568 GetOrthancWebViewerJpegCommand() : |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
569 frame_(0), |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
570 quality_(95), |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
571 timeout_(10), |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
572 expectedFormat_(Orthanc::PixelFormat_Grayscale8) |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
573 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
574 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
575 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
576 virtual Type GetType() const |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
577 { |
641 | 578 return Type_GetOrthancWebViewerJpeg; |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
579 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
580 |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
581 void SetExpectedPixelFormat(Orthanc::PixelFormat format) |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
582 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
583 expectedFormat_ = format; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
584 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
585 |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
586 void SetInstance(const std::string& instanceId) |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
587 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
588 instanceId_ = instanceId; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
589 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
590 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
591 void SetFrame(unsigned int frame) |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
592 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
593 frame_ = frame; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
594 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
595 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
596 void SetQuality(unsigned int quality) |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
597 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
598 if (quality <= 0 || |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
599 quality > 100) |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
600 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
601 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
602 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
603 else |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
604 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
605 quality_ = quality; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
606 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
607 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
608 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
609 void SetHttpHeader(const std::string& key, |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
610 const std::string& value) |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
611 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
612 headers_[key] = value; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
613 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
614 |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
615 Orthanc::PixelFormat GetExpectedPixelFormat() const |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
616 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
617 return expectedFormat_; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
618 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
619 |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
620 const std::string& GetInstanceId() const |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
621 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
622 return instanceId_; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
623 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
624 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
625 unsigned int GetFrame() const |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
626 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
627 return frame_; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
628 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
629 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
630 unsigned int GetQuality() const |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
631 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
632 return quality_; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
633 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
634 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
635 const HttpHeaders& GetHttpHeaders() const |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
636 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
637 return headers_; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
638 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
639 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
640 void SetTimeout(unsigned int seconds) |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
641 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
642 timeout_ = seconds; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
643 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
644 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
645 unsigned int GetTimeout() const |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
646 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
647 return timeout_; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
648 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
649 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
650 std::string GetUri() const |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
651 { |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
652 return ("/web-viewer/instances/jpeg" + boost::lexical_cast<std::string>(quality_) + |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
653 "-" + instanceId_ + "_" + boost::lexical_cast<std::string>(frame_)); |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
654 } |
640 | 655 |
656 void ProcessHttpAnswer(IMessageEmitter& emitter, | |
657 const OrthancStone::IObserver& receiver, | |
658 const std::string& answer) const | |
659 { | |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
660 // This code comes from older "OrthancSlicesLoader::ParseSliceImageJpeg()" |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
661 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
662 Json::Value encoded; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
663 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
664 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
665 Json::Reader reader; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
666 if (!reader.parse(answer, encoded)) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
667 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
668 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
669 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
670 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
671 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
672 if (encoded.type() != Json::objectValue || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
673 !encoded.isMember("Orthanc") || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
674 encoded["Orthanc"].type() != Json::objectValue) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
675 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
676 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
677 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
678 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
679 const Json::Value& info = encoded["Orthanc"]; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
680 if (!info.isMember("PixelData") || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
681 !info.isMember("Stretched") || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
682 !info.isMember("Compression") || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
683 info["Compression"].type() != Json::stringValue || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
684 info["PixelData"].type() != Json::stringValue || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
685 info["Stretched"].type() != Json::booleanValue || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
686 info["Compression"].asString() != "Jpeg") |
640 | 687 { |
688 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
689 } | |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
690 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
691 bool isSigned = false; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
692 bool isStretched = info["Stretched"].asBool(); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
693 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
694 if (info.isMember("IsSigned")) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
695 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
696 if (info["IsSigned"].type() != Json::booleanValue) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
697 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
698 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
699 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
700 else |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
701 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
702 isSigned = info["IsSigned"].asBool(); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
703 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
704 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
705 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
706 std::auto_ptr<Orthanc::ImageAccessor> reader; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
707 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
708 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
709 std::string jpeg; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
710 Orthanc::Toolbox::DecodeBase64(jpeg, info["PixelData"].asString()); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
711 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
712 reader.reset(new Orthanc::JpegReader); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
713 dynamic_cast<Orthanc::JpegReader&>(*reader).ReadFromMemory(jpeg); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
714 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
715 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
716 if (reader->GetFormat() == Orthanc::PixelFormat_RGB24) // This is a color image |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
717 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
718 if (expectedFormat_ != Orthanc::PixelFormat_RGB24) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
719 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
720 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
721 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
722 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
723 if (isSigned || isStretched) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
724 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
725 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
726 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
727 else |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
728 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
729 SuccessMessage message(*this, reader.release()); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
730 emitter.EmitMessage(receiver, message); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
731 return; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
732 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
733 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
734 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
735 if (reader->GetFormat() != Orthanc::PixelFormat_Grayscale8) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
736 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
737 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
738 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
739 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
740 if (!isStretched) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
741 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
742 if (expectedFormat_ != reader->GetFormat()) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
743 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
744 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
745 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
746 else |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
747 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
748 SuccessMessage message(*this, reader.release()); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
749 emitter.EmitMessage(receiver, message); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
750 return; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
751 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
752 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
753 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
754 int32_t stretchLow = 0; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
755 int32_t stretchHigh = 0; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
756 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
757 if (!info.isMember("StretchLow") || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
758 !info.isMember("StretchHigh") || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
759 info["StretchLow"].type() != Json::intValue || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
760 info["StretchHigh"].type() != Json::intValue) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
761 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
762 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
763 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
764 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
765 stretchLow = info["StretchLow"].asInt(); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
766 stretchHigh = info["StretchHigh"].asInt(); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
767 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
768 if (stretchLow < -32768 || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
769 stretchHigh > 65535 || |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
770 (stretchLow < 0 && stretchHigh > 32767)) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
771 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
772 // This range cannot be represented with a uint16_t or an int16_t |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
773 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
774 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
775 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
776 // Decode a grayscale JPEG 8bpp image coming from the Web viewer |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
777 std::auto_ptr<Orthanc::ImageAccessor> image |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
778 (new Orthanc::Image(expectedFormat_, reader->GetWidth(), reader->GetHeight(), false)); |
640 | 779 |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
780 Orthanc::ImageProcessing::Convert(*image, *reader); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
781 reader.reset(); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
782 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
783 float scaling = static_cast<float>(stretchHigh - stretchLow) / 255.0f; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
784 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
785 if (!OrthancStone::LinearAlgebra::IsCloseToZero(scaling)) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
786 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
787 float offset = static_cast<float>(stretchLow) / scaling; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
788 Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling, true); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
789 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
790 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
791 SuccessMessage message(*this, image.release()); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
792 emitter.EmitMessage(receiver, message); |
640 | 793 } |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
794 }; |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
795 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
796 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
797 |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
798 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
799 |
648 | 800 class DicomInstanceParameters : |
801 public Orthanc::IDynamicObject /* to be used as a payload of SlicesSorter */ | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
802 { |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
803 private: |
669 | 804 struct Data // Struct to ease the copy constructor |
805 { | |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
806 std::string orthancInstanceId_; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
807 std::string studyInstanceUid_; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
808 std::string seriesInstanceUid_; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
809 std::string sopInstanceUid_; |
669 | 810 Orthanc::DicomImageInformation imageInformation_; |
811 OrthancStone::SopClassUid sopClassUid_; | |
812 double thickness_; | |
813 double pixelSpacingX_; | |
814 double pixelSpacingY_; | |
815 OrthancStone::CoordinateSystem3D geometry_; | |
816 OrthancStone::Vector frameOffsets_; | |
817 bool isColor_; | |
818 bool hasRescale_; | |
712 | 819 double rescaleIntercept_; |
669 | 820 double rescaleSlope_; |
821 bool hasDefaultWindowing_; | |
822 float defaultWindowingCenter_; | |
823 float defaultWindowingWidth_; | |
824 Orthanc::PixelFormat expectedPixelFormat_; | |
825 | |
826 void ComputeDoseOffsets(const Orthanc::DicomMap& dicom) | |
827 { | |
828 // http://dicom.nema.org/medical/Dicom/2016a/output/chtml/part03/sect_C.8.8.3.2.html | |
829 | |
830 { | |
831 std::string increment; | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
832 |
669 | 833 if (dicom.CopyToString(increment, Orthanc::DICOM_TAG_FRAME_INCREMENT_POINTER, false)) |
834 { | |
835 Orthanc::Toolbox::ToUpperCase(increment); | |
836 if (increment != "3004,000C") // This is the "Grid Frame Offset Vector" tag | |
837 { | |
838 LOG(ERROR) << "RT-DOSE: Bad value for the \"FrameIncrementPointer\" tag"; | |
839 return; | |
840 } | |
841 } | |
842 } | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
843 |
669 | 844 if (!OrthancStone::LinearAlgebra::ParseVector(frameOffsets_, dicom, Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR) || |
845 frameOffsets_.size() < imageInformation_.GetNumberOfFrames()) | |
846 { | |
847 LOG(ERROR) << "RT-DOSE: No information about the 3D location of some slice(s)"; | |
848 frameOffsets_.clear(); | |
849 } | |
850 else | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
851 { |
669 | 852 if (frameOffsets_.size() >= 2) |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
853 { |
669 | 854 thickness_ = frameOffsets_[1] - frameOffsets_[0]; |
855 | |
856 if (thickness_ < 0) | |
857 { | |
858 thickness_ = -thickness_; | |
859 } | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
860 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
861 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
862 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
863 |
669 | 864 Data(const Orthanc::DicomMap& dicom) : |
865 imageInformation_(dicom) | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
866 { |
669 | 867 if (imageInformation_.GetNumberOfFrames() <= 0) |
868 { | |
869 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
870 } | |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
871 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
872 if (!dicom.CopyToString(studyInstanceUid_, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) || |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
873 !dicom.CopyToString(seriesInstanceUid_, Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, false) || |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
874 !dicom.CopyToString(sopInstanceUid_, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false)) |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
875 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
876 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
877 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
878 |
669 | 879 std::string s; |
880 if (!dicom.CopyToString(s, Orthanc::DICOM_TAG_SOP_CLASS_UID, false)) | |
881 { | |
882 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
883 } | |
884 else | |
885 { | |
886 sopClassUid_ = OrthancStone::StringToSopClassUid(s); | |
887 } | |
888 | |
889 if (!dicom.ParseDouble(thickness_, Orthanc::DICOM_TAG_SLICE_THICKNESS)) | |
890 { | |
891 thickness_ = 100.0 * std::numeric_limits<double>::epsilon(); | |
892 } | |
893 | |
894 OrthancStone::GeometryToolbox::GetPixelSpacing(pixelSpacingX_, pixelSpacingY_, dicom); | |
895 | |
896 std::string position, orientation; | |
897 if (dicom.CopyToString(position, Orthanc::DICOM_TAG_IMAGE_POSITION_PATIENT, false) && | |
898 dicom.CopyToString(orientation, Orthanc::DICOM_TAG_IMAGE_ORIENTATION_PATIENT, false)) | |
899 { | |
900 geometry_ = OrthancStone::CoordinateSystem3D(position, orientation); | |
901 } | |
902 | |
903 if (sopClassUid_ == OrthancStone::SopClassUid_RTDose) | |
904 { | |
905 ComputeDoseOffsets(dicom); | |
906 } | |
907 | |
908 isColor_ = (imageInformation_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome1 && | |
909 imageInformation_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome2); | |
910 | |
911 double doseGridScaling; | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
912 |
712 | 913 if (dicom.ParseDouble(rescaleIntercept_, Orthanc::DICOM_TAG_RESCALE_INTERCEPT) && |
669 | 914 dicom.ParseDouble(rescaleSlope_, Orthanc::DICOM_TAG_RESCALE_SLOPE)) |
915 { | |
916 hasRescale_ = true; | |
917 } | |
918 else if (dicom.ParseDouble(doseGridScaling, Orthanc::DICOM_TAG_DOSE_GRID_SCALING)) | |
919 { | |
920 hasRescale_ = true; | |
712 | 921 rescaleIntercept_ = 0; |
669 | 922 rescaleSlope_ = doseGridScaling; |
923 } | |
924 else | |
925 { | |
926 hasRescale_ = false; | |
927 } | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
928 |
669 | 929 OrthancStone::Vector c, w; |
930 if (OrthancStone::LinearAlgebra::ParseVector(c, dicom, Orthanc::DICOM_TAG_WINDOW_CENTER) && | |
931 OrthancStone::LinearAlgebra::ParseVector(w, dicom, Orthanc::DICOM_TAG_WINDOW_WIDTH) && | |
932 c.size() > 0 && | |
933 w.size() > 0) | |
934 { | |
935 hasDefaultWindowing_ = true; | |
936 defaultWindowingCenter_ = static_cast<float>(c[0]); | |
937 defaultWindowingWidth_ = static_cast<float>(w[0]); | |
938 } | |
939 else | |
940 { | |
941 hasDefaultWindowing_ = false; | |
942 } | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
943 |
669 | 944 if (sopClassUid_ == OrthancStone::SopClassUid_RTDose) |
945 { | |
946 switch (imageInformation_.GetBitsStored()) | |
947 { | |
948 case 16: | |
949 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale16; | |
950 break; | |
951 | |
952 case 32: | |
953 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale32; | |
954 break; | |
955 | |
956 default: | |
957 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
958 } | |
959 } | |
960 else if (isColor_) | |
961 { | |
962 expectedPixelFormat_ = Orthanc::PixelFormat_RGB24; | |
963 } | |
964 else if (imageInformation_.IsSigned()) | |
965 { | |
966 expectedPixelFormat_ = Orthanc::PixelFormat_SignedGrayscale16; | |
967 } | |
968 else | |
969 { | |
970 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale16; | |
971 } | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
972 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
973 |
669 | 974 OrthancStone::CoordinateSystem3D GetFrameGeometry(unsigned int frame) const |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
975 { |
669 | 976 if (frame == 0) |
977 { | |
978 return geometry_; | |
979 } | |
980 else if (frame >= imageInformation_.GetNumberOfFrames()) | |
981 { | |
982 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
983 } | |
984 else if (sopClassUid_ == OrthancStone::SopClassUid_RTDose) | |
985 { | |
986 if (frame >= frameOffsets_.size()) | |
987 { | |
988 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
989 } | |
990 | |
991 return OrthancStone::CoordinateSystem3D( | |
992 geometry_.GetOrigin() + frameOffsets_[frame] * geometry_.GetNormal(), | |
993 geometry_.GetAxisX(), | |
994 geometry_.GetAxisY()); | |
995 } | |
996 else | |
997 { | |
998 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
999 } | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1000 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1001 |
669 | 1002 // TODO - Is this necessary? |
1003 bool FrameContainsPlane(unsigned int frame, | |
1004 const OrthancStone::CoordinateSystem3D& plane) const | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1005 { |
669 | 1006 if (frame >= imageInformation_.GetNumberOfFrames()) |
1007 { | |
1008 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
1009 } | |
626 | 1010 |
669 | 1011 OrthancStone::CoordinateSystem3D tmp = geometry_; |
1012 | |
1013 if (frame != 0) | |
626 | 1014 { |
669 | 1015 tmp = GetFrameGeometry(frame); |
1016 } | |
626 | 1017 |
669 | 1018 double distance; |
626 | 1019 |
669 | 1020 return (OrthancStone::CoordinateSystem3D::GetDistance(distance, tmp, plane) && |
1021 distance <= thickness_ / 2.0); | |
626 | 1022 } |
712 | 1023 |
1024 | |
1025 void ApplyRescale(Orthanc::ImageAccessor& image, | |
1026 bool useDouble) const | |
1027 { | |
1028 if (image.GetFormat() != Orthanc::PixelFormat_Float32) | |
1029 { | |
1030 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); | |
1031 } | |
1032 | |
1033 if (hasRescale_) | |
1034 { | |
1035 const unsigned int width = image.GetWidth(); | |
1036 const unsigned int height = image.GetHeight(); | |
1037 | |
1038 for (unsigned int y = 0; y < height; y++) | |
1039 { | |
1040 float* p = reinterpret_cast<float*>(image.GetRow(y)); | |
1041 | |
1042 if (useDouble) | |
1043 { | |
1044 // Slower, accurate implementation using double | |
1045 for (unsigned int x = 0; x < width; x++, p++) | |
1046 { | |
1047 double value = static_cast<double>(*p); | |
1048 *p = static_cast<float>(value * rescaleSlope_ + rescaleIntercept_); | |
1049 } | |
1050 } | |
1051 else | |
1052 { | |
1053 // Fast, approximate implementation using float | |
1054 for (unsigned int x = 0; x < width; x++, p++) | |
1055 { | |
1056 *p = (*p) * static_cast<float>(rescaleSlope_) + static_cast<float>(rescaleIntercept_); | |
1057 } | |
1058 } | |
1059 } | |
1060 } | |
1061 } | |
669 | 1062 }; |
712 | 1063 |
669 | 1064 |
1065 Data data_; | |
1066 | |
1067 | |
1068 public: | |
1069 DicomInstanceParameters(const DicomInstanceParameters& other) : | |
1070 data_(other.data_) | |
1071 { | |
1072 } | |
1073 | |
1074 DicomInstanceParameters(const Orthanc::DicomMap& dicom) : | |
1075 data_(dicom) | |
1076 { | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1077 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1078 |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1079 void SetOrthancInstanceIdentifier(const std::string& id) |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1080 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1081 data_.orthancInstanceId_ = id; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1082 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1083 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1084 const std::string& GetOrthancInstanceIdentifier() const |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1085 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1086 return data_.orthancInstanceId_; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1087 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1088 |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1089 const Orthanc::DicomImageInformation& GetImageInformation() const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1090 { |
669 | 1091 return data_.imageInformation_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1092 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1093 |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1094 const std::string& GetStudyInstanceUid() const |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1095 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1096 return data_.studyInstanceUid_; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1097 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1098 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1099 const std::string& GetSeriesInstanceUid() const |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1100 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1101 return data_.seriesInstanceUid_; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1102 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1103 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1104 const std::string& GetSopInstanceUid() const |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1105 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1106 return data_.sopInstanceUid_; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1107 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1108 |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1109 OrthancStone::SopClassUid GetSopClassUid() const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1110 { |
669 | 1111 return data_.sopClassUid_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1112 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1113 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1114 double GetThickness() const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1115 { |
669 | 1116 return data_.thickness_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1117 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1118 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1119 double GetPixelSpacingX() const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1120 { |
669 | 1121 return data_.pixelSpacingX_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1122 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1123 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1124 double GetPixelSpacingY() const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1125 { |
669 | 1126 return data_.pixelSpacingY_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1127 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1128 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1129 const OrthancStone::CoordinateSystem3D& GetGeometry() const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1130 { |
669 | 1131 return data_.geometry_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1132 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1133 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1134 OrthancStone::CoordinateSystem3D GetFrameGeometry(unsigned int frame) const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1135 { |
669 | 1136 return data_.GetFrameGeometry(frame); |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1137 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1138 |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1139 // TODO - Is this necessary? |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1140 bool FrameContainsPlane(unsigned int frame, |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1141 const OrthancStone::CoordinateSystem3D& plane) const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1142 { |
669 | 1143 return data_.FrameContainsPlane(frame, plane); |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1144 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1145 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1146 bool IsColor() const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1147 { |
669 | 1148 return data_.isColor_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1149 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1150 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1151 bool HasRescale() const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1152 { |
669 | 1153 return data_.hasRescale_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1154 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1155 |
712 | 1156 double GetRescaleIntercept() const |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1157 { |
669 | 1158 if (data_.hasRescale_) |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1159 { |
712 | 1160 return data_.rescaleIntercept_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1161 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1162 else |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1163 { |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1164 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1165 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1166 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1167 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1168 double GetRescaleSlope() const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1169 { |
669 | 1170 if (data_.hasRescale_) |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1171 { |
669 | 1172 return data_.rescaleSlope_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1173 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1174 else |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1175 { |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1176 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1177 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1178 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1179 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1180 bool HasDefaultWindowing() const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1181 { |
669 | 1182 return data_.hasDefaultWindowing_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1183 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1184 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1185 float GetDefaultWindowingCenter() const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1186 { |
669 | 1187 if (data_.hasDefaultWindowing_) |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1188 { |
669 | 1189 return data_.defaultWindowingCenter_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1190 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1191 else |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1192 { |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1193 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1194 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1195 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1196 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1197 float GetDefaultWindowingWidth() const |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1198 { |
669 | 1199 if (data_.hasDefaultWindowing_) |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1200 { |
669 | 1201 return data_.defaultWindowingWidth_; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1202 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1203 else |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1204 { |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1205 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1206 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1207 } |
626 | 1208 |
1209 Orthanc::PixelFormat GetExpectedPixelFormat() const | |
1210 { | |
669 | 1211 return data_.expectedPixelFormat_; |
626 | 1212 } |
712 | 1213 |
1214 | |
1215 OrthancStone::TextureBaseSceneLayer* CreateTexture(const Orthanc::ImageAccessor& source) const | |
1216 { | |
1217 assert(sizeof(float) == 4); | |
1218 | |
1219 Orthanc::PixelFormat sourceFormat = source.GetFormat(); | |
1220 | |
1221 if (sourceFormat != GetExpectedPixelFormat()) | |
1222 { | |
1223 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); | |
1224 } | |
1225 | |
1226 if (sourceFormat == Orthanc::PixelFormat_RGB24) | |
1227 { | |
1228 // This is the case of a color image. No conversion has to be done. | |
1229 return new OrthancStone::ColorTextureSceneLayer(source); | |
1230 } | |
1231 else | |
1232 { | |
1233 if (sourceFormat != Orthanc::PixelFormat_Grayscale16 && | |
1234 sourceFormat != Orthanc::PixelFormat_Grayscale32 && | |
1235 sourceFormat != Orthanc::PixelFormat_SignedGrayscale16) | |
1236 { | |
1237 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
1238 } | |
1239 | |
1240 std::auto_ptr<OrthancStone::FloatTextureSceneLayer> texture; | |
1241 | |
1242 { | |
1243 // This is the case of a grayscale frame. Convert it to Float32. | |
1244 std::auto_ptr<Orthanc::Image> converted(new Orthanc::Image(Orthanc::PixelFormat_Float32, | |
1245 source.GetWidth(), | |
1246 source.GetHeight(), | |
1247 false)); | |
1248 Orthanc::ImageProcessing::Convert(*converted, source); | |
1249 | |
1250 // Correct rescale slope/intercept if need be | |
1251 data_.ApplyRescale(*converted, (sourceFormat == Orthanc::PixelFormat_Grayscale32)); | |
1252 | |
1253 texture.reset(new OrthancStone::FloatTextureSceneLayer(*converted)); | |
1254 } | |
1255 | |
1256 if (data_.hasDefaultWindowing_) | |
1257 { | |
1258 texture->SetCustomWindowing(data_.defaultWindowingCenter_, | |
1259 data_.defaultWindowingWidth_); | |
1260 } | |
1261 | |
1262 return texture.release(); | |
1263 } | |
1264 } | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1265 }; |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1266 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1267 |
669 | 1268 class DicomVolumeImage : public boost::noncopyable |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1269 { |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1270 private: |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1271 std::auto_ptr<OrthancStone::ImageBuffer3D> image_; |
669 | 1272 std::vector<DicomInstanceParameters*> slices_; |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1273 uint64_t revision_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1274 std::vector<uint64_t> slicesRevision_; |
709
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1275 std::vector<unsigned int> slicesQuality_; |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1276 |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1277 void CheckSlice(size_t index, |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1278 const DicomInstanceParameters& reference) const |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1279 { |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1280 const DicomInstanceParameters& slice = *slices_[index]; |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1281 |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1282 if (!OrthancStone::GeometryToolbox::IsParallel( |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1283 reference.GetGeometry().GetNormal(), |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1284 slice.GetGeometry().GetNormal())) |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1285 { |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1286 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1287 "A slice in the volume image is not parallel to the others"); |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1288 } |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1289 |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1290 if (reference.GetExpectedPixelFormat() != slice.GetExpectedPixelFormat()) |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1291 { |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1292 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat, |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1293 "The pixel format changes across the slices of the volume image"); |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1294 } |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1295 |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1296 if (reference.GetImageInformation().GetWidth() != slice.GetImageInformation().GetWidth() || |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1297 reference.GetImageInformation().GetHeight() != slice.GetImageInformation().GetHeight()) |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1298 { |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1299 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize, |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1300 "The width/height of slices are not constant in the volume image"); |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1301 } |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1302 |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1303 if (!OrthancStone::LinearAlgebra::IsNear(reference.GetPixelSpacingX(), slice.GetPixelSpacingX()) || |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1304 !OrthancStone::LinearAlgebra::IsNear(reference.GetPixelSpacingY(), slice.GetPixelSpacingY())) |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1305 { |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1306 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1307 "The pixel spacing of the slices change across the volume image"); |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1308 } |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1309 } |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1310 |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1311 |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1312 void CheckVolume() const |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1313 { |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1314 for (size_t i = 0; i < slices_.size(); i++) |
669 | 1315 { |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1316 assert(slices_[i] != NULL); |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1317 if (slices_[i]->GetImageInformation().GetNumberOfFrames() != 1) |
669 | 1318 { |
1319 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, | |
1320 "This class does not support multi-frame images"); | |
1321 } | |
1322 } | |
1323 | |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1324 if (slices_.size() != 0) |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1325 { |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1326 const DicomInstanceParameters& reference = *slices_[0]; |
669 | 1327 |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1328 for (size_t i = 1; i < slices_.size(); i++) |
669 | 1329 { |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1330 CheckSlice(i, reference); |
669 | 1331 } |
1332 } | |
1333 } | |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1334 |
669 | 1335 |
1336 void Clear() | |
1337 { | |
1338 image_.reset(); | |
1339 | |
1340 for (size_t i = 0; i < slices_.size(); i++) | |
1341 { | |
1342 assert(slices_[i] != NULL); | |
1343 delete slices_[i]; | |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1344 } |
709
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1345 |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1346 slices_.clear(); |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1347 slicesRevision_.clear(); |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1348 slicesQuality_.clear(); |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1349 } |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1350 |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1351 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1352 void CheckSliceIndex(size_t index) const |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1353 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1354 assert(slices_.size() == image_->GetDepth() && |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1355 slices_.size() == slicesRevision_.size()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1356 |
691 | 1357 if (!HasGeometry()) |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1358 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1359 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1360 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1361 else if (index >= slices_.size()) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1362 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1363 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1364 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1365 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1366 |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1367 |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1368 public: |
669 | 1369 DicomVolumeImage() |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1370 { |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1371 } |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1372 |
669 | 1373 ~DicomVolumeImage() |
1374 { | |
1375 Clear(); | |
1376 } | |
1377 | |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1378 // WARNING: The payload of "slices" must be of class "DicomInstanceParameters" |
669 | 1379 void SetGeometry(OrthancStone::SlicesSorter& slices) |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1380 { |
669 | 1381 Clear(); |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1382 |
669 | 1383 if (!slices.Sort()) |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1384 { |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1385 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1386 "Cannot sort the 3D slices of a DICOM series"); |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1387 } |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1388 |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1389 if (slices.GetSlicesCount() == 0) |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1390 { |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1391 // Empty volume |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1392 image_.reset(new OrthancStone::ImageBuffer3D(Orthanc::PixelFormat_Grayscale8, 0, 0, 0, |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1393 false /* don't compute range */)); |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1394 } |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1395 else |
669 | 1396 { |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1397 slices_.reserve(slices.GetSlicesCount()); |
709
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1398 slicesRevision_.resize(slices.GetSlicesCount(), 0); |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1399 slicesQuality_.resize(slices.GetSlicesCount(), 0); |
669 | 1400 |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1401 for (size_t i = 0; i < slices.GetSlicesCount(); i++) |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1402 { |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1403 const DicomInstanceParameters& slice = |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1404 dynamic_cast<const DicomInstanceParameters&>(slices.GetSlicePayload(i)); |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1405 slices_.push_back(new DicomInstanceParameters(slice)); |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1406 } |
669 | 1407 |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1408 CheckVolume(); |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1409 |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1410 const double spacingZ = slices.ComputeSpacingBetweenSlices(); |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1411 LOG(INFO) << "Computed spacing between slices: " << spacingZ << "mm"; |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1412 |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1413 const DicomInstanceParameters& parameters = *slices_[0]; |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1414 |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1415 image_.reset(new OrthancStone::ImageBuffer3D(parameters.GetExpectedPixelFormat(), |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1416 parameters.GetImageInformation().GetWidth(), |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1417 parameters.GetImageInformation().GetHeight(), |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1418 slices.GetSlicesCount(), false /* don't compute range */)); |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1419 |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
683
diff
changeset
|
1420 image_->GetGeometry().SetAxialGeometry(slices.GetSliceGeometry(0)); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
683
diff
changeset
|
1421 image_->GetGeometry().SetVoxelDimensions(parameters.GetPixelSpacingX(), |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
683
diff
changeset
|
1422 parameters.GetPixelSpacingY(), spacingZ); |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1423 } |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1424 |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1425 image_->Clear(); |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1426 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1427 revision_++; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1428 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1429 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1430 uint64_t GetRevision() const |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1431 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1432 return revision_; |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1433 } |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1434 |
691 | 1435 bool HasGeometry() const |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1436 { |
669 | 1437 return (image_.get() != NULL); |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1438 } |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1439 |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1440 const OrthancStone::ImageBuffer3D& GetImage() const |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1441 { |
691 | 1442 if (!HasGeometry()) |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1443 { |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1444 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1445 } |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1446 else |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1447 { |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1448 return *image_; |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1449 } |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1450 } |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1451 |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1452 size_t GetSlicesCount() const |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1453 { |
691 | 1454 if (!HasGeometry()) |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1455 { |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1456 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1457 } |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1458 else |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1459 { |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1460 return slices_.size(); |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1461 } |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1462 } |
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1463 |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1464 const DicomInstanceParameters& GetSliceParameters(size_t index) const |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1465 { |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1466 CheckSliceIndex(index); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1467 return *slices_[index]; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1468 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1469 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1470 uint64_t GetSliceRevision(size_t index) const |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1471 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1472 CheckSliceIndex(index); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1473 return slicesRevision_[index]; |
678
6f10f9a6676a
turning DicomVolumeImage into a bean class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
669
diff
changeset
|
1474 } |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1475 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1476 void SetSliceContent(size_t index, |
709
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1477 const Orthanc::ImageAccessor& image, |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1478 unsigned int quality) |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1479 { |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1480 CheckSliceIndex(index); |
709
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1481 |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1482 // If a better image quality is already available, don't update the content |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1483 if (quality >= slicesQuality_[index]) |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1484 { |
709
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1485 { |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1486 OrthancStone::ImageBuffer3D::SliceWriter writer |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1487 (*image_, OrthancStone::VolumeProjection_Axial, index); |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1488 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), image); |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1489 } |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1490 |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1491 revision_ ++; |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1492 slicesRevision_[index] += 1; |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1493 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1494 } |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1495 }; |
712 | 1496 |
1497 | |
1498 | |
1499 class IDicomVolumeSource : public boost::noncopyable | |
1500 { | |
1501 public: | |
1502 virtual ~IDicomVolumeSource() | |
1503 { | |
1504 } | |
1505 | |
1506 virtual const DicomVolumeImage& GetVolume() const = 0; | |
1507 | |
1508 virtual void NotifyAxialSliceAccessed(unsigned int sliceIndex) = 0; | |
1509 }; | |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1510 |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1511 |
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
1512 |
712 | 1513 class VolumeSeriesOrthancLoader : |
1514 public OrthancStone::IObserver, | |
1515 public IDicomVolumeSource | |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
1516 { |
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
1517 private: |
711 | 1518 static const unsigned int LOW_QUALITY = 0; |
1519 static const unsigned int MIDDLE_QUALITY = 1; | |
1520 static const unsigned int BEST_QUALITY = 2; | |
1521 | |
1522 | |
1523 static unsigned int GetSliceIndexPayload(const OracleCommandWithPayload& command) | |
1524 { | |
1525 return dynamic_cast< const Orthanc::SingleValueObject<unsigned int>& >(command.GetPayload()).GetValue(); | |
1526 } | |
1527 | |
1528 | |
1529 void ScheduleNextSliceDownload() | |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
1530 { |
711 | 1531 assert(strategy_.get() != NULL); |
1532 | |
1533 unsigned int sliceIndex, quality; | |
1534 | |
1535 if (strategy_->GetNext(sliceIndex, quality)) | |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1536 { |
711 | 1537 assert(quality <= BEST_QUALITY); |
1538 | |
1539 const DicomInstanceParameters& slice = volume_.GetSliceParameters(sliceIndex); | |
1540 | |
1541 const std::string& instance = slice.GetOrthancInstanceIdentifier(); | |
1542 if (instance.empty()) | |
1543 { | |
1544 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
1545 } | |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1546 |
711 | 1547 std::auto_ptr<Refactoring::OracleCommandWithPayload> command; |
1548 | |
1549 if (quality == BEST_QUALITY) | |
1550 { | |
1551 std::auto_ptr<Refactoring::GetOrthancImageCommand> tmp( | |
1552 new Refactoring::GetOrthancImageCommand); | |
1553 tmp->SetHttpHeader("Accept-Encoding", "gzip"); | |
1554 tmp->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Pam))); | |
1555 tmp->SetInstanceUri(instance, slice.GetExpectedPixelFormat()); | |
1556 tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat()); | |
1557 command.reset(tmp.release()); | |
1558 } | |
1559 else | |
1560 { | |
1561 std::auto_ptr<Refactoring::GetOrthancWebViewerJpegCommand> tmp( | |
1562 new Refactoring::GetOrthancWebViewerJpegCommand); | |
1563 tmp->SetHttpHeader("Accept-Encoding", "gzip"); | |
1564 tmp->SetInstance(instance); | |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1565 tmp->SetQuality((quality == 0 ? 50 : 90)); |
711 | 1566 tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat()); |
1567 command.reset(tmp.release()); | |
1568 } | |
1569 | |
1570 command->SetPayload(new Orthanc::SingleValueObject<unsigned int>(sliceIndex)); | |
1571 oracle_.Schedule(*this, command.release()); | |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1572 } |
711 | 1573 } |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
1574 |
711 | 1575 |
1576 void LoadGeometry(const OrthancRestApiCommand::SuccessMessage& message) | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1577 { |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1578 Json::Value body; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1579 message.ParseJsonBody(body); |
711 | 1580 |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1581 if (body.type() != Json::objectValue) |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1582 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1583 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1584 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1585 |
710 | 1586 { |
1587 Json::Value::Members instances = body.getMemberNames(); | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1588 |
710 | 1589 OrthancStone::SlicesSorter slices; |
1590 | |
1591 for (size_t i = 0; i < instances.size(); i++) | |
1592 { | |
1593 Orthanc::DicomMap dicom; | |
1594 dicom.FromDicomAsJson(body[instances[i]]); | |
1595 | |
1596 std::auto_ptr<DicomInstanceParameters> instance(new DicomInstanceParameters(dicom)); | |
1597 instance->SetOrthancInstanceIdentifier(instances[i]); | |
1598 | |
1599 OrthancStone::CoordinateSystem3D geometry = instance->GetGeometry(); | |
1600 slices.AddSlice(geometry, instance.release()); | |
1601 } | |
1602 | |
1603 volume_.SetGeometry(slices); | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1604 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1605 |
710 | 1606 if (volume_.GetSlicesCount() != 0) |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1607 { |
710 | 1608 strategy_.reset(new OrthancStone::BasicFetchingStrategy( |
711 | 1609 new OrthancStone::BasicFetchingItemsSorter(volume_.GetSlicesCount()), BEST_QUALITY)); |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1610 |
710 | 1611 for (unsigned int i = 0; i < 4; i++) // Schedule up to 4 simultaneous downloads (TODO - parameter) |
1612 { | |
1613 ScheduleNextSliceDownload(); | |
1614 } | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1615 } |
710 | 1616 } |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1617 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1618 |
711 | 1619 void LoadBestQualitySliceContent(const Refactoring::GetOrthancImageCommand::SuccessMessage& message) |
1620 { | |
1621 volume_.SetSliceContent(GetSliceIndexPayload(message.GetOrigin()), | |
1622 message.GetImage(), BEST_QUALITY); | |
709
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1623 |
711 | 1624 ScheduleNextSliceDownload(); |
709
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1625 } |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1626 |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1627 |
711 | 1628 void LoadJpegSliceContent(const Refactoring::GetOrthancWebViewerJpegCommand::SuccessMessage& message) |
710 | 1629 { |
711 | 1630 unsigned int quality; |
710 | 1631 |
711 | 1632 switch (message.GetOrigin().GetQuality()) |
1633 { | |
1634 case 50: | |
1635 quality = LOW_QUALITY; | |
1636 break; | |
1637 | |
1638 case 90: | |
1639 quality = MIDDLE_QUALITY; | |
1640 break; | |
1641 | |
1642 default: | |
1643 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
1644 } | |
1645 | |
1646 volume_.SetSliceContent(GetSliceIndexPayload(message.GetOrigin()), message.GetImage(), quality); | |
1647 | |
710 | 1648 ScheduleNextSliceDownload(); |
1649 } | |
711 | 1650 |
710 | 1651 |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1652 IOracle& oracle_; |
669 | 1653 bool active_; |
683
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
1654 DicomVolumeImage volume_; |
709
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1655 |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
1656 std::auto_ptr<OrthancStone::IFetchingStrategy> strategy_; |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
1657 |
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
1658 public: |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1659 VolumeSeriesOrthancLoader(IOracle& oracle, |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1660 OrthancStone::IObservable& oracleObservable) : |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1661 IObserver(oracleObservable.GetBroker()), |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1662 oracle_(oracle), |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1663 active_(false) |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
1664 { |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1665 oracleObservable.RegisterObserverCallback( |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1666 new OrthancStone::Callable<VolumeSeriesOrthancLoader, OrthancRestApiCommand::SuccessMessage> |
711 | 1667 (*this, &VolumeSeriesOrthancLoader::LoadGeometry)); |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1668 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1669 oracleObservable.RegisterObserverCallback( |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1670 new OrthancStone::Callable<VolumeSeriesOrthancLoader, GetOrthancImageCommand::SuccessMessage> |
711 | 1671 (*this, &VolumeSeriesOrthancLoader::LoadBestQualitySliceContent)); |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1672 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1673 oracleObservable.RegisterObserverCallback( |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1674 new OrthancStone::Callable<VolumeSeriesOrthancLoader, GetOrthancWebViewerJpegCommand::SuccessMessage> |
711 | 1675 (*this, &VolumeSeriesOrthancLoader::LoadJpegSliceContent)); |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
1676 } |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1677 |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1678 void LoadSeries(const std::string& seriesId) |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1679 { |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1680 if (active_) |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1681 { |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1682 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1683 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1684 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1685 active_ = true; |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1686 |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
1687 std::auto_ptr<Refactoring::OrthancRestApiCommand> command(new Refactoring::OrthancRestApiCommand); |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1688 command->SetUri("/series/" + seriesId + "/instances-tags"); |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1689 |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
1690 oracle_.Schedule(*this, command.release()); |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1691 } |
712 | 1692 |
1693 | |
1694 virtual const DicomVolumeImage& GetVolume() const | |
1695 { | |
1696 return volume_; | |
1697 } | |
1698 | |
1699 | |
1700 virtual void NotifyAxialSliceAccessed(unsigned int sliceIndex) | |
1701 { | |
1702 if (strategy_.get() == NULL) | |
1703 { | |
1704 // Should have called GetVolume().HasGeometry() before | |
1705 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
1706 } | |
1707 else | |
1708 { | |
1709 strategy_->SetCurrent(sliceIndex); | |
1710 } | |
1711 } | |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
1712 }; |
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
1713 |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1714 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1715 |
710 | 1716 #if 0 |
1717 void LoadInstance(const std::string& instanceId) | |
1718 { | |
1719 if (active_) | |
1720 { | |
1721 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
1722 } | |
1723 | |
1724 active_ = true; | |
1725 | |
1726 // Tag "3004-000c" is "Grid Frame Offset Vector", which is | |
1727 // mandatory to read RT DOSE, but is too long to be returned by default | |
1728 | |
1729 // TODO => Should be part of a second call if needed | |
1730 | |
1731 std::auto_ptr<Refactoring::OrthancRestApiCommand> command(new Refactoring::OrthancRestApiCommand); | |
1732 command->SetUri("/instances/" + instanceId + "/tags?ignore-length=3004-000c"); | |
1733 command->SetPayload(new LoadInstanceGeometryHandler(*this)); | |
1734 | |
1735 oracle_.Schedule(*this, command.release()); | |
1736 } | |
1737 #endif | |
1738 | |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1739 |
692
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1740 /* class VolumeSlicerBase : public IVolumeSlicer |
711 | 1741 { |
1742 private: | |
1743 OrthancStone::Scene2D& scene_; | |
1744 int layerDepth_; | |
1745 bool first_; | |
1746 OrthancStone::CoordinateSystem3D lastPlane_; | |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1747 |
711 | 1748 protected: |
1749 bool HasViewportPlaneChanged(const OrthancStone::CoordinateSystem3D& plane) const | |
1750 { | |
691 | 1751 if (first_ || |
711 | 1752 !OrthancStone::LinearAlgebra::IsCloseToZero( |
1753 boost::numeric::ublas::norm_2(lastPlane_.GetNormal() - plane.GetNormal()))) | |
691 | 1754 { |
711 | 1755 // This is the first rendering, or the plane has not the same orientation |
1756 return false; | |
691 | 1757 } |
1758 else | |
1759 { | |
711 | 1760 double offset1 = lastPlane_.ProjectAlongNormal(plane.GetOrigin()); |
1761 double offset2 = lastPlane_.ProjectAlongNormal(lastPlane_.GetOrigin()); | |
1762 return OrthancStone::LinearAlgebra::IsCloseToZero(offset2 - offset1); | |
691 | 1763 } |
711 | 1764 } |
691 | 1765 |
711 | 1766 void SetLastViewportPlane(const OrthancStone::CoordinateSystem3D& plane) |
1767 { | |
691 | 1768 first_ = false; |
1769 lastPlane_ = plane; | |
711 | 1770 } |
691 | 1771 |
711 | 1772 void SetLayer(OrthancStone::ISceneLayer* layer) |
1773 { | |
691 | 1774 scene_.SetLayer(layerDepth_, layer); |
711 | 1775 } |
691 | 1776 |
711 | 1777 void DeleteLayer() |
1778 { | |
691 | 1779 scene_.DeleteLayer(layerDepth_); |
711 | 1780 } |
691 | 1781 |
711 | 1782 public: |
1783 VolumeSlicerBase(OrthancStone::Scene2D& scene, | |
1784 int layerDepth) : | |
691 | 1785 scene_(scene), |
1786 layerDepth_(layerDepth), | |
1787 first_(true) | |
711 | 1788 { |
1789 } | |
1790 };*/ | |
691 | 1791 |
1792 | |
1793 | |
712 | 1794 class DicomVolumeMPRSlicer : public IVolumeSlicer |
691 | 1795 { |
1796 private: | |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1797 bool linearInterpolation_; |
692
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1798 OrthancStone::Scene2D& scene_; |
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1799 int layerDepth_; |
712 | 1800 IDicomVolumeSource& source_; |
692
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1801 bool first_; |
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1802 OrthancStone::VolumeProjection lastProjection_; |
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1803 unsigned int lastSliceIndex_; |
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1804 uint64_t lastSliceRevision_; |
691 | 1805 |
1806 public: | |
712 | 1807 DicomVolumeMPRSlicer(OrthancStone::Scene2D& scene, |
1808 int layerDepth, | |
1809 IDicomVolumeSource& source) : | |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1810 linearInterpolation_(false), |
692
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1811 scene_(scene), |
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1812 layerDepth_(layerDepth), |
712 | 1813 source_(source), |
692
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1814 first_(true) |
691 | 1815 { |
1816 } | |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1817 |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1818 void SetLinearInterpolation(bool enabled) |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1819 { |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1820 linearInterpolation_ = enabled; |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1821 } |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1822 |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1823 bool IsLinearInterpolation() const |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1824 { |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1825 return linearInterpolation_; |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1826 } |
691 | 1827 |
1828 virtual void SetViewportPlane(const OrthancStone::CoordinateSystem3D& plane) | |
1829 { | |
712 | 1830 if (!source_.GetVolume().HasGeometry() || |
1831 source_.GetVolume().GetSlicesCount() == 0) | |
691 | 1832 { |
692
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1833 scene_.DeleteLayer(layerDepth_); |
691 | 1834 return; |
1835 } | |
1836 | |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1837 const OrthancStone::VolumeImageGeometry& geometry = source_.GetVolume().GetImage().GetGeometry(); |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1838 |
691 | 1839 OrthancStone::VolumeProjection projection; |
1840 unsigned int sliceIndex; | |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1841 if (!geometry.DetectSlice(projection, sliceIndex, plane)) |
691 | 1842 { |
1843 // The cutting plane is neither axial, nor coronal, nor | |
1844 // sagittal. Could use "VolumeReslicer" here. | |
692
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1845 scene_.DeleteLayer(layerDepth_); |
691 | 1846 return; |
1847 } | |
1848 | |
1849 uint64_t sliceRevision; | |
1850 if (projection == OrthancStone::VolumeProjection_Axial) | |
1851 { | |
712 | 1852 sliceRevision = source_.GetVolume().GetSliceRevision(sliceIndex); |
1853 | |
1854 if (first_ || | |
1855 lastSliceIndex_ != sliceIndex) | |
1856 { | |
1857 // Reorder the prefetching queue | |
1858 source_.NotifyAxialSliceAccessed(sliceIndex); | |
1859 } | |
691 | 1860 } |
1861 else | |
1862 { | |
1863 // For coronal and sagittal projections, we take the global | |
1864 // revision of the volume | |
712 | 1865 sliceRevision = source_.GetVolume().GetRevision(); |
691 | 1866 } |
692
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1867 |
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1868 if (first_ || |
712 | 1869 lastProjection_ != projection || |
1870 lastSliceIndex_ != sliceIndex || | |
1871 lastSliceRevision_ != sliceRevision) | |
691 | 1872 { |
712 | 1873 // Either the viewport plane, or the content of the slice have not |
692
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1874 // changed since the last time the layer was set: Update is needed |
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1875 |
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1876 first_ = false; |
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1877 lastProjection_ = projection; |
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1878 lastSliceIndex_ = sliceIndex; |
691 | 1879 lastSliceRevision_ = sliceRevision; |
712 | 1880 |
1881 std::auto_ptr<OrthancStone::TextureBaseSceneLayer> texture; | |
692
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1882 |
691 | 1883 { |
712 | 1884 const DicomInstanceParameters& parameters = source_.GetVolume().GetSliceParameters |
1885 (projection == OrthancStone::VolumeProjection_Axial ? sliceIndex : 0); | |
1886 | |
1887 OrthancStone::ImageBuffer3D::SliceReader reader(source_.GetVolume().GetImage(), projection, sliceIndex); | |
1888 texture.reset(parameters.CreateTexture(reader.GetAccessor())); | |
1889 } | |
691 | 1890 |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1891 const OrthancStone::CoordinateSystem3D& system = geometry.GetProjectionGeometry(projection); |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1892 |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1893 double x0, y0, x1, y1; |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1894 system.ProjectPoint(x0, y0, system.GetOrigin()); |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1895 system.ProjectPoint(x0, y0, system.GetOrigin() + system.GetAxisX()); |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1896 texture->SetOrigin(x0, y0); |
712 | 1897 |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1898 double dx = x1 - x0; |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1899 double dy = y1 - y0; |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1900 if (!OrthancStone::LinearAlgebra::IsCloseToZero(dx) || |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1901 !OrthancStone::LinearAlgebra::IsCloseToZero(dy)) |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1902 { |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1903 texture->SetAngle(atan2(dy, dx)); |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1904 } |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1905 |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1906 OrthancStone::Vector tmp; |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1907 geometry.GetVoxelDimensions(projection); |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1908 texture->SetPixelSpacing(tmp[0], tmp[1]); |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1909 |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1910 texture->SetLinearInterpolation(linearInterpolation_); |
712 | 1911 |
1912 scene_.SetLayer(layerDepth_, texture.release()); | |
691 | 1913 } |
1914 } | |
1915 }; | |
1916 | |
1917 | |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1918 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1919 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1920 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1921 class NativeOracle : public IOracle |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1922 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1923 private: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1924 class Item : public Orthanc::IDynamicObject |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1925 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1926 private: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1927 const OrthancStone::IObserver& receiver_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1928 std::auto_ptr<IOracleCommand> command_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1929 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1930 public: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1931 Item(const OrthancStone::IObserver& receiver, |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1932 IOracleCommand* command) : |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1933 receiver_(receiver), |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1934 command_(command) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1935 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1936 if (command == NULL) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1937 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1938 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1939 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1940 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1941 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1942 const OrthancStone::IObserver& GetReceiver() const |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1943 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1944 return receiver_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1945 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1946 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1947 const IOracleCommand& GetCommand() const |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1948 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1949 assert(command_.get() != NULL); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1950 return *command_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1951 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1952 }; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1953 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1954 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1955 enum State |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1956 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1957 State_Setup, |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1958 State_Running, |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1959 State_Stopped |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1960 }; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1961 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1962 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1963 IMessageEmitter& emitter_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1964 Orthanc::WebServiceParameters orthanc_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1965 Orthanc::SharedMessageQueue queue_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1966 State state_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1967 boost::mutex mutex_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1968 std::vector<boost::thread*> workers_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1969 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1970 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1971 void CopyHttpHeaders(Orthanc::HttpClient& client, |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1972 const HttpHeaders& headers) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1973 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1974 for (HttpHeaders::const_iterator it = headers.begin(); it != headers.end(); it++ ) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1975 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1976 client.AddHeader(it->first, it->second); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1977 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1978 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1979 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1980 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1981 void DecodeAnswer(std::string& answer, |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1982 const HttpHeaders& headers) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1983 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1984 Orthanc::HttpCompression contentEncoding = Orthanc::HttpCompression_None; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1985 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1986 for (HttpHeaders::const_iterator it = headers.begin(); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1987 it != headers.end(); ++it) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1988 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1989 std::string s; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1990 Orthanc::Toolbox::ToLowerCase(s, it->first); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1991 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1992 if (s == "content-encoding") |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1993 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1994 if (it->second == "gzip") |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1995 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1996 contentEncoding = Orthanc::HttpCompression_Gzip; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1997 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1998 else |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1999 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2000 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol, |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2001 "Unsupported HTTP Content-Encoding: " + it->second); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2002 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2003 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2004 break; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2005 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2006 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2007 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2008 if (contentEncoding == Orthanc::HttpCompression_Gzip) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2009 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2010 std::string compressed; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2011 answer.swap(compressed); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2012 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2013 Orthanc::GzipCompressor compressor; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2014 compressor.Uncompress(answer, compressed.c_str(), compressed.size()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2015 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2016 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2017 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2018 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2019 void Execute(const OrthancStone::IObserver& receiver, |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2020 const OrthancRestApiCommand& command) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2021 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2022 Orthanc::HttpClient client(orthanc_, command.GetUri()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2023 client.SetMethod(command.GetMethod()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2024 client.SetTimeout(command.GetTimeout()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2025 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2026 CopyHttpHeaders(client, command.GetHttpHeaders()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2027 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2028 if (command.GetMethod() == Orthanc::HttpMethod_Post || |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2029 command.GetMethod() == Orthanc::HttpMethod_Put) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2030 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2031 client.SetBody(command.GetBody()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2032 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2033 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2034 std::string answer; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2035 HttpHeaders answerHeaders; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2036 client.ApplyAndThrowException(answer, answerHeaders); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2037 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2038 DecodeAnswer(answer, answerHeaders); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2039 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2040 OrthancRestApiCommand::SuccessMessage message(command, answerHeaders, answer); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2041 emitter_.EmitMessage(receiver, message); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2042 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2043 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2044 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2045 void Execute(const OrthancStone::IObserver& receiver, |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2046 const GetOrthancImageCommand& command) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2047 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2048 Orthanc::HttpClient client(orthanc_, command.GetUri()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2049 client.SetTimeout(command.GetTimeout()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2050 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2051 CopyHttpHeaders(client, command.GetHttpHeaders()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2052 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2053 std::string answer; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2054 HttpHeaders answerHeaders; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2055 client.ApplyAndThrowException(answer, answerHeaders); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2056 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2057 DecodeAnswer(answer, answerHeaders); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2058 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2059 command.ProcessHttpAnswer(emitter_, receiver, answer, answerHeaders); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2060 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2061 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2062 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2063 void Execute(const OrthancStone::IObserver& receiver, |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2064 const GetOrthancWebViewerJpegCommand& command) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2065 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2066 Orthanc::HttpClient client(orthanc_, command.GetUri()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2067 client.SetTimeout(command.GetTimeout()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2068 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2069 CopyHttpHeaders(client, command.GetHttpHeaders()); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2070 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2071 std::string answer; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2072 HttpHeaders answerHeaders; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2073 client.ApplyAndThrowException(answer, answerHeaders); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2074 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2075 DecodeAnswer(answer, answerHeaders); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2076 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2077 command.ProcessHttpAnswer(emitter_, receiver, answer); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2078 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2079 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2080 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2081 void Step() |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2082 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2083 std::auto_ptr<Orthanc::IDynamicObject> object(queue_.Dequeue(100)); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2084 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2085 if (object.get() != NULL) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2086 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2087 const Item& item = dynamic_cast<Item&>(*object); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2088 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2089 try |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2090 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2091 switch (item.GetCommand().GetType()) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2092 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2093 case IOracleCommand::Type_OrthancRestApi: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2094 Execute(item.GetReceiver(), |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2095 dynamic_cast<const OrthancRestApiCommand&>(item.GetCommand())); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2096 break; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2097 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2098 case IOracleCommand::Type_GetOrthancImage: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2099 Execute(item.GetReceiver(), |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2100 dynamic_cast<const GetOrthancImageCommand&>(item.GetCommand())); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2101 break; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2102 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2103 case IOracleCommand::Type_GetOrthancWebViewerJpeg: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2104 Execute(item.GetReceiver(), |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2105 dynamic_cast<const GetOrthancWebViewerJpegCommand&>(item.GetCommand())); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2106 break; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2107 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2108 default: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2109 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2110 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2111 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2112 catch (Orthanc::OrthancException& e) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2113 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2114 LOG(ERROR) << "Exception within the oracle: " << e.What(); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2115 emitter_.EmitMessage(item.GetReceiver(), OracleCommandExceptionMessage(item.GetCommand(), e)); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2116 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2117 catch (...) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2118 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2119 LOG(ERROR) << "Native exception within the oracle"; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2120 emitter_.EmitMessage(item.GetReceiver(), OracleCommandExceptionMessage |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2121 (item.GetCommand(), Orthanc::ErrorCode_InternalError)); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2122 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2123 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2124 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2125 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2126 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2127 static void Worker(NativeOracle* that) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2128 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2129 assert(that != NULL); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2130 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2131 for (;;) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2132 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2133 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2134 boost::mutex::scoped_lock lock(that->mutex_); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2135 if (that->state_ != State_Running) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2136 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2137 return; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2138 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2139 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2140 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2141 that->Step(); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2142 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2143 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2144 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2145 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2146 void StopInternal() |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2147 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2148 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2149 boost::mutex::scoped_lock lock(mutex_); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2150 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2151 if (state_ == State_Setup || |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2152 state_ == State_Stopped) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2153 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2154 return; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2155 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2156 else |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2157 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2158 state_ = State_Stopped; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2159 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2160 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2161 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2162 for (size_t i = 0; i < workers_.size(); i++) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2163 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2164 if (workers_[i] != NULL) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2165 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2166 if (workers_[i]->joinable()) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2167 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2168 workers_[i]->join(); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2169 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2170 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2171 delete workers_[i]; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2172 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2173 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2174 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2175 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2176 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2177 public: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2178 NativeOracle(IMessageEmitter& emitter) : |
711 | 2179 emitter_(emitter), |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2180 state_(State_Setup), |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2181 workers_(4) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2182 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2183 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2184 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2185 virtual ~NativeOracle() |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2186 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2187 StopInternal(); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2188 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2189 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2190 void SetOrthancParameters(const Orthanc::WebServiceParameters& orthanc) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2191 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2192 boost::mutex::scoped_lock lock(mutex_); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2193 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2194 if (state_ != State_Setup) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2195 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2196 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2197 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2198 else |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2199 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2200 orthanc_ = orthanc; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2201 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2202 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2203 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2204 void SetWorkersCount(unsigned int count) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2205 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2206 boost::mutex::scoped_lock lock(mutex_); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2207 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2208 if (count <= 0) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2209 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2210 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2211 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2212 else if (state_ != State_Setup) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2213 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2214 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2215 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2216 else |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2217 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2218 workers_.resize(count); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2219 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2220 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2221 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2222 void Start() |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2223 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2224 boost::mutex::scoped_lock lock(mutex_); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2225 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2226 if (state_ != State_Setup) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2227 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2228 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2229 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2230 else |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2231 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2232 state_ = State_Running; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2233 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2234 for (unsigned int i = 0; i < workers_.size(); i++) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2235 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2236 workers_[i] = new boost::thread(Worker, this); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2237 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2238 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2239 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2240 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2241 void Stop() |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2242 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2243 StopInternal(); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2244 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2245 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2246 virtual void Schedule(const OrthancStone::IObserver& receiver, |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2247 IOracleCommand* command) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2248 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2249 queue_.Enqueue(new Item(receiver, command)); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2250 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2251 }; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2252 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2253 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2254 class NativeApplicationContext : public IMessageEmitter |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2255 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2256 private: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2257 boost::shared_mutex mutex_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2258 OrthancStone::MessageBroker broker_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2259 OrthancStone::IObservable oracleObservable_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2260 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2261 public: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2262 NativeApplicationContext() : |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2263 oracleObservable_(broker_) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2264 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2265 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2266 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2267 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2268 virtual void EmitMessage(const OrthancStone::IObserver& observer, |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2269 const OrthancStone::IMessage& message) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2270 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2271 try |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2272 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2273 boost::unique_lock<boost::shared_mutex> lock(mutex_); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2274 oracleObservable_.EmitMessage(observer, message); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2275 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2276 catch (Orthanc::OrthancException& e) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2277 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2278 LOG(ERROR) << "Exception while emitting a message: " << e.What(); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2279 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2280 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2281 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2282 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2283 class ReaderLock : public boost::noncopyable |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2284 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2285 private: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2286 NativeApplicationContext& that_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2287 boost::shared_lock<boost::shared_mutex> lock_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2288 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2289 public: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2290 ReaderLock(NativeApplicationContext& that) : |
711 | 2291 that_(that), |
2292 lock_(that.mutex_) | |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2293 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2294 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2295 }; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2296 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2297 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2298 class WriterLock : public boost::noncopyable |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2299 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2300 private: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2301 NativeApplicationContext& that_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2302 boost::unique_lock<boost::shared_mutex> lock_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2303 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2304 public: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2305 WriterLock(NativeApplicationContext& that) : |
711 | 2306 that_(that), |
2307 lock_(that.mutex_) | |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2308 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2309 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2310 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2311 OrthancStone::MessageBroker& GetBroker() |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2312 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2313 return that_.broker_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2314 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2315 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2316 OrthancStone::IObservable& GetOracleObservable() |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2317 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2318 return that_.oracleObservable_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2319 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2320 }; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2321 }; |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2322 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2323 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2324 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2325 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2326 class Toto : public OrthancStone::IObserver |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2327 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2328 private: |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2329 void Handle(const Refactoring::OrthancRestApiCommand::SuccessMessage& message) |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2330 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2331 Json::Value v; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
2332 message.ParseJsonBody(v); |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2333 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2334 printf("ICI [%s]\n", v.toStyledString().c_str()); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2335 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2336 |
641 | 2337 void Handle(const Refactoring::GetOrthancImageCommand::SuccessMessage& message) |
637
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
2338 { |
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
2339 printf("IMAGE %dx%d\n", message.GetImage().GetWidth(), message.GetImage().GetHeight()); |
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
2340 } |
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
2341 |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2342 void Handle(const Refactoring::GetOrthancWebViewerJpegCommand::SuccessMessage& message) |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2343 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2344 printf("WebViewer %dx%d\n", message.GetImage().GetWidth(), message.GetImage().GetHeight()); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2345 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2346 |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2347 void Handle(const Refactoring::OracleCommandExceptionMessage& message) |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2348 { |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2349 printf("EXCEPTION: [%s] on command type %d\n", message.GetException().What(), message.GetCommand().GetType()); |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2350 |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2351 switch (message.GetCommand().GetType()) |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2352 { |
641 | 2353 case Refactoring::IOracleCommand::Type_GetOrthancWebViewerJpeg: |
2354 printf("URI: [%s]\n", dynamic_cast<const Refactoring::GetOrthancWebViewerJpegCommand&> | |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2355 (message.GetCommand()).GetUri().c_str()); |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2356 break; |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2357 |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2358 default: |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2359 break; |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2360 } |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2361 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2362 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2363 public: |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2364 Toto(OrthancStone::IObservable& oracle) : |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2365 IObserver(oracle.GetBroker()) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2366 { |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
2367 oracle.RegisterObserverCallback |
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
2368 (new OrthancStone::Callable |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2369 <Toto, Refactoring::OrthancRestApiCommand::SuccessMessage>(*this, &Toto::Handle)); |
637
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
2370 |
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
2371 oracle.RegisterObserverCallback |
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
2372 (new OrthancStone::Callable |
641 | 2373 <Toto, Refactoring::GetOrthancImageCommand::SuccessMessage>(*this, &Toto::Handle)); |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2374 |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2375 oracle.RegisterObserverCallback |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2376 (new OrthancStone::Callable |
711 | 2377 <Toto, Refactoring::GetOrthancWebViewerJpegCommand::SuccessMessage>(*this, &Toto::Handle)); |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2378 |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2379 oracle.RegisterObserverCallback |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2380 (new OrthancStone::Callable |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2381 <Toto, Refactoring::OracleCommandExceptionMessage>(*this, &Toto::Handle)); |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2382 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2383 }; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2384 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2385 |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2386 void Run(Refactoring::NativeApplicationContext& context, |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2387 Refactoring::IOracle& oracle) |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2388 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2389 std::auto_ptr<Toto> toto; |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2390 std::auto_ptr<Refactoring::VolumeSeriesOrthancLoader> loader1, loader2; |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2391 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2392 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2393 Refactoring::NativeApplicationContext::WriterLock lock(context); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2394 toto.reset(new Toto(lock.GetOracleObservable())); |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2395 loader1.reset(new Refactoring::VolumeSeriesOrthancLoader(oracle, lock.GetOracleObservable())); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2396 loader2.reset(new Refactoring::VolumeSeriesOrthancLoader(oracle, lock.GetOracleObservable())); |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
2397 } |
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
2398 |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2399 if (1) |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2400 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2401 Json::Value v = Json::objectValue; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2402 v["Level"] = "Series"; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2403 v["Query"] = Json::objectValue; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2404 |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2405 std::auto_ptr<Refactoring::OrthancRestApiCommand> command(new Refactoring::OrthancRestApiCommand); |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2406 command->SetMethod(Orthanc::HttpMethod_Post); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2407 command->SetUri("/tools/find"); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2408 command->SetBody(v); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2409 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
2410 oracle.Schedule(*toto, command.release()); |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2411 } |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
2412 |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2413 if (1) |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2414 { |
641 | 2415 std::auto_ptr<Refactoring::GetOrthancImageCommand> command(new Refactoring::GetOrthancImageCommand); |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2416 command->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Jpeg))); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2417 command->SetUri("/instances/6687cc73-07cae193-52ff29c8-f646cb16-0753ed92/preview"); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2418 oracle.Schedule(*toto, command.release()); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2419 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2420 |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2421 if (1) |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2422 { |
641 | 2423 std::auto_ptr<Refactoring::GetOrthancImageCommand> command(new Refactoring::GetOrthancImageCommand); |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2424 command->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Png))); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2425 command->SetUri("/instances/6687cc73-07cae193-52ff29c8-f646cb16-0753ed92/preview"); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2426 oracle.Schedule(*toto, command.release()); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2427 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2428 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2429 if (1) |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2430 { |
641 | 2431 std::auto_ptr<Refactoring::GetOrthancImageCommand> command(new Refactoring::GetOrthancImageCommand); |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2432 command->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Png))); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2433 command->SetUri("/instances/6687cc73-07cae193-52ff29c8-f646cb16-0753ed92/image-uint16"); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2434 oracle.Schedule(*toto, command.release()); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2435 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2436 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2437 if (1) |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2438 { |
641 | 2439 std::auto_ptr<Refactoring::GetOrthancImageCommand> command(new Refactoring::GetOrthancImageCommand); |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2440 command->SetHttpHeader("Accept-Encoding", "gzip"); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2441 command->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Pam))); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2442 command->SetUri("/instances/6687cc73-07cae193-52ff29c8-f646cb16-0753ed92/image-uint16"); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2443 oracle.Schedule(*toto, command.release()); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2444 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2445 |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2446 if (1) |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2447 { |
641 | 2448 std::auto_ptr<Refactoring::GetOrthancImageCommand> command(new Refactoring::GetOrthancImageCommand); |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2449 command->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Pam))); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2450 command->SetUri("/instances/6687cc73-07cae193-52ff29c8-f646cb16-0753ed92/image-uint16"); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2451 oracle.Schedule(*toto, command.release()); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2452 } |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2453 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2454 if (1) |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2455 { |
641 | 2456 std::auto_ptr<Refactoring::GetOrthancWebViewerJpegCommand> command(new Refactoring::GetOrthancWebViewerJpegCommand); |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2457 command->SetHttpHeader("Accept-Encoding", "gzip"); |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2458 command->SetInstance("e6c7c20b-c9f65d7e-0d76f2e2-830186f2-3e3c600e"); |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2459 command->SetQuality(90); |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2460 oracle.Schedule(*toto, command.release()); |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2461 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2462 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2463 |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
2464 // 2017-11-17-Anonymized |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2465 //loader1->LoadSeries("cb3ea4d1-d08f3856-ad7b6314-74d88d77-60b05618"); // CT |
710 | 2466 //loader2->LoadInstance("41029085-71718346-811efac4-420e2c15-d39f99b6"); // RT-DOSE |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2467 |
661 | 2468 // Delphine |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2469 loader1->LoadSeries("5990e39c-51e5f201-fe87a54c-31a55943-e59ef80e"); // CT |
661 | 2470 |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2471 LOG(WARNING) << "...Waiting for Ctrl-C..."; |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2472 Orthanc::SystemToolbox::ServerBarrier(); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2473 //boost::this_thread::sleep(boost::posix_time::seconds(1)); |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2474 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2475 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2476 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2477 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2478 /** |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2479 * IMPORTANT: The full arguments to "main()" are needed for SDL on |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2480 * Windows. Otherwise, one gets the linking error "undefined reference |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2481 * to `SDL_main'". https://wiki.libsdl.org/FAQWindows |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2482 **/ |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2483 int main(int argc, char* argv[]) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2484 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2485 OrthancStone::StoneInitialize(); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2486 Orthanc::Logging::EnableInfoLevel(true); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2487 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2488 try |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2489 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2490 Refactoring::NativeApplicationContext context; |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2491 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2492 Refactoring::NativeOracle oracle(context); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2493 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2494 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2495 Orthanc::WebServiceParameters p; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2496 //p.SetUrl("http://localhost:8043/"); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2497 p.SetCredentials("orthanc", "orthanc"); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2498 oracle.SetOrthancParameters(p); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2499 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2500 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2501 oracle.Start(); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2502 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2503 Run(context, oracle); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2504 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2505 oracle.Stop(); |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2506 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2507 catch (Orthanc::OrthancException& e) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2508 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2509 LOG(ERROR) << "EXCEPTION: " << e.What(); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2510 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2511 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2512 OrthancStone::StoneFinalize(); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2513 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2514 return 0; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2515 } |