Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Scene2D/TextureBaseSceneLayer.cpp @ 1775:fca942f4b4a7
fix conversion from voxel centers to texture borders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 12 May 2021 19:57:50 +0200 |
parents | 073484e33bee |
children | 6e8105942146 |
comparison
equal
deleted
inserted
replaced
1774:95ece40bb298 | 1775:fca942f4b4a7 |
---|---|
163 void TextureBaseSceneLayer::SetCuttingPlaneTransform(const CoordinateSystem3D& cuttingPlane, | 163 void TextureBaseSceneLayer::SetCuttingPlaneTransform(const CoordinateSystem3D& cuttingPlane, |
164 const Vector& origin, | 164 const Vector& origin, |
165 const Vector& pixelOffsetX, | 165 const Vector& pixelOffsetX, |
166 const Vector& pixelOffsetY) | 166 const Vector& pixelOffsetY) |
167 { | 167 { |
168 /** | |
169 * Shift from the center of the voxel (DICOM convention for 3D | |
170 * slices) to the corner of the voxel, because 2D textures are | |
171 * expressed relatively to their borders. (*) | |
172 **/ | |
173 Vector p = origin + cuttingPlane.GetOrigin() - 0.5 * pixelOffsetX - 0.5 * pixelOffsetY; | |
174 | |
168 double x0, y0, x1, y1, x2, y2; | 175 double x0, y0, x1, y1, x2, y2; |
169 cuttingPlane.ProjectPoint(x0, y0, origin + cuttingPlane.GetOrigin()); | 176 cuttingPlane.ProjectPoint(x0, y0, p); |
170 cuttingPlane.ProjectPoint(x1, y1, origin + cuttingPlane.GetOrigin() + pixelOffsetX); | 177 cuttingPlane.ProjectPoint(x1, y1, p + pixelOffsetX); |
171 cuttingPlane.ProjectPoint(x2, y2, origin + cuttingPlane.GetOrigin() + pixelOffsetY); | 178 cuttingPlane.ProjectPoint(x2, y2, p + pixelOffsetY); |
172 | 179 |
173 /** | 180 /** |
174 | 181 |
175 A = [ a11 a12 ; a21 a22 ] | 182 A = [ a11 a12 ; a21 a22 ] |
176 | 183 |
213 | 220 |
214 return AffineTransform2D::Combine( | 221 return AffineTransform2D::Combine( |
215 AffineTransform2D::CreateOffset(originX_, originY_), | 222 AffineTransform2D::CreateOffset(originX_, originY_), |
216 AffineTransform2D::CreateRotation(angle_), | 223 AffineTransform2D::CreateRotation(angle_), |
217 AffineTransform2D::CreateScaling(pixelSpacingX_, pixelSpacingY_), | 224 AffineTransform2D::CreateScaling(pixelSpacingX_, pixelSpacingY_), |
218 AffineTransform2D::CreateOffset(-0.5, -0.5), | 225 AffineTransform2D::CreateOffset(-0.5, -0.5), // (*) |
219 AffineTransform2D::CreateFlip(flipX_, flipY_, width, height)); | 226 AffineTransform2D::CreateFlip(flipX_, flipY_, width, height)); |
220 } | 227 } |
221 else | 228 else |
222 { | 229 { |
223 return *transform_; | 230 return *transform_; |