annotate Framework/Volumes/VolumeImageGeometry.cpp @ 1026:a416ce923b60

fix for ie11
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 02 Oct 2019 11:50:34 +0200
parents 32eaf4929b08
children 19b1c8caade4 2d8ab34c8c91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
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: 811
diff changeset
49 LOG(TRACE) << "VolumeImageGeometry::Invalidate() origin = " << origin(0) << "," << origin(1) << "," << origin(2) << " | width_ = " << width_ << " | height_ = " << height_ << " | depth_ = " << depth_;
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: 811
diff changeset
50
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 Vector scaling;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 if (width_ == 0 ||
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 height_ == 0 ||
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 depth_ == 0)
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 LinearAlgebra::AssignVector(scaling, 1, 1, 1);
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 else
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 scaling = (
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 axialGeometry_.GetAxisX() * voxelDimensions_[0] * static_cast<double>(width_) +
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 axialGeometry_.GetAxisY() * voxelDimensions_[1] * static_cast<double>(height_) +
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 axialGeometry_.GetNormal() * voxelDimensions_[2] * static_cast<double>(depth_));
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 transform_ = LinearAlgebra::Product(
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 GeometryToolbox::CreateTranslationMatrix(origin[0], origin[1], origin[2]),
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 GeometryToolbox::CreateScalingMatrix(scaling[0], scaling[1], scaling[2]));
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 LinearAlgebra::InvertMatrix(transformInverse_, transform_);
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
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 VolumeImageGeometry::VolumeImageGeometry() :
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 width_(0),
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 height_(0),
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 depth_(0)
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 {
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 LinearAlgebra::AssignVector(voxelDimensions_, 1, 1, 1);
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 Invalidate();
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
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
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: 811
diff changeset
85 void VolumeImageGeometry::SetSizeInVoxels(unsigned int width,
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 unsigned int height,
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 unsigned int depth)
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 width_ = width;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 height_ = height;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 depth_ = depth;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 Invalidate();
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
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 void VolumeImageGeometry::SetAxialGeometry(const CoordinateSystem3D& geometry)
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 axialGeometry_ = geometry;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 Invalidate();
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
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 void VolumeImageGeometry::SetVoxelDimensions(double x,
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 double y,
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 double z)
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 {
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 if (x <= 0 ||
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 y <= 0 ||
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 z <= 0)
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
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 else
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 {
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 LinearAlgebra::AssignVector(voxelDimensions_, x, y, z);
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 Invalidate();
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 }
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
689
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
121 const CoordinateSystem3D& VolumeImageGeometry::GetProjectionGeometry(VolumeProjection projection) const
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 switch (projection)
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
124 {
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
125 case VolumeProjection_Axial:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
126 return axialGeometry_;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
127
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
128 case VolumeProjection_Coronal:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
129 return coronalGeometry_;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
130
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
131 case VolumeProjection_Sagittal:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
132 return sagittalGeometry_;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
133
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
134 default:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
135 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
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 }
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
138
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
139
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 Vector VolumeImageGeometry::GetVoxelDimensions(VolumeProjection projection) const
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 switch (projection)
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 {
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 case VolumeProjection_Axial:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 return voxelDimensions_;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 case VolumeProjection_Coronal:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 return LinearAlgebra::CreateVector(voxelDimensions_[0], voxelDimensions_[2], voxelDimensions_[1]);
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 case VolumeProjection_Sagittal:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 return LinearAlgebra::CreateVector(voxelDimensions_[1], voxelDimensions_[2], voxelDimensions_[0]);
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 default:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
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 }
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158
689
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
159 unsigned int VolumeImageGeometry::GetProjectionWidth(VolumeProjection projection) const
684
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 switch (projection)
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 {
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 case VolumeProjection_Axial:
689
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
164 return width_;
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 case VolumeProjection_Coronal:
689
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
167 return width_;
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 case VolumeProjection_Sagittal:
689
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
170 return height_;
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 default:
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
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 }
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177
689
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
178 unsigned int VolumeImageGeometry::GetProjectionHeight(VolumeProjection projection) const
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 switch (projection)
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
181 {
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
182 case VolumeProjection_Axial:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
183 return height_;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
184
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
185 case VolumeProjection_Coronal:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
186 return depth_;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
187
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
188 case VolumeProjection_Sagittal:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
189 return depth_;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
190
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
191 default:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
192 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
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
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 unsigned int VolumeImageGeometry::GetProjectionDepth(VolumeProjection projection) const
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 switch (projection)
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
200 {
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
201 case VolumeProjection_Axial:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
202 return depth_;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
203
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
204 case VolumeProjection_Coronal:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
205 return height_;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
206
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
207 case VolumeProjection_Sagittal:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
208 return width_;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
209
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
210 default:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
211 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
212 }
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
213 }
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
214
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 Vector VolumeImageGeometry::GetCoordinates(float x,
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 float y,
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 float z) const
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 Vector p = LinearAlgebra::Product(transform_, LinearAlgebra::CreateVector(x, y, z, 1));
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 assert(LinearAlgebra::IsNear(p[3], 1)); // Affine transform, no perspective effect
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 // Back to non-homogeneous coordinates
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 return LinearAlgebra::CreateVector(p[0], p[1], p[2]);
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
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 bool VolumeImageGeometry::DetectProjection(VolumeProjection& projection,
689
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
230 const Vector& planeNormal) const
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 {
689
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
232 if (GeometryToolbox::IsParallel(planeNormal, axialGeometry_.GetNormal()))
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 {
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 projection = VolumeProjection_Axial;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 return true;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 }
689
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
237 else if (GeometryToolbox::IsParallel(planeNormal, coronalGeometry_.GetNormal()))
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 {
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 projection = VolumeProjection_Coronal;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 return true;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 }
689
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
242 else if (GeometryToolbox::IsParallel(planeNormal, sagittalGeometry_.GetNormal()))
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 {
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 projection = VolumeProjection_Sagittal;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 return true;
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 else
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 return false;
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 }
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 }
689
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
252
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
253
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
254 bool VolumeImageGeometry::DetectSlice(VolumeProjection& projection,
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
255 unsigned int& slice,
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
256 const CoordinateSystem3D& plane) const
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 if (!DetectProjection(projection, plane.GetNormal()))
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 return false;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
261 }
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
262
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
263 // Transforms the coordinates of the origin of the plane, into the
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
264 // coordinates of the axial geometry
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
265 const Vector& origin = plane.GetOrigin();
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
266 Vector p = LinearAlgebra::Product(
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
267 transformInverse_,
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
268 LinearAlgebra::CreateVector(origin[0], origin[1], origin[2], 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 assert(LinearAlgebra::IsNear(p[3], 1));
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 double z;
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 switch (projection)
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
275 {
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
276 case VolumeProjection_Axial:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
277 z = p[2];
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
278 break;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
279
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
280 case VolumeProjection_Coronal:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
281 z = p[1];
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
282 break;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
283
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
284 case VolumeProjection_Sagittal:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
285 z = p[0];
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
286 break;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
287
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
288 default:
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
289 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
290 }
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 const unsigned int projectionDepth = GetProjectionDepth(projection);
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
293
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
294 z *= static_cast<double>(projectionDepth);
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
295 if (z < 0)
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 return false;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
298 }
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
299
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
300 unsigned int d = static_cast<unsigned int>(std::floor(z));
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
301 if (d >= projectionDepth)
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 return false;
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 else
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
306 {
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
307 slice = d;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
308 return true;
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
309 }
93a8949a1ef7 VolumeImageGeometry::DetectSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 684
diff changeset
310 }
809
e8fdf29cd0ca VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 742
diff changeset
311
e8fdf29cd0ca VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 742
diff changeset
312
e8fdf29cd0ca VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 742
diff changeset
313 CoordinateSystem3D VolumeImageGeometry::GetProjectionSlice(VolumeProjection projection,
811
ffec76a5f7eb deprecating ParallelSlices
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
314 unsigned int z) const
809
e8fdf29cd0ca VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 742
diff changeset
315 {
811
ffec76a5f7eb deprecating ParallelSlices
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
316 if (z >= GetProjectionDepth(projection))
809
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
e8fdf29cd0ca VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 742
diff changeset
319 }
e8fdf29cd0ca VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 742
diff changeset
320
e8fdf29cd0ca VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 742
diff changeset
321 Vector dim = GetVoxelDimensions(projection);
e8fdf29cd0ca VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 742
diff changeset
322 CoordinateSystem3D plane = GetProjectionGeometry(projection);
e8fdf29cd0ca VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 742
diff changeset
323
811
ffec76a5f7eb deprecating ParallelSlices
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
324 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
325
e8fdf29cd0ca VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 742
diff changeset
326 return plane;
e8fdf29cd0ca VolumeImageGeometry::GetProjectionSlice()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 742
diff changeset
327 }
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: 811
diff changeset
328
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: 811
diff changeset
329 std::ostream& operator<<(std::ostream& s, const VolumeImageGeometry& v)
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: 811
diff changeset
330 {
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: 811
diff changeset
331 s << "width: " << v.width_ << " height: " << v.height_
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: 811
diff changeset
332 << " depth: " << v.depth_
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: 811
diff changeset
333 << " axialGeometry: " << v.axialGeometry_
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: 811
diff changeset
334 << " coronalGeometry: " << v.coronalGeometry_
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: 811
diff changeset
335 << " sagittalGeometry: " << v.sagittalGeometry_
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: 811
diff changeset
336 << " voxelDimensions_: " << v.voxelDimensions_
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: 811
diff changeset
337 << " height: " << v.height_
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: 811
diff changeset
338 << " transform: " << v.transform_
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: 811
diff changeset
339 << " transformInverse: " << v.transformInverse_;
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: 811
diff changeset
340 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: 811
diff changeset
341 }
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: 811
diff changeset
342
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 }