annotate Framework/Deprecated/Toolbox/Slice.cpp @ 819:a68cd7ae8838

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 29 May 2019 13:39:31 +0200
parents c35e98d22764
children 1f74bc3459ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
439
b70e9be013e4 preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "Slice.h"
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
732
c35e98d22764 move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
24 #include "../../StoneEnumerations.h"
c35e98d22764 move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
25 #include "../../Toolbox/GeometryToolbox.h"
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
26
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
27 #include <Core/Logging.h>
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
28 #include <Core/OrthancException.h>
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
29 #include <Core/Toolbox.h>
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
30
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
31 #include <boost/lexical_cast.hpp>
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
714
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
33 namespace Deprecated
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
35 static bool ParseDouble(double& target,
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
36 const std::string& source)
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
37 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
38 try
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
39 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
40 target = boost::lexical_cast<double>(source);
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
41 return true;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
42 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
43 catch (boost::bad_lexical_cast&)
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
44 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
45 return false;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
46 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
47 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
48
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
49 Slice* Slice::Clone() const
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
50 {
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
51 std::auto_ptr<Slice> target(new Slice());
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
52
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
53 target->type_ = type_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
54 target->orthancInstanceId_ = orthancInstanceId_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
55 target->sopClassUid_ = sopClassUid_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
56 target->frame_ = frame_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
57 target->frameCount_ = frameCount_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
58 target->geometry_ = geometry_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
59 target->pixelSpacingX_ = pixelSpacingX_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
60 target->pixelSpacingY_ = pixelSpacingY_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
61 target->thickness_ = thickness_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
62 target->width_ = width_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
63 target->height_ = height_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
64 target->converter_ = converter_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
65 if (imageInformation_.get() != NULL)
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
66 target->imageInformation_.reset(imageInformation_->Clone());
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
67
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
68 return target.release();
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 212
diff changeset
69 }
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
70
118
a4d0b6c82b29 using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
71 bool Slice::ComputeRTDoseGeometry(const Orthanc::DicomMap& dataset,
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
72 unsigned int frame)
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
73 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
74 // http://dicom.nema.org/medical/Dicom/2016a/output/chtml/part03/sect_C.8.8.3.2.html
118
a4d0b6c82b29 using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
75
174
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
76 {
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
77 std::string increment;
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
78
174
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
79 if (dataset.CopyToString(increment, Orthanc::DICOM_TAG_FRAME_INCREMENT_POINTER, false))
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
80 {
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
81 Orthanc::Toolbox::ToUpperCase(increment);
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
82 if (increment != "3004,000C") // This is the "Grid Frame Offset Vector" tag
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
83 {
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
84 LOG(ERROR) << "Bad value for the \"FrameIncrementPointer\" tag";
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
85 return false;
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
86 }
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
87 }
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
88 }
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
89
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
90 std::string offsetTag;
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
91
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
92 if (!dataset.CopyToString(offsetTag, Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR, false) ||
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
93 offsetTag.empty())
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
94 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
95 LOG(ERROR) << "Cannot read the \"GridFrameOffsetVector\" tag, check you are using Orthanc >= 1.3.1";
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
96 return false;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
97 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
98
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
99 std::vector<std::string> offsets;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
100 Orthanc::Toolbox::TokenizeString(offsets, offsetTag, '\\');
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
101
120
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
102 if (frameCount_ <= 1 ||
174
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
103 offsets.size() < frameCount_ ||
a7674c0ae4ac fix captain rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 159
diff changeset
104 offsets.size() < 2 ||
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
105 frame >= frameCount_)
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
106 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
107 LOG(ERROR) << "No information about the 3D location of some slice(s) in a RT DOSE";
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
108 return false;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
109 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
110
120
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
111 double offset0, offset1, z;
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
112
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
113 if (!ParseDouble(offset0, offsets[0]) ||
120
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
114 !ParseDouble(offset1, offsets[1]) ||
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
115 !ParseDouble(z, offsets[frame]))
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
116 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
117 LOG(ERROR) << "Invalid syntax";
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
118 return false;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
119 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
120
714
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
121 if (!OrthancStone::LinearAlgebra::IsCloseToZero(offset0))
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
122 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
123 LOG(ERROR) << "Invalid syntax";
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
124 return false;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
125 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
126
714
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
127 geometry_ = OrthancStone::CoordinateSystem3D(geometry_.GetOrigin() + z * geometry_.GetNormal(),
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
128 //+ 650 * geometry_.GetAxisX(),
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
129 geometry_.GetAxisX(),
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
130 geometry_.GetAxisY());
120
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
131
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
132 thickness_ = offset1 - offset0;
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
133 if (thickness_ < 0)
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
134 {
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
135 thickness_ = -thickness_;
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
136 }
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
137
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
138 return true;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
139 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
140
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
141
118
a4d0b6c82b29 using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
142 bool Slice::ParseOrthancFrame(const Orthanc::DicomMap& dataset,
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 const std::string& instanceId,
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 unsigned int frame)
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 {
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
146 orthancInstanceId_ = instanceId;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
147 frame_ = frame;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
148 type_ = Type_OrthancDecodableFrame;
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
149 imageInformation_.reset(new Orthanc::DicomImageInformation(dataset));
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
150
118
a4d0b6c82b29 using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
151 if (!dataset.CopyToString(sopClassUid_, Orthanc::DICOM_TAG_SOP_CLASS_UID, false) ||
a4d0b6c82b29 using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
152 sopClassUid_.empty())
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 {
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
154 LOG(ERROR) << "Instance without a SOP class UID";
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
155 return false;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
156 }
118
a4d0b6c82b29 using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
157
a4d0b6c82b29 using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
158 if (!dataset.ParseUnsignedInteger32(frameCount_, Orthanc::DICOM_TAG_NUMBER_OF_FRAMES))
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
159 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
160 frameCount_ = 1; // Assume instance with one frame
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
163 if (frame >= frameCount_)
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 return false;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
118
a4d0b6c82b29 using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
168 if (!dataset.ParseUnsignedInteger32(width_, Orthanc::DICOM_TAG_COLUMNS) ||
a4d0b6c82b29 using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
169 !dataset.ParseUnsignedInteger32(height_, Orthanc::DICOM_TAG_ROWS))
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 {
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
171 return false;
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
174 thickness_ = 100.0 * std::numeric_limits<double>::epsilon();
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
175
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
176 std::string tmp;
118
a4d0b6c82b29 using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
177 if (dataset.CopyToString(tmp, Orthanc::DICOM_TAG_SLICE_THICKNESS, false))
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
178 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
179 if (!tmp.empty() &&
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
180 !ParseDouble(thickness_, tmp))
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
181 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
182 return false; // Syntax error
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
183 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
184 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
185
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
186 converter_.ReadParameters(dataset);
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
187
714
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
188 OrthancStone::GeometryToolbox::GetPixelSpacing(pixelSpacingX_, pixelSpacingY_, dataset);
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 std::string position, orientation;
118
a4d0b6c82b29 using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
191 if (dataset.CopyToString(position, Orthanc::DICOM_TAG_IMAGE_POSITION_PATIENT, false) &&
a4d0b6c82b29 using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
192 dataset.CopyToString(orientation, Orthanc::DICOM_TAG_IMAGE_ORIENTATION_PATIENT, false))
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 {
714
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
194 geometry_ = OrthancStone::CoordinateSystem3D(position, orientation);
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
195
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
196 bool ok = true;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
197
714
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
198 switch (OrthancStone::StringToSopClassUid(sopClassUid_))
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
199 {
714
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
200 case OrthancStone::SopClassUid_RTDose:
625
2eeb5857eb43 DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
201 type_ = Type_OrthancRawFrame;
2eeb5857eb43 DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
202 ok = ComputeRTDoseGeometry(dataset, frame);
2eeb5857eb43 DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
203 break;
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
204
625
2eeb5857eb43 DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
205 default:
2eeb5857eb43 DicomInstanceParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
206 break;
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
207 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
208
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
209 if (!ok)
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
210 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
211 LOG(ERROR) << "Cannot deduce the 3D location of frame " << frame
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
212 << " in instance " << instanceId << ", whose SOP class UID is: " << sopClassUid_;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
213 return false;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
214 }
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
217 return true;
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 const std::string Slice::GetOrthancInstanceId() const
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 {
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
223 if (type_ == Type_OrthancDecodableFrame ||
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
224 type_ == Type_OrthancRawFrame)
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
225 {
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
226 return orthancInstanceId_;
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
227 }
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
228 else
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
231 }
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 unsigned int Slice::GetFrame() const
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 if (type_ == Type_Invalid)
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 return frame_;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245
714
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
246 const OrthancStone::CoordinateSystem3D& Slice::GetGeometry() const
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 if (type_ == Type_Invalid)
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 return geometry_;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 double Slice::GetThickness() const
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 if (type_ == Type_Invalid)
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 return thickness_;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 double Slice::GetPixelSpacingX() const
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 if (type_ == Type_Invalid)
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 return pixelSpacingX_;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 double Slice::GetPixelSpacingY() const
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 if (type_ == Type_Invalid)
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 return pixelSpacingY_;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 unsigned int Slice::GetWidth() const
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 if (type_ == Type_Invalid)
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 return width_;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 unsigned int Slice::GetHeight() const
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 if (type_ == Type_Invalid)
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 return height_;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 const DicomFrameConverter& Slice::GetConverter() const
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 if (type_ == Type_Invalid)
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 return converter_;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 }
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
321
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
322
714
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
323 bool Slice::ContainsPlane(const OrthancStone::CoordinateSystem3D& plane) const
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
324 {
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
325 if (type_ == Type_Invalid)
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
326 {
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
327 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
328 }
101
af312ce4fe59 support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 89
diff changeset
329
af312ce4fe59 support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 89
diff changeset
330 bool opposite;
714
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
331 return (OrthancStone::GeometryToolbox::IsParallelOrOpposite(opposite,
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
332 GetGeometry().GetNormal(),
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
333 plane.GetNormal()) &&
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
334 OrthancStone::LinearAlgebra::IsNear(GetGeometry().ProjectAlongNormal(GetGeometry().GetOrigin()),
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
335 GetGeometry().ProjectAlongNormal(plane.GetOrigin()),
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
336 thickness_ / 2.0));
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
337 }
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
338
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
339
714
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 625
diff changeset
340 void Slice::GetExtent(std::vector<OrthancStone::Vector>& points) const
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
341 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
342 double sx = GetPixelSpacingX();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
343 double sy = GetPixelSpacingY();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
344 double w = static_cast<double>(GetWidth());
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
345 double h = static_cast<double>(GetHeight());
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
346
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
347 points.clear();
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
348 points.push_back(GetGeometry().MapSliceToWorldCoordinates(-0.5 * sx, -0.5 * sy));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
349 points.push_back(GetGeometry().MapSliceToWorldCoordinates((w - 0.5) * sx, -0.5 * sy));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
350 points.push_back(GetGeometry().MapSliceToWorldCoordinates(-0.5 * sx, (h - 0.5) * sy));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
351 points.push_back(GetGeometry().MapSliceToWorldCoordinates((w - 0.5) * sx, (h - 0.5) * sy));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
352 }
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
353
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
354
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
355 const Orthanc::DicomImageInformation& Slice::GetImageInformation() const
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
356 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
357 if (imageInformation_.get() == NULL)
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
358 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
359 // Only available if constructing the "Slice" object with a DICOM map
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
360 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
361 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
362 else
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
363 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
364 return *imageInformation_;
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
365 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
366 }
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 }