Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/TextureBaseSceneLayer.cpp @ 2032:d10bab7cc396 deep-learning
added OpenGLTexture::Download()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 21 Jan 2023 16:48:56 +0100 |
parents | 7053b8a0aaec |
children | 07964689cb0b |
rev | line source |
---|---|
590 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
590 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
590 | 10 * as published by the Free Software Foundation, either version 3 of |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
16 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1554
diff
changeset
|
17 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
590 | 21 **/ |
22 | |
23 | |
24 #include "TextureBaseSceneLayer.h" | |
25 | |
1624 | 26 #include <Logging.h> |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
27 #include <OrthancException.h> |
590 | 28 |
29 namespace OrthancStone | |
30 { | |
1787
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
31 void TextureBaseSceneLayer::CheckNoManualTransform() const |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
32 { |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
33 if (transform_.get() != NULL) |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
34 { |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
35 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
36 "A transform has been manually set, first call ClearTransform()"); |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
37 } |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
38 } |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
39 |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
40 |
590 | 41 void TextureBaseSceneLayer::SetTexture(Orthanc::ImageAccessor* texture) |
42 { | |
43 if (texture == NULL) | |
44 { | |
45 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
46 } | |
47 else | |
48 { | |
49 texture_.reset(texture); | |
50 IncrementRevision(); | |
51 } | |
52 } | |
53 | |
54 | |
55 void TextureBaseSceneLayer::CopyParameters(const TextureBaseSceneLayer& other) | |
56 { | |
57 originX_ = other.originX_; | |
58 originY_ = other.originY_; | |
59 pixelSpacingX_ = other.pixelSpacingX_; | |
60 pixelSpacingY_ = other.pixelSpacingY_; | |
61 angle_ = other.angle_; | |
62 isLinearInterpolation_ = other.isLinearInterpolation_; | |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
63 flipX_ = other.flipX_; |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
64 flipY_ = other.flipY_; |
1768
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
65 |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
66 if (other.transform_.get() != NULL) |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
67 { |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
68 transform_.reset(new AffineTransform2D(*other.transform_)); |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
69 } |
590 | 70 } |
71 | |
72 | |
73 TextureBaseSceneLayer::TextureBaseSceneLayer() : | |
74 originX_(0), | |
75 originY_(0), | |
76 pixelSpacingX_(1), | |
77 pixelSpacingY_(1), | |
78 angle_(0), | |
79 isLinearInterpolation_(false), | |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
80 flipX_(false), |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
81 flipY_(false), |
590 | 82 revision_(0) |
83 { | |
84 if (pixelSpacingX_ <= 0 || | |
85 pixelSpacingY_ <= 0) | |
86 { | |
87 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
88 } | |
89 } | |
90 | |
91 | |
92 void TextureBaseSceneLayer::SetOrigin(double x, | |
93 double y) | |
94 { | |
1787
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
95 CheckNoManualTransform(); |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
96 |
590 | 97 originX_ = x; |
98 originY_ = y; | |
99 IncrementRevision(); | |
100 } | |
101 | |
102 | |
103 void TextureBaseSceneLayer::SetPixelSpacing(double sx, | |
104 double sy) | |
105 { | |
1787
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
106 CheckNoManualTransform(); |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
107 |
590 | 108 if (sx <= 0 || |
109 sy <= 0) | |
110 { | |
111 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
112 } | |
113 else | |
114 { | |
115 pixelSpacingX_ = sx; | |
116 pixelSpacingY_ = sy; | |
117 IncrementRevision(); | |
118 } | |
119 } | |
120 | |
121 | |
122 void TextureBaseSceneLayer::SetAngle(double angle) | |
123 { | |
1787
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
124 CheckNoManualTransform(); |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
125 |
590 | 126 angle_ = angle; |
127 IncrementRevision(); | |
128 } | |
129 | |
130 | |
131 void TextureBaseSceneLayer::SetLinearInterpolation(bool isLinearInterpolation) | |
132 { | |
133 isLinearInterpolation_ = isLinearInterpolation; | |
134 IncrementRevision(); | |
135 } | |
136 | |
137 | |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
138 void TextureBaseSceneLayer::SetFlipX(bool flip) |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
139 { |
1787
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
140 CheckNoManualTransform(); |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
141 |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
142 flipX_ = flip; |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
143 IncrementRevision(); |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
144 } |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
145 |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
146 |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
147 void TextureBaseSceneLayer::SetFlipY(bool flip) |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
148 { |
1787
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
149 CheckNoManualTransform(); |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
150 |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
151 flipY_ = flip; |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
152 IncrementRevision(); |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
153 } |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
154 |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
155 |
590 | 156 const Orthanc::ImageAccessor& TextureBaseSceneLayer::GetTexture() const |
157 { | |
158 if (!HasTexture()) | |
159 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
590
diff
changeset
|
160 LOG(ERROR) << "TextureBaseSceneLayer::GetTexture(): (!HasTexture())"; |
590 | 161 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
162 } | |
163 else | |
164 { | |
165 return *texture_; | |
166 } | |
167 } | |
168 | |
169 | |
1768
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
170 void TextureBaseSceneLayer::SetTransform(const AffineTransform2D& transform) |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
171 { |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
172 transform_.reset(new AffineTransform2D(transform)); |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
173 IncrementRevision(); |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
174 } |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
175 |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
176 |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
177 void TextureBaseSceneLayer::ClearTransform() |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
178 { |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
179 transform_.reset(NULL); |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
180 IncrementRevision(); |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
181 } |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
182 |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
183 |
1769 | 184 void TextureBaseSceneLayer::SetCuttingPlaneTransform(const CoordinateSystem3D& cuttingPlane, |
185 const Vector& origin, | |
186 const Vector& pixelOffsetX, | |
187 const Vector& pixelOffsetY) | |
188 { | |
1775
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1770
diff
changeset
|
189 /** |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1770
diff
changeset
|
190 * Shift from the center of the voxel (DICOM convention for 3D |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1770
diff
changeset
|
191 * slices) to the corner of the voxel, because 2D textures are |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1770
diff
changeset
|
192 * expressed relatively to their borders. (*) |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1770
diff
changeset
|
193 **/ |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1770
diff
changeset
|
194 Vector p = origin + cuttingPlane.GetOrigin() - 0.5 * pixelOffsetX - 0.5 * pixelOffsetY; |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1770
diff
changeset
|
195 |
1769 | 196 double x0, y0, x1, y1, x2, y2; |
1775
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1770
diff
changeset
|
197 cuttingPlane.ProjectPoint(x0, y0, p); |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1770
diff
changeset
|
198 cuttingPlane.ProjectPoint(x1, y1, p + pixelOffsetX); |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1770
diff
changeset
|
199 cuttingPlane.ProjectPoint(x2, y2, p + pixelOffsetY); |
1769 | 200 |
201 /** | |
202 | |
203 A = [ a11 a12 ; a21 a22 ] | |
204 | |
205 (1) A * (0 ; 0) + (b1 ; b2) = (x0 ; y0) | |
206 (2) A * (1 ; 0) + (b1 ; b2) = (x1 ; y1) | |
207 (3) A * (0 ; 1) + (b1 ; b2) = (x2 ; y2) | |
208 | |
209 (2-1) A * (1 ; 0) = (x1 - x0 ; y1 - y0) <=> (a11 ; a21) = (x1 - x0 ; y1 - y0) | |
210 (3-1) A * (0 ; 1) = (x2 - x0 ; y2 - y0) <=> (a12 ; a22) = (x2 - x0 ; y2 - y0) | |
211 | |
212 **/ | |
213 | |
214 Matrix m(3, 3); | |
215 m(0, 0) = x1 - x0; // a11 | |
216 m(0, 1) = x2 - x0; // a12 | |
217 m(0, 2) = x0; // b1 | |
218 m(1, 0) = y1 - y0; // a21 | |
219 m(1, 1) = y2 - y0; // a22 | |
220 m(1, 2) = y0; // b2 | |
221 m(2, 0) = 0; | |
222 m(2, 1) = 0; | |
223 m(2, 2) = 1; | |
224 | |
225 SetTransform(AffineTransform2D(m)); | |
226 } | |
227 | |
228 | |
590 | 229 AffineTransform2D TextureBaseSceneLayer::GetTransform() const |
230 { | |
1768
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
231 if (transform_.get() == NULL) |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
232 { |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
233 unsigned int width = 0; |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
234 unsigned int height = 0; |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
235 |
1768
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
236 if (texture_.get() != NULL) |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
237 { |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
238 width = texture_->GetWidth(); |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
239 height = texture_->GetHeight(); |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
240 } |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
241 |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
242 return AffineTransform2D::Combine( |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
243 AffineTransform2D::CreateOffset(originX_, originY_), |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
244 AffineTransform2D::CreateRotation(angle_), |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
245 AffineTransform2D::CreateScaling(pixelSpacingX_, pixelSpacingY_), |
1775
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1770
diff
changeset
|
246 AffineTransform2D::CreateOffset(-0.5, -0.5), // (*) |
1768
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
247 AffineTransform2D::CreateFlip(flipX_, flipY_, width, height)); |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
248 } |
1768
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
249 else |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
250 { |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
251 return *transform_; |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
252 } |
590 | 253 } |
254 | |
255 | |
1610
b7630b1a0253
ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
256 void TextureBaseSceneLayer::GetBoundingBox(Extent2D& target) const |
590 | 257 { |
1610
b7630b1a0253
ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
258 target.Clear(); |
b7630b1a0253
ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
259 |
b7630b1a0253
ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
260 if (texture_.get() != NULL) |
590 | 261 { |
262 const AffineTransform2D t = GetTransform(); | |
263 | |
264 double x, y; | |
265 | |
266 x = 0; | |
267 y = 0; | |
268 t.Apply(x, y); | |
269 target.AddPoint(x, y); | |
270 | |
271 x = static_cast<double>(texture_->GetWidth()); | |
272 y = 0; | |
273 t.Apply(x, y); | |
274 target.AddPoint(x, y); | |
275 | |
276 x = 0; | |
277 y = static_cast<double>(texture_->GetHeight()); | |
278 t.Apply(x, y); | |
279 target.AddPoint(x, y); | |
280 | |
281 x = static_cast<double>(texture_->GetWidth()); | |
282 y = static_cast<double>(texture_->GetHeight()); | |
283 t.Apply(x, y); | |
284 target.AddPoint(x, y); | |
285 } | |
286 } | |
287 } |