annotate Framework/dev.h @ 254:abc1c6231947 am-2

cleanup
author am@osimis.io
date Tue, 03 Jul 2018 11:49:02 +0200
parents 40b21c1f8b8d
children c9cf95b49a86
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.
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
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
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 class OrthancVolumeImage :
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 public SlicedVolumeBase,
252
40b21c1f8b8d more usage of IObservable/IObserver
am@osimis.io
parents: 251
diff changeset
46 private OrthancSlicesLoader::ISliceLoaderObserver
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
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
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 static bool IsCompatible(const Slice& a,
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
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 static double GetDistance(const Slice& a,
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 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 return fabs(a.GetGeometry().ProjectAlongNormal(a.GetGeometry().GetOrigin()) -
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
252
40b21c1f8b8d more usage of IObservable/IObserver
am@osimis.io
parents: 251
diff changeset
109 virtual 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();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 LOG(INFO) << "Creating a volume image of size " << width << "x" << height
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());
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 image_->SetVoxelDimensions(loader.GetSlice(0).GetPixelSpacingX(),
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();
120
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
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 OnSliceGeometryError(const OrthancSlicesLoader& loader)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 LOG(ERROR) << "Unable to download a volume image";
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 SlicedVolumeBase::NotifyGeometryError();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181
252
40b21c1f8b8d more usage of IObservable/IObserver
am@osimis.io
parents: 251
diff changeset
182 virtual void OnSliceImageReady(const OrthancSlicesLoader& loader,
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 unsigned int sliceIndex,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 const Slice& slice,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 std::auto_ptr<Orthanc::ImageAccessor>& image,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 SliceImageQuality quality)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 ImageBuffer3D::SliceWriter writer(*image_, VolumeProjection_Axial, sliceIndex);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), *image);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192
136
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
193 SlicedVolumeBase::NotifySliceChange(sliceIndex, slice);
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
194
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
195 if (pendingSlices_ == 1)
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
196 {
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
197 SlicedVolumeBase::NotifyVolumeReady();
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
198 pendingSlices_ = 0;
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
199 }
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
200 else if (pendingSlices_ > 1)
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
201 {
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
202 pendingSlices_ -= 1;
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
203 }
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 ScheduleSliceDownload();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207
252
40b21c1f8b8d more usage of IObservable/IObserver
am@osimis.io
parents: 251
diff changeset
208 virtual void OnSliceImageError(const OrthancSlicesLoader& loader,
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 unsigned int sliceIndex,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 const Slice& slice,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 SliceImageQuality quality)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 LOG(ERROR) << "Cannot download slice " << sliceIndex << " in a volume image";
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 ScheduleSliceDownload();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 public:
251
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 216
diff changeset
218 OrthancVolumeImage(MessageBroker& broker,
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 216
diff changeset
219 IWebService& orthanc,
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
220 bool computeRange) :
252
40b21c1f8b8d more usage of IObservable/IObserver
am@osimis.io
parents: 251
diff changeset
221 OrthancSlicesLoader::ISliceLoaderObserver(broker),
251
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 216
diff changeset
222 loader_(broker, *this, orthanc),
136
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
223 computeRange_(computeRange),
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
224 pendingSlices_(0)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 void ScheduleLoadSeries(const std::string& seriesId)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 loader_.ScheduleLoadSeries(seriesId);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
233 void ScheduleLoadInstance(const std::string& instanceId)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 {
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
235 loader_.ScheduleLoadInstance(instanceId);
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
236 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
237
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
238 void ScheduleLoadFrame(const std::string& instanceId,
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
239 unsigned int frame)
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
240 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
241 loader_.ScheduleLoadFrame(instanceId, frame);
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 virtual size_t GetSliceCount() const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 return loader_.GetSliceCount();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 virtual const Slice& GetSlice(size_t index) const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 return loader_.GetSlice(index);
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
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 ImageBuffer3D& GetImage() const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 if (image_.get() == NULL)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 // The geometry is not ready yet
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 else
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 return *image_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 }
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
266
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
267 bool FitWindowingToRange(RenderStyle& style,
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
268 const DicomFrameConverter& converter) const
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
269 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
270 if (image_.get() == NULL)
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
271 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
272 return false;
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
273 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
274 else
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
275 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
276 return image_->FitWindowingToRange(style, converter);
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
277 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
278 }
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 };
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
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 class VolumeImageGeometry
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 private:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 unsigned int width_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 unsigned int height_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 size_t depth_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 double pixelSpacingX_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 double pixelSpacingY_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 double sliceThickness_;
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
291 CoordinateSystem3D reference_;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 DicomFrameConverter converter_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 double ComputeAxialThickness(const OrthancVolumeImage& volume) const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 double thickness;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 size_t n = volume.GetSliceCount();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 if (n > 1)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 const Slice& a = volume.GetSlice(0);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 const Slice& b = volume.GetSlice(n - 1);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 thickness = ((reference_.ProjectAlongNormal(b.GetGeometry().GetOrigin()) -
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 reference_.ProjectAlongNormal(a.GetGeometry().GetOrigin())) /
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 (static_cast<double>(n) - 1.0));
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 else
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 thickness = volume.GetSlice(0).GetThickness();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 if (thickness <= 0)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 // The slices should have been sorted with increasing Z
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 // (along the normal) by the OrthancSlicesLoader
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 else
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 return thickness;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 }
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
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 void SetupAxial(const OrthancVolumeImage& volume)
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& axial = volume.GetSlice(0);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 width_ = axial.GetWidth();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 height_ = axial.GetHeight();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 depth_ = volume.GetSliceCount();
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 pixelSpacingX_ = axial.GetPixelSpacingX();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 pixelSpacingY_ = axial.GetPixelSpacingY();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 sliceThickness_ = ComputeAxialThickness(volume);
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 reference_ = axial.GetGeometry();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 }
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 void SetupCoronal(const OrthancVolumeImage& volume)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 const Slice& axial = volume.GetSlice(0);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 double axialThickness = ComputeAxialThickness(volume);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 width_ = axial.GetWidth();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 height_ = volume.GetSliceCount();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 depth_ = axial.GetHeight();
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 pixelSpacingX_ = axial.GetPixelSpacingX();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 pixelSpacingY_ = axialThickness;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 sliceThickness_ = axial.GetPixelSpacingY();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 Vector origin = axial.GetGeometry().GetOrigin();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 origin += (static_cast<double>(volume.GetSliceCount() - 1) *
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 axialThickness * axial.GetGeometry().GetNormal());
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
356 reference_ = CoordinateSystem3D(origin,
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
357 axial.GetGeometry().GetAxisX(),
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
358 -axial.GetGeometry().GetNormal());
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 }
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 void SetupSagittal(const OrthancVolumeImage& volume)
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 const Slice& axial = volume.GetSlice(0);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 double axialThickness = ComputeAxialThickness(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 width_ = axial.GetHeight();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 height_ = volume.GetSliceCount();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 depth_ = axial.GetWidth();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 pixelSpacingX_ = axial.GetPixelSpacingY();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 pixelSpacingY_ = axialThickness;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 sliceThickness_ = axial.GetPixelSpacingX();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 Vector origin = axial.GetGeometry().GetOrigin();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 origin += (static_cast<double>(volume.GetSliceCount() - 1) *
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 axialThickness * axial.GetGeometry().GetNormal());
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
378 reference_ = CoordinateSystem3D(origin,
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
379 axial.GetGeometry().GetAxisY(),
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
380 axial.GetGeometry().GetNormal());
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 public:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 VolumeImageGeometry(const OrthancVolumeImage& volume,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 VolumeProjection projection)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 if (volume.GetSliceCount() == 0)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
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
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 converter_ = volume.GetSlice(0).GetConverter();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 switch (projection)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 case VolumeProjection_Axial:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 SetupAxial(volume);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 break;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 case VolumeProjection_Coronal:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 SetupCoronal(volume);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 break;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 case VolumeProjection_Sagittal:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 SetupSagittal(volume);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 break;
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 default:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 }
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
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 size_t GetSliceCount() const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 return depth_;
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
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 const Vector& GetNormal() const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 return reference_.GetNormal();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 bool LookupSlice(size_t& index,
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
424 const CoordinateSystem3D& slice) const
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 bool opposite;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 if (!GeometryToolbox::IsParallelOrOpposite(opposite,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 reference_.GetNormal(),
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 slice.GetNormal()))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 return false;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 double z = (reference_.ProjectAlongNormal(slice.GetOrigin()) -
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 reference_.ProjectAlongNormal(reference_.GetOrigin())) / sliceThickness_;
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 int s = static_cast<int>(boost::math::iround(z));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 if (s < 0 ||
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 s >= static_cast<int>(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 return false;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 else
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446 index = static_cast<size_t>(s);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 return true;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
451 Slice* GetSlice(size_t slice) const
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 {
216
c4ea26865975 fix warning, size_t is always > 0
am@osimis.io
parents: 212
diff changeset
453 if (slice >= depth_)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 else
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 {
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
459 CoordinateSystem3D origin(reference_.GetOrigin() +
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
460 static_cast<double>(slice) * sliceThickness_ * reference_.GetNormal(),
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
461 reference_.GetAxisX(),
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
462 reference_.GetAxisY());
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
464 return new Slice(origin, pixelSpacingX_, pixelSpacingY_, sliceThickness_,
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
465 width_, height_, converter_);
102
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 }
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
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
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 class VolumeImageSource :
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 public LayerSourceBase,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 private ISlicedVolume::IObserver
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 private:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 OrthancVolumeImage& volume_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 std::auto_ptr<VolumeImageGeometry> axialGeometry_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 std::auto_ptr<VolumeImageGeometry> coronalGeometry_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 std::auto_ptr<VolumeImageGeometry> sagittalGeometry_;
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
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 bool IsGeometryReady() const
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 return axialGeometry_.get() != NULL;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 virtual void NotifyGeometryReady(const ISlicedVolume& volume)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 // These 3 values are only used to speed up the ILayerSource
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 axialGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Axial));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 coronalGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Coronal));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 sagittalGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Sagittal));
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 LayerSourceBase::NotifyGeometryReady();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 virtual void NotifyGeometryError(const ISlicedVolume& volume)
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 LayerSourceBase::NotifyGeometryError();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 virtual void NotifyContentChange(const ISlicedVolume& volume)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 LayerSourceBase::NotifyContentChange();
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
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 virtual void NotifySliceChange(const ISlicedVolume& volume,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510 const size_t& sliceIndex,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 const Slice& slice)
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 //LayerSourceBase::NotifySliceChange(slice);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 // TODO Improve this?
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 LayerSourceBase::NotifyContentChange();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518
138
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
519 virtual void NotifyVolumeReady(const ISlicedVolume& volume)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
520 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
521 }
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 const VolumeImageGeometry& GetProjectionGeometry(VolumeProjection projection)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 if (!IsGeometryReady())
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
528 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 switch (projection)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 case VolumeProjection_Axial:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533 return *axialGeometry_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 case VolumeProjection_Sagittal:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 return *sagittalGeometry_;
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 case VolumeProjection_Coronal:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 return *coronalGeometry_;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 default:
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 bool DetectProjection(VolumeProjection& projection,
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
548 const CoordinateSystem3D& viewportSlice)
102
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 bool isOpposite; // Ignored
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 if (GeometryToolbox::IsParallelOrOpposite(isOpposite,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 viewportSlice.GetNormal(),
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 axialGeometry_->GetNormal()))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 projection = VolumeProjection_Axial;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 return true;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 else if (GeometryToolbox::IsParallelOrOpposite(isOpposite,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 viewportSlice.GetNormal(),
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 sagittalGeometry_->GetNormal()))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563 projection = VolumeProjection_Sagittal;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 return true;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566 else if (GeometryToolbox::IsParallelOrOpposite(isOpposite,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 viewportSlice.GetNormal(),
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 coronalGeometry_->GetNormal()))
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 projection = VolumeProjection_Coronal;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571 return true;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573 else
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 return false;
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 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 public:
251
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 216
diff changeset
581 VolumeImageSource(MessageBroker& broker, OrthancVolumeImage& volume) :
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 216
diff changeset
582 LayerSourceBase(broker),
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 volume_(volume)
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 volume_.Register(*this);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 }
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 virtual bool GetExtent(std::vector<Vector>& points,
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
589 const CoordinateSystem3D& viewportSlice)
102
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 VolumeProjection projection;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593 if (!IsGeometryReady() ||
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 !DetectProjection(projection, viewportSlice))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 return false;
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 // As the slices of the volumic image are arranged in a box,
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 // 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
602 std::auto_ptr<Slice> slice(GetProjectionGeometry(projection).GetSlice(0));
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
603 slice->GetExtent(points);
102
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 return true;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
607 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609
110
53025eecbc95 renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 104
diff changeset
610 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice)
102
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 VolumeProjection projection;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614 if (IsGeometryReady() &&
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 DetectProjection(projection, viewportSlice))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617 const VolumeImageGeometry& geometry = GetProjectionGeometry(projection);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 size_t closest;
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 if (geometry.LookupSlice(closest, viewportSlice))
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 bool isFullQuality = true; // TODO
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
624
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 std::auto_ptr<Orthanc::Image> frame;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628 ImageBuffer3D::SliceReader reader(volume_.GetImage(), projection, closest);
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 // TODO Transfer ownership if non-axial, to avoid memcpy
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
631 frame.reset(Orthanc::Image::Clone(reader.GetAccessor()));
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
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
634 std::auto_ptr<Slice> slice(geometry.GetSlice(closest));
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
635 LayerSourceBase::NotifyLayerReady(
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
636 FrameRenderer::CreateRenderer(frame.release(), *slice, isFullQuality),
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
637 //new SliceOutlineRenderer(slice),
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 120
diff changeset
638 slice->GetGeometry(), false);
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 return;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640 }
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
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
643 // Error
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 120
diff changeset
644 CoordinateSystem3D slice;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
645 LayerSourceBase::NotifyLayerReady(NULL, slice, true);
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647 };
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
648
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
649
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
650 class VolumeImageInteractor :
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
651 public IWorldSceneInteractor,
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
652 protected ISlicedVolume::IObserver
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
653 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
654 private:
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
655 LayerWidget& widget_;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
656 VolumeProjection projection_;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
657 std::auto_ptr<VolumeImageGeometry> slices_;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
658 size_t slice_;
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
659
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
660 protected:
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
661 virtual void NotifyGeometryReady(const ISlicedVolume& volume)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
662 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
663 if (slices_.get() == NULL)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
664 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
665 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
666
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
667 slices_.reset(new VolumeImageGeometry(image, projection_));
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
668 SetSlice(slices_->GetSliceCount() / 2);
120
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
669
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
670 widget_.SetDefaultView();
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
671 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
672 }
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 virtual void NotifyGeometryError(const ISlicedVolume& volume)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
675 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
676 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
677
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
678 virtual void NotifyContentChange(const ISlicedVolume& volume)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
679 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
680 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
681
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
682 virtual void NotifySliceChange(const ISlicedVolume& volume,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
683 const size_t& sliceIndex,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
684 const Slice& slice)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
685 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
686 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
687
138
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
688 virtual void NotifyVolumeReady(const ISlicedVolume& volume)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
689 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
690 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
691
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
692 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
693 const ViewportGeometry& view,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
694 MouseButton button,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
695 double x,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
696 double y,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
697 IStatusBar* statusBar)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
698 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
699 return NULL;
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
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
702 virtual void MouseOver(CairoContext& context,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
703 WorldSceneWidget& widget,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
704 const ViewportGeometry& view,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
705 double x,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
706 double y,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
707 IStatusBar* statusBar)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
708 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
709 }
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 virtual void MouseWheel(WorldSceneWidget& widget,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
712 MouseWheelDirection direction,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
713 KeyboardModifiers modifiers,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
714 IStatusBar* statusBar)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
715 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
716 int scale = (modifiers & KeyboardModifiers_Control ? 10 : 1);
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
717
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
718 switch (direction)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
719 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
720 case MouseWheelDirection_Up:
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
721 OffsetSlice(-scale);
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
722 break;
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 case MouseWheelDirection_Down:
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
725 OffsetSlice(scale);
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
726 break;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
727
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
728 default:
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
729 break;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
730 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
731 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
732
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
733 virtual void KeyPressed(WorldSceneWidget& widget,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
734 char key,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
735 KeyboardModifiers modifiers,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
736 IStatusBar* statusBar)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
737 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
738 switch (key)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
739 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
740 case 's':
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
741 widget.SetDefaultView();
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
742 break;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
743
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
744 default:
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
745 break;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
746 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
747 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
748
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
749 public:
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
750 VolumeImageInteractor(OrthancVolumeImage& volume,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
751 LayerWidget& widget,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
752 VolumeProjection projection) :
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
753 widget_(widget),
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
754 projection_(projection)
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 volume.Register(*this);
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
757 widget.SetInteractor(*this);
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
758 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
759
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
760 bool IsGeometryReady() const
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
761 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
762 return slices_.get() != NULL;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
763 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
764
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
765 size_t GetSliceCount() const
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
766 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
767 if (slices_.get() == NULL)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
768 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
769 return 0;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
770 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
771 else
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 return slices_->GetSliceCount();
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
774 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
775 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
776
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
777 void OffsetSlice(int offset)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
778 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
779 if (slices_.get() != NULL)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
780 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
781 int slice = static_cast<int>(slice_) + offset;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
782
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
783 if (slice < 0)
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 slice = 0;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
786 }
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 if (slice >= static_cast<int>(slices_->GetSliceCount()))
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 slice = slices_->GetSliceCount() - 1;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
791 }
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 (slice != static_cast<int>(slice_))
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 SetSlice(slice);
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 }
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
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
800 void SetSlice(size_t slice)
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 if (slices_.get() != NULL)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
803 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
804 slice_ = slice;
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
805
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
806 std::auto_ptr<Slice> tmp(slices_->GetSlice(slice_));
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
807 widget_.SetSlice(tmp->GetGeometry());
104
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 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
810 };
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
811
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
812
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
813
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
814 class SliceLocationSource : public LayerSourceBase
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
815 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
816 private:
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
817 LayerWidget& otherPlane_;
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
818
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
819 public:
251
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 216
diff changeset
820 SliceLocationSource(MessageBroker& broker, LayerWidget& otherPlane) :
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 216
diff changeset
821 LayerSourceBase(broker),
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
822 otherPlane_(otherPlane)
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
823 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
824 NotifyGeometryReady();
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
825 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
826
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
827 virtual bool GetExtent(std::vector<Vector>& points,
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
828 const CoordinateSystem3D& viewportSlice)
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
829 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
830 return false;
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
831 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
832
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
833 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice)
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
834 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
835 Slice reference(viewportSlice, 0.001);
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
836
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
837 Vector p, d;
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 const CoordinateSystem3D& slice = otherPlane_.GetSlice();
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
840
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
841 // Compute the line of intersection between the two slices
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
842 if (!GeometryToolbox::IntersectTwoPlanes(p, d,
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
843 slice.GetOrigin(), slice.GetNormal(),
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
844 viewportSlice.GetOrigin(), viewportSlice.GetNormal()))
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
845 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
846 // The two slice are parallel, don't try and display the intersection
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 120
diff changeset
847 NotifyLayerReady(NULL, reference.GetGeometry(), false);
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
848 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
849 else
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
850 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
851 double x1, y1, x2, y2;
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
852 viewportSlice.ProjectPoint(x1, y1, p);
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
853 viewportSlice.ProjectPoint(x2, y2, p + 1000.0 * d);
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
854
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
855 const Extent2D extent = otherPlane_.GetSceneExtent();
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
856
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
857 if (GeometryToolbox::ClipLineToRectangle(x1, y1, x2, y2,
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
858 x1, y1, x2, y2,
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
859 extent.GetX1(), extent.GetY1(),
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
860 extent.GetX2(), extent.GetY2()))
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
861 {
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 120
diff changeset
862 NotifyLayerReady(new LineLayerRenderer(x1, y1, x2, y2, slice), reference.GetGeometry(), false);
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
863 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
864 else
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
865 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
866 // Parallel slices
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 120
diff changeset
867 NotifyLayerReady(NULL, reference.GetGeometry(), false);
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
868 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
869 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
870 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
871 };
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
872 }