Mercurial > hg > orthanc-stone
annotate Framework/Volumes/VolumeImageGeometry.cpp @ 872:733c6db3e5a3 am-dev
limiting the size of the cache
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Mon, 01 Jul 2019 13:36:51 +0200 |
parents | ffec76a5f7eb |
children | 32eaf4929b08 |
rev | line source |
---|---|
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #include "VolumeImageGeometry.h" |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "../Toolbox/GeometryToolbox.h" |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include <Core/OrthancException.h> |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 namespace OrthancStone |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 void VolumeImageGeometry::Invalidate() |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 Vector p = (axialGeometry_.GetOrigin() + |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 static_cast<double>(depth_ - 1) * voxelDimensions_[2] * axialGeometry_.GetNormal()); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 coronalGeometry_ = CoordinateSystem3D(p, |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 axialGeometry_.GetAxisX(), |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 -axialGeometry_.GetNormal()); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 sagittalGeometry_ = CoordinateSystem3D(p, |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 axialGeometry_.GetAxisY(), |
689
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
42 axialGeometry_.GetNormal()); |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 Vector origin = ( |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 axialGeometry_.MapSliceToWorldCoordinates(-0.5 * voxelDimensions_[0], |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 -0.5 * voxelDimensions_[1]) - |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 0.5 * voxelDimensions_[2] * axialGeometry_.GetNormal()); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 Vector scaling; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 if (width_ == 0 || |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 height_ == 0 || |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 depth_ == 0) |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 LinearAlgebra::AssignVector(scaling, 1, 1, 1); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 else |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 scaling = ( |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 axialGeometry_.GetAxisX() * voxelDimensions_[0] * static_cast<double>(width_) + |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 axialGeometry_.GetAxisY() * voxelDimensions_[1] * static_cast<double>(height_) + |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 axialGeometry_.GetNormal() * voxelDimensions_[2] * static_cast<double>(depth_)); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 transform_ = LinearAlgebra::Product( |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 GeometryToolbox::CreateTranslationMatrix(origin[0], origin[1], origin[2]), |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 GeometryToolbox::CreateScalingMatrix(scaling[0], scaling[1], scaling[2])); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 LinearAlgebra::InvertMatrix(transformInverse_, transform_); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 VolumeImageGeometry::VolumeImageGeometry() : |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 width_(0), |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 height_(0), |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 depth_(0) |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 LinearAlgebra::AssignVector(voxelDimensions_, 1, 1, 1); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 Invalidate(); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 void VolumeImageGeometry::SetSize(unsigned int width, |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 unsigned int height, |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 unsigned int depth) |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 width_ = width; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 height_ = height; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 depth_ = depth; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 Invalidate(); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 void VolumeImageGeometry::SetAxialGeometry(const CoordinateSystem3D& geometry) |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 axialGeometry_ = geometry; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 Invalidate(); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 void VolumeImageGeometry::SetVoxelDimensions(double x, |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 double y, |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 double z) |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 if (x <= 0 || |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 y <= 0 || |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 z <= 0) |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 else |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 LinearAlgebra::AssignVector(voxelDimensions_, x, y, z); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 Invalidate(); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 |
689
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
119 const CoordinateSystem3D& VolumeImageGeometry::GetProjectionGeometry(VolumeProjection projection) const |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
120 { |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
121 switch (projection) |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
122 { |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
123 case VolumeProjection_Axial: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
124 return axialGeometry_; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
125 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
126 case VolumeProjection_Coronal: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
127 return coronalGeometry_; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
128 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
129 case VolumeProjection_Sagittal: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
130 return sagittalGeometry_; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
131 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
132 default: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
133 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
134 } |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
135 } |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
136 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
137 |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 Vector VolumeImageGeometry::GetVoxelDimensions(VolumeProjection projection) const |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 switch (projection) |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 case VolumeProjection_Axial: |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 return voxelDimensions_; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 case VolumeProjection_Coronal: |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 return LinearAlgebra::CreateVector(voxelDimensions_[0], voxelDimensions_[2], voxelDimensions_[1]); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 case VolumeProjection_Sagittal: |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 return LinearAlgebra::CreateVector(voxelDimensions_[1], voxelDimensions_[2], voxelDimensions_[0]); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 default: |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |
689
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
157 unsigned int VolumeImageGeometry::GetProjectionWidth(VolumeProjection projection) const |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 switch (projection) |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 case VolumeProjection_Axial: |
689
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
162 return width_; |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 case VolumeProjection_Coronal: |
689
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
165 return width_; |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 case VolumeProjection_Sagittal: |
689
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
168 return height_; |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 default: |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 |
689
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
176 unsigned int VolumeImageGeometry::GetProjectionHeight(VolumeProjection projection) const |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
177 { |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
178 switch (projection) |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
179 { |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
180 case VolumeProjection_Axial: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
181 return height_; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
182 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
183 case VolumeProjection_Coronal: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
184 return depth_; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
185 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
186 case VolumeProjection_Sagittal: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
187 return depth_; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
188 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
189 default: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
190 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
191 } |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
192 } |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
193 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
194 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
195 unsigned int VolumeImageGeometry::GetProjectionDepth(VolumeProjection projection) const |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
196 { |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
197 switch (projection) |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
198 { |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
199 case VolumeProjection_Axial: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
200 return depth_; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
201 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
202 case VolumeProjection_Coronal: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
203 return height_; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
204 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
205 case VolumeProjection_Sagittal: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
206 return width_; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
207 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
208 default: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
209 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
210 } |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
211 } |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
212 |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 Vector VolumeImageGeometry::GetCoordinates(float x, |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 float y, |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 float z) const |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 Vector p = LinearAlgebra::Product(transform_, LinearAlgebra::CreateVector(x, y, z, 1)); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 assert(LinearAlgebra::IsNear(p[3], 1)); // Affine transform, no perspective effect |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 // Back to non-homogeneous coordinates |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 return LinearAlgebra::CreateVector(p[0], p[1], p[2]); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 bool VolumeImageGeometry::DetectProjection(VolumeProjection& projection, |
689
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
228 const Vector& planeNormal) const |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 { |
689
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
230 if (GeometryToolbox::IsParallel(planeNormal, axialGeometry_.GetNormal())) |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 projection = VolumeProjection_Axial; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 return true; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 } |
689
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
235 else if (GeometryToolbox::IsParallel(planeNormal, coronalGeometry_.GetNormal())) |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 projection = VolumeProjection_Coronal; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 return true; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 } |
689
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
240 else if (GeometryToolbox::IsParallel(planeNormal, sagittalGeometry_.GetNormal())) |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 projection = VolumeProjection_Sagittal; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 return true; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 else |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 { |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 return false; |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 } |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 } |
689
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
250 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
251 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
252 bool VolumeImageGeometry::DetectSlice(VolumeProjection& projection, |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
253 unsigned int& slice, |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
254 const CoordinateSystem3D& plane) const |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
255 { |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
256 if (!DetectProjection(projection, plane.GetNormal())) |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
257 { |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
258 return false; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
259 } |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
260 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
261 // Transforms the coordinates of the origin of the plane, into the |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
262 // coordinates of the axial geometry |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
263 const Vector& origin = plane.GetOrigin(); |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
264 Vector p = LinearAlgebra::Product( |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
265 transformInverse_, |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
266 LinearAlgebra::CreateVector(origin[0], origin[1], origin[2], 1)); |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
267 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
268 assert(LinearAlgebra::IsNear(p[3], 1)); |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
269 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
270 double z; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
271 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
272 switch (projection) |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
273 { |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
274 case VolumeProjection_Axial: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
275 z = p[2]; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
276 break; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
277 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
278 case VolumeProjection_Coronal: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
279 z = p[1]; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
280 break; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
281 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
282 case VolumeProjection_Sagittal: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
283 z = p[0]; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
284 break; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
285 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
286 default: |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
287 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
288 } |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
289 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
290 const unsigned int projectionDepth = GetProjectionDepth(projection); |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
291 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
292 z *= static_cast<double>(projectionDepth); |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
293 if (z < 0) |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
294 { |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
295 return false; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
296 } |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
297 |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
298 unsigned int d = static_cast<unsigned int>(std::floor(z)); |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
299 if (d >= projectionDepth) |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
300 { |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
301 return false; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
302 } |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
303 else |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
304 { |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
305 slice = d; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
306 return true; |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
307 } |
93a8949a1ef7
VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
684
diff
changeset
|
308 } |
809
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
309 |
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
310 |
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
311 CoordinateSystem3D VolumeImageGeometry::GetProjectionSlice(VolumeProjection projection, |
811
ffec76a5f7eb
deprecating ParallelSlices
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
312 unsigned int z) const |
809
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
313 { |
811
ffec76a5f7eb
deprecating ParallelSlices
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
314 if (z >= GetProjectionDepth(projection)) |
809
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
315 { |
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
316 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
317 } |
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
318 |
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
319 Vector dim = GetVoxelDimensions(projection); |
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
320 CoordinateSystem3D plane = GetProjectionGeometry(projection); |
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
321 |
811
ffec76a5f7eb
deprecating ParallelSlices
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
322 plane.SetOrigin(plane.GetOrigin() + static_cast<double>(z) * plane.GetNormal() * dim[2]); |
809
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
323 |
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
324 return plane; |
e8fdf29cd0ca
VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
742
diff
changeset
|
325 } |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 } |