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