comparison OrthancStone/Sources/Volumes/DicomVolumeImageMPRSlicer.cpp @ 1768:226718777702

fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 May 2021 17:18:39 +0200
parents 9ac2a65d4172
children a217140dd41a
comparison
equal deleted inserted replaced
1767:e7b4479dea6f 1768:226718777702
87 texture.reset(dynamic_cast<TextureBaseSceneLayer*> 87 texture.reset(dynamic_cast<TextureBaseSceneLayer*>
88 (configurator->CreateTextureFromDicom(reader.GetAccessor(), parameters))); 88 (configurator->CreateTextureFromDicom(reader.GetAccessor(), parameters)));
89 } 89 }
90 90
91 const CoordinateSystem3D& system = volume_.GetGeometry().GetProjectionGeometry(projection_); 91 const CoordinateSystem3D& system = volume_.GetGeometry().GetProjectionGeometry(projection_);
92 92
93 double x0, y0, x1, y1; 93 /**
94 * TODO => There was a shift of (0.5, 0.5) introduced by
95 * TextureBaseSceneLayer::GetTransform(). Is it an error?
96 **/
97
98 Vector pixelSpacing = volume_.GetGeometry().GetVoxelDimensions(projection_);
99
100 double x0, y0, x1, y1, x2, y2;
94 cuttingPlane.ProjectPoint(x0, y0, system.GetOrigin()); 101 cuttingPlane.ProjectPoint(x0, y0, system.GetOrigin());
95 cuttingPlane.ProjectPoint(x1, y1, system.GetOrigin() + system.GetAxisX()); 102 cuttingPlane.ProjectPoint(x1, y1, system.GetOrigin() + system.GetAxisX() * pixelSpacing[0]);
103 cuttingPlane.ProjectPoint(x2, y2, system.GetOrigin() + system.GetAxisY() * pixelSpacing[1]);
96 104
97 { 105 /**
98 double xz, yz;
99 cuttingPlane.ProjectPoint(xz, yz, LinearAlgebra::CreateVector(0, 0, 0));
100 texture->SetOrigin(x0 - xz, y0 - yz);
101 }
102 106
103 double dx = x1 - x0; 107 A = [ a11 a12 ; a21 a22 ]
104 double dy = y1 - y0; 108
105 if (!LinearAlgebra::IsCloseToZero(dx) || 109 (1) A * (0 ; 0) + (b1 ; b2) = (x0 ; y0)
106 !LinearAlgebra::IsCloseToZero(dy)) 110 (2) A * (1 ; 0) + (b1 ; b2) = (x1 ; y1)
107 { 111 (3) A * (0 ; 1) + (b1 ; b2) = (x2 ; y2)
108 texture->SetAngle(atan2(dy, dx));
109 }
110 112
111 Vector tmp = volume_.GetGeometry().GetVoxelDimensions(projection_); 113 (2-1) A * (1 ; 0) = (x1 - x0 ; y1 - y0) <=> (a11 ; a21) = (x1 - x0 ; y1 - y0)
112 texture->SetPixelSpacing(tmp[0], tmp[1]); 114 (3-1) A * (0 ; 1) = (x2 - x0 ; y2 - y0) <=> (a12 ; a22) = (x2 - x0 ; y2 - y0)
115
116 **/
117
118 Matrix m(3, 3);
119 m(0, 0) = x1 - x0; // a11
120 m(0, 1) = x2 - x0; // a12
121 m(0, 2) = x0; // b1
122 m(1, 0) = y1 - y0; // a21
123 m(1, 1) = y2 - y0; // a22
124 m(1, 2) = y0; // b2
125 m(2, 0) = 0;
126 m(2, 1) = 0;
127 m(2, 2) = 1;
128
129 texture->SetTransform(AffineTransform2D(m));
113 130
114 return texture.release(); 131 return texture.release();
115 } 132 }
116 133
117 134