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