annotate Core/DicomFormat/DicomMap.cpp @ 3821:f2488b645f5f transcoding

adding storage commitment to DicomAssociation
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 09 Apr 2020 18:29:42 +0200
parents 74889e6f6d68
children e7003b2203a7
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
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
11 *
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
12 * In addition, as a special exception, the copyright holders of this
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
13 * program give permission to link the code of its release with the
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
16 * the linked executables. You must obey the GNU General Public License
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
20 * you do not wish to do so, delete this exception statement from your
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
21 * version. If you delete this exception statement from all source files
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
22 * in the program, then also delete it here.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * 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
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
824
a811bdf8b8eb precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 730
diff changeset
34 #include "../PrecompiledHeaders.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "DicomMap.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include <stdio.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include <memory>
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
39
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3690
diff changeset
40 #include "../Compatibility.h"
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
41 #include "../Endianness.h"
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
42 #include "../Logging.h"
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 53
diff changeset
43 #include "../OrthancException.h"
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
44 #include "../Toolbox.h"
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
45 #include "DicomArray.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 53
diff changeset
48 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
50 namespace
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
52 struct MainDicomTag
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
53 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
54 const DicomTag tag_;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
55 const char* name_;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
56 };
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
57 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
59 static const MainDicomTag PATIENT_MAIN_DICOM_TAGS[] =
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
61 // { DicomTag(0x0010, 0x1010), "PatientAge" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
62 // { DicomTag(0x0010, 0x1040), "PatientAddress" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
63 { DicomTag(0x0010, 0x0010), "PatientName" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
64 { DicomTag(0x0010, 0x0030), "PatientBirthDate" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
65 { DicomTag(0x0010, 0x0040), "PatientSex" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
66 { DicomTag(0x0010, 0x1000), "OtherPatientIDs" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
67 { DICOM_TAG_PATIENT_ID, "PatientID" }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 };
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
69
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
70 static const MainDicomTag STUDY_MAIN_DICOM_TAGS[] =
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
71 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
72 // { DicomTag(0x0010, 0x1020), "PatientSize" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
73 // { DicomTag(0x0010, 0x1030), "PatientWeight" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
74 { DICOM_TAG_STUDY_DATE, "StudyDate" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
75 { DicomTag(0x0008, 0x0030), "StudyTime" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
76 { DicomTag(0x0020, 0x0010), "StudyID" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
77 { DICOM_TAG_STUDY_DESCRIPTION, "StudyDescription" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
78 { DICOM_TAG_ACCESSION_NUMBER, "AccessionNumber" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
79 { DICOM_TAG_STUDY_INSTANCE_UID, "StudyInstanceUID" },
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
81 // New in db v6
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
82 { DICOM_TAG_REQUESTED_PROCEDURE_DESCRIPTION, "RequestedProcedureDescription" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
83 { DICOM_TAG_INSTITUTION_NAME, "InstitutionName" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
84 { DICOM_TAG_REQUESTING_PHYSICIAN, "RequestingPhysician" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
85 { DICOM_TAG_REFERRING_PHYSICIAN_NAME, "ReferringPhysicianName" }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
86 };
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
87
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
88 static const MainDicomTag SERIES_MAIN_DICOM_TAGS[] =
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
90 // { DicomTag(0x0010, 0x1080), "MilitaryRank" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
91 { DicomTag(0x0008, 0x0021), "SeriesDate" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
92 { DicomTag(0x0008, 0x0031), "SeriesTime" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
93 { DICOM_TAG_MODALITY, "Modality" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
94 { DicomTag(0x0008, 0x0070), "Manufacturer" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
95 { DicomTag(0x0008, 0x1010), "StationName" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
96 { DICOM_TAG_SERIES_DESCRIPTION, "SeriesDescription" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
97 { DicomTag(0x0018, 0x0015), "BodyPartExamined" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
98 { DicomTag(0x0018, 0x0024), "SequenceName" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
99 { DicomTag(0x0018, 0x1030), "ProtocolName" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
100 { DicomTag(0x0020, 0x0011), "SeriesNumber" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
101 { DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES, "CardiacNumberOfImages" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
102 { DICOM_TAG_IMAGES_IN_ACQUISITION, "ImagesInAcquisition" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
103 { DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS, "NumberOfTemporalPositions" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
104 { DICOM_TAG_NUMBER_OF_SLICES, "NumberOfSlices" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
105 { DICOM_TAG_NUMBER_OF_TIME_SLICES, "NumberOfTimeSlices" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
106 { DICOM_TAG_SERIES_INSTANCE_UID, "SeriesInstanceUID" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
107
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
108 // New in db v6
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
109 { DICOM_TAG_IMAGE_ORIENTATION_PATIENT, "ImageOrientationPatient" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
110 { DICOM_TAG_SERIES_TYPE, "SeriesType" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
111 { DICOM_TAG_OPERATOR_NAME, "OperatorsName" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
112 { DICOM_TAG_PERFORMED_PROCEDURE_STEP_DESCRIPTION, "PerformedProcedureStepDescription" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
113 { DICOM_TAG_ACQUISITION_DEVICE_PROCESSING_DESCRIPTION, "AcquisitionDeviceProcessingDescription" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
114 { DICOM_TAG_CONTRAST_BOLUS_AGENT, "ContrastBolusAgent" }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 };
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
116
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
117 static const MainDicomTag INSTANCE_MAIN_DICOM_TAGS[] =
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
119 { DicomTag(0x0008, 0x0012), "InstanceCreationDate" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
120 { DicomTag(0x0008, 0x0013), "InstanceCreationTime" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
121 { DicomTag(0x0020, 0x0012), "AcquisitionNumber" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
122 { DICOM_TAG_IMAGE_INDEX, "ImageIndex" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
123 { DICOM_TAG_INSTANCE_NUMBER, "InstanceNumber" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
124 { DICOM_TAG_NUMBER_OF_FRAMES, "NumberOfFrames" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
125 { DICOM_TAG_TEMPORAL_POSITION_IDENTIFIER, "TemporalPositionIdentifier" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
126 { DICOM_TAG_SOP_INSTANCE_UID, "SOPInstanceUID" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
127
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
128 // New in db v6
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
129 { DICOM_TAG_IMAGE_POSITION_PATIENT, "ImagePositionPatient" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
130 { 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
131
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
132 /**
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
133 * 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
134 * 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
135 * 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
136 * 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
137 * 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
138 **/
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
139 { 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
140 };
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
143 static void LoadMainDicomTags(const MainDicomTag*& tags,
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
144 size_t& size,
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
145 ResourceType level)
1749
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
146 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
147 switch (level)
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
148 {
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
149 case ResourceType_Patient:
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
150 tags = PATIENT_MAIN_DICOM_TAGS;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
151 size = sizeof(PATIENT_MAIN_DICOM_TAGS) / sizeof(MainDicomTag);
1749
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
152 break;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
153
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
154 case ResourceType_Study:
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
155 tags = STUDY_MAIN_DICOM_TAGS;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
156 size = sizeof(STUDY_MAIN_DICOM_TAGS) / sizeof(MainDicomTag);
1749
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
157 break;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
158
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
159 case ResourceType_Series:
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
160 tags = SERIES_MAIN_DICOM_TAGS;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
161 size = sizeof(SERIES_MAIN_DICOM_TAGS) / sizeof(MainDicomTag);
1749
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
162 break;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
163
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
164 case ResourceType_Instance:
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
165 tags = INSTANCE_MAIN_DICOM_TAGS;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
166 size = sizeof(INSTANCE_MAIN_DICOM_TAGS) / sizeof(MainDicomTag);
1749
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
167 break;
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
168
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
169 default:
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
170 throw OrthancException(ErrorCode_ParameterOutOfRange);
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
171 }
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
172 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
175 static void LoadMainDicomTags(std::map<DicomTag, std::string>& target,
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
176 ResourceType level)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
177 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
178 const MainDicomTag* tags = NULL;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
179 size_t size;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
180 LoadMainDicomTags(tags, size, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
181
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
182 assert(tags != NULL &&
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
183 size != 0);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
184
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
185 for (size_t i = 0; i < size; i++)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
186 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
187 assert(target.find(tags[i].tag_) == target.end());
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
188
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
189 target[tags[i].tag_] = tags[i].name_;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
190 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
191 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
192
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
193
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
194 namespace
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
195 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
196 class DicomTag2 : public DicomTag
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
197 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
198 public:
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
199 DicomTag2() :
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
200 DicomTag(0, 0) // To make std::map<> happy
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
201 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
202 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
203
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
204 DicomTag2(const DicomTag& tag) :
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
205 DicomTag(tag)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
206 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
207 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
208 };
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
209 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
210
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
211
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
212 static void LoadMainDicomTags(std::map<std::string, DicomTag2>& target,
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
213 ResourceType level)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
214 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
215 const MainDicomTag* tags = NULL;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
216 size_t size;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
217 LoadMainDicomTags(tags, size, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
218
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
219 assert(tags != NULL &&
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
220 size != 0);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
221
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
222 for (size_t i = 0; i < size; i++)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
223 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
224 assert(target.find(tags[i].name_) == target.end());
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
225
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
226 target[tags[i].name_] = tags[i].tag_;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
227 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
228 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
229
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
230
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
231 void DicomMap::SetValueInternal(uint16_t group,
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
232 uint16_t element,
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
233 DicomValue* value)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 DicomTag tag(group, element);
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
236 Content::iterator it = content_.find(tag);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
238 if (it != content_.end())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 delete it->second;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 it->second = value;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
245 content_.insert(std::make_pair(tag, value));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 void DicomMap::Clear()
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
252 for (Content::iterator it = content_.begin(); it != content_.end(); ++it)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 {
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
254 assert(it->second != NULL);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 delete it->second;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
258 content_.clear();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
262 static void ExtractTags(DicomMap& result,
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
263 const DicomMap::Content& source,
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
264 const MainDicomTag* tags,
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
265 size_t count)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 result.Clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 for (unsigned int i = 0; i < count; i++)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
271 DicomMap::Content::const_iterator it = source.find(tags[i].tag_);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
272 if (it != source.end())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
274 result.SetValue(it->first, *it->second /* value will be cloned */);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 void DicomMap::ExtractPatientInformation(DicomMap& result) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
282 ExtractTags(result, content_, PATIENT_MAIN_DICOM_TAGS, sizeof(PATIENT_MAIN_DICOM_TAGS) / sizeof(MainDicomTag));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 void DicomMap::ExtractStudyInformation(DicomMap& result) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
287 ExtractTags(result, content_, STUDY_MAIN_DICOM_TAGS, sizeof(STUDY_MAIN_DICOM_TAGS) / sizeof(MainDicomTag));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 void DicomMap::ExtractSeriesInformation(DicomMap& result) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
292 ExtractTags(result, content_, SERIES_MAIN_DICOM_TAGS, sizeof(SERIES_MAIN_DICOM_TAGS) / sizeof(MainDicomTag));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 void DicomMap::ExtractInstanceInformation(DicomMap& result) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
297 ExtractTags(result, content_, INSTANCE_MAIN_DICOM_TAGS, sizeof(INSTANCE_MAIN_DICOM_TAGS) / sizeof(MainDicomTag));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
301
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 DicomMap* DicomMap::Clone() const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3690
diff changeset
304 std::unique_ptr<DicomMap> result(new DicomMap);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
306 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
308 result->content_.insert(std::make_pair(it->first, it->second->Clone()));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 return result.release();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
315 void DicomMap::Assign(const DicomMap& other)
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
316 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
317 Clear();
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
318
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
319 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
320 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
321 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
322 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
323 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
324
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
325
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 const DicomValue& DicomMap::GetValue(const DicomTag& tag) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 {
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
328 const DicomValue* value = TestAndGetValue(tag);
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
329
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
330 if (value)
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
331 {
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
332 return *value;
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
333 }
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
334 else
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
335 {
730
309e686b41e7 better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
336 throw OrthancException(ErrorCode_InexistentTag);
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
337 }
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
338 }
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
339
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
340
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
341 const DicomValue* DicomMap::TestAndGetValue(const DicomTag& tag) const
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
342 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
343 Content::const_iterator it = content_.find(tag);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
345 if (it == content_.end())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 {
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
347 return NULL;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 {
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
351 return it->second;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 void DicomMap::Remove(const DicomTag& tag)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
358 Content::iterator it = content_.find(tag);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
359 if (it != content_.end())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 delete it->second;
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
362 content_.erase(it);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 static void SetupFindTemplate(DicomMap& result,
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
368 const MainDicomTag* tags,
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 size_t count)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 result.Clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 for (size_t i = 0; i < count; i++)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
375 result.SetValue(tags[i].tag_, "", false);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 void DicomMap::SetupFindPatientTemplate(DicomMap& result)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
381 SetupFindTemplate(result, PATIENT_MAIN_DICOM_TAGS, sizeof(PATIENT_MAIN_DICOM_TAGS) / sizeof(MainDicomTag));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 void DicomMap::SetupFindStudyTemplate(DicomMap& result)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
386 SetupFindTemplate(result, STUDY_MAIN_DICOM_TAGS, sizeof(STUDY_MAIN_DICOM_TAGS) / sizeof(MainDicomTag));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
387 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
388 result.SetValue(DICOM_TAG_PATIENT_ID, "", false);
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
389
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
390 // 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
391 // General Study Module, remove them
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
392 result.Remove(DICOM_TAG_INSTITUTION_NAME);
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
393 result.Remove(DICOM_TAG_REQUESTING_PHYSICIAN);
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
394 result.Remove(DICOM_TAG_REQUESTED_PROCEDURE_DESCRIPTION);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 void DicomMap::SetupFindSeriesTemplate(DicomMap& result)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
399 SetupFindTemplate(result, SERIES_MAIN_DICOM_TAGS, sizeof(SERIES_MAIN_DICOM_TAGS) / sizeof(MainDicomTag));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
400 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
401 result.SetValue(DICOM_TAG_PATIENT_ID, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
402 result.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "", false);
1372
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
403
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
404 // 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
405 result.Remove(DicomTag(0x0008, 0x0070)); // Manufacturer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
406 result.Remove(DicomTag(0x0008, 0x1010)); // Station name
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
407 result.Remove(DicomTag(0x0018, 0x0024)); // Sequence name
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
408 result.Remove(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
409 result.Remove(DICOM_TAG_IMAGES_IN_ACQUISITION);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
410 result.Remove(DICOM_TAG_NUMBER_OF_SLICES);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
411 result.Remove(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
412 result.Remove(DICOM_TAG_NUMBER_OF_TIME_SLICES);
1706
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
413 result.Remove(DICOM_TAG_IMAGE_ORIENTATION_PATIENT);
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
414 result.Remove(DICOM_TAG_SERIES_TYPE);
1850
68854412c7bc new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
415 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
416 result.Remove(DICOM_TAG_CONTRAST_BOLUS_AGENT);
0
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
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 void DicomMap::SetupFindInstanceTemplate(DicomMap& result)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
421 SetupFindTemplate(result, INSTANCE_MAIN_DICOM_TAGS, sizeof(INSTANCE_MAIN_DICOM_TAGS) / sizeof(MainDicomTag));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
422 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
423 result.SetValue(DICOM_TAG_PATIENT_ID, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
424 result.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
425 result.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, "", false);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 }
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
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 void DicomMap::CopyTagIfExists(const DicomMap& source,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 const DicomTag& tag)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 if (source.HasTag(tag))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 SetValue(tag, source.GetValue(tag));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 }
562
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
437
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
438
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
439 bool DicomMap::IsMainDicomTag(const DicomTag& tag, ResourceType level)
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
440 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
441 const MainDicomTag *tags = NULL;
562
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
442 size_t size;
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
443 LoadMainDicomTags(tags, size, level);
562
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
444
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
445 for (size_t i = 0; i < size; i++)
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
446 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
447 if (tags[i].tag_ == tag)
562
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
448 {
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
449 return true;
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
450 }
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
451 }
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
452
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
453 return false;
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
454 }
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
455
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
456 bool DicomMap::IsMainDicomTag(const DicomTag& tag)
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
457 {
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
458 return (IsMainDicomTag(tag, ResourceType_Patient) ||
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
459 IsMainDicomTag(tag, ResourceType_Study) ||
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
460 IsMainDicomTag(tag, ResourceType_Series) ||
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
461 IsMainDicomTag(tag, ResourceType_Instance));
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
462 }
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
463
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
464
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
465 void DicomMap::GetMainDicomTagsInternal(std::set<DicomTag>& result, ResourceType level)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
466 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
467 const MainDicomTag *tags = NULL;
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
468 size_t size;
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
469 LoadMainDicomTags(tags, size, level);
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
470
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
471 for (size_t i = 0; i < size; i++)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
472 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
473 result.insert(tags[i].tag_);
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
474 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
475 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
476
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
477
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
478 void DicomMap::GetMainDicomTags(std::set<DicomTag>& result, ResourceType level)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
479 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
480 result.clear();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
481 GetMainDicomTagsInternal(result, level);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
482 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
483
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
484
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
485 void DicomMap::GetMainDicomTags(std::set<DicomTag>& result)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
486 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
487 result.clear();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
488 GetMainDicomTagsInternal(result, ResourceType_Patient);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
489 GetMainDicomTagsInternal(result, ResourceType_Study);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
490 GetMainDicomTagsInternal(result, ResourceType_Series);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
491 GetMainDicomTagsInternal(result, ResourceType_Instance);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
492 }
1206
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
493
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
494
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
495 void DicomMap::GetTags(std::set<DicomTag>& tags) const
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
496 {
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
497 tags.clear();
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
498
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
499 for (Content::const_iterator it = content_.begin();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
500 it != content_.end(); ++it)
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
501 {
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
502 tags.insert(it->first);
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
503 }
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
504 }
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
505
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
506
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
507 static uint16_t ReadUnsignedInteger16(const char* dicom)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
508 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
509 return le16toh(*reinterpret_cast<const uint16_t*>(dicom));
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
510 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
511
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
512
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
513 static uint32_t ReadUnsignedInteger32(const char* dicom)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
514 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
515 return le32toh(*reinterpret_cast<const uint32_t*>(dicom));
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
516 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
517
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
518
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
519 static bool ValidateTag(const ValueRepresentation& vr,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
520 const std::string& value)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
521 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
522 switch (vr)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
523 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
524 case ValueRepresentation_ApplicationEntity:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
525 return value.size() <= 16;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
526
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
527 case ValueRepresentation_AgeString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
528 return (value.size() == 4 &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
529 isdigit(value[0]) &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
530 isdigit(value[1]) &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
531 isdigit(value[2]) &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
532 (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
533
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
534 case ValueRepresentation_AttributeTag:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
535 return value.size() == 4;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
536
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
537 case ValueRepresentation_CodeString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
538 return value.size() <= 16;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
539
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
540 case ValueRepresentation_Date:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
541 return value.size() <= 18;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
542
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
543 case ValueRepresentation_DecimalString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
544 return value.size() <= 16;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
545
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
546 case ValueRepresentation_DateTime:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
547 return value.size() <= 54;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
548
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
549 case ValueRepresentation_FloatingPointSingle:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
550 return value.size() == 4;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
551
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
552 case ValueRepresentation_FloatingPointDouble:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
553 return value.size() == 8;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
554
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
555 case ValueRepresentation_IntegerString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
556 return value.size() <= 12;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
557
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
558 case ValueRepresentation_LongString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
559 return value.size() <= 64;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
560
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
561 case ValueRepresentation_LongText:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
562 return value.size() <= 10240;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
563
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
564 case ValueRepresentation_OtherByte:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
565 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
566
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
567 case ValueRepresentation_OtherDouble:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
568 return value.size() <= (static_cast<uint64_t>(1) << 32) - 8;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
569
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
570 case ValueRepresentation_OtherFloat:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
571 return value.size() <= (static_cast<uint64_t>(1) << 32) - 4;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
572
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
573 case ValueRepresentation_OtherLong:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
574 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
575
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
576 case ValueRepresentation_OtherWord:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
577 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
578
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
579 case ValueRepresentation_PersonName:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
580 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
581
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
582 case ValueRepresentation_ShortString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
583 return value.size() <= 16;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
584
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
585 case ValueRepresentation_SignedLong:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
586 return value.size() == 4;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
587
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
588 case ValueRepresentation_Sequence:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
589 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
590
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
591 case ValueRepresentation_SignedShort:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
592 return value.size() == 2;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
593
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
594 case ValueRepresentation_ShortText:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
595 return value.size() <= 1024;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
596
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
597 case ValueRepresentation_Time:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
598 return value.size() <= 28;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
599
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
600 case ValueRepresentation_UnlimitedCharacters:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
601 return value.size() <= (static_cast<uint64_t>(1) << 32) - 2;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
602
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
603 case ValueRepresentation_UniqueIdentifier:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
604 return value.size() <= 64;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
605
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
606 case ValueRepresentation_UnsignedLong:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
607 return value.size() == 4;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
608
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
609 case ValueRepresentation_Unknown:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
610 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
611
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
612 case ValueRepresentation_UniversalResource:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
613 return value.size() <= (static_cast<uint64_t>(1) << 32) - 2;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
614
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
615 case ValueRepresentation_UnsignedShort:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
616 return value.size() == 2;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
617
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
618 case ValueRepresentation_UnlimitedText:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
619 return value.size() <= (static_cast<uint64_t>(1) << 32) - 2;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
620
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
621 default:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
622 // Assume unsupported tags are OK
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
623 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
624 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
625 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
626
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
627
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
628 static void RemoveTagPadding(std::string& value,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
629 const ValueRepresentation& vr)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
630 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
631 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
632 * Remove padding from character strings, if need be. For the time
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
633 * being, only the UI VR is supported.
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
634 * 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
635 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
636
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
637 switch (vr)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
638 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
639 case ValueRepresentation_UniqueIdentifier:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
640 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
641 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
642 * "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
643 * trailing NULL (00H) character when necessary to achieve even
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
644 * length."
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
645 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
646
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
647 if (!value.empty() &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
648 value[value.size() - 1] == '\0')
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
649 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
650 value.resize(value.size() - 1);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
651 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
652
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
653 break;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
654 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
655
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
656 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
657 * TODO implement other VR
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
658 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
659
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
660 default:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
661 // No padding is applicable to this VR
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
662 break;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
663 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
664 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
665
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
666
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
667 static bool ReadNextTag(DicomTag& tag,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
668 ValueRepresentation& vr,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
669 std::string& value,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
670 const char* dicom,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
671 size_t size,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
672 size_t& position)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
673 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
674 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
675 * 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
676 * 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
677 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
678
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
679 if (position + 6 > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
680 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
681 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
682 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
683
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
684 tag = DicomTag(ReadUnsignedInteger16(dicom + position),
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
685 ReadUnsignedInteger16(dicom + position + 2));
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
686
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
687 vr = StringToValueRepresentation(std::string(dicom + position + 4, 2), true);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
688 if (vr == ValueRepresentation_NotSupported)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
689 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
690 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
691 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
692
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
693 if (vr == ValueRepresentation_OtherByte ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
694 vr == ValueRepresentation_OtherDouble ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
695 vr == ValueRepresentation_OtherFloat ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
696 vr == ValueRepresentation_OtherLong ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
697 vr == ValueRepresentation_OtherWord ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
698 vr == ValueRepresentation_Sequence ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
699 vr == ValueRepresentation_UnlimitedCharacters ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
700 vr == ValueRepresentation_UniversalResource ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
701 vr == ValueRepresentation_UnlimitedText ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
702 vr == ValueRepresentation_Unknown) // Note that "UN" should never appear in the Meta Information
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
703 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
704 if (position + 12 > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
705 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
706 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
707 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
708
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
709 uint32_t length = ReadUnsignedInteger32(dicom + position + 8);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
710
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
711 if (position + 12 + length > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
712 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
713 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
714 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
715
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
716 value.assign(dicom + position + 12, length);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
717 position += (12 + length);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
718 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
719 else
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
720 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
721 if (position + 8 > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
722 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
723 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
724 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
725
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
726 uint16_t length = ReadUnsignedInteger16(dicom + position + 6);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
727
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
728 if (position + 8 + length > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
729 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
730 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
731 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
732
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
733 value.assign(dicom + position + 8, length);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
734 position += (8 + length);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
735 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
736
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
737 if (!ValidateTag(vr, value))
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
738 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
739 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
740 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
741
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
742 RemoveTagPadding(value, vr);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
743
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
744 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
745 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
746
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
747
3771
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
748 bool DicomMap::IsDicomFile(const char* dicom,
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
749 size_t size)
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
750 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
751 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
752 * 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
753 * 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
754 * 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
755 * 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
756 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
757
3771
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
758 return (size >= 132 &&
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
759 dicom[128] == 'D' &&
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
760 dicom[129] == 'I' &&
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
761 dicom[130] == 'C' &&
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
762 dicom[131] == 'M');
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
763 }
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
764
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
765
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
766 bool DicomMap::ParseDicomMetaInformation(DicomMap& result,
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
767 const char* dicom,
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
768 size_t size)
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
769 {
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
770 if (!IsDicomFile(dicom, size))
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
771 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
772 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
773 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
774
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
775
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
776 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
777 * The DICOM File Meta Information must be encoded using the
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
778 * Explicit VR Little Endian Transfer Syntax
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
779 * (UID=1.2.840.10008.1.2.1).
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
780 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
781
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
782 result.Clear();
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
783
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
784 // First, we read the "File Meta Information Group Length" tag
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
785 // (0002,0000) to know where to stop reading the meta header
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
786 size_t position = 132;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
787
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
788 DicomTag tag(0x0000, 0x0000); // Dummy initialization
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
789 ValueRepresentation vr;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
790 std::string value;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
791 if (!ReadNextTag(tag, vr, value, dicom, size, position) ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
792 tag.GetGroup() != 0x0002 ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
793 tag.GetElement() != 0x0000 ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
794 vr != ValueRepresentation_UnsignedLong ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
795 value.size() != 4)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
796 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
797 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
798 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
799
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
800 size_t stopPosition = position + ReadUnsignedInteger32(value.c_str());
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
801 if (stopPosition > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
802 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
803 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
804 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
805
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
806 while (position < stopPosition)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
807 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
808 if (ReadNextTag(tag, vr, value, dicom, size, position))
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
809 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
810 result.SetValue(tag, value, IsBinaryValueRepresentation(vr));
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
811 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
812 else
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
813 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
814 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
815 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
816 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
817
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
818 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
819 }
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
820
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
821
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
822 static std::string ValueAsString(const DicomMap& summary,
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
823 const DicomTag& tag)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
824 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
825 const DicomValue& value = summary.GetValue(tag);
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
826 if (value.IsNull())
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
827 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
828 return "(null)";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
829 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
830 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
831 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
832 return value.GetContent();
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
833 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
834 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
835
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
836
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
837 void DicomMap::LogMissingTagsForStore() const
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
838 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
839 std::string s, t;
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
840
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
841 if (HasTag(DICOM_TAG_PATIENT_ID))
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
842 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
843 if (t.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
844 t += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
845 t += "PatientID=" + ValueAsString(*this, DICOM_TAG_PATIENT_ID);
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
846 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
847 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
848 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
849 if (s.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
850 s += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
851 s += "PatientID";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
852 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
853
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
854 if (HasTag(DICOM_TAG_STUDY_INSTANCE_UID))
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
855 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
856 if (t.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
857 t += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
858 t += "StudyInstanceUID=" + ValueAsString(*this, DICOM_TAG_STUDY_INSTANCE_UID);
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
859 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
860 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
861 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
862 if (s.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
863 s += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
864 s += "StudyInstanceUID";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
865 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
866
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
867 if (HasTag(DICOM_TAG_SERIES_INSTANCE_UID))
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
868 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
869 if (t.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
870 t += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
871 t += "SeriesInstanceUID=" + ValueAsString(*this, DICOM_TAG_SERIES_INSTANCE_UID);
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
872 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
873 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
874 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
875 if (s.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
876 s += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
877 s += "SeriesInstanceUID";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
878 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
879
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
880 if (HasTag(DICOM_TAG_SOP_INSTANCE_UID))
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
881 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
882 if (t.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
883 t += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
884 t += "SOPInstanceUID=" + ValueAsString(*this, DICOM_TAG_SOP_INSTANCE_UID);
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
885 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
886 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
887 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
888 if (s.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
889 s += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
890 s += "SOPInstanceUID";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
891 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
892
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
893 if (t.size() == 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
894 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
895 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
896 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
897 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
898 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
899 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
900 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
901 }
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
902
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
903
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
904 bool DicomMap::LookupStringValue(std::string& result,
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
905 const DicomTag& tag,
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
906 bool allowBinary) const
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
907 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
908 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
909
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
910 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
911 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
912 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
913 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
914 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
915 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
916 return value->CopyToString(result, allowBinary);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
917 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
918 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
919
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
920 bool DicomMap::ParseInteger32(int32_t& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
921 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
922 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
923 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
924
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
925 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
926 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
927 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
928 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
929 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
930 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
931 return value->ParseInteger32(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
932 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
933 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
934
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
935 bool DicomMap::ParseInteger64(int64_t& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
936 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
937 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
938 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
939
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
940 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
941 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
942 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
943 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
944 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
945 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
946 return value->ParseInteger64(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
947 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
948 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
949
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
950 bool DicomMap::ParseUnsignedInteger32(uint32_t& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
951 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
952 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
953 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
954
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
955 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
956 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
957 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
958 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
959 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
960 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
961 return value->ParseUnsignedInteger32(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
962 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
963 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
964
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
965 bool DicomMap::ParseUnsignedInteger64(uint64_t& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
966 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
967 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
968 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
969
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
970 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
971 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
972 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
973 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
974 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
975 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
976 return value->ParseUnsignedInteger64(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
977 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
978 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
979
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
980 bool DicomMap::ParseFloat(float& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
981 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
982 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
983 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
984
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
985 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
986 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
987 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
988 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
989 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
990 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
991 return value->ParseFloat(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
992 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
993 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
994
3690
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
995 bool DicomMap::ParseFirstFloat(float& result,
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
996 const DicomTag& tag) const
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
997 {
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
998 const DicomValue* value = TestAndGetValue(tag);
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
999
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1000 if (value == NULL)
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1001 {
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1002 return false;
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1003 }
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1004 else
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1005 {
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1006 return value->ParseFirstFloat(result);
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1007 }
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1008 }
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1009
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1010 bool DicomMap::ParseDouble(double& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1011 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1012 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1013 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1014
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1015 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1016 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1017 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1018 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1019 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1020 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1021 return value->ParseDouble(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1022 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1023 }
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1024
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1025
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1026 void DicomMap::FromDicomAsJson(const Json::Value& dicomAsJson)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1027 {
3498
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1028 if (dicomAsJson.type() != Json::objectValue)
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1029 {
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1030 throw OrthancException(ErrorCode_BadFileFormat);
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1031 }
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1032
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1033 Clear();
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1034
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1035 Json::Value::Members tags = dicomAsJson.getMemberNames();
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1036 for (Json::Value::Members::const_iterator
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1037 it = tags.begin(); it != tags.end(); ++it)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1038 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1039 DicomTag tag(0, 0);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1040 if (!DicomTag::ParseHexadecimal(tag, it->c_str()))
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1041 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1042 throw OrthancException(ErrorCode_CorruptedFile);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1043 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1044
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1045 const Json::Value& value = dicomAsJson[*it];
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1046
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1047 if (value.type() != Json::objectValue ||
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1048 !value.isMember("Type") ||
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1049 !value.isMember("Value") ||
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1050 value["Type"].type() != Json::stringValue)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1051 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1052 throw OrthancException(ErrorCode_CorruptedFile);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1053 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1054
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1055 if (value["Type"] == "String")
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1056 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1057 if (value["Value"].type() != Json::stringValue)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1058 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1059 throw OrthancException(ErrorCode_CorruptedFile);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1060 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1061 else
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1062 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1063 SetValue(tag, value["Value"].asString(), false /* not binary */);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1064 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1065 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1066 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1067 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1068
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1069
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1070 void DicomMap::Merge(const DicomMap& other)
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1071 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1072 for (Content::const_iterator it = other.content_.begin();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1073 it != other.content_.end(); ++it)
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1074 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1075 assert(it->second != NULL);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1076
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1077 if (content_.find(it->first) == content_.end())
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1078 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1079 content_[it->first] = it->second->Clone();
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1080 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1081 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1082 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1083
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1084
3678
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1085 void DicomMap::MergeMainDicomTags(const DicomMap& other,
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1086 ResourceType level)
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1087 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1088 const MainDicomTag* tags = NULL;
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1089 size_t size = 0;
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1090
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1091 LoadMainDicomTags(tags, size, level);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1092 assert(tags != NULL && size > 0);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1093
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1094 for (size_t i = 0; i < size; i++)
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1095 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1096 Content::const_iterator found = other.content_.find(tags[i].tag_);
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1097
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1098 if (found != other.content_.end() &&
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1099 content_.find(tags[i].tag_) == content_.end())
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1100 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1101 assert(found->second != NULL);
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1102 content_[tags[i].tag_] = found->second->Clone();
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1103 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1104 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1105 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1106
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1107
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1108 void DicomMap::ExtractMainDicomTags(const DicomMap& other)
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1109 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1110 Clear();
3678
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1111 MergeMainDicomTags(other, ResourceType_Patient);
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1112 MergeMainDicomTags(other, ResourceType_Study);
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1113 MergeMainDicomTags(other, ResourceType_Series);
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1114 MergeMainDicomTags(other, ResourceType_Instance);
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1115 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1116
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1117
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1118 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
1119 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1120 // TODO - Speed up possible by making this std::set a global variable
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1121
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1122 std::set<DicomTag> mainDicomTags;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1123 GetMainDicomTags(mainDicomTags);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1124
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1125 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
1126 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1127 if (mainDicomTags.find(it->first) == mainDicomTags.end())
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1128 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1129 return false;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1130 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1131 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1132
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1133 return true;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1134 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1135
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1136
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1137 void DicomMap::Serialize(Json::Value& target) const
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1138 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1139 target = Json::objectValue;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1140
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1141 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
1142 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1143 assert(it->second != NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1144
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1145 std::string tag = it->first.Format();
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1146
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1147 Json::Value value;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1148 it->second->Serialize(value);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1149
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1150 target[tag] = value;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1151 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1152 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1153
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1154
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1155 void DicomMap::Unserialize(const Json::Value& source)
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1156 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1157 Clear();
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1158
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1159 if (source.type() != Json::objectValue)
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1160 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1161 throw OrthancException(ErrorCode_BadFileFormat);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1162 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1163
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1164 Json::Value::Members tags = source.getMemberNames();
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1165
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1166 for (size_t i = 0; i < tags.size(); i++)
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1167 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1168 DicomTag tag(0, 0);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1169
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1170 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
1171 content_.find(tag) != content_.end())
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1172 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1173 throw OrthancException(ErrorCode_BadFileFormat);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1174 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1175
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3690
diff changeset
1176 std::unique_ptr<DicomValue> value(new DicomValue);
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1177 value->Unserialize(source[tags[i]]);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1178
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1179 content_[tag] = value.release();
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1180 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1181 }
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1182
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1183
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1184 void DicomMap::FromDicomWeb(const Json::Value& source)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1185 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1186 static const char* const ALPHABETIC = "Alphabetic";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1187 static const char* const IDEOGRAPHIC = "Ideographic";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1188 static const char* const INLINE_BINARY = "InlineBinary";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1189 static const char* const PHONETIC = "Phonetic";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1190 static const char* const VALUE = "Value";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1191 static const char* const VR = "vr";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1192
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1193 Clear();
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1194
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1195 if (source.type() != Json::objectValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1196 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1197 throw OrthancException(ErrorCode_BadFileFormat);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1198 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1199
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1200 Json::Value::Members tags = source.getMemberNames();
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1201
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1202 for (size_t i = 0; i < tags.size(); i++)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1203 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1204 const Json::Value& item = source[tags[i]];
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1205 DicomTag tag(0, 0);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1206
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1207 if (item.type() != Json::objectValue ||
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1208 !item.isMember(VR) ||
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1209 item[VR].type() != Json::stringValue ||
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1210 !DicomTag::ParseHexadecimal(tag, tags[i].c_str()))
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1211 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1212 throw OrthancException(ErrorCode_BadFileFormat);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1213 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1214
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1215 ValueRepresentation vr = StringToValueRepresentation(item[VR].asString(), false);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1216
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1217 if (item.isMember(INLINE_BINARY))
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1218 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1219 const Json::Value& value = item[INLINE_BINARY];
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1220
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1221 if (value.type() == Json::stringValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1222 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1223 std::string decoded;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1224 Toolbox::DecodeBase64(decoded, value.asString());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1225 SetValue(tag, decoded, true /* binary data */);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1226 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1227 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1228 else if (!item.isMember(VALUE))
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1229 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1230 // Tag is present, but it has a null value
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1231 SetValue(tag, "", false /* not binary */);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1232 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1233 else
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1234 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1235 const Json::Value& value = item[VALUE];
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1236
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1237 if (value.type() == Json::arrayValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1238 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1239 bool supported = true;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1240
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1241 std::string s;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1242 for (Json::Value::ArrayIndex i = 0; i < value.size() && supported; i++)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1243 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1244 if (!s.empty())
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1245 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1246 s += '\\';
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1247 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1248
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1249 switch (value[i].type())
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1250 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1251 case Json::objectValue:
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1252 if (vr == ValueRepresentation_PersonName &&
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1253 value[i].type() == Json::objectValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1254 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1255 if (value[i].isMember(ALPHABETIC) &&
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1256 value[i][ALPHABETIC].type() == Json::stringValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1257 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1258 s += value[i][ALPHABETIC].asString();
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1259 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1260
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1261 bool hasIdeographic = false;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1262
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1263 if (value[i].isMember(IDEOGRAPHIC) &&
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1264 value[i][IDEOGRAPHIC].type() == Json::stringValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1265 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1266 s += '=' + value[i][IDEOGRAPHIC].asString();
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1267 hasIdeographic = true;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1268 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1269
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1270 if (value[i].isMember(PHONETIC) &&
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1271 value[i][PHONETIC].type() == Json::stringValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1272 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1273 if (!hasIdeographic)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1274 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1275 s += '=';
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1276 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1277
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1278 s += '=' + value[i][PHONETIC].asString();
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1279 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1280 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1281 else
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1282 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1283 // This is the case of sequences
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1284 supported = false;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1285 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1286
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1287 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1288
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1289 case Json::stringValue:
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1290 s += value[i].asString();
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1291 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1292
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1293 case Json::intValue:
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1294 s += boost::lexical_cast<std::string>(value[i].asInt());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1295 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1296
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1297 case Json::uintValue:
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1298 s += boost::lexical_cast<std::string>(value[i].asUInt());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1299 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1300
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1301 case Json::realValue:
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1302 s += boost::lexical_cast<std::string>(value[i].asDouble());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1303 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1304
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1305 default:
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1306 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1307 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1308 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1309
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1310 if (supported)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1311 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1312 SetValue(tag, s, false /* not binary */);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1313 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1314 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1315 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1316 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1317 }
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1318
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1319
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1320 std::string DicomMap::GetStringValue(const DicomTag& tag,
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1321 const std::string& defaultValue,
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1322 bool allowBinary) const
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1323 {
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1324 std::string s;
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1325 if (LookupStringValue(s, tag, allowBinary))
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1326 {
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1327 return s;
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1328 }
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1329 else
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1330 {
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1331 return defaultValue;
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1332 }
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1333 }
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1334
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1335
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1336 void DicomMap::RemoveBinaryTags()
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1337 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1338 Content kept;
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1339
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1340 for (Content::iterator it = content_.begin(); it != content_.end(); ++it)
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1341 {
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1342 assert(it->second != NULL);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1343
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1344 if (!it->second->IsBinary() &&
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1345 !it->second->IsNull())
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1346 {
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1347 kept[it->first] = it->second;
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1348 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1349 else
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1350 {
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1351 delete it->second;
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1352 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1353 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1354
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1355 content_ = kept;
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1356 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1357
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1358
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1359 void DicomMap::DumpMainDicomTags(Json::Value& target,
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1360 ResourceType level) const
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1361 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1362 std::map<DicomTag, std::string> mainTags; // TODO - Create a singleton to hold this map
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1363 LoadMainDicomTags(mainTags, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1364
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1365 target = Json::objectValue;
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1366
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1367 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
1368 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1369 assert(it->second != NULL);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1370
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1371 if (!it->second->IsBinary() &&
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1372 !it->second->IsNull())
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1373 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1374 std::map<DicomTag, std::string>::const_iterator found = mainTags.find(it->first);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1375
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1376 if (found != mainTags.end())
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1377 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1378 target[found->second] = it->second->GetContent();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1379 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1380 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1381 }
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1382 }
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1383
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1384
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1385 void DicomMap::ParseMainDicomTags(const Json::Value& source,
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1386 ResourceType level)
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1387 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1388 if (source.type() != Json::objectValue)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1389 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1390 throw OrthancException(ErrorCode_BadFileFormat);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1391 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1392
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1393 std::map<std::string, DicomTag2> mainTags; // TODO - Create a singleton to hold this map
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1394 LoadMainDicomTags(mainTags, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1395
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1396 Json::Value::Members members = source.getMemberNames();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1397 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
1398 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1399 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
1400
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1401 if (found != mainTags.end())
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1402 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1403 const Json::Value& value = source[members[i]];
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1404 if (value.type() != Json::stringValue)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1405 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1406 throw OrthancException(ErrorCode_BadFileFormat);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1407 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1408 else
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1409 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1410 SetValue(found->second, value.asString(), false);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1411 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1412 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1413 }
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1414 }
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1415
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1416
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1417 void DicomMap::Print(FILE* fp) const
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1418 {
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1419 DicomArray a(*this);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1420 a.Print(fp);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1421 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1422 }