Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Toolbox/OsiriX/Annotation.cpp @ 2043:f3d756e5503f deep-learning
fix build on wasm
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 10 Feb 2023 09:13:49 +0100 |
parents | 7053b8a0aaec |
children | 07964689cb0b |
rev | line source |
---|---|
1584
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1584
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * 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
|
9 * modify it under the terms of the GNU Lesser General Public License |
1584
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * the License, or (at your option) any later version. |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * 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
|
15 * 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
|
16 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1584
diff
changeset
|
17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
1584
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "Annotation.h" |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include "AngleAnnotation.h" |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #include "IntegerValue.h" |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #include "LineAnnotation.h" |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 #include "StringValue.h" |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 #include "TextAnnotation.h" |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 #include <Logging.h> |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 namespace OrthancStone |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 namespace OsiriX |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 void Annotation::SetupCommon(const DictionaryValue& dict) |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 const IValue* value = dict.LookupValue("Name"); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 if (value == NULL) |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 name_.clear(); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 } |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 else |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 name_ = dynamic_cast<const StringValue&>(*value).GetValue(); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 } |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 value = dict.LookupValue("StudyInstanceUID"); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 if (value == NULL) |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 studyInstanceUid_.clear(); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 } |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 else |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 studyInstanceUid_ = dynamic_cast<const StringValue&>(*value).GetValue(); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 } |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 value = dict.LookupValue("SeriesInstanceUID"); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 if (value == NULL) |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 seriesInstanceUid_.clear(); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 } |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 else |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 seriesInstanceUid_ = dynamic_cast<const StringValue&>(*value).GetValue(); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 } |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 value = dict.LookupValue("SOPInstanceUID"); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 if (value == NULL) |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 sopInstanceUid_.clear(); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 } |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 else |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 sopInstanceUid_ = dynamic_cast<const StringValue&>(*value).GetValue(); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 } |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 } |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 Annotation* Annotation::Create(const DictionaryValue& dict) |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 const IntegerValue& type = dynamic_cast<const IntegerValue&>(dict.GetValue("Type")); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 switch (type.GetValue()) |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 { |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 case 5: |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 return new LineAnnotation(dict, false); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 case 12: |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 return new AngleAnnotation(dict); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 case 13: |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 return new TextAnnotation(dict); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 case 14: |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 return new LineAnnotation(dict, true); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 default: |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 LOG(WARNING) << "Unsupported OsiriX annotation type: " << type.GetValue(); |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 return NULL; |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 } |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 } |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 } |
bd180f97c734
parsing osirix annotations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 } |