annotate OrthancStone/Sources/Toolbox/DicomStructureSet2.cpp @ 1598:8563ea5d8ae4

relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 26 Oct 2020 20:49:28 +0100
parents 4fb8fdf03314
children 9ac2a65d4172
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
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1019
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
987
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
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
987
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
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
15 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
16 *
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
18 * License along with this program. If not, see
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
19 * <http://www.gnu.org/licenses/>.
987
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
1019
29f5f2031310 Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents: 1010
diff changeset
22 #ifdef BGO_ENABLE_DICOMSTRUCTURESETLOADER2
29f5f2031310 Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents: 1010
diff changeset
23
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24 #include "DicomStructureSet2.h"
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
26 #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
27 #include "../StoneException.h"
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
29 #include <Logging.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
30 #include <OrthancException.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
31 #include <Toolbox.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
32 #include <DicomFormat/DicomTag.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
33
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
34 #include <FullOrthancDataset.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
35 #include <DicomDatasetReader.h>
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 namespace OrthancStone
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 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 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
48 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
49 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
50 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
51
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
52 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
53 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 if (v < 0)
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 return 0;
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 else if (v >= 255)
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 return 255;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 else
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 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
65 }
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
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
68 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
69 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
70 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
71 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 std::string value;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 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
74 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
75 }
1010
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
76
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
77
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
78 void DicomPathToString(std::string& 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
79 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
80 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
81 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
82 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
83 OrthancPlugins::DicomTag tag = dicomPath.GetPrefixTag(i);
1010
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
84
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
85 // 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
86 // 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
87 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
88 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
89 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
90 }
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
91 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
92 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
93 tmp << tag2.GetMainTagsName() << " (" << tag2.Format() << ")";
1010
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
94 s = tmp.str();
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
95 }
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
96
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
97 std::ostream& operator<<(std::ostream& s, const OrthancPlugins::DicomPath& dicomPath)
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
98 {
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
99 std::string tmp;
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
100 DicomPathToString(tmp, dicomPath);
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
101 s << tmp;
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
102 return s;
987
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
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
105
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
106 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
107 {
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
108
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
109 }
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
110
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
111
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
112 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
113 {
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
114
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
115 }
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
116
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
117 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
118 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
119 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
120 ComputeDependentProperties();
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
121 }
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
122
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
123 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
124 {
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
125 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
126 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
127 structures_[i].ComputeDependentProperties();
987
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
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 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
132 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
133 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
134
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
135 // 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
136 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
137
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
138 // 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
139 // 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
140 // 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
141 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
142 !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
143 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
144 !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
145 tmp != count)
987
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
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
150 // 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
151 // 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
152 // 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
153 // 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
154 // 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
155 structures_.resize(count);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156 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
157 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
158 // (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
159 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
160 (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
161 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
162 "No interpretation");
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
163
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
164 // (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
165 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
166 (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
167 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
168 "No name");
987
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 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
171 // (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
172 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
173 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
174 && color.size() == 3)
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
175 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
176 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
177 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
178 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
179 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
180 else
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
181 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
182 structures_[i].red_ = 255;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
183 structures_[i].green_ = 0;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
184 structures_[i].blue_ = 0;
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
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
187 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
188 // 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
189 // 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
190 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
191 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
192 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
193 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
194 countSlices = 0;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
195 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
196
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
197 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
198 << "\" 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
199 << "\" 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
200 << 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
201 << 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
202 << 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
203
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
204 // 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
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 // (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
207 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
208 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
209 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
210 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
211
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 geometricTypePath(
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_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
216
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
217 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
218 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
219 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
220 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
221
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
222 // (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
223 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
224 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
225 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
226 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
227 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
228
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
229 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
230 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
231 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
232 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
233
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
234 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
235 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
236 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
237
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
238 countPointsPath.SetPrefixIndex(1, j);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
239 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
240 {
1010
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
241 std::string s;
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
242 DicomPathToString(s, countPointsPath);
efe1c44628a1 Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents: 1006
diff changeset
243 LOG(ERROR) << "Dicom path " << s << " 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
244 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
245 }
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
246
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
247 //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
248
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
249 geometricTypePath.SetPrefixIndex(1, j);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
250 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
251 if (type != "CLOSED_PLANAR")
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
252 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
253 // TODO: support points!!
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
254 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
255 continue;
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
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
258 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
259
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
260 imageSequencePath.SetPrefixIndex(1, j);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
261 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
262 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
263 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
264 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
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 referencedInstancePath.SetPrefixIndex(1, j);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
268 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
269
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
270 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
271 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
272
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
273 Vector points;
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
274 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
275 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
276 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
277 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
278 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
279
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
280 // 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
281 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
282 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
283 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
284 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
285
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
286 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
287 polygon.Reserve(countPoints);
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 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
290 {
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
291 Vector v(3);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
292 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
293 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
294 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
295 polygon.AddPoint(v);
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
296 }
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
297 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
298 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
299 }
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
300 }
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
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
303 void DicomStructureSet2::Clear()
987
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
304 {
998
38b6bb0bdd72 added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
305 structures_.clear();
987
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
d225bccd4d4a Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
308 }
1019
29f5f2031310 Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents: 1010
diff changeset
309
29f5f2031310 Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents: 1010
diff changeset
310 #endif
29f5f2031310 Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents: 1010
diff changeset
311 // BGO_ENABLE_DICOMSTRUCTURESETLOADER2
29f5f2031310 Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents: 1010
diff changeset
312