Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/DicomStructureSet.cpp @ 981:c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 06 Sep 2019 09:38:18 +0200 |
parents | 13e078adfb94 |
children | 4c9b4c4de814 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 8 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
0 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
47 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #include "DicomStructureSet.h" | |
23 | |
159
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
24 #include "../Toolbox/GeometryToolbox.h" |
0 | 25 |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
26 #include <Core/Logging.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
27 #include <Core/OrthancException.h> |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
28 #include <Core/Toolbox.h> |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
29 #include <Plugins/Samples/Common/FullOrthancDataset.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
30 #include <Plugins/Samples/Common/DicomDatasetReader.h> |
113
2eca030792aa
using the Orthanc Framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
31 |
126
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
32 #include <limits> |
0 | 33 #include <stdio.h> |
126
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
34 #include <boost/geometry.hpp> |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
35 #include <boost/geometry/geometries/point_xy.hpp> |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
36 #include <boost/geometry/geometries/polygon.hpp> |
137 | 37 #include <boost/geometry/multi/geometries/multi_polygon.hpp> |
126
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
38 |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
39 typedef boost::geometry::model::d2::point_xy<double> BoostPoint; |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
40 typedef boost::geometry::model::polygon<BoostPoint> BoostPolygon; |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
41 typedef boost::geometry::model::multi_polygon<BoostPolygon> BoostMultiPolygon; |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
42 |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
43 |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
44 static void Union(BoostMultiPolygon& output, |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
45 std::vector<BoostPolygon>& input) |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
46 { |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
47 for (size_t i = 0; i < input.size(); i++) |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
48 { |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
49 boost::geometry::correct(input[i]); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
50 } |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
51 |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
52 if (input.size() == 0) |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
53 { |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
54 output.clear(); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
55 } |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
56 else if (input.size() == 1) |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
57 { |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
58 output.resize(1); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
59 output[0] = input[0]; |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
60 } |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
61 else |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
62 { |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
63 boost::geometry::union_(input[0], input[1], output); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
64 |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
65 for (size_t i = 0; i < input.size(); i++) |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
66 { |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
67 BoostMultiPolygon tmp; |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
68 boost::geometry::union_(output, input[i], tmp); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
69 output = tmp; |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
70 } |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
71 } |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
72 } |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
73 |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
74 |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
75 static BoostPolygon CreateRectangle(float x1, float y1, |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
76 float x2, float y2) |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
77 { |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
78 BoostPolygon r; |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
79 boost::geometry::append(r, BoostPoint(x1, y1)); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
80 boost::geometry::append(r, BoostPoint(x1, y2)); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
81 boost::geometry::append(r, BoostPoint(x2, y2)); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
82 boost::geometry::append(r, BoostPoint(x2, y1)); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
83 return r; |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
84 } |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
85 |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
86 |
0 | 87 |
88 namespace OrthancStone | |
89 { | |
32 | 90 static const OrthancPlugins::DicomTag DICOM_TAG_CONTOUR_GEOMETRIC_TYPE(0x3006, 0x0042); |
91 static const OrthancPlugins::DicomTag DICOM_TAG_CONTOUR_IMAGE_SEQUENCE(0x3006, 0x0016); | |
92 static const OrthancPlugins::DicomTag DICOM_TAG_CONTOUR_SEQUENCE(0x3006, 0x0040); | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
93 static const OrthancPlugins::DicomTag DICOM_TAG_CONTOUR_DATA(0x3006, 0x0050); |
32 | 94 static const OrthancPlugins::DicomTag DICOM_TAG_NUMBER_OF_CONTOUR_POINTS(0x3006, 0x0046); |
95 static const OrthancPlugins::DicomTag DICOM_TAG_REFERENCED_SOP_INSTANCE_UID(0x0008, 0x1155); | |
96 static const OrthancPlugins::DicomTag DICOM_TAG_ROI_CONTOUR_SEQUENCE(0x3006, 0x0039); | |
97 static const OrthancPlugins::DicomTag DICOM_TAG_ROI_DISPLAY_COLOR(0x3006, 0x002a); | |
98 static const OrthancPlugins::DicomTag DICOM_TAG_ROI_NAME(0x3006, 0x0026); | |
99 static const OrthancPlugins::DicomTag DICOM_TAG_RT_ROI_INTERPRETED_TYPE(0x3006, 0x00a4); | |
100 static const OrthancPlugins::DicomTag DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE(0x3006, 0x0080); | |
101 static const OrthancPlugins::DicomTag DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE(0x3006, 0x0020); | |
0 | 102 |
103 | |
104 static uint8_t ConvertColor(double v) | |
105 { | |
106 if (v < 0) | |
107 { | |
108 return 0; | |
109 } | |
110 else if (v >= 255) | |
111 { | |
112 return 255; | |
113 } | |
114 else | |
115 { | |
116 return static_cast<uint8_t>(v); | |
117 } | |
118 } | |
119 | |
120 | |
118
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
121 static bool ParseVector(Vector& target, |
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
122 const OrthancPlugins::IDicomDataset& dataset, |
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
123 const OrthancPlugins::DicomPath& tag) |
0 | 124 { |
118
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
125 std::string value; |
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
126 return (dataset.GetStringValue(value, tag) && |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
137
diff
changeset
|
127 LinearAlgebra::ParseVector(target, value)); |
118
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
128 } |
0 | 129 |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
130 void DicomStructureSet::Polygon::CheckPointIsOnSlice(const Vector& v) const |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
131 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
132 if (hasSlice_) |
0 | 133 { |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
134 double magnitude = |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
135 GeometryToolbox::ProjectAlongNormal(v, geometry_.GetNormal()); |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
136 if(!LinearAlgebra::IsNear( |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
137 magnitude, |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
138 projectionAlongNormal_, |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
139 sliceThickness_ / 2.0 /* in mm */ )) |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
140 { |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
141 LOG(ERROR) << "This RT-STRUCT contains a point that is off the " |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
142 << "slice of its instance | " |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
143 << "magnitude = " << magnitude << " | " |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
144 << "projectionAlongNormal_ = " << projectionAlongNormal_ << " | " |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
145 << "tolerance (sliceThickness_ / 2.0) = " << (sliceThickness_ / 2.0); |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
146 |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
147 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
148 } |
0 | 149 } |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
150 } |
0 | 151 |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
152 bool DicomStructureSet::Polygon::IsPointOnSlice(const Vector& v) const |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
153 { |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
154 if (hasSlice_) |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
155 { |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
156 double magnitude = |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
157 GeometryToolbox::ProjectAlongNormal(v, geometry_.GetNormal()); |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
158 bool onSlice = LinearAlgebra::IsNear( |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
159 magnitude, |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
160 projectionAlongNormal_, |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
161 sliceThickness_ / 2.0 /* in mm */); |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
162 if (!onSlice) |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
163 { |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
164 LOG(WARNING) << "This RT-STRUCT contains a point that is off the " |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
165 << "slice of its instance | " |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
166 << "magnitude = " << magnitude << " | " |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
167 << "projectionAlongNormal_ = " << projectionAlongNormal_ << " | " |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
168 << "tolerance (sliceThickness_ / 2.0) = " << (sliceThickness_ / 2.0); |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
169 } |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
170 return onSlice; |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
171 } |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
172 else |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
173 { |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
174 return false; |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
175 } |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
176 } |
0 | 177 |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
178 void DicomStructureSet::Polygon::AddPoint(const Vector& v) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
179 { |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
180 #if 1 |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
181 // BGO 2019-09-03 |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
182 if (IsPointOnSlice(v)) |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
183 { |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
184 points_.push_back(v); |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
185 } |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
186 #else |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
187 CheckPoint(v); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
188 points_.push_back(v); |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
189 #endif |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
190 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
191 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
192 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
193 bool DicomStructureSet::Polygon::UpdateReferencedSlice(const ReferencedSlices& slices) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
194 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
195 if (hasSlice_) |
0 | 196 { |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
197 return true; |
32 | 198 } |
199 else | |
200 { | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
201 ReferencedSlices::const_iterator it = slices.find(sopInstanceUid_); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
202 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
203 if (it == slices.end()) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
204 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
205 return false; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
206 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
207 else |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
208 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
209 const CoordinateSystem3D& geometry = it->second.geometry_; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
210 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
211 hasSlice_ = true; |
131 | 212 geometry_ = geometry; |
213 projectionAlongNormal_ = GeometryToolbox::ProjectAlongNormal(geometry.GetOrigin(), geometry.GetNormal()); | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
214 sliceThickness_ = it->second.thickness_; |
0 | 215 |
131 | 216 extent_.Reset(); |
217 | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
218 for (Points::const_iterator it = points_.begin(); it != points_.end(); ++it) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
219 { |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
220 if (IsPointOnSlice(*it)) |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
221 { |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
222 double x, y; |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
223 geometry.ProjectPoint(x, y, *it); |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
224 extent_.AddPoint(x, y); |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
225 } |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
226 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
227 return true; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
228 } |
0 | 229 } |
230 } | |
231 | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
232 bool DicomStructureSet::Polygon::IsOnSlice(const CoordinateSystem3D& slice) const |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
233 { |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
234 bool isOpposite = false; |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
235 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
236 if (points_.empty() || |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
237 !hasSlice_ || |
131 | 238 !GeometryToolbox::IsParallelOrOpposite(isOpposite, slice.GetNormal(), geometry_.GetNormal())) |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
239 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
240 return false; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
241 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
242 |
131 | 243 double d = GeometryToolbox::ProjectAlongNormal(slice.GetOrigin(), geometry_.GetNormal()); |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
244 |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
137
diff
changeset
|
245 return (LinearAlgebra::IsNear(d, projectionAlongNormal_, |
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
137
diff
changeset
|
246 sliceThickness_ / 2.0)); |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
247 } |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
248 |
131 | 249 bool DicomStructureSet::Polygon::Project(double& x1, |
250 double& y1, | |
251 double& x2, | |
252 double& y2, | |
253 const CoordinateSystem3D& slice) const | |
254 { | |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
255 // TODO: optimize this method using a sweep-line algorithm for polygons |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
256 |
131 | 257 if (!hasSlice_ || |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
258 points_.size() <= 1) |
131 | 259 { |
260 return false; | |
261 } | |
262 | |
263 double x, y; | |
264 geometry_.ProjectPoint(x, y, slice.GetOrigin()); | |
265 | |
266 bool isOpposite; | |
267 if (GeometryToolbox::IsParallelOrOpposite | |
268 (isOpposite, slice.GetNormal(), geometry_.GetAxisY())) | |
269 { | |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
270 if (y < extent_.GetY1() || |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
271 y > extent_.GetY2()) |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
272 { |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
273 // The polygon does not intersect the input slice |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
274 return false; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
275 } |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
276 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
277 bool isFirst = true; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
278 double xmin = std::numeric_limits<double>::infinity(); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
279 double xmax = -std::numeric_limits<double>::infinity(); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
280 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
281 double prevX, prevY; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
282 geometry_.ProjectPoint(prevX, prevY, points_[points_.size() - 1]); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
283 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
284 for (size_t i = 0; i < points_.size(); i++) |
131 | 285 { |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
286 // Reference: ../../Resources/Computations/IntersectSegmentAndHorizontalLine.py |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
287 double curX, curY; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
288 geometry_.ProjectPoint(curX, curY, points_[i]); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
289 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
290 if ((prevY < y && curY > y) || |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
291 (prevY > y && curY < y)) |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
292 { |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
293 double p = (curX * prevY - curY * prevX + y * (prevX - curX)) / (prevY - curY); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
294 xmin = std::min(xmin, p); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
295 xmax = std::max(xmax, p); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
296 isFirst = false; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
297 } |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
298 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
299 prevX = curX; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
300 prevY = curY; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
301 } |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
302 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
303 if (isFirst) |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
304 { |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
305 return false; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
306 } |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
307 else |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
308 { |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
309 Vector p1 = (geometry_.MapSliceToWorldCoordinates(xmin, y) + |
131 | 310 sliceThickness_ / 2.0 * geometry_.GetNormal()); |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
311 Vector p2 = (geometry_.MapSliceToWorldCoordinates(xmax, y) - |
131 | 312 sliceThickness_ / 2.0 * geometry_.GetNormal()); |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
313 |
131 | 314 slice.ProjectPoint(x1, y1, p1); |
315 slice.ProjectPoint(x2, y2, p2); | |
316 return true; | |
317 } | |
318 } | |
319 else if (GeometryToolbox::IsParallelOrOpposite | |
320 (isOpposite, slice.GetNormal(), geometry_.GetAxisX())) | |
321 { | |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
322 if (x < extent_.GetX1() || |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
323 x > extent_.GetX2()) |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
324 { |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
325 return false; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
326 } |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
327 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
328 bool isFirst = true; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
329 double ymin = std::numeric_limits<double>::infinity(); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
330 double ymax = -std::numeric_limits<double>::infinity(); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
331 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
332 double prevX, prevY; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
333 geometry_.ProjectPoint(prevX, prevY, points_[points_.size() - 1]); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
334 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
335 for (size_t i = 0; i < points_.size(); i++) |
131 | 336 { |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
337 // Reference: ../../Resources/Computations/IntersectSegmentAndVerticalLine.py |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
338 double curX, curY; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
339 geometry_.ProjectPoint(curX, curY, points_[i]); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
340 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
341 if ((prevX < x && curX > x) || |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
342 (prevX > x && curX < x)) |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
343 { |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
344 double p = (curX * prevY - curY * prevX + x * (curY - prevY)) / (curX - prevX); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
345 ymin = std::min(ymin, p); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
346 ymax = std::max(ymax, p); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
347 isFirst = false; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
348 } |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
349 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
350 prevX = curX; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
351 prevY = curY; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
352 } |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
353 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
354 if (isFirst) |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
355 { |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
356 return false; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
357 } |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
358 else |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
359 { |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
360 Vector p1 = (geometry_.MapSliceToWorldCoordinates(x, ymin) + |
131 | 361 sliceThickness_ / 2.0 * geometry_.GetNormal()); |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
362 Vector p2 = (geometry_.MapSliceToWorldCoordinates(x, ymax) - |
131 | 363 sliceThickness_ / 2.0 * geometry_.GetNormal()); |
364 | |
365 slice.ProjectPoint(x1, y1, p1); | |
366 slice.ProjectPoint(x2, y2, p2); | |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
367 |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
368 // TODO WHY THIS??? |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
369 y1 = -y1; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
370 y2 = -y2; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
371 |
131 | 372 return true; |
373 } | |
374 } | |
375 else | |
376 { | |
377 // Should not happen | |
378 return false; | |
379 } | |
380 } | |
381 | |
382 | |
0 | 383 const DicomStructureSet::Structure& DicomStructureSet::GetStructure(size_t index) const |
384 { | |
385 if (index >= structures_.size()) | |
386 { | |
125 | 387 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
0 | 388 } |
389 | |
390 return structures_[index]; | |
391 } | |
392 | |
393 | |
125 | 394 DicomStructureSet::Structure& DicomStructureSet::GetStructure(size_t index) |
0 | 395 { |
125 | 396 if (index >= structures_.size()) |
397 { | |
398 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
0 | 399 } |
400 | |
401 return structures_[index]; | |
402 } | |
403 | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
404 DicomStructureSet::DicomStructureSet(const OrthancPlugins::FullOrthancDataset& tags) |
0 | 405 { |
738
8e31b174ab26
removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
516
diff
changeset
|
406 OrthancPlugins::DicomDatasetReader reader(tags); |
32 | 407 |
408 size_t count, tmp; | |
409 if (!tags.GetSequenceSize(count, DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE) || | |
410 !tags.GetSequenceSize(tmp, DICOM_TAG_ROI_CONTOUR_SEQUENCE) || | |
411 tmp != count || | |
412 !tags.GetSequenceSize(tmp, DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE) || | |
413 tmp != count) | |
0 | 414 { |
415 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
416 } | |
417 | |
32 | 418 structures_.resize(count); |
419 for (size_t i = 0; i < count; i++) | |
420 { | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
421 structures_[i].interpretation_ = reader.GetStringValue |
738
8e31b174ab26
removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
516
diff
changeset
|
422 (OrthancPlugins::DicomPath(DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE, i, |
8e31b174ab26
removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
516
diff
changeset
|
423 DICOM_TAG_RT_ROI_INTERPRETED_TYPE), |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
424 "No interpretation"); |
0 | 425 |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
426 structures_[i].name_ = reader.GetStringValue |
738
8e31b174ab26
removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
516
diff
changeset
|
427 (OrthancPlugins::DicomPath(DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE, i, |
8e31b174ab26
removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
516
diff
changeset
|
428 DICOM_TAG_ROI_NAME), |
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:
841
diff
changeset
|
429 "No name"); |
0 | 430 |
431 Vector color; | |
738
8e31b174ab26
removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
516
diff
changeset
|
432 if (ParseVector(color, tags, OrthancPlugins::DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, |
8e31b174ab26
removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
516
diff
changeset
|
433 DICOM_TAG_ROI_DISPLAY_COLOR)) && |
32 | 434 color.size() == 3) |
0 | 435 { |
32 | 436 structures_[i].red_ = ConvertColor(color[0]); |
437 structures_[i].green_ = ConvertColor(color[1]); | |
438 structures_[i].blue_ = ConvertColor(color[2]); | |
439 } | |
440 else | |
441 { | |
442 structures_[i].red_ = 255; | |
443 structures_[i].green_ = 0; | |
444 structures_[i].blue_ = 0; | |
0 | 445 } |
446 | |
32 | 447 size_t countSlices; |
738
8e31b174ab26
removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
516
diff
changeset
|
448 if (!tags.GetSequenceSize(countSlices, OrthancPlugins::DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, |
8e31b174ab26
removing using namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
516
diff
changeset
|
449 DICOM_TAG_CONTOUR_SEQUENCE))) |
32 | 450 { |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
451 countSlices = 0; |
32 | 452 } |
0 | 453 |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
454 LOG(INFO) << "New RT structure: \"" << structures_[i].name_ |
0 | 455 << "\" with interpretation \"" << structures_[i].interpretation_ |
32 | 456 << "\" containing " << countSlices << " slices (color: " |
0 | 457 << static_cast<int>(structures_[i].red_) << "," |
458 << static_cast<int>(structures_[i].green_) << "," | |
459 << static_cast<int>(structures_[i].blue_) << ")"; | |
460 | |
786
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
461 // These temporary variables avoid allocating many vectors in the loop below |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
462 OrthancPlugins::DicomPath countPointsPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
463 DICOM_TAG_CONTOUR_SEQUENCE, 0, |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
464 DICOM_TAG_NUMBER_OF_CONTOUR_POINTS); |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
465 |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
466 OrthancPlugins::DicomPath geometricTypePath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
467 DICOM_TAG_CONTOUR_SEQUENCE, 0, |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
468 DICOM_TAG_CONTOUR_GEOMETRIC_TYPE); |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
469 |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
470 OrthancPlugins::DicomPath imageSequencePath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
471 DICOM_TAG_CONTOUR_SEQUENCE, 0, |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
472 DICOM_TAG_CONTOUR_IMAGE_SEQUENCE); |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
473 |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
474 // (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155) |
786
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
475 OrthancPlugins::DicomPath referencedInstancePath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
476 DICOM_TAG_CONTOUR_SEQUENCE, 0, |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
477 DICOM_TAG_CONTOUR_IMAGE_SEQUENCE, 0, |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
478 DICOM_TAG_REFERENCED_SOP_INSTANCE_UID); |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
479 |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
480 OrthancPlugins::DicomPath contourDataPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
481 DICOM_TAG_CONTOUR_SEQUENCE, 0, |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
482 DICOM_TAG_CONTOUR_DATA); |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
483 |
32 | 484 for (size_t j = 0; j < countSlices; j++) |
0 | 485 { |
32 | 486 unsigned int countPoints; |
0 | 487 |
786
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
488 countPointsPath.SetPrefixIndex(1, j); |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
489 if (!reader.GetUnsignedIntegerValue(countPoints, countPointsPath)) |
32 | 490 { |
491 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
492 } | |
493 | |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
494 //LOG(INFO) << "Parsing slice containing " << countPoints << " vertices"; |
0 | 495 |
786
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
496 geometricTypePath.SetPrefixIndex(1, j); |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
497 std::string type = reader.GetMandatoryStringValue(geometricTypePath); |
32 | 498 if (type != "CLOSED_PLANAR") |
0 | 499 { |
173
6b0411ac843a
fix captain rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
159
diff
changeset
|
500 LOG(WARNING) << "Ignoring contour with geometry type: " << type; |
6b0411ac843a
fix captain rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
159
diff
changeset
|
501 continue; |
0 | 502 } |
503 | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
504 size_t size; |
786
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
505 |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
506 imageSequencePath.SetPrefixIndex(1, j); |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
507 if (!tags.GetSequenceSize(size, imageSequencePath) || size != 1) |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
508 { |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
509 LOG(ERROR) << "The ContourImageSequence sequence (tag 3006,0016) must be present and contain one entry."; |
0 | 510 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
511 } | |
512 | |
786
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
513 referencedInstancePath.SetPrefixIndex(1, j); |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
514 std::string sopInstanceUid = reader.GetMandatoryStringValue(referencedInstancePath); |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
515 |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
516 contourDataPath.SetPrefixIndex(1, j); |
5aa728500586
optimizing constructor of DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
738
diff
changeset
|
517 std::string slicesData = reader.GetMandatoryStringValue(contourDataPath); |
0 | 518 |
519 Vector points; | |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
137
diff
changeset
|
520 if (!LinearAlgebra::ParseVector(points, slicesData) || |
32 | 521 points.size() != 3 * countPoints) |
0 | 522 { |
523 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
524 } | |
525 | |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
526 // seen in real world |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
527 if(Orthanc::Toolbox::StripSpaces(sopInstanceUid) == "") |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
528 { |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
529 LOG(ERROR) << "WARNING. The following Dicom tag (Referenced SOP Instance UID) contains an empty value : // (3006,0039)[" << i << "] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)"; |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
530 } |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
531 |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
532 Polygon polygon(sopInstanceUid); |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
533 polygon.Reserve(countPoints); |
0 | 534 |
32 | 535 for (size_t k = 0; k < countPoints; k++) |
0 | 536 { |
537 Vector v(3); | |
538 v[0] = points[3 * k]; | |
539 v[1] = points[3 * k + 1]; | |
540 v[2] = points[3 * k + 2]; | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
541 polygon.AddPoint(v); |
0 | 542 } |
543 | |
544 structures_[i].polygons_.push_back(polygon); | |
545 } | |
546 } | |
547 } | |
548 | |
549 | |
550 Vector DicomStructureSet::GetStructureCenter(size_t index) const | |
551 { | |
552 const Structure& structure = GetStructure(index); | |
553 | |
554 Vector center; | |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
137
diff
changeset
|
555 LinearAlgebra::AssignVector(center, 0, 0, 0); |
0 | 556 if (structure.polygons_.empty()) |
557 { | |
558 return center; | |
559 } | |
560 | |
561 double n = static_cast<double>(structure.polygons_.size()); | |
562 | |
563 for (Polygons::const_iterator polygon = structure.polygons_.begin(); | |
564 polygon != structure.polygons_.end(); ++polygon) | |
565 { | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
566 if (!polygon->GetPoints().empty()) |
0 | 567 { |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
568 center += polygon->GetPoints().front() / n; |
0 | 569 } |
570 } | |
571 | |
572 return center; | |
573 } | |
574 | |
575 | |
576 const std::string& DicomStructureSet::GetStructureName(size_t index) const | |
577 { | |
578 return GetStructure(index).name_; | |
579 } | |
580 | |
581 | |
582 const std::string& DicomStructureSet::GetStructureInterpretation(size_t index) const | |
583 { | |
584 return GetStructure(index).interpretation_; | |
585 } | |
586 | |
587 | |
804
61ba4b504e9a
PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
588 Color DicomStructureSet::GetStructureColor(size_t index) const |
61ba4b504e9a
PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
589 { |
61ba4b504e9a
PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
590 const Structure& s = GetStructure(index); |
61ba4b504e9a
PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
591 return Color(s.red_, s.green_, s.blue_); |
61ba4b504e9a
PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
592 } |
61ba4b504e9a
PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
593 |
61ba4b504e9a
PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
794
diff
changeset
|
594 |
0 | 595 void DicomStructureSet::GetStructureColor(uint8_t& red, |
596 uint8_t& green, | |
597 uint8_t& blue, | |
598 size_t index) const | |
599 { | |
600 const Structure& s = GetStructure(index); | |
601 red = s.red_; | |
602 green = s.green_; | |
603 blue = s.blue_; | |
604 } | |
605 | |
606 | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
607 void DicomStructureSet::GetReferencedInstances(std::set<std::string>& instances) |
0 | 608 { |
609 for (Structures::const_iterator structure = structures_.begin(); | |
610 structure != structures_.end(); ++structure) | |
611 { | |
612 for (Polygons::const_iterator polygon = structure->polygons_.begin(); | |
613 polygon != structure->polygons_.end(); ++polygon) | |
614 { | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
615 instances.insert(polygon->GetSopInstanceUid()); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
616 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
617 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
618 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
619 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
620 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
621 void DicomStructureSet::AddReferencedSlice(const std::string& sopInstanceUid, |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
622 const std::string& seriesInstanceUid, |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
623 const CoordinateSystem3D& geometry, |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
624 double thickness) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
625 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
626 if (referencedSlices_.find(sopInstanceUid) != referencedSlices_.end()) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
627 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
628 // This geometry is already known |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
629 LOG(ERROR) << "DicomStructureSet::AddReferencedSlice(): (referencedSlices_.find(sopInstanceUid) != referencedSlices_.end()). sopInstanceUid = " << sopInstanceUid; |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
630 |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
631 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
632 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
633 else |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
634 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
635 if (thickness < 0) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
636 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
637 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
638 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
639 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
640 if (!referencedSlices_.empty()) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
641 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
642 const ReferencedSlice& reference = referencedSlices_.begin()->second; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
643 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
644 if (reference.seriesInstanceUid_ != seriesInstanceUid) |
0 | 645 { |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
646 LOG(ERROR) << "This RT-STRUCT refers to several different series"; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
647 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
648 } |
0 | 649 |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
650 if (!GeometryToolbox::IsParallel(reference.geometry_.GetNormal(), geometry.GetNormal())) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
651 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
652 LOG(ERROR) << "The slices in this RT-STRUCT are not parallel"; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
653 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
654 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
655 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
656 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
657 referencedSlices_[sopInstanceUid] = ReferencedSlice(seriesInstanceUid, geometry, thickness); |
0 | 658 |
131 | 659 for (Structures::iterator structure = structures_.begin(); |
660 structure != structures_.end(); ++structure) | |
661 { | |
662 for (Polygons::iterator polygon = structure->polygons_.begin(); | |
663 polygon != structure->polygons_.end(); ++polygon) | |
664 { | |
665 polygon->UpdateReferencedSlice(referencedSlices_); | |
666 } | |
667 } | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
668 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
669 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
670 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
671 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
672 void DicomStructureSet::AddReferencedSlice(const Orthanc::DicomMap& dataset) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
673 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
674 CoordinateSystem3D slice(dataset); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
675 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
676 double thickness = 1; // 1 mm by default |
0 | 677 |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
678 std::string s; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
679 Vector v; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
680 if (dataset.CopyToString(s, Orthanc::DICOM_TAG_SLICE_THICKNESS, false) && |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
137
diff
changeset
|
681 LinearAlgebra::ParseVector(v, s) && |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
682 v.size() > 0) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
683 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
684 thickness = v[0]; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
685 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
686 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
687 std::string instance, series; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
688 if (dataset.CopyToString(instance, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false) && |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
689 dataset.CopyToString(series, Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, false)) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
690 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
691 AddReferencedSlice(instance, series, slice, thickness); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
692 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
693 else |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
694 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
695 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
696 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
697 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
698 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
699 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
700 void DicomStructureSet::CheckReferencedSlices() |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
701 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
702 for (Structures::iterator structure = structures_.begin(); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
703 structure != structures_.end(); ++structure) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
704 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
705 for (Polygons::iterator polygon = structure->polygons_.begin(); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
706 polygon != structure->polygons_.end(); ++polygon) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
707 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
708 if (!polygon->UpdateReferencedSlice(referencedSlices_)) |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
709 { |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
710 std::string sopInstanceUid = polygon->GetSopInstanceUid(); |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
711 if (Orthanc::Toolbox::StripSpaces(sopInstanceUid) == "") |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
712 { |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
713 LOG(ERROR) << "DicomStructureSet::CheckReferencedSlices(): " |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
714 << " missing information about referenced instance " |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
715 << "(sopInstanceUid is empty!)"; |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
716 } |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
717 else |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
718 { |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
719 LOG(ERROR) << "DicomStructureSet::CheckReferencedSlices(): " |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
720 << " missing information about referenced instance " |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
721 << "(sopInstanceUid = " << sopInstanceUid << ")"; |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
722 } |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
723 //throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
0 | 724 } |
725 } | |
726 } | |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
727 } |
0 | 728 |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
729 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
730 Vector DicomStructureSet::GetNormal() const |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
731 { |
126
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
732 if (referencedSlices_.empty()) |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
733 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
734 Vector v; |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
137
diff
changeset
|
735 LinearAlgebra::AssignVector(v, 0, 0, 1); |
122
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
736 return v; |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
737 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
738 else |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
739 { |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
740 return referencedSlices_.begin()->second.geometry_.GetNormal(); |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
741 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
742 } |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
743 |
e3433dabfb8d
refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
744 |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
745 bool DicomStructureSet::ProjectStructure(std::vector< std::vector<PolygonPoint2D> >& polygons, |
794 | 746 const Structure& structure, |
747 const CoordinateSystem3D& slice) const | |
125 | 748 { |
749 polygons.clear(); | |
750 | |
751 Vector normal = GetNormal(); | |
752 | |
753 bool isOpposite; | |
754 if (GeometryToolbox::IsParallelOrOpposite(isOpposite, normal, slice.GetNormal())) | |
755 { | |
756 // This is an axial projection | |
757 | |
794 | 758 for (Polygons::const_iterator polygon = structure.polygons_.begin(); |
125 | 759 polygon != structure.polygons_.end(); ++polygon) |
760 { | |
761 if (polygon->IsOnSlice(slice)) | |
762 { | |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
763 polygons.push_back(std::vector<PolygonPoint2D>()); |
125 | 764 |
765 for (Points::const_iterator p = polygon->GetPoints().begin(); | |
766 p != polygon->GetPoints().end(); ++p) | |
767 { | |
768 double x, y; | |
769 slice.ProjectPoint(x, y, *p); | |
770 polygons.back().push_back(std::make_pair(x, y)); | |
771 } | |
772 } | |
773 } | |
774 | |
775 return true; | |
776 } | |
777 else if (GeometryToolbox::IsParallelOrOpposite(isOpposite, normal, slice.GetAxisX()) || | |
778 GeometryToolbox::IsParallelOrOpposite(isOpposite, normal, slice.GetAxisY())) | |
779 { | |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
780 #if 1 |
126
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
781 // Sagittal or coronal projection |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
782 std::vector<BoostPolygon> projected; |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
783 |
794 | 784 for (Polygons::const_iterator polygon = structure.polygons_.begin(); |
126
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
785 polygon != structure.polygons_.end(); ++polygon) |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
786 { |
131 | 787 double x1, y1, x2, y2; |
788 if (polygon->Project(x1, y1, x2, y2, slice)) | |
126
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
789 { |
516
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
790 projected.push_back(CreateRectangle( |
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
791 static_cast<float>(x1), |
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
792 static_cast<float>(y1), |
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
793 static_cast<float>(x2), |
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
794 static_cast<float>(y2))); |
126
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
795 } |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
796 } |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
797 |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
798 BoostMultiPolygon merged; |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
799 Union(merged, projected); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
800 |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
801 polygons.resize(merged.size()); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
802 for (size_t i = 0; i < merged.size(); i++) |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
803 { |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
804 const std::vector<BoostPoint>& outer = merged[i].outer(); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
805 |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
806 polygons[i].resize(outer.size()); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
807 for (size_t j = 0; j < outer.size(); j++) |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
808 { |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
809 polygons[i][j] = std::make_pair(outer[j].x(), outer[j].y()); |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
810 } |
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
811 } |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
812 #else |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
813 for (Polygons::iterator polygon = structure.polygons_.begin(); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
814 polygon != structure.polygons_.end(); ++polygon) |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
815 { |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
816 double x1, y1, x2, y2; |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
817 if (polygon->Project(x1, y1, x2, y2, slice)) |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
818 { |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
959
diff
changeset
|
819 std::vector<PolygonPoint2D> p(4); |
132
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
820 p[0] = std::make_pair(x1, y1); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
821 p[1] = std::make_pair(x2, y1); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
822 p[2] = std::make_pair(x2, y2); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
823 p[3] = std::make_pair(x1, y2); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
824 polygons.push_back(p); |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
825 } |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
826 } |
35c2b85836ce
fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
827 #endif |
125 | 828 |
126
c9e88e7935a4
rt-struct projection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
125
diff
changeset
|
829 return true; |
125 | 830 } |
831 else | |
832 { | |
833 return false; | |
834 } | |
0 | 835 } |
836 } |