Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/CoordinateSystem3D.cpp @ 1037:4e713ef78a5a
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 07 Oct 2019 18:01:03 +0200 |
parents | ac88989817e3 |
children | 19b1c8caade4 2d8ab34c8c91 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 8 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
0 | 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 | |
47 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
22 #include "CoordinateSystem3D.h" |
0 | 23 |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
157
diff
changeset
|
24 #include "LinearAlgebra.h" |
0 | 25 #include "GeometryToolbox.h" |
26 | |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
27 #include <Core/Logging.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
28 #include <Core/Toolbox.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
29 #include <Core/OrthancException.h> |
0 | 30 |
31 namespace OrthancStone | |
32 { | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
33 void CoordinateSystem3D::CheckAndComputeNormal() |
0 | 34 { |
35 // DICOM expects normal vectors to define the axes: "The row and | |
36 // column direction cosine vectors shall be normal, i.e., the dot | |
37 // product of each direction cosine vector with itself shall be | |
38 // unity." | |
39 // http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.2.html | |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
157
diff
changeset
|
40 if (!LinearAlgebra::IsNear(boost::numeric::ublas::norm_2(axisX_), 1.0) || |
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
157
diff
changeset
|
41 !LinearAlgebra::IsNear(boost::numeric::ublas::norm_2(axisY_), 1.0)) |
0 | 42 { |
43 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
44 } | |
45 | |
46 // The vectors within "Image Orientation Patient" must be | |
47 // orthogonal, according to the DICOM specification: "The row and | |
48 // column direction cosine vectors shall be orthogonal, i.e., | |
49 // their dot product shall be zero." | |
50 // http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.2.html | |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
157
diff
changeset
|
51 if (!LinearAlgebra::IsCloseToZero(boost::numeric::ublas::inner_prod(axisX_, axisY_))) |
0 | 52 { |
53 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
54 } | |
55 | |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
157
diff
changeset
|
56 LinearAlgebra::CrossProduct(normal_, axisX_, axisY_); |
0 | 57 |
157
2309e8d86efe
IntersectPlaneAndLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
58 d_ = -(normal_[0] * origin_[0] + normal_[1] * origin_[1] + normal_[2] * origin_[2]); |
2309e8d86efe
IntersectPlaneAndLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
59 |
0 | 60 // Just a sanity check, it should be useless by construction |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
157
diff
changeset
|
61 assert(LinearAlgebra::IsNear(boost::numeric::ublas::norm_2(normal_), 1.0)); |
0 | 62 } |
63 | |
64 | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
65 void CoordinateSystem3D::SetupCanonical() |
0 | 66 { |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
157
diff
changeset
|
67 LinearAlgebra::AssignVector(origin_, 0, 0, 0); |
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
157
diff
changeset
|
68 LinearAlgebra::AssignVector(axisX_, 1, 0, 0); |
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
157
diff
changeset
|
69 LinearAlgebra::AssignVector(axisY_, 0, 1, 0); |
0 | 70 CheckAndComputeNormal(); |
71 } | |
72 | |
73 | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
74 CoordinateSystem3D::CoordinateSystem3D(const Vector& origin, |
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
75 const Vector& axisX, |
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
76 const Vector& axisY) : |
0 | 77 origin_(origin), |
78 axisX_(axisX), | |
79 axisY_(axisY) | |
80 { | |
81 CheckAndComputeNormal(); | |
82 } | |
83 | |
84 | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
85 void CoordinateSystem3D::Setup(const std::string& imagePositionPatient, |
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
86 const std::string& imageOrientationPatient) |
0 | 87 { |
88 std::string tmpPosition = Orthanc::Toolbox::StripSpaces(imagePositionPatient); | |
89 std::string tmpOrientation = Orthanc::Toolbox::StripSpaces(imageOrientationPatient); | |
90 | |
91 Vector orientation; | |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
157
diff
changeset
|
92 if (!LinearAlgebra::ParseVector(origin_, tmpPosition) || |
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
157
diff
changeset
|
93 !LinearAlgebra::ParseVector(orientation, tmpOrientation) || |
0 | 94 origin_.size() != 3 || |
95 orientation.size() != 6) | |
96 { | |
97 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
98 } | |
99 | |
100 axisX_.resize(3); | |
101 axisX_[0] = orientation[0]; | |
102 axisX_[1] = orientation[1]; | |
103 axisX_[2] = orientation[2]; | |
104 | |
105 axisY_.resize(3); | |
106 axisY_[0] = orientation[3]; | |
107 axisY_[1] = orientation[4]; | |
108 axisY_[2] = orientation[5]; | |
109 | |
110 CheckAndComputeNormal(); | |
111 } | |
112 | |
113 | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
114 CoordinateSystem3D::CoordinateSystem3D(const OrthancPlugins::IDicomDataset& dicom) |
0 | 115 { |
32 | 116 std::string a, b; |
117 | |
118 if (dicom.GetStringValue(a, OrthancPlugins::DICOM_TAG_IMAGE_POSITION_PATIENT) && | |
119 dicom.GetStringValue(b, OrthancPlugins::DICOM_TAG_IMAGE_ORIENTATION_PATIENT)) | |
0 | 120 { |
32 | 121 Setup(a, b); |
0 | 122 } |
123 else | |
124 { | |
125 SetupCanonical(); | |
126 } | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
127 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
128 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
129 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
130 CoordinateSystem3D::CoordinateSystem3D(const Orthanc::DicomMap& dicom) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
131 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
132 std::string a, b; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
133 |
994
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
986
diff
changeset
|
134 if (dicom.LookupStringValue(a, Orthanc::DICOM_TAG_IMAGE_POSITION_PATIENT, false) && |
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
986
diff
changeset
|
135 dicom.LookupStringValue(b, Orthanc::DICOM_TAG_IMAGE_ORIENTATION_PATIENT, false)) |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
136 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
137 Setup(a, b); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
138 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
139 else |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
140 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
141 SetupCanonical(); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
142 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
143 } |
0 | 144 |
145 | |
760
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
146 void CoordinateSystem3D::SetOrigin(const Vector& origin) |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
147 { |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
148 if (origin.size() != 3) |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
149 { |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
150 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
151 } |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
152 else |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
153 { |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
154 origin_ = origin; |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
155 } |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
156 } |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
157 |
1181e1ad98ec
progressive loading working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
158 |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
159 Vector CoordinateSystem3D::MapSliceToWorldCoordinates(double x, |
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
160 double y) const |
0 | 161 { |
162 return origin_ + x * axisX_ + y * axisY_; | |
163 } | |
164 | |
165 | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
166 double CoordinateSystem3D::ProjectAlongNormal(const Vector& point) const |
0 | 167 { |
168 return boost::numeric::ublas::inner_prod(point, normal_); | |
169 } | |
170 | |
1013
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
171 void CoordinateSystem3D::ProjectPoint2(double& offsetX, double& offsetY, const Vector& point) const |
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
172 { |
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
173 // Project the point onto the slice |
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
174 double projectionX,projectionY,projectionZ; |
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
175 GeometryToolbox::ProjectPointOntoPlane2(projectionX, projectionY, projectionZ, point, normal_, origin_); |
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
176 |
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
177 // As the axes are orthonormal vectors thanks to |
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
178 // CheckAndComputeNormal(), the following dot products give the |
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
179 // offset of the origin of the slice wrt. the origin of the |
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
180 // reference plane https://en.wikipedia.org/wiki/Vector_projection |
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
181 offsetX = axisX_[0] * (projectionX - origin_[0]) + axisX_[1] * (projectionY - origin_[1]) + axisX_[2] * (projectionZ - origin_[2]); |
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
182 offsetY = axisY_[0] * (projectionX - origin_[0]) + axisY_[1] * (projectionY - origin_[1]) + axisY_[2] * (projectionZ - origin_[2]); |
53cc787bd7bc
- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
183 } |
0 | 184 |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
185 void CoordinateSystem3D::ProjectPoint(double& offsetX, |
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
186 double& offsetY, |
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
187 const Vector& point) const |
0 | 188 { |
189 // Project the point onto the slice | |
190 Vector projection; | |
191 GeometryToolbox::ProjectPointOntoPlane(projection, point, normal_, origin_); | |
192 | |
193 // As the axes are orthonormal vectors thanks to | |
194 // CheckAndComputeNormal(), the following dot products give the | |
195 // offset of the origin of the slice wrt. the origin of the | |
196 // reference plane https://en.wikipedia.org/wiki/Vector_projection | |
197 offsetX = boost::numeric::ublas::inner_prod(axisX_, projection - origin_); | |
198 offsetY = boost::numeric::ublas::inner_prod(axisY_, projection - origin_); | |
199 } | |
151
c5044bbfc303
CoordinateSystem3D::IntersectSegment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
200 |
152 | 201 bool CoordinateSystem3D::IntersectSegment(Vector& p, |
151
c5044bbfc303
CoordinateSystem3D::IntersectSegment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
202 const Vector& edgeFrom, |
c5044bbfc303
CoordinateSystem3D::IntersectSegment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
203 const Vector& edgeTo) const |
c5044bbfc303
CoordinateSystem3D::IntersectSegment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
204 { |
157
2309e8d86efe
IntersectPlaneAndLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
205 return GeometryToolbox::IntersectPlaneAndSegment(p, normal_, d_, edgeFrom, edgeTo); |
2309e8d86efe
IntersectPlaneAndLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
206 } |
2309e8d86efe
IntersectPlaneAndLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
207 |
2309e8d86efe
IntersectPlaneAndLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
208 |
2309e8d86efe
IntersectPlaneAndLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
209 bool CoordinateSystem3D::IntersectLine(Vector& p, |
2309e8d86efe
IntersectPlaneAndLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
210 const Vector& origin, |
2309e8d86efe
IntersectPlaneAndLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
211 const Vector& direction) const |
2309e8d86efe
IntersectPlaneAndLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
212 { |
2309e8d86efe
IntersectPlaneAndLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
213 return GeometryToolbox::IntersectPlaneAndLine(p, normal_, d_, origin, direction); |
151
c5044bbfc303
CoordinateSystem3D::IntersectSegment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
214 } |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
215 |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
216 |
757 | 217 bool CoordinateSystem3D::ComputeDistance(double& distance, |
218 const CoordinateSystem3D& a, | |
219 const CoordinateSystem3D& b) | |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
220 { |
986 | 221 bool opposite = false; // Ignored |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
222 |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
223 if (OrthancStone::GeometryToolbox::IsParallelOrOpposite( |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
224 opposite, a.GetNormal(), b.GetNormal())) |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
225 { |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
226 distance = std::abs(a.ProjectAlongNormal(a.GetOrigin()) - |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
227 a.ProjectAlongNormal(b.GetOrigin())); |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
228 return true; |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
229 } |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
230 else |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
231 { |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
232 return false; |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
233 } |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
234 } |
949
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
760
diff
changeset
|
235 |
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
760
diff
changeset
|
236 std::ostream& operator<< (std::ostream& s, const CoordinateSystem3D& that) |
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
760
diff
changeset
|
237 { |
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
760
diff
changeset
|
238 s << "origin: " << that.origin_ << " normal: " << that.normal_ |
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
760
diff
changeset
|
239 << " axisX: " << that.axisX_ << " axisY: " << that.axisY_ |
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
760
diff
changeset
|
240 << " D: " << that.d_; |
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
760
diff
changeset
|
241 return s; |
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
760
diff
changeset
|
242 } |
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
760
diff
changeset
|
243 |
0 | 244 } |