annotate Framework/dev.h @ 380:ba5ad93f935a

ILayerSource::LayerErrorMessage
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 06 Nov 2018 14:59:20 +0100
parents 814fa32e2fcc
children 19bd222283ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
135
e2fe9352f240 upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 121
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
16 *
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #pragma once
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "Layers/FrameRenderer.h"
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "Layers/LayerSourceBase.h"
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "Layers/SliceOutlineRenderer.h"
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
27 #include "Layers/LineLayerRenderer.h"
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
28 #include "Widgets/LayerWidget.h"
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include "Toolbox/DownloadStack.h"
159
0a73d76333db populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 158
diff changeset
30 #include "Toolbox/GeometryToolbox.h"
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include "Toolbox/OrthancSlicesLoader.h"
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include "Volumes/ImageBuffer3D.h"
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include "Volumes/SlicedVolumeBase.h"
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
35 #include <Core/Logging.h>
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
36 #include <Core/Images/ImageProcessing.h>
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include <boost/math/special_functions/round.hpp>
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace OrthancStone
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
136
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
43 // TODO: Handle errors while loading
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
44 class OrthancVolumeImage :
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
45 public SlicedVolumeBase,
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
46 public OrthancStone::IObserver
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
47 {
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 private:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 OrthancSlicesLoader loader_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 std::auto_ptr<ImageBuffer3D> image_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 std::auto_ptr<DownloadStack> downloadStack_;
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
52 bool computeRange_;
136
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
53 size_t pendingSlices_;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 void ScheduleSliceDownload()
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 assert(downloadStack_.get() != NULL);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 unsigned int slice;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 if (downloadStack_->Pop(slice))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 loader_.ScheduleLoadSliceImage(slice, SliceImageQuality_Jpeg90);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
67 static bool IsCompatible(const Slice& a,
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 const Slice& b)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 if (!GeometryToolbox::IsParallel(a.GetGeometry().GetNormal(),
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 b.GetGeometry().GetNormal()))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 LOG(ERROR) << "Some slice in the volume image is not parallel to the others";
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 return false;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 if (a.GetConverter().GetExpectedPixelFormat() != b.GetConverter().GetExpectedPixelFormat())
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 LOG(ERROR) << "The pixel format changes across the slices of the volume image";
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 return false;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 if (a.GetWidth() != b.GetWidth() ||
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 a.GetHeight() != b.GetHeight())
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 LOG(ERROR) << "The width/height of the slices change across the volume image";
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 return false;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
158
a053ca7fa5c6 LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 138
diff changeset
90 if (!LinearAlgebra::IsNear(a.GetPixelSpacingX(), b.GetPixelSpacingX()) ||
a053ca7fa5c6 LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 138
diff changeset
91 !LinearAlgebra::IsNear(a.GetPixelSpacingY(), b.GetPixelSpacingY()))
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 LOG(ERROR) << "The pixel spacing of the slices change across the volume image";
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 return false;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 return true;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
101 static double GetDistance(const Slice& a,
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 const Slice& b)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
104 return fabs(a.GetGeometry().ProjectAlongNormal(a.GetGeometry().GetOrigin()) -
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 a.GetGeometry().ProjectAlongNormal(b.GetGeometry().GetOrigin()));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 252
diff changeset
109 void OnSliceGeometryReady(const OrthancSlicesLoader& loader)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 if (loader.GetSliceCount() == 0)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 LOG(ERROR) << "Empty volume image";
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 SlicedVolumeBase::NotifyGeometryError();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 return;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 for (size_t i = 1; i < loader.GetSliceCount(); i++)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 if (!IsCompatible(loader.GetSlice(0), loader.GetSlice(i)))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 SlicedVolumeBase::NotifyGeometryError();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 return;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 double spacingZ;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 if (loader.GetSliceCount() > 1)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 spacingZ = GetDistance(loader.GetSlice(0), loader.GetSlice(1));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 else
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 // This is a volume with one single slice: Choose a dummy
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 // z-dimension for voxels
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 spacingZ = 1;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 }
120
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
139
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 for (size_t i = 1; i < loader.GetSliceCount(); i++)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 {
158
a053ca7fa5c6 LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 138
diff changeset
142 if (!LinearAlgebra::IsNear(spacingZ, GetDistance(loader.GetSlice(i - 1), loader.GetSlice(i)),
a053ca7fa5c6 LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 138
diff changeset
143 0.001 /* this is expressed in mm */))
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 LOG(ERROR) << "The distance between successive slices is not constant in a volume image";
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 SlicedVolumeBase::NotifyGeometryError();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 return;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 unsigned int width = loader.GetSlice(0).GetWidth();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 unsigned int height = loader.GetSlice(0).GetHeight();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 Orthanc::PixelFormat format = loader.GetSlice(0).GetConverter().GetExpectedPixelFormat();
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 252
diff changeset
154 LOG(INFO) << "Creating a volume image of size " << width << "x" << height
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 << "x" << loader.GetSliceCount() << " in " << Orthanc::EnumerationToString(format);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
157 image_.reset(new ImageBuffer3D(format, width, height, loader.GetSliceCount(), computeRange_));
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 image_->SetAxialGeometry(loader.GetSlice(0).GetGeometry());
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 252
diff changeset
159 image_->SetVoxelDimensions(loader.GetSlice(0).GetPixelSpacingX(),
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 loader.GetSlice(0).GetPixelSpacingY(), spacingZ);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 image_->Clear();
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 252
diff changeset
162
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 downloadStack_.reset(new DownloadStack(loader.GetSliceCount()));
136
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
164 pendingSlices_ = loader.GetSliceCount();
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 for (unsigned int i = 0; i < 4; i++) // Limit to 4 simultaneous downloads
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 ScheduleSliceDownload();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 // TODO Check the DicomFrameConverter are constant
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 SlicedVolumeBase::NotifyGeometryReady();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175
252
40b21c1f8b8d more usage of IObservable/IObserver
am@osimis.io
parents: 251
diff changeset
176 virtual void OnSliceImageReady(const OrthancSlicesLoader& loader,
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
177 unsigned int sliceIndex,
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
178 const Slice& slice,
378
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
179 const Orthanc::ImageAccessor& image,
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
180 SliceImageQuality quality)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 ImageBuffer3D::SliceWriter writer(*image_, VolumeProjection_Axial, sliceIndex);
378
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
184 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), image);
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 252
diff changeset
187 SlicedVolumeBase::NotifySliceChange(sliceIndex, slice);
136
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
188
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
189 if (pendingSlices_ == 1)
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
190 {
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
191 SlicedVolumeBase::NotifyVolumeReady();
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
192 pendingSlices_ = 0;
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
193 }
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
194 else if (pendingSlices_ > 1)
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
195 {
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
196 pendingSlices_ -= 1;
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
197 }
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 ScheduleSliceDownload();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 252
diff changeset
202 virtual void HandleMessage(const IObservable& from, const IMessage& message)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 {
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 252
diff changeset
204 switch (message.GetType())
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 252
diff changeset
205 {
378
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
206 case MessageType_SliceLoader_GeometryReady:
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
207 OnSliceGeometryReady(dynamic_cast<const OrthancSlicesLoader&>(from));
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
208 break;
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
209
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
210 case MessageType_SliceLoader_GeometryError:
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
211 LOG(ERROR) << "Unable to download a volume image";
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
212 SlicedVolumeBase::NotifyGeometryError();
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
213 break;
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
214
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
215 case MessageType_SliceLoader_ImageReady:
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
216 {
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
217 const OrthancSlicesLoader::SliceImageReadyMessage& msg =
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
218 dynamic_cast<const OrthancSlicesLoader::SliceImageReadyMessage&>(message);
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
219 OnSliceImageReady(dynamic_cast<const OrthancSlicesLoader&>(from),
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
220 msg.GetSliceIndex(),
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
221 msg.GetSlice(),
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
222 msg.GetImage(),
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
223 msg.GetEffectiveQuality());
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
224 break;
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
225 }
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
226
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
227 case MessageType_SliceLoader_ImageError:
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
228 {
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
229 const OrthancSlicesLoader::SliceImageErrorMessage& msg =
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
230 dynamic_cast<const OrthancSlicesLoader::SliceImageErrorMessage&>(message);
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
231 LOG(ERROR) << "Cannot download slice " << msg.GetSliceIndex() << " in a volume image";
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
232 ScheduleSliceDownload();
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
233 break;
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
234 }
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
235
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
236 default:
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
237 VLOG("unhandled message type" << message.GetType());
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 252
diff changeset
238 }
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 public:
251
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 216
diff changeset
242 OrthancVolumeImage(MessageBroker& broker,
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
243 OrthancApiClient& orthanc,
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
244 bool computeRange) :
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 252
diff changeset
245 OrthancStone::IObserver(broker),
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 252
diff changeset
246 loader_(broker, orthanc),
136
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
247 computeRange_(computeRange),
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
248 pendingSlices_(0)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 {
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
250 // TODO: replace with new callables loader_.RegisterObserver(*this);
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 void ScheduleLoadSeries(const std::string& seriesId)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 loader_.ScheduleLoadSeries(seriesId);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
258 void ScheduleLoadInstance(const std::string& instanceId)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 {
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
260 loader_.ScheduleLoadInstance(instanceId);
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
261 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
262
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
263 void ScheduleLoadFrame(const std::string& instanceId,
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
264 unsigned int frame)
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
265 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
266 loader_.ScheduleLoadFrame(instanceId, frame);
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 virtual size_t GetSliceCount() const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 return loader_.GetSliceCount();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 virtual const Slice& GetSlice(size_t index) const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 return loader_.GetSlice(index);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 ImageBuffer3D& GetImage() const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 if (image_.get() == NULL)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 // The geometry is not ready yet
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 else
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 return *image_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 }
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
291
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
292 bool FitWindowingToRange(RenderStyle& style,
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
293 const DicomFrameConverter& converter) const
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
294 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
295 if (image_.get() == NULL)
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
296 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
297 return false;
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
298 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
299 else
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
300 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
301 return image_->FitWindowingToRange(style, converter);
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
302 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
303 }
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 };
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 class VolumeImageGeometry
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 private:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 unsigned int width_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 unsigned int height_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 size_t depth_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 double pixelSpacingX_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 double pixelSpacingY_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 double sliceThickness_;
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
316 CoordinateSystem3D reference_;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 DicomFrameConverter converter_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 double ComputeAxialThickness(const OrthancVolumeImage& volume) const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 double thickness;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 size_t n = volume.GetSliceCount();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 if (n > 1)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 const Slice& a = volume.GetSlice(0);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 const Slice& b = volume.GetSlice(n - 1);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 thickness = ((reference_.ProjectAlongNormal(b.GetGeometry().GetOrigin()) -
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 reference_.ProjectAlongNormal(a.GetGeometry().GetOrigin())) /
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 (static_cast<double>(n) - 1.0));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 else
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 thickness = volume.GetSlice(0).GetThickness();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 if (thickness <= 0)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 // The slices should have been sorted with increasing Z
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 // (along the normal) by the OrthancSlicesLoader
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 else
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 return thickness;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 void SetupAxial(const OrthancVolumeImage& volume)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 const Slice& axial = volume.GetSlice(0);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 width_ = axial.GetWidth();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 height_ = axial.GetHeight();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 depth_ = volume.GetSliceCount();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 pixelSpacingX_ = axial.GetPixelSpacingX();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 pixelSpacingY_ = axial.GetPixelSpacingY();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 sliceThickness_ = ComputeAxialThickness(volume);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 reference_ = axial.GetGeometry();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 void SetupCoronal(const OrthancVolumeImage& volume)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 const Slice& axial = volume.GetSlice(0);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 double axialThickness = ComputeAxialThickness(volume);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 width_ = axial.GetWidth();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 height_ = volume.GetSliceCount();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 depth_ = axial.GetHeight();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 pixelSpacingX_ = axial.GetPixelSpacingX();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 pixelSpacingY_ = axialThickness;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 sliceThickness_ = axial.GetPixelSpacingY();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 Vector origin = axial.GetGeometry().GetOrigin();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 origin += (static_cast<double>(volume.GetSliceCount() - 1) *
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 axialThickness * axial.GetGeometry().GetNormal());
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
381 reference_ = CoordinateSystem3D(origin,
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
382 axial.GetGeometry().GetAxisX(),
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
383 -axial.GetGeometry().GetNormal());
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 void SetupSagittal(const OrthancVolumeImage& volume)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 const Slice& axial = volume.GetSlice(0);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 double axialThickness = ComputeAxialThickness(volume);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 width_ = axial.GetHeight();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 height_ = volume.GetSliceCount();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 depth_ = axial.GetWidth();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 pixelSpacingX_ = axial.GetPixelSpacingY();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 pixelSpacingY_ = axialThickness;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 sliceThickness_ = axial.GetPixelSpacingX();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 Vector origin = axial.GetGeometry().GetOrigin();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 origin += (static_cast<double>(volume.GetSliceCount() - 1) *
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 axialThickness * axial.GetGeometry().GetNormal());
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
403 reference_ = CoordinateSystem3D(origin,
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
404 axial.GetGeometry().GetAxisY(),
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
405 axial.GetGeometry().GetNormal());
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 public:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 VolumeImageGeometry(const OrthancVolumeImage& volume,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 VolumeProjection projection)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 if (volume.GetSliceCount() == 0)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 converter_ = volume.GetSlice(0).GetConverter();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 switch (projection)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 {
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
421 case VolumeProjection_Axial:
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
422 SetupAxial(volume);
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
423 break;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
425 case VolumeProjection_Coronal:
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
426 SetupCoronal(volume);
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
427 break;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
429 case VolumeProjection_Sagittal:
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
430 SetupSagittal(volume);
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
431 break;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
433 default:
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
434 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 size_t GetSliceCount() const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 return depth_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 const Vector& GetNormal() const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 return reference_.GetNormal();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 bool LookupSlice(size_t& index,
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
449 const CoordinateSystem3D& slice) const
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 bool opposite;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 if (!GeometryToolbox::IsParallelOrOpposite(opposite,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 reference_.GetNormal(),
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 slice.GetNormal()))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 return false;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 double z = (reference_.ProjectAlongNormal(slice.GetOrigin()) -
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 reference_.ProjectAlongNormal(reference_.GetOrigin())) / sliceThickness_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 int s = static_cast<int>(boost::math::iround(z));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 if (s < 0 ||
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 s >= static_cast<int>(depth_))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 return false;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 else
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 index = static_cast<size_t>(s);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 return true;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
476 Slice* GetSlice(size_t slice) const
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 {
216
c4ea26865975 fix warning, size_t is always > 0
am@osimis.io
parents: 212
diff changeset
478 if (slice >= depth_)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 else
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 {
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
484 CoordinateSystem3D origin(reference_.GetOrigin() +
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
485 static_cast<double>(slice) * sliceThickness_ * reference_.GetNormal(),
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
486 reference_.GetAxisX(),
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
487 reference_.GetAxisY());
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
489 return new Slice(origin, pixelSpacingX_, pixelSpacingY_, sliceThickness_,
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
490 width_, height_, converter_);
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 };
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 class VolumeImageSource :
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
498 public LayerSourceBase,
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
499 private ISlicedVolume::IObserver
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 private:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 OrthancVolumeImage& volume_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 std::auto_ptr<VolumeImageGeometry> axialGeometry_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 std::auto_ptr<VolumeImageGeometry> coronalGeometry_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 std::auto_ptr<VolumeImageGeometry> sagittalGeometry_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 bool IsGeometryReady() const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510 return axialGeometry_.get() != NULL;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514 virtual void NotifyGeometryReady(const ISlicedVolume& volume)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 // These 3 values are only used to speed up the ILayerSource
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 axialGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Axial));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 coronalGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Coronal));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 sagittalGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Sagittal));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 LayerSourceBase::NotifyGeometryReady();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
523
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 virtual void NotifyGeometryError(const ISlicedVolume& volume)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 LayerSourceBase::NotifyGeometryError();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
528
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529 virtual void NotifyContentChange(const ISlicedVolume& volume)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 LayerSourceBase::NotifyContentChange();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534 virtual void NotifySliceChange(const ISlicedVolume& volume,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 const size_t& sliceIndex,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 const Slice& slice)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 //LayerSourceBase::NotifySliceChange(slice);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540 // TODO Improve this?
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 LayerSourceBase::NotifyContentChange();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543
138
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
544 virtual void NotifyVolumeReady(const ISlicedVolume& volume)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
545 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
546 }
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 const VolumeImageGeometry& GetProjectionGeometry(VolumeProjection projection)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550 if (!IsGeometryReady())
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 switch (projection)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 {
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
557 case VolumeProjection_Axial:
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
558 return *axialGeometry_;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
560 case VolumeProjection_Sagittal:
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
561 return *sagittalGeometry_;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
563 case VolumeProjection_Coronal:
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
564 return *coronalGeometry_;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
566 default:
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
567 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572 bool DetectProjection(VolumeProjection& projection,
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
573 const CoordinateSystem3D& viewportSlice)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 bool isOpposite; // Ignored
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577 if (GeometryToolbox::IsParallelOrOpposite(isOpposite,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578 viewportSlice.GetNormal(),
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 axialGeometry_->GetNormal()))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 projection = VolumeProjection_Axial;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582 return true;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 else if (GeometryToolbox::IsParallelOrOpposite(isOpposite,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 viewportSlice.GetNormal(),
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 sagittalGeometry_->GetNormal()))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 projection = VolumeProjection_Sagittal;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589 return true;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 else if (GeometryToolbox::IsParallelOrOpposite(isOpposite,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 viewportSlice.GetNormal(),
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593 coronalGeometry_->GetNormal()))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 projection = VolumeProjection_Coronal;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 return true;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 else
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 return false;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 public:
251
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 216
diff changeset
606 VolumeImageSource(MessageBroker& broker, OrthancVolumeImage& volume) :
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 216
diff changeset
607 LayerSourceBase(broker),
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608 volume_(volume)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610 volume_.Register(*this);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
612
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613 virtual bool GetExtent(std::vector<Vector>& points,
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
614 const CoordinateSystem3D& viewportSlice)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 VolumeProjection projection;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618 if (!IsGeometryReady() ||
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 !DetectProjection(projection, viewportSlice))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621 return false;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
622 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623 else
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
624 {
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 // As the slices of the volumic image are arranged in a box,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626 // we only consider one single reference slice (the one with index 0).
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
627 std::auto_ptr<Slice> slice(GetProjectionGeometry(projection).GetSlice(0));
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
628 slice->GetExtent(points);
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
630 return true;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
631 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
634
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
635 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
637 VolumeProjection projection;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 if (IsGeometryReady() &&
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640 DetectProjection(projection, viewportSlice))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
641 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
642 const VolumeImageGeometry& geometry = GetProjectionGeometry(projection);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
643
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
644 size_t closest;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
645
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646 if (geometry.LookupSlice(closest, viewportSlice))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 bool isFullQuality = true; // TODO
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 std::auto_ptr<Orthanc::Image> frame;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
651
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653 ImageBuffer3D::SliceReader reader(volume_.GetImage(), projection, closest);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655 // TODO Transfer ownership if non-axial, to avoid memcpy
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
656 frame.reset(Orthanc::Image::Clone(reader.GetAccessor()));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
657 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
658
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
659 std::auto_ptr<Slice> slice(geometry.GetSlice(closest));
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
660 LayerSourceBase::NotifyLayerReady(
378
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
661 FrameRenderer::CreateRenderer(*frame, *slice, isFullQuality),
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
662 //new SliceOutlineRenderer(slice),
380
ba5ad93f935a ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 378
diff changeset
663 slice->GetGeometry());
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
664 return;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
666 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
667
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
668 // Error
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 120
diff changeset
669 CoordinateSystem3D slice;
380
ba5ad93f935a ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 378
diff changeset
670 LayerSourceBase::NotifyLayerError(slice);
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
672 };
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
673
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
674
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
675 class VolumeImageInteractor :
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
676 public IWorldSceneInteractor,
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
677 protected ISlicedVolume::IObserver
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
678 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
679 private:
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
680 LayerWidget& widget_;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
681 VolumeProjection projection_;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
682 std::auto_ptr<VolumeImageGeometry> slices_;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
683 size_t slice_;
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
684
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
685 protected:
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
686 virtual void NotifyGeometryReady(const ISlicedVolume& volume)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
687 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
688 if (slices_.get() == NULL)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
689 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
690 const OrthancVolumeImage& image = dynamic_cast<const OrthancVolumeImage&>(volume);
120
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
691
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
692 slices_.reset(new VolumeImageGeometry(image, projection_));
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
693 SetSlice(slices_->GetSliceCount() / 2);
120
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
694
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 327
diff changeset
695 widget_.FitContent();
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
696 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
697 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
698
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
699 virtual void NotifyGeometryError(const ISlicedVolume& volume)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
700 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
701 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
702
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
703 virtual void NotifyContentChange(const ISlicedVolume& volume)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
704 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
705 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
706
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
707 virtual void NotifySliceChange(const ISlicedVolume& volume,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
708 const size_t& sliceIndex,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
709 const Slice& slice)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
710 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
711 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
712
138
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
713 virtual void NotifyVolumeReady(const ISlicedVolume& volume)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
714 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
715 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
716
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
717 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
718 const ViewportGeometry& view,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
719 MouseButton button,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
720 double x,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
721 double y,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
722 IStatusBar* statusBar)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
723 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
724 return NULL;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
725 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
726
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
727 virtual void MouseOver(CairoContext& context,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
728 WorldSceneWidget& widget,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
729 const ViewportGeometry& view,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
730 double x,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
731 double y,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
732 IStatusBar* statusBar)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
733 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
734 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
735
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
736 virtual void MouseWheel(WorldSceneWidget& widget,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
737 MouseWheelDirection direction,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
738 KeyboardModifiers modifiers,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
739 IStatusBar* statusBar)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
740 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
741 int scale = (modifiers & KeyboardModifiers_Control ? 10 : 1);
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
742
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
743 switch (direction)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
744 {
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
745 case MouseWheelDirection_Up:
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
746 OffsetSlice(-scale);
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
747 break;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
748
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
749 case MouseWheelDirection_Down:
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
750 OffsetSlice(scale);
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
751 break;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
752
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
753 default:
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
754 break;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
755 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
756 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
757
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
758 virtual void KeyPressed(WorldSceneWidget& widget,
327
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 318
diff changeset
759 KeyboardKeys key,
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 318
diff changeset
760 char keyChar,
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
761 KeyboardModifiers modifiers,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
762 IStatusBar* statusBar)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
763 {
327
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 318
diff changeset
764 switch (keyChar)
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
765 {
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
766 case 's':
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 327
diff changeset
767 widget.FitContent();
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
768 break;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
769
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
770 default:
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
771 break;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
772 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
773 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
774
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
775 public:
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
776 VolumeImageInteractor(OrthancVolumeImage& volume,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
777 LayerWidget& widget,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
778 VolumeProjection projection) :
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
779 widget_(widget),
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
780 projection_(projection)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
781 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
782 volume.Register(*this);
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
783 widget.SetInteractor(*this);
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
784 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
785
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
786 bool IsGeometryReady() const
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
787 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
788 return slices_.get() != NULL;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
789 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
790
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
791 size_t GetSliceCount() const
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
792 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
793 if (slices_.get() == NULL)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
794 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
795 return 0;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
796 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
797 else
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
798 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
799 return slices_->GetSliceCount();
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
800 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
801 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
802
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
803 void OffsetSlice(int offset)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
804 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
805 if (slices_.get() != NULL)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
806 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
807 int slice = static_cast<int>(slice_) + offset;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
808
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
809 if (slice < 0)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
810 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
811 slice = 0;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
812 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
813
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
814 if (slice >= static_cast<int>(slices_->GetSliceCount()))
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
815 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
816 slice = slices_->GetSliceCount() - 1;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
817 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
818
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
819 if (slice != static_cast<int>(slice_))
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
820 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
821 SetSlice(slice);
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
822 }
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
823 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
824 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
825
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
826 void SetSlice(size_t slice)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
827 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
828 if (slices_.get() != NULL)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
829 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
830 slice_ = slice;
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
831
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
832 std::auto_ptr<Slice> tmp(slices_->GetSlice(slice_));
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
833 widget_.SetSlice(tmp->GetGeometry());
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
834 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
835 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
836 };
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
837
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
838
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
839
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
840 class SliceLocationSource : public LayerSourceBase
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
841 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
842 private:
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
843 LayerWidget& otherPlane_;
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
844
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
845 public:
251
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 216
diff changeset
846 SliceLocationSource(MessageBroker& broker, LayerWidget& otherPlane) :
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 216
diff changeset
847 LayerSourceBase(broker),
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
848 otherPlane_(otherPlane)
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
849 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
850 NotifyGeometryReady();
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
851 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
852
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
853 virtual bool GetExtent(std::vector<Vector>& points,
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
854 const CoordinateSystem3D& viewportSlice)
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
855 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
856 return false;
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
857 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
858
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
859 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice)
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
860 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
861 Slice reference(viewportSlice, 0.001);
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
862
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
863 Vector p, d;
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
864
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
865 const CoordinateSystem3D& slice = otherPlane_.GetSlice();
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
866
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
867 // Compute the line of intersection between the two slices
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
868 if (!GeometryToolbox::IntersectTwoPlanes(p, d,
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
869 slice.GetOrigin(), slice.GetNormal(),
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
870 viewportSlice.GetOrigin(), viewportSlice.GetNormal()))
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
871 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
872 // The two slice are parallel, don't try and display the intersection
380
ba5ad93f935a ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 378
diff changeset
873 NotifyLayerError(reference.GetGeometry());
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
874 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
875 else
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
876 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
877 double x1, y1, x2, y2;
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
878 viewportSlice.ProjectPoint(x1, y1, p);
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
879 viewportSlice.ProjectPoint(x2, y2, p + 1000.0 * d);
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
880
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
881 const Extent2D extent = otherPlane_.GetSceneExtent();
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
882
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
883 if (GeometryToolbox::ClipLineToRectangle(x1, y1, x2, y2,
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
884 x1, y1, x2, y2,
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
885 extent.GetX1(), extent.GetY1(),
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
886 extent.GetX2(), extent.GetY2()))
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
887 {
380
ba5ad93f935a ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 378
diff changeset
888 NotifyLayerReady(new LineLayerRenderer(x1, y1, x2, y2, slice), reference.GetGeometry());
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
889 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
890 else
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
891 {
380
ba5ad93f935a ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 378
diff changeset
892 // Error: Parallel slices
ba5ad93f935a ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 378
diff changeset
893 NotifyLayerError(reference.GetGeometry());
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
894 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
895 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
896 }
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
897 };
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898 }