annotate Framework/Toolbox/DicomStructureSet2.cpp @ 1006:4f28d9459e31 toa2019092001

Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 20 Sep 2019 12:13:10 +0200
parents 38b6bb0bdd72
children efe1c44628a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 #include "DicomStructureSet2.h"
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
23 #include "../Toolbox/LinearAlgebra.h"
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
24 #include "../StoneException.h"
987
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>
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
29 #include <Core/DicomFormat/DicomTag.h>
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
30
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31 #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
32 #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
33
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 namespace OrthancStone
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 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
37 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
38 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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 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
48
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
49 static inline uint8_t ConvertAndClipToByte(double v)
987
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 if (v < 0)
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 return 0;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 else if (v >= 255)
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 return 255;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 else
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 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
62 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
65 static bool ReadDicomToVector(Vector& target,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
66 const OrthancPlugins::IDicomDataset& dataset,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
67 const OrthancPlugins::DicomPath& tag)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 std::string value;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 return (dataset.GetStringValue(value, tag) &&
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
71 LinearAlgebra::ParseVector(target, value));
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 }
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
73
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
74 std::ostream& operator<<(std::ostream& s, const OrthancPlugins::DicomPath& dicomPath)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
76 std::stringstream tmp;
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
77 for (size_t i = 0; i < dicomPath.GetPrefixLength(); ++i)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
79 OrthancPlugins::DicomTag tag = dicomPath.GetPrefixTag(i);
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
80
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
81 // We use this other object to be able to use GetMainTagsName
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
82 // and Format
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
83 Orthanc::DicomTag tag2(tag.GetGroup(), tag.GetElement());
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
84 size_t index = dicomPath.GetPrefixIndex(i);
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
85 tmp << tag2.GetMainTagsName() << " (" << tag2.Format() << ") [" << index << "] / ";
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 }
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
87 const OrthancPlugins::DicomTag& tag = dicomPath.GetFinalTag();
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
88 Orthanc::DicomTag tag2(tag.GetGroup(), tag.GetElement());
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
89 tmp << tag2.GetMainTagsName() << " (" << tag2.Format() << ")";
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
90 s << tmp.str();
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
91 return s;
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94
1006
4f28d9459e31 Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents: 998
diff changeset
95 DicomStructureSet2::DicomStructureSet2()
4f28d9459e31 Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents: 998
diff changeset
96 {
4f28d9459e31 Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents: 998
diff changeset
97
4f28d9459e31 Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents: 998
diff changeset
98 }
4f28d9459e31 Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents: 998
diff changeset
99
4f28d9459e31 Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents: 998
diff changeset
100
4f28d9459e31 Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents: 998
diff changeset
101 DicomStructureSet2::~DicomStructureSet2()
4f28d9459e31 Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents: 998
diff changeset
102 {
4f28d9459e31 Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents: 998
diff changeset
103
4f28d9459e31 Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents: 998
diff changeset
104 }
4f28d9459e31 Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents: 998
diff changeset
105
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
106 void DicomStructureSet2::SetContents(const OrthancPlugins::FullOrthancDataset& tags)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
108 FillStructuresFromDataset(tags);
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
109 ComputeDependentProperties();
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
110 }
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
111
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
112 void DicomStructureSet2::ComputeDependentProperties()
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
113 {
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
114 for (size_t i = 0; i < structures_.size(); ++i)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
115 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
116 structures_[i].ComputeDependentProperties();
987
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
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
120 void DicomStructureSet2::FillStructuresFromDataset(const OrthancPlugins::FullOrthancDataset& tags)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122 OrthancPlugins::DicomDatasetReader reader(tags);
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
123
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
124 // a few sanity checks
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
125 size_t count = 0, tmp = 0;
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
126
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
127 // DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE (0x3006, 0x0080);
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
128 // DICOM_TAG_ROI_CONTOUR_SEQUENCE (0x3006, 0x0039);
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
129 // DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE (0x3006, 0x0020);
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
130 if (!tags.GetSequenceSize(count, DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE) ||
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
131 !tags.GetSequenceSize(tmp, DICOM_TAG_ROI_CONTOUR_SEQUENCE) ||
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
132 tmp != count ||
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
133 !tags.GetSequenceSize(tmp, DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE) ||
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
134 tmp != count)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
135 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
136 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
137 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
139 // let's now parse the structures stored in the dicom file
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
140 // DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE (0x3006, 0x0080)
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
141 // DICOM_TAG_RT_ROI_INTERPRETED_TYPE (0x3006, 0x00a4)
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
142 // DICOM_TAG_ROI_DISPLAY_COLOR (0x3006, 0x002a)
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
143 // DICOM_TAG_ROI_NAME (0x3006, 0x0026)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144 structures_.resize(count);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
145 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
146 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
147 // (0x3006, 0x0080)[i]/(0x3006, 0x00a4)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 structures_[i].interpretation_ = reader.GetStringValue
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
149 (OrthancPlugins::DicomPath(DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE, i,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
150 DICOM_TAG_RT_ROI_INTERPRETED_TYPE),
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
151 "No interpretation");
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
152
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
153 // (0x3006, 0x0020)[i]/(0x3006, 0x0026)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
154 structures_[i].name_ = reader.GetStringValue
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
155 (OrthancPlugins::DicomPath(DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE, i,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
156 DICOM_TAG_ROI_NAME),
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
157 "No name");
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
158
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
159 Vector color;
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
160 // (0x3006, 0x0039)[i]/(0x3006, 0x002a)
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
161 if (ReadDicomToVector(color, tags, OrthancPlugins::DicomPath(
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
162 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_ROI_DISPLAY_COLOR))
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
163 && color.size() == 3)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
164 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
165 structures_[i].red_ = ConvertAndClipToByte(color[0]);
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
166 structures_[i].green_ = ConvertAndClipToByte(color[1]);
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
167 structures_[i].blue_ = ConvertAndClipToByte(color[2]);
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
168 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
169 else
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
170 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
171 structures_[i].red_ = 255;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
172 structures_[i].green_ = 0;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
173 structures_[i].blue_ = 0;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
174 }
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 size_t countSlices;
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
177 // DICOM_TAG_ROI_CONTOUR_SEQUENCE (0x3006, 0x0039);
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
178 // DICOM_TAG_CONTOUR_SEQUENCE (0x3006, 0x0040);
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
179 if (!tags.GetSequenceSize(countSlices, OrthancPlugins::DicomPath(
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
180 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_CONTOUR_SEQUENCE)))
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
181 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
182 LOG(WARNING) << "DicomStructureSet2::SetContents | structure \"" << structures_[i].name_ << "\" has no slices!";
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
183 countSlices = 0;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
184 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
185
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
186 LOG(INFO) << "New RT structure: \"" << structures_[i].name_
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
187 << "\" with interpretation \"" << structures_[i].interpretation_
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
188 << "\" containing " << countSlices << " slices (color: "
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
189 << static_cast<int>(structures_[i].red_) << ","
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
190 << static_cast<int>(structures_[i].green_) << ","
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
191 << static_cast<int>(structures_[i].blue_) << ")";
987
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 // These temporary variables avoid allocating many vectors in the loop below
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
194
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
195 // (0x3006, 0x0039)[i]/(0x3006, 0x0040)[0]/(0x3006, 0x0046)
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
196 OrthancPlugins::DicomPath countPointsPath(
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
197 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
198 DICOM_TAG_CONTOUR_SEQUENCE, 0,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
199 DICOM_TAG_NUMBER_OF_CONTOUR_POINTS);
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
200
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
201 OrthancPlugins::DicomPath geometricTypePath(
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
202 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
203 DICOM_TAG_CONTOUR_SEQUENCE, 0,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
204 DICOM_TAG_CONTOUR_GEOMETRIC_TYPE);
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
205
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
206 OrthancPlugins::DicomPath imageSequencePath(
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
207 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
208 DICOM_TAG_CONTOUR_SEQUENCE, 0,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
209 DICOM_TAG_CONTOUR_IMAGE_SEQUENCE);
987
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 // (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
212 OrthancPlugins::DicomPath referencedInstancePath(
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
213 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
214 DICOM_TAG_CONTOUR_SEQUENCE, 0,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
215 DICOM_TAG_CONTOUR_IMAGE_SEQUENCE, 0,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
216 DICOM_TAG_REFERENCED_SOP_INSTANCE_UID);
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
217
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
218 OrthancPlugins::DicomPath contourDataPath(
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
219 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
220 DICOM_TAG_CONTOUR_SEQUENCE, 0,
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
221 DICOM_TAG_CONTOUR_DATA);
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
222
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
223 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
224 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
225 unsigned int countPoints = 0;
987
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 countPointsPath.SetPrefixIndex(1, j);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
228 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
229 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
230 LOG(ERROR) << "Dicom path " << countPointsPath << " is not valid (should contain an unsigned integer)";
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
231 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
232 }
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
233
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
234 //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
235
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
236 geometricTypePath.SetPrefixIndex(1, j);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
237 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
238 if (type != "CLOSED_PLANAR")
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
239 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
240 // TODO: support points!!
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
241 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
242 continue;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
243 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
244
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
245 size_t size = 0;
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
246
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
247 imageSequencePath.SetPrefixIndex(1, j);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
248 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
249 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
250 LOG(ERROR) << "The ContourImageSequence sequence (tag 3006,0016) must be present and contain one entry.";
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
251 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
252 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
253
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
254 referencedInstancePath.SetPrefixIndex(1, j);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
255 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
256
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
257 contourDataPath.SetPrefixIndex(1, j);
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
258 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
259
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
260 Vector points;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
261 if (!LinearAlgebra::ParseVector(points, slicesData) ||
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
262 points.size() != 3 * countPoints)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
263 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
264 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
987
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
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
267 // seen in real world
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
268 if (Orthanc::Toolbox::StripSpaces(sopInstanceUid) == "")
987
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 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
271 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
272
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
273 DicomStructurePolygon2 polygon(sopInstanceUid,type);
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
274 polygon.Reserve(countPoints);
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 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
277 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
278 Vector v(3);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
279 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
280 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
281 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
282 polygon.AddPoint(v);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
283 }
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
284 structures_[i].AddPolygon(polygon);
987
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 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
287 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
288
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
289
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
290 void DicomStructureSet2::Clear()
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
291 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
292 structures_.clear();
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
293 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
294
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
295 }