annotate OrthancFramework/Sources/DicomFormat/DicomMap.cpp @ 4998:e9f9711667e1

updated CA for HttpClient.Ssl test
author Alain Mazy <am@osimis.io>
date Fri, 06 May 2022 10:26:22 +0200
parents 40fd2a485a84
children 877bc3b96476
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 53
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1850
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1206
diff changeset
4 * Department, University Hospital of Liege, Belgium
4870
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
11 * the License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
12 *
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
16 * Lesser General Public License for more details.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
19 * License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
20 * <http://www.gnu.org/licenses/>.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
824
a811bdf8b8eb precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 730
diff changeset
24 #include "../PrecompiledHeaders.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "DicomMap.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include <stdio.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include <memory>
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
29 #include <boost/algorithm/string/join.hpp>
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
30
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3690
diff changeset
31 #include "../Compatibility.h"
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
32 #include "../Endianness.h"
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
33 #include "../Logging.h"
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 53
diff changeset
34 #include "../OrthancException.h"
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
35 #include "../Toolbox.h"
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
36 #include "DicomArray.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 53
diff changeset
39 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
41 namespace
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
43 struct MainDicomTag
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
44 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
45 const DicomTag tag_;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
46 const char* name_;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
47 };
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
48 typedef std::vector<MainDicomTag> MainDicomTags;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
49
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
50 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
52
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
53 // WARNING: the DEFAULT list of main dicom tags below are the list as they
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
54 // were in Orthanc 1.10 before we introduced the dynamic main dicom tags.
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
55 // This list has not changed since Orthanc 1.4.2 and had a single change since
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
56 // Orthanc 0.9.5.
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
57 // These lists have a specific signature. When a resource does not have
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
58 // the metadata "MainDicomTagsSignature", we'll assume that they were stored
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
59 // with an Orthanc prior to 1.11. It is therefore very important that you never
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
60 // change these lists !
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
61
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
62 static const MainDicomTag DEFAULT_PATIENT_MAIN_DICOM_TAGS[] =
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
64 // { DicomTag(0x0010, 0x1010), "PatientAge" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
65 // { DicomTag(0x0010, 0x1040), "PatientAddress" },
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
66 { DICOM_TAG_PATIENT_NAME, "PatientName" },
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
67 { DICOM_TAG_PATIENT_BIRTH_DATE, "PatientBirthDate" },
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
68 { DICOM_TAG_PATIENT_SEX, "PatientSex" },
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
69 { DICOM_TAG_OTHER_PATIENT_IDS, "OtherPatientIDs" },
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
70 { DICOM_TAG_PATIENT_ID, "PatientID" }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 };
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
72
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
73 static const MainDicomTag DEFAULT_STUDY_MAIN_DICOM_TAGS[] =
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
74 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
75 // { DicomTag(0x0010, 0x1020), "PatientSize" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
76 // { DicomTag(0x0010, 0x1030), "PatientWeight" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
77 { DICOM_TAG_STUDY_DATE, "StudyDate" },
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
78 { DICOM_TAG_STUDY_TIME, "StudyTime" },
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
79 { DICOM_TAG_STUDY_ID, "StudyID" },
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
80 { DICOM_TAG_STUDY_DESCRIPTION, "StudyDescription" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
81 { DICOM_TAG_ACCESSION_NUMBER, "AccessionNumber" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
82 { DICOM_TAG_STUDY_INSTANCE_UID, "StudyInstanceUID" },
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
84 // New in db v6
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
85 { DICOM_TAG_REQUESTED_PROCEDURE_DESCRIPTION, "RequestedProcedureDescription" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
86 { DICOM_TAG_INSTITUTION_NAME, "InstitutionName" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
87 { DICOM_TAG_REQUESTING_PHYSICIAN, "RequestingPhysician" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
88 { DICOM_TAG_REFERRING_PHYSICIAN_NAME, "ReferringPhysicianName" }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
89 };
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
90
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
91 static const MainDicomTag DEFAULT_SERIES_MAIN_DICOM_TAGS[] =
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
93 // { DicomTag(0x0010, 0x1080), "MilitaryRank" },
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
94 { DICOM_TAG_SERIES_DATE, "SeriesDate" },
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
95 { DICOM_TAG_SERIES_TIME, "SeriesTime" },
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
96 { DICOM_TAG_MODALITY, "Modality" },
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
97 { DICOM_TAG_MANUFACTURER, "Manufacturer" },
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
98 { DICOM_TAG_STATION_NAME, "StationName" },
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
99 { DICOM_TAG_SERIES_DESCRIPTION, "SeriesDescription" },
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
100 { DICOM_TAG_BODY_PART_EXAMINED, "BodyPartExamined" },
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
101 { DICOM_TAG_SEQUENCE_NAME, "SequenceName" },
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
102 { DICOM_TAG_PROTOCOL_NAME, "ProtocolName" },
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
103 { DICOM_TAG_SERIES_NUMBER, "SeriesNumber" },
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
104 { DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES, "CardiacNumberOfImages" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
105 { DICOM_TAG_IMAGES_IN_ACQUISITION, "ImagesInAcquisition" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
106 { DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS, "NumberOfTemporalPositions" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
107 { DICOM_TAG_NUMBER_OF_SLICES, "NumberOfSlices" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
108 { DICOM_TAG_NUMBER_OF_TIME_SLICES, "NumberOfTimeSlices" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
109 { DICOM_TAG_SERIES_INSTANCE_UID, "SeriesInstanceUID" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
110
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
111 // New in db v6
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
112 { DICOM_TAG_IMAGE_ORIENTATION_PATIENT, "ImageOrientationPatient" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
113 { DICOM_TAG_SERIES_TYPE, "SeriesType" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
114 { DICOM_TAG_OPERATOR_NAME, "OperatorsName" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
115 { DICOM_TAG_PERFORMED_PROCEDURE_STEP_DESCRIPTION, "PerformedProcedureStepDescription" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
116 { DICOM_TAG_ACQUISITION_DEVICE_PROCESSING_DESCRIPTION, "AcquisitionDeviceProcessingDescription" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
117 { DICOM_TAG_CONTRAST_BOLUS_AGENT, "ContrastBolusAgent" }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 };
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
119
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
120 static const MainDicomTag DEFAULT_INSTANCE_MAIN_DICOM_TAGS[] =
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
122 { DICOM_TAG_INSTANCE_CREATION_DATE, "InstanceCreationDate" },
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
123 { DICOM_TAG_INSTANCE_CREATION_TIME, "InstanceCreationTime" },
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
124 { DICOM_TAG_ACQUISITION_NUMBER, "AcquisitionNumber" },
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
125 { DICOM_TAG_IMAGE_INDEX, "ImageIndex" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
126 { DICOM_TAG_INSTANCE_NUMBER, "InstanceNumber" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
127 { DICOM_TAG_NUMBER_OF_FRAMES, "NumberOfFrames" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
128 { DICOM_TAG_TEMPORAL_POSITION_IDENTIFIER, "TemporalPositionIdentifier" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
129 { DICOM_TAG_SOP_INSTANCE_UID, "SOPInstanceUID" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
130
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
131 // New in db v6
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
132 { DICOM_TAG_IMAGE_POSITION_PATIENT, "ImagePositionPatient" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
133 { DICOM_TAG_IMAGE_COMMENTS, "ImageComments" },
2804
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
134
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
135 /**
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
136 * Main DICOM tags that are not part of any release of the
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
137 * database schema yet, and that will be part of future db v7. In
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
138 * the meantime, the user must call "/tools/reconstruct" once to
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
139 * access these tags if the corresponding DICOM files where
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
140 * indexed in the database by an older version of Orthanc.
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
141 **/
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
142 { DICOM_TAG_IMAGE_ORIENTATION_PATIENT, "ImageOrientationPatient" } // New in Orthanc 1.4.2
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 };
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
146 namespace
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
147 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
148 class DicomTag2 : public DicomTag
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
149 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
150 public:
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
151 DicomTag2() :
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
152 DicomTag(0, 0) // To make std::map<> happy
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
153 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
154 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
155
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
156 explicit DicomTag2(const DicomTag& tag) :
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
157 DicomTag(tag)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
158 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
159 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
160 };
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
161 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
162
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
163
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
164 class DicomMap::MainDicomTagsConfiguration
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
165 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
166 private:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
167 friend DicomMap;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
168
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
169 // we keep many "copies" of the same data to guarantee quick access to organized data
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
170 // and avoid rebuilding it all the time.
4982
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
171 std::map<DicomTag, std::string> patientsMainDicomTagsByTag_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
172 std::map<std::string, DicomTag2> patientsMainDicomTagsByName_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
173 std::set<DicomTag> patientsMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
174
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
175 std::map<DicomTag, std::string> studiesMainDicomTagsByTag_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
176 std::map<std::string, DicomTag2> studiesMainDicomTagsByName_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
177 std::set<DicomTag> studiesMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
178
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
179 std::map<DicomTag, std::string> seriesMainDicomTagsByTag_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
180 std::map<std::string, DicomTag2> seriesMainDicomTagsByName_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
181 std::set<DicomTag> seriesMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
182
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
183 std::map<DicomTag, std::string> instancesMainDicomTagsByTag_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
184 std::map<std::string, DicomTag2> instancesMainDicomTagsByName_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
185 std::set<DicomTag> instancesMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
186
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
187 std::set<DicomTag> allMainDicomTags_;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
188
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
189 std::map<ResourceType, std::string> signatures_;
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
190 std::map<ResourceType, std::string> defaultSignatures_;
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
191
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
192 MainDicomTagsConfiguration()
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
193 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
194 ResetDefaultMainDicomTags();
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
195 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
196
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
197 void ResetDefaultMainDicomTags()
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
198 {
4982
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
199 patientsMainDicomTagsByTag_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
200 patientsMainDicomTagsByName_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
201 patientsMainDicomTagsByLevel_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
202
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
203 studiesMainDicomTagsByTag_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
204 studiesMainDicomTagsByName_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
205 studiesMainDicomTagsByLevel_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
206
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
207 seriesMainDicomTagsByTag_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
208 seriesMainDicomTagsByName_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
209 seriesMainDicomTagsByLevel_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
210
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
211 instancesMainDicomTagsByTag_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
212 instancesMainDicomTagsByName_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
213 instancesMainDicomTagsByLevel_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
214
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
215 allMainDicomTags_.clear();
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
216
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
217 // by default, initialize with the previous static list (up to 1.10.0)
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
218 LoadDefaultMainDicomTags(ResourceType_Patient);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
219 LoadDefaultMainDicomTags(ResourceType_Study);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
220 LoadDefaultMainDicomTags(ResourceType_Series);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
221 LoadDefaultMainDicomTags(ResourceType_Instance);
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
222
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
223 defaultSignatures_[ResourceType_Patient] = signatures_[ResourceType_Patient];
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
224 defaultSignatures_[ResourceType_Study] = signatures_[ResourceType_Study];
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
225 defaultSignatures_[ResourceType_Series] = signatures_[ResourceType_Series];
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
226 defaultSignatures_[ResourceType_Instance] = signatures_[ResourceType_Instance];
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
227 }
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
228
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
229 std::string ComputeSignature(const std::set<DicomTag>& tags)
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
230 {
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
231 // std::set are sorted by default (which is important for us !)
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
232 std::set<std::string> tagsIds;
4981
d0c34145320c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4960
diff changeset
233 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
234 {
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
235 tagsIds.insert(it->Format());
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
236 }
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
237
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
238 std::string signatureText = boost::algorithm::join(tagsIds, ";");
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
239
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
240 return signatureText;
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
241 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
242
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
243 void LoadDefaultMainDicomTags(ResourceType level)
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
244 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
245 const MainDicomTag* tags = NULL;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
246 size_t size;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
247
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
248 switch (level)
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
249 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
250 case ResourceType_Patient:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
251 tags = DEFAULT_PATIENT_MAIN_DICOM_TAGS;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
252 size = sizeof(DEFAULT_PATIENT_MAIN_DICOM_TAGS) / sizeof(MainDicomTag);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
253 break;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
254
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
255 case ResourceType_Study:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
256 tags = DEFAULT_STUDY_MAIN_DICOM_TAGS;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
257 size = sizeof(DEFAULT_STUDY_MAIN_DICOM_TAGS) / sizeof(MainDicomTag);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
258 break;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
259
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
260 case ResourceType_Series:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
261 tags = DEFAULT_SERIES_MAIN_DICOM_TAGS;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
262 size = sizeof(DEFAULT_SERIES_MAIN_DICOM_TAGS) / sizeof(MainDicomTag);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
263 break;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
264
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
265 case ResourceType_Instance:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
266 tags = DEFAULT_INSTANCE_MAIN_DICOM_TAGS;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
267 size = sizeof(DEFAULT_INSTANCE_MAIN_DICOM_TAGS) / sizeof(MainDicomTag);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
268 break;
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
269
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
270 default:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
271 throw OrthancException(ErrorCode_ParameterOutOfRange);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
272 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
273
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
274 assert(tags != NULL &&
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
275 size != 0);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
276
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
277 for (size_t i = 0; i < size; i++)
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
278 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
279 AddMainDicomTag(tags[i].tag_, tags[i].name_, level);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
280 }
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
281
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
282 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
283
4982
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
284 std::map<DicomTag, std::string>& GetMainDicomTags(ResourceType level)
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
285 {
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
286 switch (level)
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
287 {
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
288 case ResourceType_Patient:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
289 return patientsMainDicomTagsByTag_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
290
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
291 case ResourceType_Study:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
292 return studiesMainDicomTagsByTag_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
293
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
294 case ResourceType_Series:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
295 return seriesMainDicomTagsByTag_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
296
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
297 case ResourceType_Instance:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
298 return instancesMainDicomTagsByTag_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
299
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
300 default:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
301 throw OrthancException(ErrorCode_InternalError);
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
302 }
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
303 }
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
304
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
305 std::map<std::string, DicomTag2>& GetMainDicomTagsByName(ResourceType level)
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
306 {
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
307 switch (level)
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
308 {
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
309 case ResourceType_Patient:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
310 return patientsMainDicomTagsByName_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
311
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
312 case ResourceType_Study:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
313 return studiesMainDicomTagsByName_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
314
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
315 case ResourceType_Series:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
316 return seriesMainDicomTagsByName_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
317
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
318 case ResourceType_Instance:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
319 return instancesMainDicomTagsByName_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
320
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
321 default:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
322 throw OrthancException(ErrorCode_InternalError);
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
323 }
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
324 }
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
325
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
326 std::set<DicomTag>& GetMainDicomTagsByLevel(ResourceType level)
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
327 {
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
328 switch (level)
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
329 {
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
330 case ResourceType_Patient:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
331 return patientsMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
332
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
333 case ResourceType_Study:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
334 return studiesMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
335
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
336 case ResourceType_Series:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
337 return seriesMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
338
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
339 case ResourceType_Instance:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
340 return instancesMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
341
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
342 default:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
343 throw OrthancException(ErrorCode_InternalError);
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
344 }
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
345 }
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
346
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
347 public:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
348 // Singleton pattern
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
349 static MainDicomTagsConfiguration& GetInstance()
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
350 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
351 static MainDicomTagsConfiguration parameters;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
352 return parameters;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
353 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
354
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
355 void AddMainDicomTag(const DicomTag& tag, const std::string& name, ResourceType level)
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
356 {
4982
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
357 std::map<DicomTag, std::string>& byTag = GetMainDicomTags(level);
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
358 std::map<std::string, DicomTag2>& byName = GetMainDicomTagsByName(level);
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
359
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
360 if (byTag.find(tag) != byTag.end())
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
361 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
362 throw OrthancException(ErrorCode_MainDicomTagsMultiplyDefined, tag.Format() + " is already defined");
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
363 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
364
4982
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
365 if (byName.find(name) != byName.end())
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
366 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
367 throw OrthancException(ErrorCode_MainDicomTagsMultiplyDefined, name + " is already defined");
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
368 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
369
4982
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
370 byTag[tag] = name;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
371 byName[name] = DicomTag2(tag);
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
372 GetMainDicomTagsByLevel(level).insert(tag);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
373 allMainDicomTags_.insert(tag);
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
374 signatures_[level] = ComputeSignature(GetMainDicomTagsByLevel(level));
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
375 }
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
376
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
377 const std::set<DicomTag>& GetAllMainDicomTags() const
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
378 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
379 return allMainDicomTags_;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
380 }
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
381
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
382 const std::string& GetMainDicomTagsSignature(ResourceType level)
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
383 {
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
384 assert(signatures_.find(level) != signatures_.end());
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
385
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
386 return signatures_[level];
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
387 }
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
388
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
389 const std::string& GetDefaultMainDicomTagsSignature(ResourceType level)
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
390 {
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
391 assert(defaultSignatures_.find(level) != defaultSignatures_.end());
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
392
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
393 return defaultSignatures_[level];
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
394 }
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
395
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
396 };
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
397
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
398
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
399 void DicomMap::SetValueInternal(uint16_t group,
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
400 uint16_t element,
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
401 DicomValue* value)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 DicomTag tag(group, element);
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
404 Content::iterator it = content_.find(tag);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
406 if (it != content_.end())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 delete it->second;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 it->second = value;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
413 content_.insert(std::make_pair(tag, value));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 void DicomMap::Clear()
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
420 for (Content::iterator it = content_.begin(); it != content_.end(); ++it)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 {
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
422 assert(it->second != NULL);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 delete it->second;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
426 content_.clear();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428
4296
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
429 void DicomMap::SetNullValue(uint16_t group, uint16_t element)
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
430 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
431 SetValueInternal(group, element, new DicomValue);
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
432 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
433
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
434 void DicomMap::SetNullValue(const DicomTag &tag)
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
435 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
436 SetValueInternal(tag.GetGroup(), tag.GetElement(), new DicomValue);
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
437 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
438
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
439 void DicomMap::SetValue(uint16_t group, uint16_t element, const DicomValue &value)
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
440 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
441 SetValueInternal(group, element, value.Clone());
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
442 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
443
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
444 void DicomMap::SetValue(const DicomTag &tag, const DicomValue &value)
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
445 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
446 SetValueInternal(tag.GetGroup(), tag.GetElement(), value.Clone());
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
447 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
448
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
449 void DicomMap::SetValue(const DicomTag &tag, const std::string &str, bool isBinary)
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
450 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
451 SetValueInternal(tag.GetGroup(), tag.GetElement(), new DicomValue(str, isBinary));
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
452 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
453
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
454 void DicomMap::SetValue(uint16_t group, uint16_t element, const std::string &str, bool isBinary)
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
455 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
456 SetValueInternal(group, element, new DicomValue(str, isBinary));
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
457 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
458
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
459 bool DicomMap::HasTag(uint16_t group, uint16_t element) const
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
460 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
461 return HasTag(DicomTag(group, element));
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
462 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
463
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
464 bool DicomMap::HasTag(const DicomTag &tag) const
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
465 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
466 return content_.find(tag) != content_.end();
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
467 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
468
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
469 const DicomValue &DicomMap::GetValue(uint16_t group, uint16_t element) const
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
470 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
471 return GetValue(DicomTag(group, element));
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
472 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
473
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
475 // MORE_TAGS: TODO: we can probably remove the std::string from MainDicomTags (not used here !!!)
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
476 static void ExtractTagsInternal(DicomMap& result,
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
477 const DicomMap::Content& source,
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
478 const std::map<DicomTag, std::string>& mainDicomTags)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 result.Clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
482 for (std::map<DicomTag, std::string>::const_iterator itmt = mainDicomTags.begin();
4981
d0c34145320c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4960
diff changeset
483 itmt != mainDicomTags.end(); ++itmt)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
485 DicomMap::Content::const_iterator it = source.find(itmt->first);
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
486 if (it != source.end())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
488 result.SetValue(it->first, *it->second /* value will be cloned */);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
493 void DicomMap::ExtractTags(DicomMap& result, const std::set<DicomTag>& tags) const
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
494 {
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
495 result.Clear();
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
496
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
497 for (std::set<DicomTag>::const_iterator itmt = tags.begin();
4981
d0c34145320c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4960
diff changeset
498 itmt != tags.end(); ++itmt)
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
499 {
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
500 DicomMap::Content::const_iterator it = content_.find(*itmt);
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
501 if (it != content_.end())
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
502 {
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
503 result.SetValue(it->first, *it->second /* value will be cloned */);
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
504 }
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
505 }
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
506 }
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
507
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
508 void DicomMap::ExtractResourceInformation(DicomMap& result, ResourceType level) const
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
509 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
510 const std::map<DicomTag, std::string>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTags(level);
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
511 ExtractTagsInternal(result, content_, mainDicomTags);
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
512 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514 void DicomMap::ExtractPatientInformation(DicomMap& result) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 {
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
516 ExtractResourceInformation(result, ResourceType_Patient);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 void DicomMap::ExtractStudyInformation(DicomMap& result) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 {
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
521 ExtractResourceInformation(result, ResourceType_Study);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 void DicomMap::ExtractSeriesInformation(DicomMap& result) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 {
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
526 ExtractResourceInformation(result, ResourceType_Series);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
528
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529 void DicomMap::ExtractInstanceInformation(DicomMap& result) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 {
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
531 ExtractResourceInformation(result, ResourceType_Instance);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4296
diff changeset
535 DicomMap::~DicomMap()
4296
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
536 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
537 Clear();
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
538 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
539
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
540 size_t DicomMap::GetSize() const
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
541 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
542 return content_.size();
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
543 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
544
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
545
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 DicomMap* DicomMap::Clone() const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3690
diff changeset
548 std::unique_ptr<DicomMap> result(new DicomMap);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
550 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
552 result->content_.insert(std::make_pair(it->first, it->second->Clone()));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 return result.release();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
559 void DicomMap::Assign(const DicomMap& other)
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
560 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
561 Clear();
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
562
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
563 for (Content::const_iterator it = other.content_.begin(); it != other.content_.end(); ++it)
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
564 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
565 content_.insert(std::make_pair(it->first, it->second->Clone()));
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
566 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
567 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
568
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
569
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 const DicomValue& DicomMap::GetValue(const DicomTag& tag) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571 {
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
572 const DicomValue* value = TestAndGetValue(tag);
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
573
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
574 if (value)
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
575 {
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
576 return *value;
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
577 }
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
578 else
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
579 {
730
309e686b41e7 better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
580 throw OrthancException(ErrorCode_InexistentTag);
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
581 }
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
582 }
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
583
4296
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
584 const DicomValue *DicomMap::TestAndGetValue(uint16_t group, uint16_t element) const
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
585 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
586 return TestAndGetValue(DicomTag(group, element));
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
587 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
588
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
589
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
590 const DicomValue* DicomMap::TestAndGetValue(const DicomTag& tag) const
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
591 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
592 Content::const_iterator it = content_.find(tag);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
594 if (it == content_.end())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 {
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
596 return NULL;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 {
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
600 return it->second;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 void DicomMap::Remove(const DicomTag& tag)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
607 Content::iterator it = content_.find(tag);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
608 if (it != content_.end())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610 delete it->second;
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
611 content_.erase(it);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
612 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 static void SetupFindTemplate(DicomMap& result,
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
617 const std::map<DicomTag, std::string>& mainDicomTags)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 result.Clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
621 for (std::map<DicomTag, std::string>::const_iterator itmt = mainDicomTags.begin();
4981
d0c34145320c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4960
diff changeset
622 itmt != mainDicomTags.end(); ++itmt)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
624 result.SetValue(itmt->first, "", false);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628 void DicomMap::SetupFindPatientTemplate(DicomMap& result)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
630 const std::map<DicomTag, std::string>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTags(ResourceType_Patient);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
631 SetupFindTemplate(result, mainDicomTags);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
634 void DicomMap::SetupFindStudyTemplate(DicomMap& result)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
635 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
636 const std::map<DicomTag, std::string>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTags(ResourceType_Study);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
637 SetupFindTemplate(result, mainDicomTags);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
638 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
639 result.SetValue(DICOM_TAG_PATIENT_ID, "", false);
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
640
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
641 // These main DICOM tags are only indirectly related to the
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
642 // General Study Module, remove them
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
643 result.Remove(DICOM_TAG_INSTITUTION_NAME);
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
644 result.Remove(DICOM_TAG_REQUESTING_PHYSICIAN);
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
645 result.Remove(DICOM_TAG_REQUESTED_PROCEDURE_DESCRIPTION);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 void DicomMap::SetupFindSeriesTemplate(DicomMap& result)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
650 const std::map<DicomTag, std::string>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTags(ResourceType_Series);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
651 SetupFindTemplate(result, mainDicomTags);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
652 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
653 result.SetValue(DICOM_TAG_PATIENT_ID, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
654 result.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "", false);
1372
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
655
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
656 // These tags are considered as "main" by Orthanc, but are not in the Series module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
657 result.Remove(DicomTag(0x0008, 0x0070)); // Manufacturer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
658 result.Remove(DicomTag(0x0008, 0x1010)); // Station name
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
659 result.Remove(DicomTag(0x0018, 0x0024)); // Sequence name
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
660 result.Remove(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
661 result.Remove(DICOM_TAG_IMAGES_IN_ACQUISITION);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
662 result.Remove(DICOM_TAG_NUMBER_OF_SLICES);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
663 result.Remove(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
664 result.Remove(DICOM_TAG_NUMBER_OF_TIME_SLICES);
1706
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
665 result.Remove(DICOM_TAG_IMAGE_ORIENTATION_PATIENT);
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
666 result.Remove(DICOM_TAG_SERIES_TYPE);
1850
68854412c7bc new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
667 result.Remove(DICOM_TAG_ACQUISITION_DEVICE_PROCESSING_DESCRIPTION);
68854412c7bc new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
668 result.Remove(DICOM_TAG_CONTRAST_BOLUS_AGENT);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
670
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671 void DicomMap::SetupFindInstanceTemplate(DicomMap& result)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
672 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
673 const std::map<DicomTag, std::string>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTags(ResourceType_Instance);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
674 SetupFindTemplate(result, mainDicomTags);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
675 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
676 result.SetValue(DICOM_TAG_PATIENT_ID, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
677 result.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
678 result.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, "", false);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
679 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
680
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
682 void DicomMap::CopyTagIfExists(const DicomMap& source,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
683 const DicomTag& tag)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
684 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
685 if (source.HasTag(tag))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
686 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
687 SetValue(tag, source.GetValue(tag));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
688 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
689 }
562
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
690
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
691
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
692 bool DicomMap::IsMainDicomTag(const DicomTag& tag, ResourceType level)
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
693 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
694 const std::map<DicomTag, std::string>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTags(level);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
695 return mainDicomTags.find(tag) != mainDicomTags.end();
562
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
696 }
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
697
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
698 bool DicomMap::IsMainDicomTag(const DicomTag& tag)
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
699 {
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
700 return (IsMainDicomTag(tag, ResourceType_Patient) ||
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
701 IsMainDicomTag(tag, ResourceType_Study) ||
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
702 IsMainDicomTag(tag, ResourceType_Series) ||
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
703 IsMainDicomTag(tag, ResourceType_Instance));
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
704 }
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
705
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
706 static bool IsGenericComputedTag(const DicomTag& tag)
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
707 {
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
708 return tag == DICOM_TAG_RETRIEVE_URL ||
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
709 tag == DICOM_TAG_RETRIEVE_AE_TITLE;
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
710 }
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
711
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
712 bool DicomMap::IsComputedTag(const DicomTag& tag)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
713 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
714 return (IsComputedTag(tag, ResourceType_Patient) ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
715 IsComputedTag(tag, ResourceType_Study) ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
716 IsComputedTag(tag, ResourceType_Series) ||
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
717 IsComputedTag(tag, ResourceType_Instance) ||
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
718 IsGenericComputedTag(tag));
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
719 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
720
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
721 bool DicomMap::IsComputedTag(const DicomTag& tag, ResourceType level)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
722 {
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
723
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
724 switch (level)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
725 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
726 case ResourceType_Patient:
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
727 return (
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
728 tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
729 tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
730 tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
731 );
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
732 case ResourceType_Study:
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
733 return (
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
734 tag == DICOM_TAG_MODALITIES_IN_STUDY ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
735 tag == DICOM_TAG_SOP_CLASSES_IN_STUDY ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
736 tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
737 tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
738 );
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
739 case ResourceType_Series:
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
740 return (
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
741 tag == DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
742 );
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
743 case ResourceType_Instance:
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
744 return (
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
745 tag == DICOM_TAG_INSTANCE_AVAILABILITY
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
746 );
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
747 default:
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
748 throw OrthancException(ErrorCode_ParameterOutOfRange);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
749 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
750 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
751
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
752 bool DicomMap::HasOnlyComputedTags(const std::set<DicomTag>& tags)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
753 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
754 if (tags.size() == 0)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
755 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
756 return false;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
757 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
758
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
759 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
760 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
761 if (!IsComputedTag(*it))
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
762 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
763 return false;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
764 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
765 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
766 return true;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
767 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
768
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
769 bool DicomMap::HasComputedTags(const std::set<DicomTag>& tags)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
770 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
771 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
772 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
773 if (IsComputedTag(*it))
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
774 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
775 return true;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
776 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
777 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
778
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
779 return false;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
780 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
781
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
782 bool DicomMap::HasComputedTags(const std::set<DicomTag>& tags, ResourceType level)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
783 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
784 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
785 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
786 if (IsComputedTag(*it, level))
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
787 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
788 return true;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
789 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
790 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
791 return false;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
792 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
793
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
794
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
795 const std::set<DicomTag>& DicomMap::GetMainDicomTags(ResourceType level)
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
796 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
797 return DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsByLevel(level);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
798 }
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
799
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
800 const std::set<DicomTag>& DicomMap::GetAllMainDicomTags()
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
801 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
802 return DicomMap::MainDicomTagsConfiguration::GetInstance().GetAllMainDicomTags();
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
803 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
804
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
805 void DicomMap::AddMainDicomTag(const DicomTag& tag, const std::string& name, ResourceType level)
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
806 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
807 DicomMap::MainDicomTagsConfiguration::GetInstance().AddMainDicomTag(tag, name, level);
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
808 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
809
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
810 void DicomMap::ResetDefaultMainDicomTags()
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
811 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
812 DicomMap::MainDicomTagsConfiguration::GetInstance().ResetDefaultMainDicomTags();
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
813 }
1206
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
814
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
815 const std::string& DicomMap::GetMainDicomTagsSignature(ResourceType level)
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
816 {
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
817 return DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsSignature(level);
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
818 }
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
819
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
820 const std::string& DicomMap::GetDefaultMainDicomTagsSignature(ResourceType level)
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
821 {
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
822 return DicomMap::MainDicomTagsConfiguration::GetInstance().GetDefaultMainDicomTagsSignature(level);
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
823 }
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
824
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
825 void DicomMap::GetTags(std::set<DicomTag>& tags) const
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
826 {
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
827 tags.clear();
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
828
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
829 for (Content::const_iterator it = content_.begin();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
830 it != content_.end(); ++it)
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
831 {
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
832 tags.insert(it->first);
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
833 }
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
834 }
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
835
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
836
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
837 static uint16_t ReadLittleEndianUint16(const char* dicom)
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
838 {
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
839 const uint8_t* p = reinterpret_cast<const uint8_t*>(dicom);
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
840
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
841 return (static_cast<uint16_t>(p[0]) |
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
842 (static_cast<uint16_t>(p[1]) << 8));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
843 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
844
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
845
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
846 static uint32_t ReadLittleEndianUint32(const char* dicom)
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
847 {
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
848 const uint8_t* p = reinterpret_cast<const uint8_t*>(dicom);
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
849
4214
7b011cfda135 working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4213
diff changeset
850 return (static_cast<uint32_t>(p[0]) |
7b011cfda135 working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4213
diff changeset
851 (static_cast<uint32_t>(p[1]) << 8) |
7b011cfda135 working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4213
diff changeset
852 (static_cast<uint32_t>(p[2]) << 16) |
7b011cfda135 working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4213
diff changeset
853 (static_cast<uint32_t>(p[3]) << 24));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
854 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
855
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
856
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
857 static bool ValidateTag(const ValueRepresentation& vr,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
858 const std::string& value)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
859 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
860 switch (vr)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
861 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
862 case ValueRepresentation_ApplicationEntity:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
863 return value.size() <= 16;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
864
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
865 case ValueRepresentation_AgeString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
866 return (value.size() == 4 &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
867 isdigit(value[0]) &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
868 isdigit(value[1]) &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
869 isdigit(value[2]) &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
870 (value[3] == 'D' || value[3] == 'W' || value[3] == 'M' || value[3] == 'Y'));
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
871
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
872 case ValueRepresentation_AttributeTag:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
873 return value.size() == 4;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
874
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
875 case ValueRepresentation_CodeString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
876 return value.size() <= 16;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
877
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
878 case ValueRepresentation_Date:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
879 return value.size() <= 18;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
880
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
881 case ValueRepresentation_DecimalString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
882 return value.size() <= 16;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
883
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
884 case ValueRepresentation_DateTime:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
885 return value.size() <= 54;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
886
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
887 case ValueRepresentation_FloatingPointSingle:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
888 return value.size() == 4;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
889
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
890 case ValueRepresentation_FloatingPointDouble:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
891 return value.size() == 8;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
892
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
893 case ValueRepresentation_IntegerString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
894 return value.size() <= 12;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
895
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
896 case ValueRepresentation_LongString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
897 return value.size() <= 64;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
898
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
899 case ValueRepresentation_LongText:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
900 return value.size() <= 10240;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
901
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
902 case ValueRepresentation_OtherByte:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
903 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
904
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
905 case ValueRepresentation_OtherDouble:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
906 return value.size() <= (static_cast<uint64_t>(1) << 32) - 8;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
907
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
908 case ValueRepresentation_OtherFloat:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
909 return value.size() <= (static_cast<uint64_t>(1) << 32) - 4;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
910
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
911 case ValueRepresentation_OtherLong:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
912 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
913
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
914 case ValueRepresentation_OtherWord:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
915 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
916
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
917 case ValueRepresentation_PersonName:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
918 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
919
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
920 case ValueRepresentation_ShortString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
921 return value.size() <= 16;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
922
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
923 case ValueRepresentation_SignedLong:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
924 return value.size() == 4;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
925
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
926 case ValueRepresentation_Sequence:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
927 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
928
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
929 case ValueRepresentation_SignedShort:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
930 return value.size() == 2;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
931
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
932 case ValueRepresentation_ShortText:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
933 return value.size() <= 1024;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
934
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
935 case ValueRepresentation_Time:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
936 return value.size() <= 28;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
937
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
938 case ValueRepresentation_UnlimitedCharacters:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
939 return value.size() <= (static_cast<uint64_t>(1) << 32) - 2;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
940
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
941 case ValueRepresentation_UniqueIdentifier:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
942 return value.size() <= 64;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
943
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
944 case ValueRepresentation_UnsignedLong:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
945 return value.size() == 4;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
946
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
947 case ValueRepresentation_Unknown:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
948 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
949
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
950 case ValueRepresentation_UniversalResource:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
951 return value.size() <= (static_cast<uint64_t>(1) << 32) - 2;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
952
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
953 case ValueRepresentation_UnsignedShort:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
954 return value.size() == 2;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
955
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
956 case ValueRepresentation_UnlimitedText:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
957 return value.size() <= (static_cast<uint64_t>(1) << 32) - 2;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
958
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
959 default:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
960 // Assume unsupported tags are OK
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
961 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
962 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
963 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
964
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
965
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
966 static void RemoveTagPadding(std::string& value,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
967 const ValueRepresentation& vr)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
968 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
969 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
970 * Remove padding from character strings, if need be. For the time
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
971 * being, only the UI VR is supported.
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
972 * http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
973 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
974
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
975 switch (vr)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
976 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
977 case ValueRepresentation_UniqueIdentifier:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
978 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
979 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
980 * "Values with a VR of UI shall be padded with a single
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
981 * trailing NULL (00H) character when necessary to achieve even
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
982 * length."
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
983 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
984
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
985 if (!value.empty() &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
986 value[value.size() - 1] == '\0')
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
987 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
988 value.resize(value.size() - 1);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
989 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
990
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
991 break;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
992 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
993
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
994 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
995 * TODO implement other VR
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
996 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
997
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
998 default:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
999 // No padding is applicable to this VR
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1000 break;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1001 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1002 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1003
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1004
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1005 static bool ReadNextTag(DicomTag& tag,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1006 ValueRepresentation& vr,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1007 std::string& value,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1008 const char* dicom,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1009 size_t size,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1010 size_t& position)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1011 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1012 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1013 * http://dicom.nema.org/medical/dicom/current/output/chtml/part05/chapter_7.html#sect_7.1.2
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1014 * This function reads a data element with Explicit VR encoded using Little-Endian.
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1015 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1016
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1017 if (position + 6 > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1018 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1019 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1020 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1021
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1022 tag = DicomTag(ReadLittleEndianUint16(dicom + position),
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1023 ReadLittleEndianUint16(dicom + position + 2));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1024
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1025 vr = StringToValueRepresentation(std::string(dicom + position + 4, 2), true);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1026 if (vr == ValueRepresentation_NotSupported)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1027 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1028 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1029 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1030
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1031 // http://dicom.nema.org/medical/dicom/current/output/chtml/part05/chapter_7.html#sect_7.1.2
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1032 if (vr == ValueRepresentation_ApplicationEntity /* AE */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1033 vr == ValueRepresentation_AgeString /* AS */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1034 vr == ValueRepresentation_AttributeTag /* AT */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1035 vr == ValueRepresentation_CodeString /* CS */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1036 vr == ValueRepresentation_Date /* DA */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1037 vr == ValueRepresentation_DecimalString /* DS */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1038 vr == ValueRepresentation_DateTime /* DT */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1039 vr == ValueRepresentation_FloatingPointSingle /* FL */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1040 vr == ValueRepresentation_FloatingPointDouble /* FD */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1041 vr == ValueRepresentation_IntegerString /* IS */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1042 vr == ValueRepresentation_LongString /* LO */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1043 vr == ValueRepresentation_LongText /* LT */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1044 vr == ValueRepresentation_PersonName /* PN */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1045 vr == ValueRepresentation_ShortString /* SH */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1046 vr == ValueRepresentation_SignedLong /* SL */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1047 vr == ValueRepresentation_SignedShort /* SS */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1048 vr == ValueRepresentation_ShortText /* ST */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1049 vr == ValueRepresentation_Time /* TM */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1050 vr == ValueRepresentation_UniqueIdentifier /* UI */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1051 vr == ValueRepresentation_UnsignedLong /* UL */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1052 vr == ValueRepresentation_UnsignedShort /* US */)
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1053 {
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1054 /**
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1055 * This is Table 7.1-2. "Data Element with Explicit VR of AE,
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1056 * AS, AT, CS, DA, DS, DT, FL, FD, IS, LO, LT, PN, SH, SL, SS,
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1057 * ST, TM, UI, UL and US"
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1058 **/
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1059 if (position + 8 > size)
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1060 {
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1061 return false;
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1062 }
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1063
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1064 uint16_t length = ReadLittleEndianUint16(dicom + position + 6);
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1065 if (position + 8 + length > size)
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1066 {
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1067 return false;
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1068 }
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1069
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1070 value.assign(dicom + position + 8, length);
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1071 position += (8 + length);
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1072 }
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1073 else
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1074 {
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1075 /**
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1076 * This is Table 7.1-1. "Data Element with Explicit VR other
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1077 * than as shown in Table 7.1-2"
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1078 **/
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1079 if (position + 12 > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1080 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1081 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1082 }
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1083
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1084 uint16_t reserved = ReadLittleEndianUint16(dicom + position + 6);
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1085 if (reserved != 0)
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1086 {
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1087 return false;
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1088 }
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1089
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1090 uint32_t length = ReadLittleEndianUint32(dicom + position + 8);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1091 if (position + 12 + length > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1092 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1093 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1094 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1095
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1096 value.assign(dicom + position + 12, length);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1097 position += (12 + length);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1098 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1099
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1100 if (!ValidateTag(vr, value))
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1101 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1102 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1103 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1104
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1105 RemoveTagPadding(value, vr);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1106
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1107 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1108 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1109
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1110
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1111 bool DicomMap::IsDicomFile(const void* dicom,
3771
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1112 size_t size)
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1113 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1114 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1115 * http://dicom.nema.org/medical/dicom/current/output/chtml/part10/chapter_7.html
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1116 * According to Table 7.1-1, besides the "DICM" DICOM prefix, the
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1117 * file preamble (i.e. dicom[0..127]) should not be taken into
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1118 * account to determine whether the file is or is not a DICOM file.
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1119 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1120
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1121 const uint8_t* p = reinterpret_cast<const uint8_t*>(dicom);
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1122
3771
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1123 return (size >= 132 &&
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1124 p[128] == 'D' &&
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1125 p[129] == 'I' &&
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1126 p[130] == 'C' &&
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1127 p[131] == 'M');
3771
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1128 }
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1129
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1130
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1131 bool DicomMap::ParseDicomMetaInformation(DicomMap& result,
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1132 const void* dicom,
3771
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1133 size_t size)
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1134 {
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1135 if (!IsDicomFile(dicom, size))
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1136 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1137 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1138 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1139
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1140
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1141 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1142 * The DICOM File Meta Information must be encoded using the
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1143 * Explicit VR Little Endian Transfer Syntax
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1144 * (UID=1.2.840.10008.1.2.1).
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1145 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1146
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1147 result.Clear();
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1148
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1149 // First, we read the "File Meta Information Group Length" tag
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1150 // (0002,0000) to know where to stop reading the meta header
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1151 size_t position = 132;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1152
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1153 DicomTag tag(0x0000, 0x0000); // Dummy initialization
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1154 ValueRepresentation vr;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1155 std::string value;
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1156 if (!ReadNextTag(tag, vr, value, reinterpret_cast<const char*>(dicom), size, position) ||
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1157 tag.GetGroup() != 0x0002 ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1158 tag.GetElement() != 0x0000 ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1159 vr != ValueRepresentation_UnsignedLong ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1160 value.size() != 4)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1161 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1162 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1163 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1164
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1165 size_t stopPosition = position + ReadLittleEndianUint32(value.c_str());
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1166 if (stopPosition > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1167 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1168 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1169 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1170
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1171 while (position < stopPosition)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1172 {
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1173 if (ReadNextTag(tag, vr, value, reinterpret_cast<const char*>(dicom), size, position))
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1174 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1175 result.SetValue(tag, value, IsBinaryValueRepresentation(vr));
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1176 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1177 else
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1178 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1179 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1180 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1181 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1182
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1183 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1184 }
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1185
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1186
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1187 static std::string ValueAsString(const DicomMap& summary,
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1188 const DicomTag& tag)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1189 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1190 const DicomValue& value = summary.GetValue(tag);
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1191 if (value.IsNull())
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1192 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1193 return "(null)";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1194 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1195 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1196 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1197 return value.GetContent();
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1198 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1199 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1200
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1201
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1202 void DicomMap::LogMissingTagsForStore() const
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1203 {
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1204 std::string patientId, studyInstanceUid, seriesInstanceUid, sopInstanceUid;
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1205
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1206 if (HasTag(DICOM_TAG_PATIENT_ID))
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1207 {
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1208 patientId = ValueAsString(*this, DICOM_TAG_PATIENT_ID);
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1209 }
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1210
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1211 if (HasTag(DICOM_TAG_STUDY_INSTANCE_UID))
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1212 {
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1213 studyInstanceUid = ValueAsString(*this, DICOM_TAG_STUDY_INSTANCE_UID);
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1214 }
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1215
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1216 if (HasTag(DICOM_TAG_SERIES_INSTANCE_UID))
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1217 {
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1218 seriesInstanceUid = ValueAsString(*this, DICOM_TAG_SERIES_INSTANCE_UID);
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1219 }
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1220
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1221 if (HasTag(DICOM_TAG_SOP_INSTANCE_UID))
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1222 {
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1223 sopInstanceUid = ValueAsString(*this, DICOM_TAG_SOP_INSTANCE_UID);
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1224 }
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1225
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1226 LogMissingTagsForStore(patientId, studyInstanceUid, seriesInstanceUid, sopInstanceUid);
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1227 }
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1228
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1229
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1230 void DicomMap::LogMissingTagsForStore(const std::string& patientId,
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1231 const std::string& studyInstanceUid,
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1232 const std::string& seriesInstanceUid,
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1233 const std::string& sopInstanceUid)
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1234 {
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1235 std::string s, t;
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1236
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1237 if (!patientId.empty())
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1238 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1239 if (t.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1240 t += ", ";
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1241 t += "PatientID=" + patientId;
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1242 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1243 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1244 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1245 if (s.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1246 s += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1247 s += "PatientID";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1248 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1249
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1250 if (!studyInstanceUid.empty())
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1251 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1252 if (t.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1253 t += ", ";
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1254 t += "StudyInstanceUID=" + studyInstanceUid;
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1255 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1256 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1257 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1258 if (s.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1259 s += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1260 s += "StudyInstanceUID";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1261 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1262
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1263 if (!seriesInstanceUid.empty())
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1264 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1265 if (t.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1266 t += ", ";
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1267 t += "SeriesInstanceUID=" + seriesInstanceUid;
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1268 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1269 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1270 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1271 if (s.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1272 s += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1273 s += "SeriesInstanceUID";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1274 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1275
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1276 if (!sopInstanceUid.empty())
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1277 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1278 if (t.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1279 t += ", ";
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1280 t += "SOPInstanceUID=" + sopInstanceUid;
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1281 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1282 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1283 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1284 if (s.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1285 s += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1286 s += "SOPInstanceUID";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1287 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1288
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1289 if (t.size() == 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1290 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1291 LOG(ERROR) << "Store has failed because all the required tags (" << s << ") are missing (is it a DICOMDIR file?)";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1292 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1293 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1294 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1295 LOG(ERROR) << "Store has failed because required tags (" << s << ") are missing for the following instance: " << t;
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1296 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1297 }
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1298
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1299
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1300 bool DicomMap::LookupStringValue(std::string& result,
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1301 const DicomTag& tag,
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1302 bool allowBinary) const
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1303 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1304 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1305
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1306 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1307 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1308 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1309 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1310 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1311 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1312 return value->CopyToString(result, allowBinary);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1313 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1314 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1315
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1316 bool DicomMap::ParseInteger32(int32_t& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1317 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1318 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1319 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1320
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1321 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1322 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1323 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1324 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1325 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1326 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1327 return value->ParseInteger32(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1328 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1329 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1330
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1331 bool DicomMap::ParseInteger64(int64_t& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1332 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1333 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1334 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1335
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1336 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1337 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1338 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1339 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1340 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1341 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1342 return value->ParseInteger64(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1343 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1344 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1345
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1346 bool DicomMap::ParseUnsignedInteger32(uint32_t& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1347 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1348 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1349 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1350
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1351 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1352 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1353 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1354 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1355 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1356 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1357 return value->ParseUnsignedInteger32(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1358 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1359 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1360
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1361 bool DicomMap::ParseUnsignedInteger64(uint64_t& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1362 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1363 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1364 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1365
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1366 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1367 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1368 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1369 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1370 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1371 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1372 return value->ParseUnsignedInteger64(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1373 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1374 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1375
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1376 bool DicomMap::ParseFloat(float& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1377 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1378 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1379 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1380
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1381 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1382 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1383 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1384 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1385 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1386 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1387 return value->ParseFloat(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1388 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1389 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1390
3690
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1391 bool DicomMap::ParseFirstFloat(float& result,
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1392 const DicomTag& tag) const
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1393 {
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1394 const DicomValue* value = TestAndGetValue(tag);
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1395
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1396 if (value == NULL)
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1397 {
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1398 return false;
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1399 }
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1400 else
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1401 {
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1402 return value->ParseFirstFloat(result);
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1403 }
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1404 }
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1405
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1406 bool DicomMap::ParseDouble(double& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1407 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1408 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1409 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1410
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1411 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1412 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1413 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1414 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1415 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1416 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1417 return value->ParseDouble(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1418 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1419 }
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1420
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1421
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1422 void DicomMap::FromDicomAsJson(const Json::Value& dicomAsJson)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1423 {
3498
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1424 if (dicomAsJson.type() != Json::objectValue)
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1425 {
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1426 throw OrthancException(ErrorCode_BadFileFormat);
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1427 }
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1428
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1429 Clear();
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1430
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1431 Json::Value::Members tags = dicomAsJson.getMemberNames();
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1432 for (Json::Value::Members::const_iterator
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1433 it = tags.begin(); it != tags.end(); ++it)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1434 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1435 DicomTag tag(0, 0);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1436 if (!DicomTag::ParseHexadecimal(tag, it->c_str()))
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1437 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1438 throw OrthancException(ErrorCode_CorruptedFile);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1439 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1440
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1441 const Json::Value& value = dicomAsJson[*it];
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1442
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1443 if (value.type() != Json::objectValue ||
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1444 !value.isMember("Type") ||
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1445 !value.isMember("Value") ||
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1446 value["Type"].type() != Json::stringValue)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1447 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1448 throw OrthancException(ErrorCode_CorruptedFile);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1449 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1450
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1451 if (value["Type"] == "String")
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1452 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1453 if (value["Value"].type() != Json::stringValue)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1454 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1455 throw OrthancException(ErrorCode_CorruptedFile);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1456 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1457 else
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1458 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1459 SetValue(tag, value["Value"].asString(), false /* not binary */);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1460 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1461 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1462 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1463 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1464
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1465
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1466 void DicomMap::Merge(const DicomMap& other)
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1467 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1468 for (Content::const_iterator it = other.content_.begin();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1469 it != other.content_.end(); ++it)
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1470 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1471 assert(it->second != NULL);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1472
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1473 if (content_.find(it->first) == content_.end())
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1474 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1475 content_[it->first] = it->second->Clone();
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1476 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1477 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1478 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1479
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1480
3678
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1481 void DicomMap::MergeMainDicomTags(const DicomMap& other,
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1482 ResourceType level)
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1483 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1484 const std::map<DicomTag, std::string>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTags(level);
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1485
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1486 for (std::map<DicomTag, std::string>::const_iterator itmt = mainDicomTags.begin();
4981
d0c34145320c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4960
diff changeset
1487 itmt != mainDicomTags.end(); ++itmt)
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1488 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1489 Content::const_iterator found = other.content_.find(itmt->first);
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1490
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1491 if (found != other.content_.end() &&
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1492 content_.find(itmt->first) == content_.end())
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1493 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1494 assert(found->second != NULL);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1495 content_[itmt->first] = found->second->Clone();
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1496 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1497 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1498 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1499
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1500
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1501 void DicomMap::ExtractMainDicomTags(const DicomMap& other)
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1502 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1503 Clear();
3678
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1504 MergeMainDicomTags(other, ResourceType_Patient);
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1505 MergeMainDicomTags(other, ResourceType_Study);
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1506 MergeMainDicomTags(other, ResourceType_Series);
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1507 MergeMainDicomTags(other, ResourceType_Instance);
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1508 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1509
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1510
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1511 bool DicomMap::HasOnlyMainDicomTags() const
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1512 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1513 const std::set<DicomTag>& allMainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetAllMainDicomTags();
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1514
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1515 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it)
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1516 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1517 if (allMainDicomTags.find(it->first) == allMainDicomTags.end())
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1518 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1519 return false;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1520 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1521 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1522
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1523 return true;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1524 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1525
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1526
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1527 void DicomMap::Serialize(Json::Value& target) const
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1528 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1529 target = Json::objectValue;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1530
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1531 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it)
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1532 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1533 assert(it->second != NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1534
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1535 std::string tag = it->first.Format();
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1536
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1537 Json::Value value;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1538 it->second->Serialize(value);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1539
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1540 target[tag] = value;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1541 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1542 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1543
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1544
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1545 void DicomMap::Unserialize(const Json::Value& source)
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1546 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1547 Clear();
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1548
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1549 if (source.type() != Json::objectValue)
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1550 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1551 throw OrthancException(ErrorCode_BadFileFormat);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1552 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1553
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1554 Json::Value::Members tags = source.getMemberNames();
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1555
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1556 for (size_t i = 0; i < tags.size(); i++)
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1557 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1558 DicomTag tag(0, 0);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1559
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1560 if (!DicomTag::ParseHexadecimal(tag, tags[i].c_str()) ||
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1561 content_.find(tag) != content_.end())
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1562 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1563 throw OrthancException(ErrorCode_BadFileFormat);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1564 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1565
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3690
diff changeset
1566 std::unique_ptr<DicomValue> value(new DicomValue);
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1567 value->Unserialize(source[tags[i]]);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1568
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1569 content_[tag] = value.release();
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1570 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1571 }
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1572
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1573
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1574 void DicomMap::FromDicomWeb(const Json::Value& source)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1575 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1576 static const char* const ALPHABETIC = "Alphabetic";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1577 static const char* const IDEOGRAPHIC = "Ideographic";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1578 static const char* const INLINE_BINARY = "InlineBinary";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1579 static const char* const PHONETIC = "Phonetic";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1580 static const char* const VALUE = "Value";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1581 static const char* const VR = "vr";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1582
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1583 Clear();
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1584
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1585 if (source.type() != Json::objectValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1586 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1587 throw OrthancException(ErrorCode_BadFileFormat);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1588 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1589
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1590 Json::Value::Members tags = source.getMemberNames();
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1591
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1592 for (size_t i = 0; i < tags.size(); i++)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1593 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1594 const Json::Value& item = source[tags[i]];
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1595 DicomTag tag(0, 0);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1596
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1597 if (item.type() != Json::objectValue ||
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1598 !item.isMember(VR) ||
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1599 item[VR].type() != Json::stringValue ||
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1600 !DicomTag::ParseHexadecimal(tag, tags[i].c_str()))
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1601 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1602 throw OrthancException(ErrorCode_BadFileFormat);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1603 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1604
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1605 ValueRepresentation vr = StringToValueRepresentation(item[VR].asString(), false);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1606
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1607 if (item.isMember(INLINE_BINARY))
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1608 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1609 const Json::Value& value = item[INLINE_BINARY];
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1610
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1611 if (value.type() == Json::stringValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1612 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1613 std::string decoded;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1614 Toolbox::DecodeBase64(decoded, value.asString());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1615 SetValue(tag, decoded, true /* binary data */);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1616 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1617 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1618 else if (!item.isMember(VALUE))
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1619 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1620 // Tag is present, but it has a null value
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1621 SetValue(tag, "", false /* not binary */);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1622 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1623 else
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1624 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1625 const Json::Value& value = item[VALUE];
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1626
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1627 if (value.type() == Json::arrayValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1628 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1629 bool supported = true;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1630
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1631 std::string s;
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1632 for (Json::Value::ArrayIndex j = 0; j < value.size() && supported; j++)
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1633 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1634 if (!s.empty())
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1635 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1636 s += '\\';
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1637 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1638
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1639 switch (value[j].type())
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1640 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1641 case Json::objectValue:
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1642 if (vr == ValueRepresentation_PersonName &&
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1643 value[j].type() == Json::objectValue)
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1644 {
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1645 if (value[j].isMember(ALPHABETIC) &&
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1646 value[j][ALPHABETIC].type() == Json::stringValue)
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1647 {
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1648 s += value[j][ALPHABETIC].asString();
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1649 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1650
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1651 bool hasIdeographic = false;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1652
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1653 if (value[j].isMember(IDEOGRAPHIC) &&
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1654 value[j][IDEOGRAPHIC].type() == Json::stringValue)
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1655 {
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1656 s += '=' + value[j][IDEOGRAPHIC].asString();
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1657 hasIdeographic = true;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1658 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1659
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1660 if (value[j].isMember(PHONETIC) &&
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1661 value[j][PHONETIC].type() == Json::stringValue)
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1662 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1663 if (!hasIdeographic)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1664 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1665 s += '=';
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1666 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1667
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1668 s += '=' + value[j][PHONETIC].asString();
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1669 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1670 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1671 else
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1672 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1673 // This is the case of sequences
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1674 supported = false;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1675 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1676
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1677 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1678
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1679 case Json::stringValue:
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1680 s += value[j].asString();
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1681 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1682
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1683 case Json::intValue:
4788
b47ee86a0d10 support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4501
diff changeset
1684 s += boost::lexical_cast<std::string>(value[j].asInt64());
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1685 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1686
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1687 case Json::uintValue:
4788
b47ee86a0d10 support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4501
diff changeset
1688 s += boost::lexical_cast<std::string>(value[j].asUInt64());
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1689 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1690
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1691 case Json::realValue:
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1692 s += boost::lexical_cast<std::string>(value[j].asDouble());
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1693 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1694
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1695 default:
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1696 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1697 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1698 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1699
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1700 if (supported)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1701 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1702 SetValue(tag, s, false /* not binary */);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1703 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1704 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1705 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1706 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1707 }
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1708
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1709
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1710 std::string DicomMap::GetStringValue(const DicomTag& tag,
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1711 const std::string& defaultValue,
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1712 bool allowBinary) const
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1713 {
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1714 std::string s;
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1715 if (LookupStringValue(s, tag, allowBinary))
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1716 {
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1717 return s;
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1718 }
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1719 else
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1720 {
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1721 return defaultValue;
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1722 }
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1723 }
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1724
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1725
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1726 void DicomMap::RemoveBinaryTags()
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1727 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1728 Content kept;
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1729
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1730 for (Content::iterator it = content_.begin(); it != content_.end(); ++it)
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1731 {
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1732 assert(it->second != NULL);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1733
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1734 if (!it->second->IsBinary() &&
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1735 !it->second->IsNull())
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1736 {
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1737 kept[it->first] = it->second;
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1738 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1739 else
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1740 {
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1741 delete it->second;
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1742 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1743 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1744
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1745 content_ = kept;
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1746 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1747
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1748
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1749 void DicomMap::DumpMainDicomTags(Json::Value& target,
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1750 ResourceType level) const
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1751 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1752 const std::map<DicomTag, std::string>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTags(level);
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1753
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1754 target = Json::objectValue;
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1755
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1756 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1757 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1758 assert(it->second != NULL);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1759
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1760 if (!it->second->IsBinary() &&
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1761 !it->second->IsNull())
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1762 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1763 std::map<DicomTag, std::string>::const_iterator found = mainDicomTags.find(it->first);
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1764
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1765 if (found != mainDicomTags.end())
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1766 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1767 target[found->second] = it->second->GetContent();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1768 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1769 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1770 }
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1771 }
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1772
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1773
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1774 void DicomMap::ParseMainDicomTags(const Json::Value& source,
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1775 ResourceType level)
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1776 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1777 if (source.type() != Json::objectValue)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1778 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1779 throw OrthancException(ErrorCode_BadFileFormat);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1780 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1781
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1782 const std::map<std::string, DicomTag2>& mainTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsByName(level);
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1783
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1784 Json::Value::Members members = source.getMemberNames();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1785 for (size_t i = 0; i < members.size(); i++)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1786 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1787 std::map<std::string, DicomTag2>::const_iterator found = mainTags.find(members[i]);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1788
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1789 if (found != mainTags.end())
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1790 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1791 const Json::Value& value = source[members[i]];
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1792 if (value.type() != Json::stringValue)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1793 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1794 throw OrthancException(ErrorCode_BadFileFormat);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1795 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1796 else
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1797 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1798 SetValue(found->second, value.asString(), false);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1799 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1800 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1801 }
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1802 }
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1803
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1804
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1805 void DicomMap::Print(FILE* fp) const
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1806 {
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1807 DicomArray a(*this);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1808 a.Print(fp);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1809 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1810 }