Mercurial > hg > orthanc-stone
annotate Samples/Sdl/Loader.cpp @ 800:98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 28 May 2019 14:14:10 +0200 |
parents | bc20e4c417ec |
children | f38c1fc08655 |
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 |
745 | 21 |
746 | 22 #include "../../Framework/Toolbox/DicomInstanceParameters.h" |
748 | 23 #include "../../Framework/Oracle/ThreadedOracle.h" |
746 | 24 #include "../../Framework/Oracle/GetOrthancWebViewerJpegCommand.h" |
25 #include "../../Framework/Oracle/GetOrthancImageCommand.h" | |
26 #include "../../Framework/Oracle/OrthancRestApiCommand.h" | |
745 | 27 #include "../../Framework/Oracle/SleepOracleCommand.h" |
28 #include "../../Framework/Oracle/OracleCommandExceptionMessage.h" | |
29 | |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 // From Stone |
712 | 31 #include "../../Framework/Loaders/BasicFetchingItemsSorter.h" |
32 #include "../../Framework/Loaders/BasicFetchingStrategy.h" | |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
33 #include "../../Framework/Scene2D/CairoCompositor.h" |
712 | 34 #include "../../Framework/Scene2D/Scene2D.h" |
767 | 35 #include "../../Framework/Scene2D/PolylineSceneLayer.h" |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
767
diff
changeset
|
36 #include "../../Framework/Scene2D/LookupTableTextureSceneLayer.h" |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
37 #include "../../Framework/StoneInitialization.h" |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
38 #include "../../Framework/Toolbox/GeometryToolbox.h" |
683
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
39 #include "../../Framework/Toolbox/SlicesSorter.h" |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
40 #include "../../Framework/Toolbox/DicomStructureSet.h" |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
41 #include "../../Framework/Volumes/ImageBuffer3D.h" |
742
fa5febe0f0c2
moved OrientedBoundingBox in the Volumes folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
735
diff
changeset
|
42 #include "../../Framework/Volumes/VolumeImageGeometry.h" |
781 | 43 #include "../../Framework/Volumes/VolumeReslicer.h" |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 // From Orthanc framework |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
46 #include <Core/DicomFormat/DicomArray.h> |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
47 #include <Core/Images/Image.h> |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 #include <Core/Images/ImageProcessing.h> |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
49 #include <Core/Images/PngWriter.h> |
787
1a28fce57ff3
Fixed Visual Studio 2008 build
Benjamin Golinvaux <bgo@osimis.io>
parents:
769
diff
changeset
|
50 #include <Core/Endianness.h> |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 #include <Core/Logging.h> |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 #include <Core/OrthancException.h> |
683
dbc1d8bfc68a
reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
681
diff
changeset
|
53 #include <Core/SystemToolbox.h> |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
54 #include <Core/Toolbox.h> |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
767
diff
changeset
|
57 #include <EmbeddedResources.h> |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
767
diff
changeset
|
58 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
767
diff
changeset
|
59 |
745 | 60 namespace OrthancStone |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 { |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
62 // Application-configurable, can be shared between 3D/2D |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
63 class ILayerStyleConfigurator |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
64 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
65 public: |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
66 virtual ~ILayerStyleConfigurator() |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
67 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
68 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
69 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
70 virtual uint64_t GetRevision() const = 0; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
71 |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
72 virtual TextureBaseSceneLayer* CreateTextureFromImage(const Orthanc::ImageAccessor& image) const = 0; |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
73 |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
74 virtual TextureBaseSceneLayer* CreateTextureFromDicom(const Orthanc::ImageAccessor& frame, |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
75 const DicomInstanceParameters& parameters) const = 0; |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
76 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
77 virtual void ApplyStyle(ISceneLayer& layer) const = 0; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
78 }; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
79 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
80 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
81 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
82 class LookupTableStyleConfigurator : public ILayerStyleConfigurator |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
83 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
84 private: |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
85 uint64_t revision_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
86 bool hasLut_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
87 std::string lut_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
88 bool hasRange_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
89 float minValue_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
90 float maxValue_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
91 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
92 public: |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
93 LookupTableStyleConfigurator() : |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
94 revision_(0), |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
95 hasLut_(false), |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
96 hasRange_(false) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
97 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
98 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
99 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
100 void SetLookupTable(Orthanc::EmbeddedResources::FileResourceId resource) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
101 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
102 hasLut_ = true; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
103 Orthanc::EmbeddedResources::GetFileResource(lut_, resource); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
104 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
105 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
106 void SetLookupTable(const std::string& lut) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
107 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
108 hasLut_ = true; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
109 lut_ = lut; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
110 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
111 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
112 void SetRange(float minValue, |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
113 float maxValue) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
114 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
115 if (minValue > maxValue) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
116 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
117 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
118 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
119 else |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
120 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
121 hasRange_ = true; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
122 minValue_ = minValue; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
123 maxValue_ = maxValue; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
124 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
125 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
126 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
127 virtual uint64_t GetRevision() const |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
128 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
129 return revision_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
130 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
131 |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
132 virtual TextureBaseSceneLayer* CreateTextureFromImage(const Orthanc::ImageAccessor& image) const |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
133 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
134 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
135 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
136 |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
137 virtual TextureBaseSceneLayer* CreateTextureFromDicom(const Orthanc::ImageAccessor& frame, |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
138 const DicomInstanceParameters& parameters) const |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
139 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
140 return parameters.CreateLookupTableTexture(frame); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
141 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
142 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
143 virtual void ApplyStyle(ISceneLayer& layer) const |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
144 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
145 LookupTableTextureSceneLayer& l = dynamic_cast<LookupTableTextureSceneLayer&>(layer); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
146 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
147 if (hasLut_) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
148 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
149 l.SetLookupTable(lut_); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
150 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
151 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
152 if (hasRange_) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
153 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
154 l.SetRange(minValue_, maxValue_); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
155 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
156 else |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
157 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
158 l.FitRange(); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
159 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
160 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
161 }; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
162 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
163 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
164 class GrayscaleStyleConfigurator : public ILayerStyleConfigurator |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
165 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
166 private: |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
167 uint64_t revision_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
168 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
169 public: |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
170 GrayscaleStyleConfigurator() : |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
171 revision_(0) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
172 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
173 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
174 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
175 virtual uint64_t GetRevision() const |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
176 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
177 return revision_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
178 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
179 |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
180 virtual TextureBaseSceneLayer* CreateTextureFromImage(const Orthanc::ImageAccessor& image) const |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
181 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
182 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
183 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
184 |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
185 virtual TextureBaseSceneLayer* CreateTextureFromDicom(const Orthanc::ImageAccessor& frame, |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
186 const DicomInstanceParameters& parameters) const |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
187 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
188 return parameters.CreateTexture(frame); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
189 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
190 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
191 virtual void ApplyStyle(ISceneLayer& layer) const |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
192 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
193 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
194 }; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
195 |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
196 /** |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
197 This interface is implemented by objects representing 3D volume data and |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
198 that are able to return an object that represent a slice of their data |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
199 and are able to create the corresponding visual representation. |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
200 */ |
757 | 201 class IVolumeSlicer : public boost::noncopyable |
202 { | |
203 public: | |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
204 /** |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
205 This interface is implemented by objects representing a slice of |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
206 volume data and that are able to create a 2D layer to display a this |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
207 slice. |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
208 |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
209 The CreateSceneLayer factory method is called with an optional |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
210 configurator that possibly impacts the ISceneLayer subclass that is |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
211 created (for instance, if a LUT must be applied on the texture when |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
212 displaying it) |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
213 */ |
781 | 214 class IExtractedSlice : public boost::noncopyable |
757 | 215 { |
216 public: | |
781 | 217 virtual ~IExtractedSlice() |
757 | 218 { |
219 } | |
220 | |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
221 /** |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
222 Invalid slices are created when the data is not ready yet or if the |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
223 cut is outside of the available geometry. |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
224 */ |
757 | 225 virtual bool IsValid() = 0; |
226 | |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
227 /** |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
228 This retrieves the *revision* that gets incremented every time the |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
229 underlying object undergoes a mutable operation (that it, changes its |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
230 state). |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
231 This **must** be a cheap call. |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
232 */ |
757 | 233 virtual uint64_t GetRevision() = 0; |
234 | |
235 // This call can take some time | |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
236 virtual ISceneLayer* CreateSceneLayer(const ILayerStyleConfigurator* configurator, // possibly absent |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
237 const CoordinateSystem3D& cuttingPlane) = 0; |
757 | 238 }; |
239 | |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
240 /** |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
241 See IExtractedSlice.IsValid() |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
242 */ |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
243 class InvalidSlice : public IExtractedSlice |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
244 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
245 public: |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
246 virtual bool IsValid() |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
247 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
248 return false; |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
249 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
250 |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
251 virtual uint64_t GetRevision() |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
252 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
253 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
254 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
255 |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
256 virtual ISceneLayer* CreateSceneLayer(const ILayerStyleConfigurator* configurator, |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
257 const CoordinateSystem3D& cuttingPlane) |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
258 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
259 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
260 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
261 }; |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
262 |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
263 |
757 | 264 virtual ~IVolumeSlicer() |
265 { | |
266 } | |
267 | |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
268 /** |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
269 This method is implemented by the objects representing volumetric data |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
270 and must returns an IExtractedSlice subclass that contains all the data |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
271 needed to, later one, create its visual representation through |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
272 CreateSceneLayer. |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
273 Subclasses a.o.: ExtractedSlice, Slice, InvalidSlice |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
274 */ |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
275 virtual IExtractedSlice* ExtractSlice(const CoordinateSystem3D& cuttingPlane) = 0; |
759 | 276 }; |
277 | |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
278 /** |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
279 This class combines a 3D image buffer, a 3D volume geometry and |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
280 information about the DICOM parameters of the series. |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
281 (MPR means MultiPlanar Reconstruction) |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
282 */ |
783 | 283 class DicomVolumeImage : public boost::noncopyable |
284 { | |
285 public: | |
286 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, GeometryReadyMessage, DicomVolumeImage); | |
287 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, ContentUpdatedMessage, DicomVolumeImage); | |
288 | |
289 private: | |
290 uint64_t revision_; | |
291 std::auto_ptr<VolumeImageGeometry> geometry_; | |
292 std::auto_ptr<ImageBuffer3D> image_; | |
293 std::auto_ptr<DicomInstanceParameters> parameters_; | |
294 | |
295 void CheckHasGeometry() const | |
296 { | |
297 if (!HasGeometry()) | |
298 { | |
299 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
300 } | |
301 } | |
302 | |
303 public: | |
304 DicomVolumeImage() : | |
305 revision_(0) | |
306 { | |
307 } | |
308 | |
309 void IncrementRevision() | |
310 { | |
311 revision_ ++; | |
312 } | |
313 | |
314 void Initialize(const VolumeImageGeometry& geometry, | |
315 Orthanc::PixelFormat format) | |
316 { | |
317 geometry_.reset(new VolumeImageGeometry(geometry)); | |
318 image_.reset(new ImageBuffer3D(format, geometry_->GetWidth(), geometry_->GetHeight(), | |
319 geometry_->GetDepth(), false /* don't compute range */)); | |
320 | |
321 revision_ ++; | |
322 } | |
323 | |
324 void SetDicomParameters(const DicomInstanceParameters& parameters) | |
325 { | |
326 parameters_.reset(parameters.Clone()); | |
327 revision_ ++; | |
328 } | |
329 | |
330 uint64_t GetRevision() const | |
331 { | |
332 return revision_; | |
333 } | |
334 | |
335 bool HasGeometry() const | |
336 { | |
337 return (geometry_.get() != NULL && | |
338 image_.get() != NULL); | |
339 } | |
340 | |
341 ImageBuffer3D& GetPixelData() | |
342 { | |
343 CheckHasGeometry(); | |
344 return *image_; | |
345 } | |
346 | |
347 const ImageBuffer3D& GetPixelData() const | |
348 { | |
349 CheckHasGeometry(); | |
350 return *image_; | |
351 } | |
352 | |
353 const VolumeImageGeometry& GetGeometry() const | |
354 { | |
355 CheckHasGeometry(); | |
356 return *geometry_; | |
357 } | |
358 | |
359 bool HasDicomParameters() const | |
360 { | |
361 return parameters_.get() != NULL; | |
362 } | |
363 | |
364 const DicomInstanceParameters& GetDicomParameters() const | |
365 { | |
366 if (HasDicomParameters()) | |
367 { | |
368 return *parameters_; | |
369 } | |
370 else | |
371 { | |
372 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
373 } | |
374 } | |
375 }; | |
376 | |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
377 /** |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
378 Implements the IVolumeSlicer on Dicom volume data when the cutting plane |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
379 that is supplied to the slicer is either axial, sagittal or coronal. |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
380 Arbitrary planes are *not* supported |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
381 */ |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
382 class DicomVolumeImageMPRSlicer : public IVolumeSlicer |
667
e9339f2b5de7
refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
661
diff
changeset
|
383 { |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
384 public: |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
385 class Slice : public IExtractedSlice |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
386 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
387 private: |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
388 const DicomVolumeImage& volume_; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
389 bool valid_; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
390 VolumeProjection projection_; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
391 unsigned int sliceIndex_; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
392 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
393 void CheckValid() const |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
394 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
395 if (!valid_) |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
396 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
397 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
398 } |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
399 } |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
400 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
401 protected: |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
402 // Can be overloaded in subclasses |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
403 virtual uint64_t GetRevisionInternal(VolumeProjection projection, |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
404 unsigned int sliceIndex) const |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
405 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
406 return volume_.GetRevision(); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
407 } |
757 | 408 |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
409 public: |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
410 /** |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
411 The constructor initializes the type of projection (axial, sagittal or |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
412 coronal) and the corresponding slice index, from the cutting plane. |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
413 */ |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
414 Slice(const DicomVolumeImage& volume, |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
415 const CoordinateSystem3D& cuttingPlane) : |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
416 volume_(volume) |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
417 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
418 valid_ = (volume_.HasDicomParameters() && |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
419 volume_.GetGeometry().DetectSlice(projection_, sliceIndex_, cuttingPlane)); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
420 } |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
421 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
422 VolumeProjection GetProjection() const |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
423 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
424 CheckValid(); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
425 return projection_; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
426 } |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
427 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
428 unsigned int GetSliceIndex() const |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
429 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
430 CheckValid(); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
431 return sliceIndex_; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
432 } |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
433 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
434 virtual bool IsValid() |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
435 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
436 return valid_; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
437 } |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
438 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
439 virtual uint64_t GetRevision() |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
440 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
441 CheckValid(); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
442 return GetRevisionInternal(projection_, sliceIndex_); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
443 } |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
444 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
445 virtual ISceneLayer* CreateSceneLayer(const ILayerStyleConfigurator* configurator, |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
446 const CoordinateSystem3D& cuttingPlane) |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
447 { |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
448 CheckValid(); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
449 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
450 if (configurator == NULL) |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
451 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
452 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer, |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
453 "A style configurator is mandatory for textures"); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
454 } |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
455 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
456 std::auto_ptr<TextureBaseSceneLayer> texture; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
457 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
458 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
459 const DicomInstanceParameters& parameters = volume_.GetDicomParameters(); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
460 ImageBuffer3D::SliceReader reader(volume_.GetPixelData(), projection_, sliceIndex_); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
461 texture.reset(dynamic_cast<TextureBaseSceneLayer*> |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
462 (configurator->CreateTextureFromDicom(reader.GetAccessor(), parameters))); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
463 } |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
464 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
465 const CoordinateSystem3D& system = volume_.GetGeometry().GetProjectionGeometry(projection_); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
466 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
467 double x0, y0, x1, y1; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
468 cuttingPlane.ProjectPoint(x0, y0, system.GetOrigin()); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
469 cuttingPlane.ProjectPoint(x1, y1, system.GetOrigin() + system.GetAxisX()); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
470 texture->SetOrigin(x0, y0); |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
471 |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
472 double dx = x1 - x0; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
473 double dy = y1 - y0; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
474 if (!LinearAlgebra::IsCloseToZero(dx) || |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
475 !LinearAlgebra::IsCloseToZero(dy)) |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
476 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
477 texture->SetAngle(atan2(dy, dx)); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
478 } |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
479 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
480 Vector tmp = volume_.GetGeometry().GetVoxelDimensions(projection_); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
481 texture->SetPixelSpacing(tmp[0], tmp[1]); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
482 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
483 return texture.release(); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
484 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
485 #if 0 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
486 double w = texture->GetTexture().GetWidth() * tmp[0]; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
487 double h = texture->GetTexture().GetHeight() * tmp[1]; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
488 printf("%.1f %.1f %.1f => %.1f %.1f => %.1f %.1f\n", |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
489 system.GetOrigin() [0], |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
490 system.GetOrigin() [1], |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
491 system.GetOrigin() [2], |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
492 x0, y0, x0 + w, y0 + h); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
493 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
494 std::auto_ptr<PolylineSceneLayer> toto(new PolylineSceneLayer); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
495 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
496 PolylineSceneLayer::Chain c; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
497 c.push_back(ScenePoint2D(x0, y0)); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
498 c.push_back(ScenePoint2D(x0 + w, y0)); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
499 c.push_back(ScenePoint2D(x0 + w, y0 + h)); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
500 c.push_back(ScenePoint2D(x0, y0 + h)); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
501 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
502 toto->AddChain(c, true); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
503 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
504 return toto.release(); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
505 #endif |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
506 } |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
507 }; |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
508 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
509 private: |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
510 boost::shared_ptr<DicomVolumeImage> volume_; |
757 | 511 |
512 public: | |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
513 DicomVolumeImageMPRSlicer(const boost::shared_ptr<DicomVolumeImage>& volume) : |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
514 volume_(volume) |
757 | 515 { |
516 } | |
517 | |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
518 virtual IExtractedSlice* ExtractSlice(const CoordinateSystem3D& cuttingPlane) |
757 | 519 { |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
520 if (volume_->HasGeometry()) |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
521 { |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
522 return new Slice(*volume_, cuttingPlane); |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
523 } |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
524 else |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
525 { |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
526 return new IVolumeSlicer::InvalidSlice; |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
527 } |
757 | 528 } |
529 }; | |
530 | |
781 | 531 |
532 | |
533 | |
712 | 534 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
535 class OrthancSeriesVolumeProgressiveLoader : |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
536 public IObserver, |
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
537 public IObservable, |
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
538 public IVolumeSlicer |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
539 { |
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
540 private: |
711 | 541 static const unsigned int LOW_QUALITY = 0; |
542 static const unsigned int MIDDLE_QUALITY = 1; | |
543 static const unsigned int BEST_QUALITY = 2; | |
544 | |
545 | |
783 | 546 // Helper class internal to OrthancSeriesVolumeProgressiveLoader |
547 class SeriesGeometry : public boost::noncopyable | |
548 { | |
549 private: | |
550 void CheckSlice(size_t index, | |
551 const DicomInstanceParameters& reference) const | |
552 { | |
553 const DicomInstanceParameters& slice = *slices_[index]; | |
554 | |
555 if (!GeometryToolbox::IsParallel( | |
556 reference.GetGeometry().GetNormal(), | |
557 slice.GetGeometry().GetNormal())) | |
558 { | |
559 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, | |
560 "A slice in the volume image is not parallel to the others"); | |
561 } | |
562 | |
563 if (reference.GetExpectedPixelFormat() != slice.GetExpectedPixelFormat()) | |
564 { | |
565 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat, | |
566 "The pixel format changes across the slices of the volume image"); | |
567 } | |
568 | |
569 if (reference.GetImageInformation().GetWidth() != slice.GetImageInformation().GetWidth() || | |
570 reference.GetImageInformation().GetHeight() != slice.GetImageInformation().GetHeight()) | |
571 { | |
572 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize, | |
573 "The width/height of slices are not constant in the volume image"); | |
574 } | |
575 | |
576 if (!LinearAlgebra::IsNear(reference.GetPixelSpacingX(), slice.GetPixelSpacingX()) || | |
577 !LinearAlgebra::IsNear(reference.GetPixelSpacingY(), slice.GetPixelSpacingY())) | |
578 { | |
579 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, | |
580 "The pixel spacing of the slices change across the volume image"); | |
581 } | |
582 } | |
583 | |
584 | |
585 void CheckVolume() const | |
586 { | |
587 for (size_t i = 0; i < slices_.size(); i++) | |
588 { | |
589 assert(slices_[i] != NULL); | |
590 if (slices_[i]->GetImageInformation().GetNumberOfFrames() != 1) | |
591 { | |
592 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, | |
593 "This class does not support multi-frame images"); | |
594 } | |
595 } | |
596 | |
597 if (slices_.size() != 0) | |
598 { | |
599 const DicomInstanceParameters& reference = *slices_[0]; | |
600 | |
601 for (size_t i = 1; i < slices_.size(); i++) | |
602 { | |
603 CheckSlice(i, reference); | |
604 } | |
605 } | |
606 } | |
607 | |
608 | |
609 void Clear() | |
610 { | |
611 for (size_t i = 0; i < slices_.size(); i++) | |
612 { | |
613 assert(slices_[i] != NULL); | |
614 delete slices_[i]; | |
615 } | |
616 | |
617 slices_.clear(); | |
618 slicesRevision_.clear(); | |
619 } | |
620 | |
621 | |
622 void CheckSliceIndex(size_t index) const | |
623 { | |
624 if (!HasGeometry()) | |
625 { | |
626 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
627 } | |
628 else if (index >= slices_.size()) | |
629 { | |
630 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
631 } | |
632 else | |
633 { | |
634 assert(slices_.size() == GetImageGeometry().GetDepth() && | |
635 slices_.size() == slicesRevision_.size()); | |
636 } | |
637 } | |
638 | |
639 | |
640 std::auto_ptr<VolumeImageGeometry> geometry_; | |
641 std::vector<DicomInstanceParameters*> slices_; | |
642 std::vector<uint64_t> slicesRevision_; | |
643 | |
644 public: | |
645 ~SeriesGeometry() | |
646 { | |
647 Clear(); | |
648 } | |
649 | |
650 // WARNING: The payload of "slices" must be of class "DicomInstanceParameters" | |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
651 // (called with the slices created in LoadGeometry) |
783 | 652 void ComputeGeometry(SlicesSorter& slices) |
653 { | |
654 Clear(); | |
655 | |
656 if (!slices.Sort()) | |
657 { | |
658 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, | |
659 "Cannot sort the 3D slices of a DICOM series"); | |
660 } | |
661 | |
662 if (slices.GetSlicesCount() == 0) | |
663 { | |
664 geometry_.reset(new VolumeImageGeometry); | |
665 } | |
666 else | |
667 { | |
668 slices_.reserve(slices.GetSlicesCount()); | |
669 slicesRevision_.resize(slices.GetSlicesCount(), 0); | |
670 | |
671 for (size_t i = 0; i < slices.GetSlicesCount(); i++) | |
672 { | |
673 const DicomInstanceParameters& slice = | |
674 dynamic_cast<const DicomInstanceParameters&>(slices.GetSlicePayload(i)); | |
675 slices_.push_back(new DicomInstanceParameters(slice)); | |
676 } | |
677 | |
678 CheckVolume(); | |
679 | |
680 const double spacingZ = slices.ComputeSpacingBetweenSlices(); | |
681 LOG(INFO) << "Computed spacing between slices: " << spacingZ << "mm"; | |
682 | |
683 const DicomInstanceParameters& parameters = *slices_[0]; | |
684 | |
685 geometry_.reset(new VolumeImageGeometry); | |
686 geometry_->SetSize(parameters.GetImageInformation().GetWidth(), | |
687 parameters.GetImageInformation().GetHeight(), | |
688 static_cast<unsigned int>(slices.GetSlicesCount())); | |
689 geometry_->SetAxialGeometry(slices.GetSliceGeometry(0)); | |
690 geometry_->SetVoxelDimensions(parameters.GetPixelSpacingX(), | |
691 parameters.GetPixelSpacingY(), spacingZ); | |
692 } | |
693 } | |
694 | |
695 bool HasGeometry() const | |
696 { | |
697 return geometry_.get() != NULL; | |
698 } | |
699 | |
700 const VolumeImageGeometry& GetImageGeometry() const | |
701 { | |
702 if (!HasGeometry()) | |
703 { | |
704 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
705 } | |
706 else | |
707 { | |
708 assert(slices_.size() == geometry_->GetDepth()); | |
709 return *geometry_; | |
710 } | |
711 } | |
712 | |
713 const DicomInstanceParameters& GetSliceParameters(size_t index) const | |
714 { | |
715 CheckSliceIndex(index); | |
716 return *slices_[index]; | |
717 } | |
718 | |
719 uint64_t GetSliceRevision(size_t index) const | |
720 { | |
721 CheckSliceIndex(index); | |
722 return slicesRevision_[index]; | |
723 } | |
724 | |
725 void IncrementSliceRevision(size_t index) | |
726 { | |
727 CheckSliceIndex(index); | |
728 slicesRevision_[index] ++; | |
729 } | |
730 }; | |
731 | |
732 | |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
733 class ExtractedSlice : public DicomVolumeImageMPRSlicer::Slice |
783 | 734 { |
735 private: | |
736 const OrthancSeriesVolumeProgressiveLoader& that_; | |
737 | |
738 protected: | |
739 virtual uint64_t GetRevisionInternal(VolumeProjection projection, | |
740 unsigned int sliceIndex) const | |
741 { | |
742 if (projection == VolumeProjection_Axial) | |
743 { | |
744 return that_.seriesGeometry_.GetSliceRevision(sliceIndex); | |
745 } | |
746 else | |
747 { | |
748 // For coronal and sagittal projections, we take the global | |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
749 // revision of the volume because even if a single slice changes, |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
750 // this means the projection will yield a different result --> |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
751 // we must increase the revision as soon as any slice changes |
783 | 752 return that_.volume_->GetRevision(); |
753 } | |
754 } | |
755 | |
756 public: | |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
757 ExtractedSlice(const OrthancSeriesVolumeProgressiveLoader& that, |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
758 const CoordinateSystem3D& plane) : |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
759 DicomVolumeImageMPRSlicer::Slice(*that.volume_, plane), |
783 | 760 that_(that) |
761 { | |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
762 if (that_.strategy_.get() != NULL && |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
763 IsValid() && |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
764 GetProjection() == VolumeProjection_Axial) |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
765 { |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
766 that_.strategy_->SetCurrent(GetSliceIndex()); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
767 } |
783 | 768 } |
769 }; | |
770 | |
771 | |
772 | |
711 | 773 static unsigned int GetSliceIndexPayload(const OracleCommandWithPayload& command) |
774 { | |
775 return dynamic_cast< const Orthanc::SingleValueObject<unsigned int>& >(command.GetPayload()).GetValue(); | |
776 } | |
777 | |
778 | |
779 void ScheduleNextSliceDownload() | |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
780 { |
711 | 781 assert(strategy_.get() != NULL); |
782 | |
783 unsigned int sliceIndex, quality; | |
784 | |
785 if (strategy_->GetNext(sliceIndex, quality)) | |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
786 { |
711 | 787 assert(quality <= BEST_QUALITY); |
788 | |
783 | 789 const DicomInstanceParameters& slice = seriesGeometry_.GetSliceParameters(sliceIndex); |
711 | 790 |
791 const std::string& instance = slice.GetOrthancInstanceIdentifier(); | |
792 if (instance.empty()) | |
793 { | |
794 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
795 } | |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
796 |
745 | 797 std::auto_ptr<OracleCommandWithPayload> command; |
711 | 798 |
799 if (quality == BEST_QUALITY) | |
800 { | |
745 | 801 std::auto_ptr<GetOrthancImageCommand> tmp(new GetOrthancImageCommand); |
711 | 802 tmp->SetHttpHeader("Accept-Encoding", "gzip"); |
803 tmp->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Pam))); | |
804 tmp->SetInstanceUri(instance, slice.GetExpectedPixelFormat()); | |
805 tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat()); | |
806 command.reset(tmp.release()); | |
807 } | |
808 else | |
809 { | |
745 | 810 std::auto_ptr<GetOrthancWebViewerJpegCommand> tmp(new GetOrthancWebViewerJpegCommand); |
711 | 811 tmp->SetHttpHeader("Accept-Encoding", "gzip"); |
812 tmp->SetInstance(instance); | |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
813 tmp->SetQuality((quality == 0 ? 50 : 90)); |
711 | 814 tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat()); |
815 command.reset(tmp.release()); | |
816 } | |
817 | |
818 command->SetPayload(new Orthanc::SingleValueObject<unsigned int>(sliceIndex)); | |
819 oracle_.Schedule(*this, command.release()); | |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
820 } |
711 | 821 } |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
822 |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
823 /** |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
824 This is called in response to GET "/series/XXXXXXXXXXXXX/instances-tags" |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
825 */ |
711 | 826 void LoadGeometry(const OrthancRestApiCommand::SuccessMessage& message) |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
827 { |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
828 Json::Value body; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
829 message.ParseJsonBody(body); |
711 | 830 |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
831 if (body.type() != Json::objectValue) |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
832 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
833 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
834 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
835 |
710 | 836 { |
837 Json::Value::Members instances = body.getMemberNames(); | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
838 |
745 | 839 SlicesSorter slices; |
710 | 840 |
841 for (size_t i = 0; i < instances.size(); i++) | |
842 { | |
843 Orthanc::DicomMap dicom; | |
844 dicom.FromDicomAsJson(body[instances[i]]); | |
845 | |
846 std::auto_ptr<DicomInstanceParameters> instance(new DicomInstanceParameters(dicom)); | |
847 instance->SetOrthancInstanceIdentifier(instances[i]); | |
848 | |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
849 // the 3D plane corresponding to the slice |
745 | 850 CoordinateSystem3D geometry = instance->GetGeometry(); |
710 | 851 slices.AddSlice(geometry, instance.release()); |
852 } | |
853 | |
783 | 854 seriesGeometry_.ComputeGeometry(slices); |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
855 } |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
856 |
783 | 857 size_t slicesCount = seriesGeometry_.GetImageGeometry().GetDepth(); |
858 | |
859 if (slicesCount == 0) | |
860 { | |
861 volume_->Initialize(seriesGeometry_.GetImageGeometry(), Orthanc::PixelFormat_Grayscale8); | |
862 } | |
863 else | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
864 { |
783 | 865 const DicomInstanceParameters& parameters = seriesGeometry_.GetSliceParameters(0); |
866 | |
867 volume_->Initialize(seriesGeometry_.GetImageGeometry(), parameters.GetExpectedPixelFormat()); | |
868 volume_->SetDicomParameters(parameters); | |
869 volume_->GetPixelData().Clear(); | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
870 |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
871 strategy_.reset(new BasicFetchingStrategy(sorter_->CreateSorter(static_cast<unsigned int>(slicesCount)), BEST_QUALITY)); |
783 | 872 |
757 | 873 assert(simultaneousDownloads_ != 0); |
874 for (unsigned int i = 0; i < simultaneousDownloads_; i++) | |
710 | 875 { |
876 ScheduleNextSliceDownload(); | |
877 } | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
878 } |
779 | 879 |
783 | 880 slicesQuality_.resize(slicesCount, 0); |
881 | |
882 BroadcastMessage(DicomVolumeImage::GeometryReadyMessage(*volume_)); | |
883 } | |
884 | |
885 | |
886 void SetSliceContent(unsigned int sliceIndex, | |
887 const Orthanc::ImageAccessor& image, | |
888 unsigned int quality) | |
889 { | |
890 assert(sliceIndex < slicesQuality_.size() && | |
891 slicesQuality_.size() == volume_->GetPixelData().GetDepth()); | |
892 | |
893 if (quality >= slicesQuality_[sliceIndex]) | |
894 { | |
895 { | |
896 ImageBuffer3D::SliceWriter writer(volume_->GetPixelData(), VolumeProjection_Axial, sliceIndex); | |
897 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), image); | |
898 } | |
899 | |
900 volume_->IncrementRevision(); | |
901 seriesGeometry_.IncrementSliceRevision(sliceIndex); | |
902 slicesQuality_[sliceIndex] = quality; | |
903 | |
904 BroadcastMessage(DicomVolumeImage::ContentUpdatedMessage(*volume_)); | |
905 } | |
906 | |
907 ScheduleNextSliceDownload(); | |
710 | 908 } |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
909 |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
910 |
745 | 911 void LoadBestQualitySliceContent(const GetOrthancImageCommand::SuccessMessage& message) |
783 | 912 { |
913 SetSliceContent(GetSliceIndexPayload(message.GetOrigin()), message.GetImage(), BEST_QUALITY); | |
709
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
914 } |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
915 |
7457b4ee1f29
VolumeSeriesOrthancLoader uses a prefetching strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
692
diff
changeset
|
916 |
745 | 917 void LoadJpegSliceContent(const GetOrthancWebViewerJpegCommand::SuccessMessage& message) |
710 | 918 { |
711 | 919 unsigned int quality; |
710 | 920 |
711 | 921 switch (message.GetOrigin().GetQuality()) |
922 { | |
923 case 50: | |
924 quality = LOW_QUALITY; | |
925 break; | |
926 | |
927 case 90: | |
928 quality = MIDDLE_QUALITY; | |
929 break; | |
930 | |
931 default: | |
932 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
933 } | |
934 | |
783 | 935 SetSliceContent(GetSliceIndexPayload(message.GetOrigin()), message.GetImage(), quality); |
710 | 936 } |
711 | 937 |
710 | 938 |
783 | 939 IOracle& oracle_; |
940 bool active_; | |
941 unsigned int simultaneousDownloads_; | |
942 SeriesGeometry seriesGeometry_; | |
943 | |
944 boost::shared_ptr<DicomVolumeImage> volume_; | |
757 | 945 std::auto_ptr<IFetchingItemsSorter::IFactory> sorter_; |
946 std::auto_ptr<IFetchingStrategy> strategy_; | |
783 | 947 std::vector<unsigned int> slicesQuality_; |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
948 |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
949 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
950 public: |
783 | 951 OrthancSeriesVolumeProgressiveLoader(const boost::shared_ptr<DicomVolumeImage>& volume, |
952 IOracle& oracle, | |
757 | 953 IObservable& oracleObservable) : |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
954 IObserver(oracleObservable.GetBroker()), |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
955 IObservable(oracleObservable.GetBroker()), |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
956 oracle_(oracle), |
757 | 957 active_(false), |
958 simultaneousDownloads_(4), | |
783 | 959 volume_(volume), |
757 | 960 sorter_(new BasicFetchingItemsSorter::Factory) |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
961 { |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
962 oracleObservable.RegisterObserverCallback( |
757 | 963 new Callable<OrthancSeriesVolumeProgressiveLoader, OrthancRestApiCommand::SuccessMessage> |
964 (*this, &OrthancSeriesVolumeProgressiveLoader::LoadGeometry)); | |
965 | |
966 oracleObservable.RegisterObserverCallback( | |
967 new Callable<OrthancSeriesVolumeProgressiveLoader, GetOrthancImageCommand::SuccessMessage> | |
968 (*this, &OrthancSeriesVolumeProgressiveLoader::LoadBestQualitySliceContent)); | |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
969 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
970 oracleObservable.RegisterObserverCallback( |
757 | 971 new Callable<OrthancSeriesVolumeProgressiveLoader, GetOrthancWebViewerJpegCommand::SuccessMessage> |
972 (*this, &OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent)); | |
973 } | |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
974 |
757 | 975 void SetSimultaneousDownloads(unsigned int count) |
976 { | |
977 if (active_) | |
978 { | |
979 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
980 } | |
981 else if (count == 0) | |
982 { | |
983 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
984 } | |
985 else | |
986 { | |
987 simultaneousDownloads_ = count; | |
988 } | |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
989 } |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
990 |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
991 void LoadSeries(const std::string& seriesId) |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
992 { |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
993 if (active_) |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
994 { |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
995 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
996 } |
757 | 997 else |
998 { | |
999 active_ = true; | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1000 |
757 | 1001 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
1002 command->SetUri("/series/" + seriesId + "/instances-tags"); | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1003 |
757 | 1004 oracle_.Schedule(*this, command.release()); |
1005 } | |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
1006 } |
781 | 1007 |
783 | 1008 |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1009 virtual IExtractedSlice* ExtractSlice(const CoordinateSystem3D& cuttingPlane) |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1010 { |
783 | 1011 if (volume_->HasGeometry()) |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1012 { |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
1013 return new ExtractedSlice(*this, cuttingPlane); |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1014 } |
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1015 else |
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1016 { |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1017 return new IVolumeSlicer::InvalidSlice; |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1018 } |
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1019 } |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1020 }; |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1021 |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1022 |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1023 /** |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1024 This class is supplied with Oracle commands and will schedule up to |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1025 simultaneousDownloads_ of them at the same time, then will schedule the |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1026 rest once slots become available. It is used, a.o., by the |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1027 OrtancMultiframeVolumeLoader class. |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1028 */ |
794 | 1029 class LoaderStateMachine : public IObserver |
1030 { | |
1031 protected: | |
1032 class State : public Orthanc::IDynamicObject | |
1033 { | |
1034 private: | |
1035 LoaderStateMachine& that_; | |
1036 | |
1037 public: | |
1038 State(LoaderStateMachine& that) : | |
1039 that_(that) | |
1040 { | |
1041 } | |
1042 | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1043 State(const State& currentState) : |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1044 that_(currentState.that_) |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1045 { |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1046 } |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1047 |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1048 void Schedule(OracleCommandWithPayload* command) const |
794 | 1049 { |
1050 that_.Schedule(command); | |
1051 } | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1052 |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1053 template <typename T> |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1054 T& GetLoader() const |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1055 { |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1056 return dynamic_cast<T&>(that_); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1057 } |
794 | 1058 |
1059 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) const | |
1060 { | |
1061 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
1062 } | |
1063 | |
1064 virtual void Handle(const GetOrthancImageCommand::SuccessMessage& message) const | |
1065 { | |
1066 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
1067 } | |
1068 | |
1069 virtual void Handle(const GetOrthancWebViewerJpegCommand::SuccessMessage& message) const | |
1070 { | |
1071 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
1072 } | |
1073 }; | |
1074 | |
1075 void Schedule(OracleCommandWithPayload* command) | |
1076 { | |
1077 std::auto_ptr<OracleCommandWithPayload> protection(command); | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1078 |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1079 if (command == NULL) |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1080 { |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1081 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1082 } |
794 | 1083 |
1084 if (!command->HasPayload()) | |
1085 { | |
1086 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, | |
1087 "The payload must contain the next state"); | |
1088 } | |
1089 | |
1090 pendingCommands_.push_back(protection.release()); | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1091 Step(); |
794 | 1092 } |
1093 | |
1094 void Start() | |
1095 { | |
1096 if (active_) | |
1097 { | |
1098 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
1099 } | |
1100 | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1101 active_ = true; |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1102 |
794 | 1103 for (size_t i = 0; i < simultaneousDownloads_; i++) |
1104 { | |
1105 Step(); | |
1106 } | |
1107 } | |
1108 | |
1109 private: | |
1110 void Step() | |
1111 { | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1112 if (!pendingCommands_.empty() && |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1113 activeCommands_ < simultaneousDownloads_) |
794 | 1114 { |
1115 oracle_.Schedule(*this, pendingCommands_.front()); | |
1116 pendingCommands_.pop_front(); | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1117 |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1118 activeCommands_++; |
794 | 1119 } |
1120 } | |
1121 | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1122 void Clear() |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1123 { |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1124 for (PendingCommands::iterator it = pendingCommands_.begin(); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1125 it != pendingCommands_.end(); ++it) |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1126 { |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1127 delete *it; |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1128 } |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1129 } |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1130 |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1131 void HandleException(const OracleCommandExceptionMessage& message) |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1132 { |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1133 LOG(ERROR) << "Error in the state machine, stopping all processing"; |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1134 Clear(); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1135 } |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1136 |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1137 template <typename T> |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1138 void Handle(const T& message) |
794 | 1139 { |
1140 dynamic_cast<const State&>(message.GetOrigin().GetPayload()).Handle(message); | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1141 activeCommands_--; |
794 | 1142 Step(); |
1143 } | |
1144 | |
1145 typedef std::list<IOracleCommand*> PendingCommands; | |
1146 | |
1147 IOracle& oracle_; | |
1148 bool active_; | |
1149 unsigned int simultaneousDownloads_; | |
1150 PendingCommands pendingCommands_; | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1151 unsigned int activeCommands_; |
794 | 1152 |
1153 public: | |
1154 LoaderStateMachine(IOracle& oracle, | |
1155 IObservable& oracleObservable) : | |
1156 IObserver(oracleObservable.GetBroker()), | |
1157 oracle_(oracle), | |
1158 active_(false), | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1159 simultaneousDownloads_(4), |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1160 activeCommands_(0) |
794 | 1161 { |
1162 oracleObservable.RegisterObserverCallback( | |
1163 new Callable<LoaderStateMachine, OrthancRestApiCommand::SuccessMessage> | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1164 (*this, &LoaderStateMachine::Handle<OrthancRestApiCommand::SuccessMessage>)); |
794 | 1165 |
1166 oracleObservable.RegisterObserverCallback( | |
1167 new Callable<LoaderStateMachine, GetOrthancImageCommand::SuccessMessage> | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1168 (*this, &LoaderStateMachine::Handle<GetOrthancImageCommand::SuccessMessage>)); |
794 | 1169 |
1170 oracleObservable.RegisterObserverCallback( | |
1171 new Callable<LoaderStateMachine, GetOrthancWebViewerJpegCommand::SuccessMessage> | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1172 (*this, &LoaderStateMachine::Handle<GetOrthancWebViewerJpegCommand::SuccessMessage>)); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1173 |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1174 oracleObservable.RegisterObserverCallback( |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1175 new Callable<LoaderStateMachine, OracleCommandExceptionMessage> |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1176 (*this, &LoaderStateMachine::HandleException)); |
794 | 1177 } |
1178 | |
1179 virtual ~LoaderStateMachine() | |
1180 { | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1181 Clear(); |
794 | 1182 } |
1183 | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1184 bool IsActive() const |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1185 { |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1186 return active_; |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1187 } |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1188 |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1189 void SetSimultaneousDownloads(unsigned int count) |
794 | 1190 { |
1191 if (active_) | |
1192 { | |
1193 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
1194 } | |
1195 else if (count == 0) | |
1196 { | |
1197 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
1198 } | |
1199 else | |
1200 { | |
1201 simultaneousDownloads_ = count; | |
1202 } | |
1203 } | |
1204 }; | |
1205 | |
1206 | |
1207 | |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1208 class OrthancMultiframeVolumeLoader : |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1209 public LoaderStateMachine, |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
1210 public IObservable |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1211 { |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1212 private: |
764 | 1213 class LoadRTDoseGeometry : public State |
712 | 1214 { |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1215 private: |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1216 std::auto_ptr<Orthanc::DicomMap> dicom_; |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1217 |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1218 public: |
764 | 1219 LoadRTDoseGeometry(OrthancMultiframeVolumeLoader& that, |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1220 Orthanc::DicomMap* dicom) : |
764 | 1221 State(that), |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1222 dicom_(dicom) |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1223 { |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1224 if (dicom == NULL) |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1225 { |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1226 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1227 } |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1228 |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1229 } |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1230 |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1231 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) const |
712 | 1232 { |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1233 // Complete the DICOM tags with just-received "Grid Frame Offset Vector" |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1234 std::string s = Orthanc::Toolbox::StripSpaces(message.GetAnswer()); |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1235 dicom_->SetValue(Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR, s, false); |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1236 |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1237 GetLoader<OrthancMultiframeVolumeLoader>().SetGeometry(*dicom_); |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1238 } |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1239 }; |
764 | 1240 |
1241 | |
1242 static std::string GetSopClassUid(const Orthanc::DicomMap& dicom) | |
1243 { | |
1244 std::string s; | |
1245 if (!dicom.CopyToString(s, Orthanc::DICOM_TAG_SOP_CLASS_UID, false)) | |
1246 { | |
1247 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat, | |
1248 "DICOM file without SOP class UID"); | |
1249 } | |
1250 else | |
1251 { | |
1252 return s; | |
1253 } | |
1254 } | |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1255 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1256 |
764 | 1257 class LoadGeometry : public State |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1258 { |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1259 public: |
764 | 1260 LoadGeometry(OrthancMultiframeVolumeLoader& that) : |
1261 State(that) | |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1262 { |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1263 } |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1264 |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1265 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) const |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1266 { |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1267 OrthancMultiframeVolumeLoader& loader = GetLoader<OrthancMultiframeVolumeLoader>(); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1268 |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1269 Json::Value body; |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1270 message.ParseJsonBody(body); |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1271 |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1272 if (body.type() != Json::objectValue) |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1273 { |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1274 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1275 } |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1276 |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1277 std::auto_ptr<Orthanc::DicomMap> dicom(new Orthanc::DicomMap); |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1278 dicom->FromDicomAsJson(body); |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1279 |
764 | 1280 if (StringToSopClassUid(GetSopClassUid(*dicom)) == SopClassUid_RTDose) |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1281 { |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1282 // Download the "Grid Frame Offset Vector" DICOM tag, that is |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1283 // mandatory for RT-DOSE, but is too long to be returned by default |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1284 |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1285 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1286 command->SetUri("/instances/" + loader.GetInstanceId() + "/content/" + |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1287 Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR.Format()); |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1288 command->SetPayload(new LoadRTDoseGeometry(loader, dicom.release())); |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1289 |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1290 Schedule(command.release()); |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1291 } |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1292 else |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1293 { |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1294 loader.SetGeometry(*dicom); |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1295 } |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1296 } |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1297 }; |
764 | 1298 |
1299 | |
1300 | |
1301 class LoadTransferSyntax : public State | |
1302 { | |
1303 public: | |
1304 LoadTransferSyntax(OrthancMultiframeVolumeLoader& that) : | |
1305 State(that) | |
1306 { | |
1307 } | |
1308 | |
1309 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) const | |
1310 { | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1311 GetLoader<OrthancMultiframeVolumeLoader>().SetTransferSyntax(message.GetAnswer()); |
764 | 1312 } |
1313 }; | |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1314 |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1315 |
765 | 1316 class LoadUncompressedPixelData : public State |
1317 { | |
1318 public: | |
1319 LoadUncompressedPixelData(OrthancMultiframeVolumeLoader& that) : | |
1320 State(that) | |
1321 { | |
1322 } | |
1323 | |
1324 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) const | |
1325 { | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1326 GetLoader<OrthancMultiframeVolumeLoader>().SetUncompressedPixelData(message.GetAnswer()); |
765 | 1327 } |
1328 }; | |
1329 | |
1330 | |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1331 |
783 | 1332 boost::shared_ptr<DicomVolumeImage> volume_; |
764 | 1333 std::string instanceId_; |
1334 std::string transferSyntaxUid_; | |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1335 |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1336 |
764 | 1337 const std::string& GetInstanceId() const |
1338 { | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1339 if (IsActive()) |
764 | 1340 { |
1341 return instanceId_; | |
1342 } | |
1343 else | |
1344 { | |
1345 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
1346 } | |
1347 } | |
1348 | |
1349 | |
1350 void ScheduleFrameDownloads() | |
1351 { | |
1352 if (transferSyntaxUid_.empty() || | |
783 | 1353 !volume_->HasGeometry()) |
764 | 1354 { |
1355 return; | |
1356 } | |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1357 /* |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1358 1.2.840.10008.1.2 Implicit VR Endian: Default Transfer Syntax for DICOM |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1359 1.2.840.10008.1.2.1 Explicit VR Little Endian |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1360 1.2.840.10008.1.2.2 Explicit VR Big Endian |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1361 |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1362 See https://www.dicomlibrary.com/dicom/transfer-syntax/ |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1363 */ |
765 | 1364 if (transferSyntaxUid_ == "1.2.840.10008.1.2" || |
1365 transferSyntaxUid_ == "1.2.840.10008.1.2.1" || | |
1366 transferSyntaxUid_ == "1.2.840.10008.1.2.2") | |
1367 { | |
1368 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); | |
1369 command->SetHttpHeader("Accept-Encoding", "gzip"); | |
1370 command->SetUri("/instances/" + instanceId_ + "/content/" + | |
1371 Orthanc::DICOM_TAG_PIXEL_DATA.Format() + "/0"); | |
1372 command->SetPayload(new LoadUncompressedPixelData(*this)); | |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1373 Schedule(command.release()); |
765 | 1374 } |
1375 else | |
764 | 1376 { |
1377 throw Orthanc::OrthancException( | |
1378 Orthanc::ErrorCode_NotImplemented, | |
1379 "No support for multiframe instances with transfer syntax: " + transferSyntaxUid_); | |
1380 } | |
1381 } | |
1382 | |
1383 | |
1384 void SetTransferSyntax(const std::string& transferSyntax) | |
1385 { | |
1386 transferSyntaxUid_ = Orthanc::Toolbox::StripSpaces(transferSyntax); | |
1387 ScheduleFrameDownloads(); | |
1388 } | |
1389 | |
1390 | |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1391 void SetGeometry(const Orthanc::DicomMap& dicom) |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1392 { |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1393 DicomInstanceParameters parameters(dicom); |
783 | 1394 volume_->SetDicomParameters(parameters); |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1395 |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1396 Orthanc::PixelFormat format; |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1397 if (!parameters.GetImageInformation().ExtractPixelFormat(format, true)) |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1398 { |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1399 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1400 } |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1401 |
764 | 1402 double spacingZ; |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1403 switch (parameters.GetSopClassUid()) |
764 | 1404 { |
1405 case SopClassUid_RTDose: | |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1406 spacingZ = parameters.GetThickness(); |
764 | 1407 break; |
1408 | |
1409 default: | |
1410 throw Orthanc::OrthancException( | |
1411 Orthanc::ErrorCode_NotImplemented, | |
1412 "No support for multiframe instances with SOP class UID: " + GetSopClassUid(dicom)); | |
1413 } | |
1414 | |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1415 const unsigned int width = parameters.GetImageInformation().GetWidth(); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1416 const unsigned int height = parameters.GetImageInformation().GetHeight(); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1417 const unsigned int depth = parameters.GetImageInformation().GetNumberOfFrames(); |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1418 |
781 | 1419 { |
783 | 1420 VolumeImageGeometry geometry; |
1421 geometry.SetSize(width, height, depth); | |
1422 geometry.SetAxialGeometry(parameters.GetGeometry()); | |
1423 geometry.SetVoxelDimensions(parameters.GetPixelSpacingX(), | |
1424 parameters.GetPixelSpacingY(), spacingZ); | |
1425 volume_->Initialize(geometry, format); | |
781 | 1426 } |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1427 |
783 | 1428 volume_->GetPixelData().Clear(); |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1429 |
764 | 1430 ScheduleFrameDownloads(); |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1431 |
783 | 1432 BroadcastMessage(DicomVolumeImage::GeometryReadyMessage(*volume_)); |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1433 } |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1434 |
765 | 1435 |
1436 ORTHANC_FORCE_INLINE | |
1437 static void CopyPixel(uint32_t& target, | |
1438 const void* source) | |
1439 { | |
1440 // TODO - check alignement? | |
1441 target = le32toh(*reinterpret_cast<const uint32_t*>(source)); | |
1442 } | |
1443 | |
1444 | |
1445 template <typename T> | |
1446 void CopyPixelData(const std::string& pixelData) | |
1447 { | |
783 | 1448 ImageBuffer3D& target = volume_->GetPixelData(); |
1449 | |
1450 const unsigned int bpp = target.GetBytesPerPixel(); | |
1451 const unsigned int width = target.GetWidth(); | |
1452 const unsigned int height = target.GetHeight(); | |
1453 const unsigned int depth = target.GetDepth(); | |
765 | 1454 |
1455 if (pixelData.size() != bpp * width * height * depth) | |
1456 { | |
1457 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat, | |
1458 "The pixel data has not the proper size"); | |
1459 } | |
1460 | |
1461 if (pixelData.empty()) | |
1462 { | |
1463 return; | |
1464 } | |
1465 | |
1466 const uint8_t* source = reinterpret_cast<const uint8_t*>(pixelData.c_str()); | |
1467 | |
1468 for (unsigned int z = 0; z < depth; z++) | |
1469 { | |
783 | 1470 ImageBuffer3D::SliceWriter writer(target, VolumeProjection_Axial, z); |
765 | 1471 |
1472 assert (writer.GetAccessor().GetWidth() == width && | |
1473 writer.GetAccessor().GetHeight() == height); | |
1474 | |
1475 for (unsigned int y = 0; y < height; y++) | |
1476 { | |
792
4fe4b221a31f
deprecating MessagingToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
789
diff
changeset
|
1477 assert(sizeof(T) == Orthanc::GetBytesPerPixel(target.GetFormat())); |
765 | 1478 |
1479 T* target = reinterpret_cast<T*>(writer.GetAccessor().GetRow(y)); | |
1480 | |
1481 for (unsigned int x = 0; x < width; x++) | |
1482 { | |
1483 CopyPixel(*target, source); | |
1484 | |
1485 target ++; | |
1486 source += bpp; | |
1487 } | |
1488 } | |
1489 } | |
1490 } | |
1491 | |
1492 | |
1493 void SetUncompressedPixelData(const std::string& pixelData) | |
1494 { | |
783 | 1495 switch (volume_->GetPixelData().GetFormat()) |
765 | 1496 { |
1497 case Orthanc::PixelFormat_Grayscale32: | |
1498 CopyPixelData<uint32_t>(pixelData); | |
1499 break; | |
1500 | |
1501 default: | |
1502 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
1503 } | |
1504 | |
783 | 1505 volume_->IncrementRevision(); |
781 | 1506 |
783 | 1507 BroadcastMessage(DicomVolumeImage::ContentUpdatedMessage(*volume_)); |
765 | 1508 } |
1509 | |
766 | 1510 |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1511 public: |
783 | 1512 OrthancMultiframeVolumeLoader(const boost::shared_ptr<DicomVolumeImage>& volume, |
1513 IOracle& oracle, | |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1514 IObservable& oracleObservable) : |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1515 LoaderStateMachine(oracle, oracleObservable), |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1516 IObservable(oracleObservable.GetBroker()), |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1517 volume_(volume) |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1518 { |
783 | 1519 if (volume.get() == NULL) |
1520 { | |
1521 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
1522 } | |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1523 } |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1524 |
764 | 1525 |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1526 void LoadInstance(const std::string& instanceId) |
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1527 { |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1528 Start(); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1529 |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1530 instanceId_ = instanceId; |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1531 |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1532 { |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1533 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1534 command->SetHttpHeader("Accept-Encoding", "gzip"); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1535 command->SetUri("/instances/" + instanceId + "/tags"); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1536 command->SetPayload(new LoadGeometry(*this)); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1537 Schedule(command.release()); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1538 } |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1539 |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1540 { |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1541 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1542 command->SetUri("/instances/" + instanceId + "/metadata/TransferSyntax"); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1543 command->SetPayload(new LoadTransferSyntax(*this)); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
1544 Schedule(command.release()); |
712 | 1545 } |
1546 } | |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
1547 }; |
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
1548 |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1549 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1550 |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1551 class VolumeImageReslicer : public IVolumeSlicer |
781 | 1552 { |
1553 private: | |
1554 class Slice : public IExtractedSlice | |
1555 { | |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1556 private: |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1557 VolumeImageReslicer& that_; |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1558 CoordinateSystem3D cuttingPlane_; |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1559 |
781 | 1560 public: |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1561 Slice(VolumeImageReslicer& that, |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1562 const CoordinateSystem3D& cuttingPlane) : |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1563 that_(that), |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1564 cuttingPlane_(cuttingPlane) |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1565 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1566 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1567 |
781 | 1568 virtual bool IsValid() |
1569 { | |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1570 return true; |
781 | 1571 } |
1572 | |
1573 virtual uint64_t GetRevision() | |
1574 { | |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1575 return that_.volume_->GetRevision(); |
781 | 1576 } |
1577 | |
1578 virtual ISceneLayer* CreateSceneLayer(const ILayerStyleConfigurator* configurator, // possibly absent | |
1579 const CoordinateSystem3D& cuttingPlane) | |
1580 { | |
783 | 1581 VolumeReslicer& reslicer = that_.reslicer_; |
1582 | |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1583 if (configurator == NULL) |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1584 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1585 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1586 "Must provide a layer style configurator"); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1587 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1588 |
783 | 1589 reslicer.SetOutputFormat(that_.volume_->GetPixelData().GetFormat()); |
1590 reslicer.Apply(that_.volume_->GetPixelData(), | |
1591 that_.volume_->GetGeometry(), | |
1592 cuttingPlane); | |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1593 |
783 | 1594 if (reslicer.IsSuccess()) |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1595 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1596 std::auto_ptr<TextureBaseSceneLayer> layer |
783 | 1597 (configurator->CreateTextureFromDicom(reslicer.GetOutputSlice(), |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1598 that_.volume_->GetDicomParameters())); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1599 if (layer.get() == NULL) |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1600 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1601 return NULL; |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1602 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1603 |
783 | 1604 double s = reslicer.GetPixelSpacing(); |
1605 layer->SetPixelSpacing(s, s); | |
1606 layer->SetOrigin(reslicer.GetOutputExtent().GetX1() + 0.5 * s, | |
1607 reslicer.GetOutputExtent().GetY1() + 0.5 * s); | |
1608 | |
1609 // TODO - Angle!! | |
1610 | |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1611 return layer.release(); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1612 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1613 else |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1614 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1615 return NULL; |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1616 } |
781 | 1617 } |
1618 }; | |
1619 | |
783 | 1620 boost::shared_ptr<DicomVolumeImage> volume_; |
1621 VolumeReslicer reslicer_; | |
781 | 1622 |
1623 public: | |
783 | 1624 VolumeImageReslicer(const boost::shared_ptr<DicomVolumeImage>& volume) : |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1625 volume_(volume) |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1626 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1627 if (volume.get() == NULL) |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1628 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1629 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1630 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1631 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1632 |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1633 ImageInterpolation GetInterpolation() const |
781 | 1634 { |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1635 return reslicer_.GetInterpolation(); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1636 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1637 |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1638 void SetInterpolation(ImageInterpolation interpolation) |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1639 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1640 reslicer_.SetInterpolation(interpolation); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1641 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1642 |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1643 bool IsFastMode() const |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1644 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1645 return reslicer_.IsFastMode(); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1646 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1647 |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1648 void SetFastMode(bool fast) |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1649 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1650 reslicer_.EnableFastMode(fast); |
781 | 1651 } |
1652 | |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1653 virtual IExtractedSlice* ExtractSlice(const CoordinateSystem3D& cuttingPlane) |
781 | 1654 { |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1655 if (volume_->HasGeometry()) |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1656 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1657 return new Slice(*this, cuttingPlane); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1658 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1659 else |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1660 { |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1661 return new IVolumeSlicer::InvalidSlice; |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1662 } |
781 | 1663 } |
1664 }; | |
1665 | |
1666 | |
1667 | |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1668 class DicomStructureSetLoader : |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1669 public IObserver, |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1670 public IVolumeSlicer |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1671 { |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1672 private: |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1673 std::auto_ptr<DicomStructureSet> content_; |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1674 IOracle& oracle_; |
794 | 1675 bool active_; |
1676 uint64_t revision_; | |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1677 std::string instanceId_; |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1678 |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1679 void Handle(const OrthancRestApiCommand::SuccessMessage& message) |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1680 { |
794 | 1681 assert(active_); |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1682 |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1683 { |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1684 OrthancPlugins::FullOrthancDataset dicom(message.GetAnswer()); |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1685 content_.reset(new DicomStructureSet(dicom)); |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1686 } |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1687 |
794 | 1688 std::set<std::string> instances; |
1689 content_->GetReferencedInstances(instances); | |
1690 | |
1691 for (std::set<std::string>::const_iterator | |
1692 it = instances.begin(); it != instances.end(); ++it) | |
1693 { | |
1694 printf("[%s]\n", it->c_str()); | |
1695 } | |
1696 } | |
1697 | |
1698 | |
1699 class Slice : public IExtractedSlice | |
1700 { | |
1701 private: | |
1702 const DicomStructureSet& content_; | |
1703 uint64_t revision_; | |
1704 bool isValid_; | |
1705 | |
1706 public: | |
1707 Slice(const DicomStructureSet& content, | |
1708 uint64_t revision, | |
1709 const CoordinateSystem3D& cuttingPlane) : | |
1710 content_(content), | |
1711 revision_(revision) | |
1712 { | |
1713 bool opposite; | |
1714 | |
1715 const Vector normal = content.GetNormal(); | |
1716 isValid_ = ( | |
1717 GeometryToolbox::IsParallelOrOpposite(opposite, normal, cuttingPlane.GetNormal()) || | |
1718 GeometryToolbox::IsParallelOrOpposite(opposite, normal, cuttingPlane.GetAxisX()) || | |
1719 GeometryToolbox::IsParallelOrOpposite(opposite, normal, cuttingPlane.GetAxisY())); | |
1720 } | |
1721 | |
1722 virtual bool IsValid() | |
1723 { | |
1724 return isValid_; | |
1725 } | |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1726 |
794 | 1727 virtual uint64_t GetRevision() |
1728 { | |
1729 return revision_; | |
1730 } | |
1731 | |
1732 virtual ISceneLayer* CreateSceneLayer(const ILayerStyleConfigurator* configurator, | |
1733 const CoordinateSystem3D& cuttingPlane) | |
1734 { | |
1735 assert(isValid_); | |
1736 | |
1737 std::auto_ptr<PolylineSceneLayer> layer(new PolylineSceneLayer); | |
1738 | |
1739 for (size_t i = 0; i < content_.GetStructuresCount(); i++) | |
1740 { | |
1741 std::vector< std::vector<DicomStructureSet::PolygonPoint> > polygons; | |
1742 | |
1743 if (content_.ProjectStructure(polygons, i, cuttingPlane)) | |
1744 { | |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
1745 printf(">> %d\n", static_cast<int>(polygons.size())); |
794 | 1746 |
1747 for (size_t j = 0; j < polygons.size(); j++) | |
1748 { | |
1749 PolylineSceneLayer::Chain chain; | |
1750 chain.resize(polygons[j].size()); | |
1751 | |
1752 for (size_t k = 0; k < polygons[i].size(); k++) | |
1753 { | |
1754 chain[k] = ScenePoint2D(polygons[j][k].first, polygons[j][k].second); | |
1755 } | |
1756 | |
1757 layer->AddChain(chain, true /* closed */); | |
1758 } | |
1759 } | |
1760 } | |
1761 | |
1762 printf("OK\n"); | |
1763 | |
1764 return layer.release(); | |
1765 } | |
1766 }; | |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1767 |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1768 public: |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1769 DicomStructureSetLoader(IOracle& oracle, |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1770 IObservable& oracleObservable) : |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1771 IObserver(oracleObservable.GetBroker()), |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1772 oracle_(oracle), |
794 | 1773 active_(false), |
1774 revision_(0) | |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1775 { |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1776 oracleObservable.RegisterObserverCallback( |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1777 new Callable<DicomStructureSetLoader, OrthancRestApiCommand::SuccessMessage> |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1778 (*this, &DicomStructureSetLoader::Handle)); |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1779 } |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1780 |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1781 |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1782 void LoadInstance(const std::string& instanceId) |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1783 { |
794 | 1784 if (active_) |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1785 { |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1786 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1787 } |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1788 else |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1789 { |
794 | 1790 active_ = true; |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1791 instanceId_ = instanceId; |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1792 |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1793 { |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1794 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1795 command->SetHttpHeader("Accept-Encoding", "gzip"); |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1796 command->SetUri("/instances/" + instanceId + "/tags?ignore-length=3006-0050"); |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1797 oracle_.Schedule(*this, command.release()); |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1798 } |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1799 } |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1800 } |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1801 |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1802 virtual IExtractedSlice* ExtractSlice(const CoordinateSystem3D& cuttingPlane) |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1803 { |
794 | 1804 if (content_.get() == NULL) |
1805 { | |
1806 // Geometry is not available yet | |
1807 return new IVolumeSlicer::InvalidSlice; | |
1808 } | |
1809 else | |
1810 { | |
1811 return new Slice(*content_, revision_, cuttingPlane); | |
1812 } | |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1813 } |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1814 }; |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1815 |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1816 |
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
1817 |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1818 class VolumeSceneLayerSource : public boost::noncopyable |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1819 { |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1820 private: |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1821 Scene2D& scene_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1822 int layerDepth_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1823 boost::shared_ptr<IVolumeSlicer> slicer_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1824 std::auto_ptr<ILayerStyleConfigurator> configurator_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1825 std::auto_ptr<CoordinateSystem3D> lastPlane_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1826 uint64_t lastRevision_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1827 uint64_t lastConfiguratorRevision_; |
691 | 1828 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1829 static bool IsSameCuttingPlane(const CoordinateSystem3D& a, |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1830 const CoordinateSystem3D& b) |
745 | 1831 { |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1832 // TODO - What if the normal is reversed? |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1833 double distance; |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1834 return (CoordinateSystem3D::ComputeDistance(distance, a, b) && |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1835 LinearAlgebra::IsCloseToZero(distance)); |
745 | 1836 } |
1837 | |
783 | 1838 void ClearLayer() |
1839 { | |
1840 scene_.DeleteLayer(layerDepth_); | |
1841 lastPlane_.reset(NULL); | |
1842 } | |
1843 | |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1844 public: |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1845 VolumeSceneLayerSource(Scene2D& scene, |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1846 int layerDepth, |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1847 const boost::shared_ptr<IVolumeSlicer>& slicer) : |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1848 scene_(scene), |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1849 layerDepth_(layerDepth), |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1850 slicer_(slicer) |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1851 { |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1852 if (slicer == NULL) |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1853 { |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1854 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1855 } |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1856 } |
745 | 1857 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1858 const IVolumeSlicer& GetSlicer() const |
691 | 1859 { |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1860 return *slicer_; |
691 | 1861 } |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1862 |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1863 void RemoveConfigurator() |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1864 { |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1865 configurator_.reset(); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1866 lastPlane_.reset(); |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1867 } |
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1868 |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1869 void SetConfigurator(ILayerStyleConfigurator* configurator) // Takes ownership |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1870 { |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1871 if (configurator == NULL) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1872 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1873 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1874 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1875 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1876 configurator_.reset(configurator); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1877 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1878 // Invalidate the layer |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1879 lastPlane_.reset(NULL); |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1880 } |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1881 |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1882 bool HasConfigurator() const |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1883 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1884 return configurator_.get() != NULL; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1885 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1886 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1887 ILayerStyleConfigurator& GetConfigurator() const |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1888 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1889 if (configurator_.get() == NULL) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1890 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1891 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1892 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1893 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1894 return *configurator_; |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1895 } |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1896 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1897 void Update(const CoordinateSystem3D& plane) |
691 | 1898 { |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
1899 assert(slicer_.get() != NULL); |
781 | 1900 std::auto_ptr<IVolumeSlicer::IExtractedSlice> slice(slicer_->ExtractSlice(plane)); |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1901 |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1902 if (slice.get() == NULL) |
691 | 1903 { |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1904 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
691 | 1905 } |
1906 | |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1907 if (!slice->IsValid()) |
691 | 1908 { |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1909 // The slicer cannot handle this cutting plane: Clear the layer |
783 | 1910 ClearLayer(); |
691 | 1911 } |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1912 else if (lastPlane_.get() != NULL && |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1913 IsSameCuttingPlane(*lastPlane_, plane) && |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1914 lastRevision_ == slice->GetRevision()) |
691 | 1915 { |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1916 // The content of the slice has not changed: Don't update the |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1917 // layer content, but possibly update its style |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1918 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1919 if (configurator_.get() != NULL && |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1920 configurator_->GetRevision() != lastConfiguratorRevision_ && |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1921 scene_.HasLayer(layerDepth_)) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1922 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1923 configurator_->ApplyStyle(scene_.GetLayer(layerDepth_)); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1924 } |
691 | 1925 } |
1926 else | |
1927 { | |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1928 // Content has changed: An update is needed |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1929 lastPlane_.reset(new CoordinateSystem3D(plane)); |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1930 lastRevision_ = slice->GetRevision(); |
692
10910827f235
simplification in DicomVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
691
diff
changeset
|
1931 |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
1932 std::auto_ptr<ISceneLayer> layer(slice->CreateSceneLayer(configurator_.get(), plane)); |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1933 if (layer.get() == NULL) |
691 | 1934 { |
783 | 1935 ClearLayer(); |
712 | 1936 } |
783 | 1937 else |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1938 { |
783 | 1939 if (configurator_.get() != NULL) |
1940 { | |
1941 lastConfiguratorRevision_ = configurator_->GetRevision(); | |
1942 configurator_->ApplyStyle(*layer); | |
1943 } | |
1944 | |
1945 scene_.SetLayer(layerDepth_, layer.release()); | |
713
e63c8b9b7b02
setting texture geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
712
diff
changeset
|
1946 } |
691 | 1947 } |
1948 } | |
1949 }; | |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1950 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1951 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1952 |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1953 |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
1954 |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1955 class NativeApplicationContext : public IMessageEmitter |
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 private: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1958 boost::shared_mutex mutex_; |
745 | 1959 MessageBroker broker_; |
1960 IObservable oracleObservable_; | |
681
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 public: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1963 NativeApplicationContext() : |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1964 oracleObservable_(broker_) |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1965 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1966 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1967 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1968 |
745 | 1969 virtual void EmitMessage(const IObserver& observer, |
1970 const IMessage& message) | |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1971 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1972 try |
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 boost::unique_lock<boost::shared_mutex> lock(mutex_); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1975 oracleObservable_.EmitMessage(observer, message); |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1976 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1977 catch (Orthanc::OrthancException& e) |
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 LOG(ERROR) << "Exception while emitting a message: " << e.What(); |
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 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1982 |
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 class ReaderLock : public boost::noncopyable |
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 private: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1987 NativeApplicationContext& that_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1988 boost::shared_lock<boost::shared_mutex> lock_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1989 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1990 public: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1991 ReaderLock(NativeApplicationContext& that) : |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1992 that_(that), |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
1993 lock_(that.mutex_) |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1994 { |
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 }; |
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 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
1999 class WriterLock : public boost::noncopyable |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2000 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2001 private: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2002 NativeApplicationContext& that_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2003 boost::unique_lock<boost::shared_mutex> lock_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2004 |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2005 public: |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2006 WriterLock(NativeApplicationContext& that) : |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
2007 that_(that), |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
2008 lock_(that.mutex_) |
681
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 } |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2011 |
745 | 2012 MessageBroker& GetBroker() |
681
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2013 { |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2014 return that_.broker_; |
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 |
745 | 2017 IObservable& GetOracleObservable() |
681
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 return that_.oracleObservable_; |
9723fceccb9f
revision counters in DicomVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
680
diff
changeset
|
2020 } |
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 }; |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2023 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2024 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2025 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2026 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2027 class Toto : public OrthancStone::IObserver |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2028 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2029 private: |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2030 OrthancStone::CoordinateSystem3D plane_; |
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2031 OrthancStone::IOracle& oracle_; |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2032 OrthancStone::Scene2D scene_; |
794 | 2033 std::auto_ptr<OrthancStone::VolumeSceneLayerSource> source1_, source2_, source3_; |
766 | 2034 |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2035 |
779 | 2036 void Refresh() |
2037 { | |
2038 if (source1_.get() != NULL) | |
2039 { | |
2040 source1_->Update(plane_); | |
2041 } | |
2042 | |
2043 if (source2_.get() != NULL) | |
2044 { | |
2045 source2_->Update(plane_); | |
2046 } | |
2047 | |
794 | 2048 if (source3_.get() != NULL) |
2049 { | |
2050 source3_->Update(plane_); | |
2051 } | |
2052 | |
779 | 2053 scene_.FitContent(1024, 768); |
2054 | |
2055 { | |
2056 OrthancStone::CairoCompositor compositor(scene_, 1024, 768); | |
2057 compositor.Refresh(); | |
2058 | |
2059 Orthanc::ImageAccessor accessor; | |
2060 compositor.GetCanvas().GetReadOnlyAccessor(accessor); | |
2061 | |
2062 Orthanc::Image tmp(Orthanc::PixelFormat_RGB24, accessor.GetWidth(), accessor.GetHeight(), false); | |
2063 Orthanc::ImageProcessing::Convert(tmp, accessor); | |
2064 | |
2065 static unsigned int count = 0; | |
2066 char buf[64]; | |
2067 sprintf(buf, "scene-%06d.png", count++); | |
2068 | |
2069 Orthanc::PngWriter writer; | |
2070 writer.WriteToFile(buf, tmp); | |
2071 } | |
2072 } | |
2073 | |
2074 | |
783 | 2075 void Handle(const OrthancStone::DicomVolumeImage::GeometryReadyMessage& message) |
766 | 2076 { |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2077 printf("Geometry ready\n"); |
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2078 |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
2079 //plane_ = message.GetOrigin().GetGeometry().GetSagittalGeometry(); |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
2080 //plane_ = message.GetOrigin().GetGeometry().GetAxialGeometry(); |
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
2081 plane_ = message.GetOrigin().GetGeometry().GetCoronalGeometry(); |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
2082 plane_.SetOrigin(message.GetOrigin().GetGeometry().GetCoordinates(0.5f, 0.5f, 0.5f)); |
779 | 2083 |
2084 Refresh(); | |
766 | 2085 } |
2086 | |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2087 |
745 | 2088 void Handle(const OrthancStone::SleepOracleCommand::TimeoutMessage& message) |
744 | 2089 { |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2090 if (message.GetOrigin().HasPayload()) |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2091 { |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2092 printf("TIMEOUT! %d\n", dynamic_cast<const Orthanc::SingleValueObject<unsigned int>& >(message.GetOrigin().GetPayload()).GetValue()); |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2093 } |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2094 else |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2095 { |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2096 printf("TIMEOUT\n"); |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2097 |
779 | 2098 Refresh(); |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2099 |
765 | 2100 /** |
2101 * The sleep() leads to a crash if the oracle is still running, | |
2102 * while this object is destroyed. Always stop the oracle before | |
2103 * destroying active objects. (*) | |
2104 **/ | |
2105 // boost::this_thread::sleep(boost::posix_time::seconds(2)); | |
2106 | |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2107 oracle_.Schedule(*this, new OrthancStone::SleepOracleCommand(message.GetOrigin().GetDelay())); |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2108 } |
744 | 2109 } |
2110 | |
745 | 2111 void Handle(const OrthancStone::OrthancRestApiCommand::SuccessMessage& message) |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2112 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2113 Json::Value v; |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
2114 message.ParseJsonBody(v); |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2115 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2116 printf("ICI [%s]\n", v.toStyledString().c_str()); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2117 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2118 |
745 | 2119 void Handle(const OrthancStone::GetOrthancImageCommand::SuccessMessage& message) |
637
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
2120 { |
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
2121 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
|
2122 } |
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
2123 |
745 | 2124 void Handle(const OrthancStone::GetOrthancWebViewerJpegCommand::SuccessMessage& message) |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2125 { |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2126 printf("WebViewer %dx%d\n", message.GetImage().GetWidth(), message.GetImage().GetHeight()); |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2127 } |
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2128 |
745 | 2129 void Handle(const OrthancStone::OracleCommandExceptionMessage& message) |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2130 { |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2131 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
|
2132 |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2133 switch (message.GetCommand().GetType()) |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2134 { |
745 | 2135 case OrthancStone::IOracleCommand::Type_GetOrthancWebViewerJpeg: |
2136 printf("URI: [%s]\n", dynamic_cast<const OrthancStone::GetOrthancWebViewerJpegCommand&> | |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2137 (message.GetCommand()).GetUri().c_str()); |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2138 break; |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2139 |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2140 default: |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2141 break; |
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2142 } |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2143 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2144 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2145 public: |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2146 Toto(OrthancStone::IOracle& oracle, |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2147 OrthancStone::IObservable& oracleObservable) : |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2148 IObserver(oracleObservable.GetBroker()), |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2149 oracle_(oracle) |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2150 { |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2151 oracleObservable.RegisterObserverCallback |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
2152 (new OrthancStone::Callable |
745 | 2153 <Toto, OrthancStone::SleepOracleCommand::TimeoutMessage>(*this, &Toto::Handle)); |
744 | 2154 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2155 oracleObservable.RegisterObserverCallback |
744 | 2156 (new OrthancStone::Callable |
745 | 2157 <Toto, OrthancStone::OrthancRestApiCommand::SuccessMessage>(*this, &Toto::Handle)); |
637
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
2158 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2159 oracleObservable.RegisterObserverCallback |
637
afc91cdc5128
decoding of images by oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
636
diff
changeset
|
2160 (new OrthancStone::Callable |
745 | 2161 <Toto, OrthancStone::GetOrthancImageCommand::SuccessMessage>(*this, &Toto::Handle)); |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2162 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2163 oracleObservable.RegisterObserverCallback |
639
d1f4521b9bbb
OracleCommandExceptionMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
638
diff
changeset
|
2164 (new OrthancStone::Callable |
745 | 2165 <Toto, OrthancStone::GetOrthancWebViewerJpegCommand::SuccessMessage>(*this, &Toto::Handle)); |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2166 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2167 oracleObservable.RegisterObserverCallback |
642
7ca8dc7ec17b
GetOrthancWebViewerJpegCommand::ProcessHttpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
641
diff
changeset
|
2168 (new OrthancStone::Callable |
745 | 2169 <Toto, OrthancStone::OracleCommandExceptionMessage>(*this, &Toto::Handle)); |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2170 } |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2171 |
783 | 2172 void SetReferenceLoader(OrthancStone::IObservable& loader) |
2173 { | |
2174 loader.RegisterObserverCallback | |
2175 (new OrthancStone::Callable | |
2176 <Toto, OrthancStone::DicomVolumeImage::GeometryReadyMessage>(*this, &Toto::Handle)); | |
2177 } | |
2178 | |
766 | 2179 void SetVolume1(int depth, |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2180 const boost::shared_ptr<OrthancStone::IVolumeSlicer>& volume, |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2181 OrthancStone::ILayerStyleConfigurator* style) |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2182 { |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2183 source1_.reset(new OrthancStone::VolumeSceneLayerSource(scene_, depth, volume)); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2184 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2185 if (style != NULL) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2186 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2187 source1_->SetConfigurator(style); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2188 } |
766 | 2189 } |
2190 | |
2191 void SetVolume2(int depth, | |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2192 const boost::shared_ptr<OrthancStone::IVolumeSlicer>& volume, |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2193 OrthancStone::ILayerStyleConfigurator* style) |
766 | 2194 { |
776
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2195 source2_.reset(new OrthancStone::VolumeSceneLayerSource(scene_, depth, volume)); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2196 |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2197 if (style != NULL) |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2198 { |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2199 source2_->SetConfigurator(style); |
0387485f048b
ILayerStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
2200 } |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2201 } |
794 | 2202 |
2203 void SetStructureSet(int depth, | |
2204 const boost::shared_ptr<OrthancStone::DicomStructureSetLoader>& volume) | |
2205 { | |
2206 source3_.reset(new OrthancStone::VolumeSceneLayerSource(scene_, depth, volume)); | |
2207 } | |
2208 | |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2209 }; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2210 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2211 |
745 | 2212 void Run(OrthancStone::NativeApplicationContext& context, |
765 | 2213 OrthancStone::ThreadedOracle& oracle) |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2214 { |
783 | 2215 boost::shared_ptr<OrthancStone::DicomVolumeImage> ct(new OrthancStone::DicomVolumeImage); |
2216 boost::shared_ptr<OrthancStone::DicomVolumeImage> dose(new OrthancStone::DicomVolumeImage); | |
2217 | |
2218 | |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
2219 boost::shared_ptr<Toto> toto; |
783 | 2220 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader; |
2221 boost::shared_ptr<OrthancStone::OrthancMultiframeVolumeLoader> doseLoader; | |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
2222 boost::shared_ptr<OrthancStone::DicomStructureSetLoader> rtstructLoader; |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2223 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2224 { |
745 | 2225 OrthancStone::NativeApplicationContext::WriterLock lock(context); |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2226 toto.reset(new Toto(oracle, lock.GetOracleObservable())); |
783 | 2227 ctLoader.reset(new OrthancStone::OrthancSeriesVolumeProgressiveLoader(ct, oracle, lock.GetOracleObservable())); |
2228 doseLoader.reset(new OrthancStone::OrthancMultiframeVolumeLoader(dose, oracle, lock.GetOracleObservable())); | |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
2229 rtstructLoader.reset(new OrthancStone::DicomStructureSetLoader(oracle, lock.GetOracleObservable())); |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
2230 } |
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
2231 |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
2232 |
794 | 2233 //toto->SetReferenceLoader(*ctLoader); |
2234 toto->SetReferenceLoader(*doseLoader); | |
783 | 2235 |
2236 | |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
2237 #if 1 |
783 | 2238 toto->SetVolume1(0, ctLoader, new OrthancStone::GrayscaleStyleConfigurator); |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
2239 #else |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
2240 { |
783 | 2241 boost::shared_ptr<OrthancStone::IVolumeSlicer> reslicer(new OrthancStone::VolumeImageReslicer(ct)); |
782
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
2242 toto->SetVolume1(0, reslicer, new OrthancStone::GrayscaleStyleConfigurator); |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
2243 } |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
2244 #endif |
b24c208fa953
VolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
781
diff
changeset
|
2245 |
780 | 2246 |
2247 { | |
2248 std::auto_ptr<OrthancStone::LookupTableStyleConfigurator> config(new OrthancStone::LookupTableStyleConfigurator); | |
2249 config->SetLookupTable(Orthanc::EmbeddedResources::COLORMAP_HOT); | |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
2250 |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
2251 boost::shared_ptr<OrthancStone::DicomVolumeImageMPRSlicer> tmp(new OrthancStone::DicomVolumeImageMPRSlicer(dose)); |
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
2252 toto->SetVolume2(1, tmp, config.release()); |
780 | 2253 } |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2254 |
794 | 2255 toto->SetStructureSet(2, rtstructLoader); |
2256 | |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
2257 oracle.Schedule(*toto, new OrthancStone::SleepOracleCommand(100)); |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2258 |
744 | 2259 if (0) |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2260 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2261 Json::Value v = Json::objectValue; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2262 v["Level"] = "Series"; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2263 v["Query"] = Json::objectValue; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2264 |
745 | 2265 std::auto_ptr<OrthancStone::OrthancRestApiCommand> command(new OrthancStone::OrthancRestApiCommand); |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2266 command->SetMethod(Orthanc::HttpMethod_Post); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2267 command->SetUri("/tools/find"); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2268 command->SetBody(v); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2269 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
622
diff
changeset
|
2270 oracle.Schedule(*toto, command.release()); |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2271 } |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
2272 |
744 | 2273 if (0) |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2274 { |
745 | 2275 std::auto_ptr<OrthancStone::GetOrthancImageCommand> command(new OrthancStone::GetOrthancImageCommand); |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2276 command->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Jpeg))); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2277 command->SetUri("/instances/6687cc73-07cae193-52ff29c8-f646cb16-0753ed92/preview"); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2278 oracle.Schedule(*toto, command.release()); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2279 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2280 |
744 | 2281 if (0) |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2282 { |
745 | 2283 std::auto_ptr<OrthancStone::GetOrthancImageCommand> command(new OrthancStone::GetOrthancImageCommand); |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2284 command->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Png))); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2285 command->SetUri("/instances/6687cc73-07cae193-52ff29c8-f646cb16-0753ed92/preview"); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2286 oracle.Schedule(*toto, command.release()); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2287 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2288 |
744 | 2289 if (0) |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2290 { |
745 | 2291 std::auto_ptr<OrthancStone::GetOrthancImageCommand> command(new OrthancStone::GetOrthancImageCommand); |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2292 command->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Png))); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2293 command->SetUri("/instances/6687cc73-07cae193-52ff29c8-f646cb16-0753ed92/image-uint16"); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2294 oracle.Schedule(*toto, command.release()); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2295 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2296 |
744 | 2297 if (0) |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2298 { |
745 | 2299 std::auto_ptr<OrthancStone::GetOrthancImageCommand> command(new OrthancStone::GetOrthancImageCommand); |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2300 command->SetHttpHeader("Accept-Encoding", "gzip"); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2301 command->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Pam))); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2302 command->SetUri("/instances/6687cc73-07cae193-52ff29c8-f646cb16-0753ed92/image-uint16"); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2303 oracle.Schedule(*toto, command.release()); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2304 } |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2305 |
744 | 2306 if (0) |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2307 { |
745 | 2308 std::auto_ptr<OrthancStone::GetOrthancImageCommand> command(new OrthancStone::GetOrthancImageCommand); |
636
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2309 command->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Pam))); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2310 command->SetUri("/instances/6687cc73-07cae193-52ff29c8-f646cb16-0753ed92/image-uint16"); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2311 oracle.Schedule(*toto, command.release()); |
fb00a8be03e2
starting DecodeOrthancImageCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
631
diff
changeset
|
2312 } |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2313 |
744 | 2314 if (0) |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2315 { |
745 | 2316 std::auto_ptr<OrthancStone::GetOrthancWebViewerJpegCommand> command(new OrthancStone::GetOrthancWebViewerJpegCommand); |
638
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2317 command->SetHttpHeader("Accept-Encoding", "gzip"); |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2318 command->SetInstance("e6c7c20b-c9f65d7e-0d76f2e2-830186f2-3e3c600e"); |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2319 command->SetQuality(90); |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2320 oracle.Schedule(*toto, command.release()); |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2321 } |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2322 |
e626f38c5512
DecodeOrthancWebViewerJpegCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
2323 |
744 | 2324 if (0) |
2325 { | |
2326 for (unsigned int i = 0; i < 10; i++) | |
2327 { | |
745 | 2328 std::auto_ptr<OrthancStone::SleepOracleCommand> command(new OrthancStone::SleepOracleCommand(i * 1000)); |
744 | 2329 command->SetPayload(new Orthanc::SingleValueObject<unsigned int>(42 * i)); |
2330 oracle.Schedule(*toto, command.release()); | |
2331 } | |
2332 } | |
2333 | |
784
9f3b2027a4a9
DicomStructureSetLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
2334 |
625
2eeb5857eb43
DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
623
diff
changeset
|
2335 // 2017-11-17-Anonymized |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
2336 #if 0 |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
2337 // BGO data |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
2338 ctLoader->LoadSeries("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa"); // CT |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
2339 doseLoader->LoadInstance("830a69ff-8e4b5ee3-b7f966c8-bccc20fb-d322dceb"); // RT-DOSE |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
2340 //rtstructLoader->LoadInstance("54460695-ba3885ee-ddf61ac0-f028e31d-a6e474d9"); // RT-STRUCT |
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
2341 #else |
794 | 2342 //ctLoader->LoadSeries("cb3ea4d1-d08f3856-ad7b6314-74d88d77-60b05618"); // CT |
793
f72b49954f62
DicomVolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
792
diff
changeset
|
2343 doseLoader->LoadInstance("41029085-71718346-811efac4-420e2c15-d39f99b6"); // RT-DOSE |
795
bc20e4c417ec
refactoring OrthancMultiframeVolumeLoader using LoaderStateMachine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
2344 //rtstructLoader->LoadInstance("83d9c0c3-913a7fee-610097d7-cbf0522d-fd75bee6"); // RT-STRUCT |
800
98a89b116b62
Added doc + fixed truncation warnings (+ inactive Orthanc IDs for BGO tests)
Benjamin Golinvaux <bgo@osimis.io>
parents:
795
diff
changeset
|
2345 #endif |
764 | 2346 // 2015-01-28-Multiframe |
783 | 2347 //doseLoader->LoadInstance("88f71e2a-5fad1c61-96ed14d6-5b3d3cf7-a5825279"); // Multiframe CT |
764 | 2348 |
661 | 2349 // Delphine |
783 | 2350 //ctLoader->LoadSeries("5990e39c-51e5f201-fe87a54c-31a55943-e59ef80e"); // CT |
2351 //ctLoader->LoadSeries("67f1b334-02c16752-45026e40-a5b60b6b-030ecab5"); // Lung 1/10mm | |
661 | 2352 |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2353 |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2354 { |
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2355 LOG(WARNING) << "...Waiting for Ctrl-C..."; |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
759
diff
changeset
|
2356 |
765 | 2357 oracle.Start(); |
2358 | |
2359 Orthanc::SystemToolbox::ServerBarrier(); | |
2360 | |
2361 /** | |
2362 * WARNING => The oracle must be stopped BEFORE the objects using | |
2363 * it are destroyed!!! This forces to wait for the completion of | |
2364 * the running callback methods. Otherwise, the callbacks methods | |
2365 * might still be running while their parent object is destroyed, | |
2366 * resulting in crashes. This is very visible if adding a sleep(), | |
2367 * as in (*). | |
2368 **/ | |
2369 | |
2370 oracle.Stop(); | |
2371 } | |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2372 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2373 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2374 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2375 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2376 /** |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2377 * IMPORTANT: The full arguments to "main()" are needed for SDL on |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2378 * Windows. Otherwise, one gets the linking error "undefined reference |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2379 * to `SDL_main'". https://wiki.libsdl.org/FAQWindows |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2380 **/ |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2381 int main(int argc, char* argv[]) |
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 OrthancStone::StoneInitialize(); |
778
78fcb907caf6
VolumeGeometryReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2384 //Orthanc::Logging::EnableInfoLevel(true); |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2385 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2386 try |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2387 { |
745 | 2388 OrthancStone::NativeApplicationContext context; |
2389 | |
2390 OrthancStone::ThreadedOracle oracle(context); | |
767 | 2391 //oracle.SetThreadsCount(1); |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2392 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2393 { |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2394 Orthanc::WebServiceParameters p; |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2395 //p.SetUrl("http://localhost:8043/"); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2396 p.SetCredentials("orthanc", "orthanc"); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2397 oracle.SetOrthancParameters(p); |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2398 } |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2399 |
765 | 2400 //oracle.Start(); |
680
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2401 |
0eb26f514ac5
loading of slice images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
678
diff
changeset
|
2402 Run(context, oracle); |
765 | 2403 |
2404 //oracle.Stop(); | |
619
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2405 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2406 catch (Orthanc::OrthancException& e) |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2407 { |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2408 LOG(ERROR) << "EXCEPTION: " << e.What(); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2409 } |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2410 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2411 OrthancStone::StoneFinalize(); |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2412 |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2413 return 0; |
9cd19b28f011
test: refactoring oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2414 } |