Mercurial > hg > orthanc
annotate Core/DicomParsing/DicomDirWriter.cpp @ 2987:96089d1aba4d
New "DicomDiskSize" and "DicomUncompressedSize" fields in statistics about resources
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 10 Dec 2018 10:33:58 +0100 |
parents | d386abc18133 |
children | 4e43e67f8ecf |
rev | line source |
---|---|
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1130
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2422
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * License, or (at your option) any later version. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * program give permission to link the code of its release with the |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * in the program, then also delete it here. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, but |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * General Public License for more details. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 **/ |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 /*========================================================================= |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 This file is based on portions of the following project: |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 Program: DCMTK 3.6.0 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 Module: http://dicom.offis.de/dcmtk.php.en |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 Copyright (C) 1994-2011, OFFIS e.V. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 All rights reserved. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 This software and supporting documentation were developed by |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 OFFIS e.V. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 R&D Division Health |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 Escherweg 2 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 26121 Oldenburg, Germany |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 Redistribution and use in source and binary forms, with or without |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 modification, are permitted provided that the following conditions |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 are met: |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 - Redistributions of source code must retain the above copyright |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 notice, this list of conditions and the following disclaimer. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 - Redistributions in binary form must reproduce the above copyright |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 notice, this list of conditions and the following disclaimer in the |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 documentation and/or other materials provided with the distribution. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 - Neither the name of OFFIS nor the names of its contributors may be |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 used to endorse or promote products derived from this software |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 without specific prior written permission. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 =========================================================================*/ |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 /*** |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 Validation: |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 # sudo apt-get install dicom3tools |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 # dciodvfy DICOMDIR 2>&1 | less |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 # dcentvfy DICOMDIR 2>&1 | less |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 http://www.dclunie.com/dicom3tools/dciodvfy.html |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 DICOMDIR viewer working with Wine under Linux: |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 http://www.microdicom.com/ |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 ***/ |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
101 #include "../PrecompiledHeaders.h" |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 #include "DicomDirWriter.h" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 #include "FromDcmtkBridge.h" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 #include "ToDcmtkBridge.h" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
107 #include "../Logging.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
108 #include "../OrthancException.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
109 #include "../TemporaryFile.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
110 #include "../Toolbox.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
111 #include "../SystemToolbox.h" |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 #include <dcmtk/dcmdata/dcdicdir.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 #include <dcmtk/dcmdata/dcmetinf.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 #include <dcmtk/dcmdata/dcdeftag.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 #include <dcmtk/dcmdata/dcuid.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 #include <dcmtk/dcmdata/dcddirif.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 #include <dcmtk/dcmdata/dcvrui.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 #include <dcmtk/dcmdata/dcsequen.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 #include <dcmtk/dcmdata/dcostrmf.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 #include "dcmtk/dcmdata/dcvrda.h" /* for class DcmDate */ |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 #include "dcmtk/dcmdata/dcvrtm.h" /* for class DcmTime */ |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 #include <memory> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 namespace Orthanc |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 class DicomDirWriter::PImpl |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 private: |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
131 bool utc_; |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
132 std::string fileSetId_; |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
133 bool extendedSopClass_; |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
134 TemporaryFile file_; |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 std::auto_ptr<DcmDicomDir> dir_; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 typedef std::pair<ResourceType, std::string> IndexKey; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 typedef std::map<IndexKey, DcmDirectoryRecord* > Index; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 Index index_; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 DcmDicomDir& GetDicomDir() |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 if (dir_.get() == NULL) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 dir_.reset(new DcmDicomDir(file_.GetPath().c_str(), |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 fileSetId_.c_str())); |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
148 //SetTagValue(dir_->getRootRecord(), DCM_SpecificCharacterSet, GetDicomSpecificCharacterSet(Encoding_Utf8)); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 return *dir_; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 DcmDirectoryRecord& GetRoot() |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 return GetDicomDir().getRootRecord(); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
161 static bool GetUtf8TagValue(std::string& result, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
162 DcmItem& source, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
163 Encoding encoding, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
164 const DcmTagKey& key) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
165 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
166 DcmElement* element = NULL; |
2571
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
167 result.clear(); |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
168 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
169 if (source.findAndGetElement(key, element).good()) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
170 { |
1893 | 171 char* s = NULL; |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
172 if (element->isLeaf() && |
2571
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
173 element->getString(s).good()) |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
174 { |
2571
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
175 if (s != NULL) |
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
176 { |
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
177 result = Toolbox::ConvertToUtf8(s, encoding); |
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
178 } |
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
179 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
180 return true; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
181 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
182 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
183 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
184 return false; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
185 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
186 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
187 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
188 static void SetTagValue(DcmDirectoryRecord& target, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
189 const DcmTagKey& key, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
190 const std::string& valueUtf8) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
191 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
192 std::string s = Toolbox::ConvertFromUtf8(valueUtf8, Encoding_Ascii); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
193 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
194 if (!target.putAndInsertString(key, s.c_str()).good()) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
195 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
196 throw OrthancException(ErrorCode_InternalError); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
197 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
198 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
199 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
200 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
201 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
202 static bool CopyString(DcmDirectoryRecord& target, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
203 DcmDataset& source, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
204 Encoding encoding, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
205 const DcmTagKey& key, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
206 bool optional, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
207 bool copyEmpty) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
208 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
209 if (optional && |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
210 !source.tagExistsWithValue(key) && |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
211 !(copyEmpty && source.tagExists(key))) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
212 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
213 return false; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
214 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
215 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
216 std::string value; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
217 bool found = GetUtf8TagValue(value, source, encoding, key); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
218 |
2421
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
219 if (!found) |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
220 { |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
221 // We don't raise an exception if "!optional", even if this |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
222 // results in an invalid DICOM file |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
223 value.clear(); |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
224 } |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
225 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
226 SetTagValue(target, key, value); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
227 return found; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
228 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
229 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
230 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
231 static void CopyStringType1(DcmDirectoryRecord& target, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
232 DcmDataset& source, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
233 Encoding encoding, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
234 const DcmTagKey& key) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
235 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
236 CopyString(target, source, encoding, key, false, false); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
237 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
238 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
239 static void CopyStringType1C(DcmDirectoryRecord& target, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
240 DcmDataset& source, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
241 Encoding encoding, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
242 const DcmTagKey& key) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
243 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
244 CopyString(target, source, encoding, key, true, false); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
245 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
246 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
247 static void CopyStringType2(DcmDirectoryRecord& target, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
248 DcmDataset& source, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
249 Encoding encoding, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
250 const DcmTagKey& key) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
251 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
252 CopyString(target, source, encoding, key, false, true); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
253 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
254 |
2421
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
255 static void CopyStringType3(DcmDirectoryRecord& target, |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
256 DcmDataset& source, |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
257 Encoding encoding, |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
258 const DcmTagKey& key) |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
259 { |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
260 CopyString(target, source, encoding, key, true, true); |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
261 } |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
262 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
263 |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 public: |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
265 PImpl() : |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
266 utc_(true), // By default, use UTC (universal time, not local time) |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
267 fileSetId_("ORTHANC_MEDIA"), |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
268 extendedSopClass_(false) |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
269 { |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
270 } |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
271 |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
272 bool IsUtcUsed() const |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
273 { |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
274 return utc_; |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
275 } |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
276 |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
277 |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
278 void SetUtcUsed(bool utc) |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
279 { |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
280 utc_ = utc; |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
281 } |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
282 |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
283 void EnableExtendedSopClass(bool enable) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 { |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
285 if (enable) |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
286 { |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
287 LOG(WARNING) << "Generating a DICOMDIR with type 3 attributes, " |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
288 << "which leads to an Extended SOP Class"; |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
289 } |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
290 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
291 extendedSopClass_ = enable; |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
292 } |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
293 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
294 bool IsExtendedSopClass() const |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
295 { |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
296 return extendedSopClass_; |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
297 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 void FillPatient(DcmDirectoryRecord& record, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
300 DcmDataset& dicom, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
301 Encoding encoding) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 // cf. "DicomDirInterface::buildPatientRecord()" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
305 CopyStringType1C(record, dicom, encoding, DCM_PatientID); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
306 CopyStringType2(record, dicom, encoding, DCM_PatientName); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 void FillStudy(DcmDirectoryRecord& record, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
310 DcmDataset& dicom, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
311 Encoding encoding) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
313 // cf. "DicomDirInterface::buildStudyRecord()" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
314 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
315 std::string nowDate, nowTime; |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
316 SystemToolbox::GetNowDicom(nowDate, nowTime, utc_); |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
317 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
318 std::string studyDate; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
319 if (!GetUtf8TagValue(studyDate, dicom, encoding, DCM_StudyDate) && |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
320 !GetUtf8TagValue(studyDate, dicom, encoding, DCM_SeriesDate) && |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
321 !GetUtf8TagValue(studyDate, dicom, encoding, DCM_AcquisitionDate) && |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
322 !GetUtf8TagValue(studyDate, dicom, encoding, DCM_ContentDate)) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
323 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
324 studyDate = nowDate; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
325 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
326 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
327 std::string studyTime; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
328 if (!GetUtf8TagValue(studyTime, dicom, encoding, DCM_StudyTime) && |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
329 !GetUtf8TagValue(studyTime, dicom, encoding, DCM_SeriesTime) && |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
330 !GetUtf8TagValue(studyTime, dicom, encoding, DCM_AcquisitionTime) && |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
331 !GetUtf8TagValue(studyTime, dicom, encoding, DCM_ContentTime)) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
332 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
333 studyTime = nowTime; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
334 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
335 |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 /* copy attribute values from dataset to study record */ |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
337 SetTagValue(record, DCM_StudyDate, studyDate); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
338 SetTagValue(record, DCM_StudyTime, studyTime); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
339 CopyStringType2(record, dicom, encoding, DCM_StudyDescription); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
340 CopyStringType1(record, dicom, encoding, DCM_StudyInstanceUID); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 /* use type 1C instead of 1 in order to avoid unwanted overwriting */ |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
342 CopyStringType1C(record, dicom, encoding, DCM_StudyID); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
343 CopyStringType2(record, dicom, encoding, DCM_AccessionNumber); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 void FillSeries(DcmDirectoryRecord& record, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
347 DcmDataset& dicom, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
348 Encoding encoding) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
349 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 // cf. "DicomDirInterface::buildSeriesRecord()" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 /* copy attribute values from dataset to series record */ |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
353 CopyStringType1(record, dicom, encoding, DCM_Modality); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
354 CopyStringType1(record, dicom, encoding, DCM_SeriesInstanceUID); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
355 /* use type 1C instead of 1 in order to avoid unwanted overwriting */ |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
356 CopyStringType1C(record, dicom, encoding, DCM_SeriesNumber); |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
357 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
358 // Add extended (non-standard) type 3 tags, those are not generated by DCMTK |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
359 // http://dicom.nema.org/medical/Dicom/2016a/output/chtml/part02/sect_7.3.html |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
360 // https://groups.google.com/d/msg/orthanc-users/Y7LOvZMDeoc/9cp3kDgxAwAJ |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
361 if (extendedSopClass_) |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
362 { |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
363 CopyStringType3(record, dicom, encoding, DCM_SeriesDescription); |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
364 } |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 void FillInstance(DcmDirectoryRecord& record, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
368 DcmDataset& dicom, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
369 Encoding encoding, |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 DcmMetaInfo& metaInfo, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
371 const char* path) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 // cf. "DicomDirInterface::buildImageRecord()" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 /* copy attribute values from dataset to image record */ |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
376 CopyStringType1(record, dicom, encoding, DCM_InstanceNumber); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
377 //CopyElementType1C(record, dicom, encoding, DCM_ImageType); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
379 // REMOVED since 0.9.7: copyElementType1C(dicom, DCM_ReferencedImageSequence, record); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
381 std::string sopClassUid, sopInstanceUid, transferSyntaxUid; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
382 if (!GetUtf8TagValue(sopClassUid, dicom, encoding, DCM_SOPClassUID) || |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
383 !GetUtf8TagValue(sopInstanceUid, dicom, encoding, DCM_SOPInstanceUID) || |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
384 !GetUtf8TagValue(transferSyntaxUid, metaInfo, encoding, DCM_TransferSyntaxUID)) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 throw OrthancException(ErrorCode_BadFileFormat); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 } |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
388 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
389 SetTagValue(record, DCM_ReferencedFileID, path); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
390 SetTagValue(record, DCM_ReferencedSOPClassUIDInFile, sopClassUid); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
391 SetTagValue(record, DCM_ReferencedSOPInstanceUIDInFile, sopInstanceUid); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
392 SetTagValue(record, DCM_ReferencedTransferSyntaxUIDInFile, transferSyntaxUid); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 bool CreateResource(DcmDirectoryRecord*& target, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
398 ResourceType level, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
399 ParsedDicomFile& dicom, |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 const char* filename, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 const char* path) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 { |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
403 DcmDataset& dataset = *dicom.GetDcmtkObject().getDataset(); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
404 Encoding encoding = dicom.GetEncoding(); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
406 bool found; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
407 std::string id; |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 E_DirRecType type; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
410 switch (level) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
412 case ResourceType_Patient: |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
413 found = GetUtf8TagValue(id, dataset, encoding, DCM_PatientID); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
414 type = ERT_Patient; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
415 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 case ResourceType_Study: |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
418 found = GetUtf8TagValue(id, dataset, encoding, DCM_StudyInstanceUID); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
419 type = ERT_Study; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
420 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
422 case ResourceType_Series: |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
423 found = GetUtf8TagValue(id, dataset, encoding, DCM_SeriesInstanceUID); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 type = ERT_Series; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
427 case ResourceType_Instance: |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
428 found = GetUtf8TagValue(id, dataset, encoding, DCM_SOPInstanceUID); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
429 type = ERT_Image; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
430 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
431 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
432 default: |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
433 throw OrthancException(ErrorCode_InternalError); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
434 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
436 if (!found) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
437 { |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
438 throw OrthancException(ErrorCode_BadFileFormat); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
439 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
441 IndexKey key = std::make_pair(level, std::string(id.c_str())); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
442 Index::iterator it = index_.find(key); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
443 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
444 if (it != index_.end()) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
445 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
446 target = it->second; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
447 return false; // Already existing |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
448 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
449 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
450 std::auto_ptr<DcmDirectoryRecord> record(new DcmDirectoryRecord(type, NULL, filename)); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
451 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
452 switch (level) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
453 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
454 case ResourceType_Patient: |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
455 FillPatient(*record, dataset, encoding); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 case ResourceType_Study: |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
459 FillStudy(*record, dataset, encoding); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
460 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
462 case ResourceType_Series: |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
463 FillSeries(*record, dataset, encoding); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
464 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
465 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
466 case ResourceType_Instance: |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
467 FillInstance(*record, dataset, encoding, *dicom.GetDcmtkObject().getMetaInfo(), path); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
468 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
469 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
470 default: |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
471 throw OrthancException(ErrorCode_InternalError); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
472 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
473 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
474 CopyStringType1C(*record, dataset, encoding, DCM_SpecificCharacterSet); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
475 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
476 target = record.get(); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
477 GetRoot().insertSub(record.release()); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
478 index_[key] = target; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 return true; // Newly created |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
482 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
483 void Read(std::string& s) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 if (!GetDicomDir().write(DICOMDIR_DEFAULT_TRANSFERSYNTAX, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
486 EET_UndefinedLength /*encodingType*/, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
487 EGL_withoutGL /*groupLength*/).good()) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
488 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
489 throw OrthancException(ErrorCode_InternalError); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
490 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
491 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
492 file_.Read(s); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
493 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
494 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
495 void SetFileSetId(const std::string& id) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
496 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
497 dir_.reset(NULL); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
498 fileSetId_ = id; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
499 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
500 }; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
501 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
502 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
503 DicomDirWriter::DicomDirWriter() : pimpl_(new PImpl) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
507 void DicomDirWriter::SetUtcUsed(bool utc) |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
508 { |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
509 pimpl_->SetUtcUsed(utc); |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
510 } |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
511 |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
512 bool DicomDirWriter::IsUtcUsed() const |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
513 { |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
514 return pimpl_->IsUtcUsed(); |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
515 } |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
516 |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
517 void DicomDirWriter::SetFileSetId(const std::string& id) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
518 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
519 pimpl_->SetFileSetId(id); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
520 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
521 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 void DicomDirWriter::Add(const std::string& directory, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
523 const std::string& filename, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
524 ParsedDicomFile& dicom) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
525 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 std::string path; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
527 if (directory.empty()) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
528 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
529 path = filename; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
530 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
531 else |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 if (directory[directory.length() - 1] == '/' || |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 directory[directory.length() - 1] == '\\') |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 throw OrthancException(ErrorCode_ParameterOutOfRange); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 path = directory + '\\' + filename; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 DcmDirectoryRecord* instance; |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
543 bool isNewInstance = pimpl_->CreateResource(instance, ResourceType_Instance, dicom, filename.c_str(), path.c_str()); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
544 if (isNewInstance) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
546 DcmDirectoryRecord* series; |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
547 bool isNewSeries = pimpl_->CreateResource(series, ResourceType_Series, dicom, filename.c_str(), NULL); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
548 series->insertSub(instance); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 if (isNewSeries) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
551 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
552 DcmDirectoryRecord* study; |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
553 bool isNewStudy = pimpl_->CreateResource(study, ResourceType_Study, dicom, filename.c_str(), NULL); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
554 study->insertSub(series); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
555 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
556 if (isNewStudy) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
557 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
558 DcmDirectoryRecord* patient; |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
559 pimpl_->CreateResource(patient, ResourceType_Patient, dicom, filename.c_str(), NULL); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
560 patient->insertSub(study); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
561 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
562 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
563 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
564 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
565 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
566 void DicomDirWriter::Encode(std::string& target) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
567 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
568 pimpl_->Read(target); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
569 } |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
570 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
571 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
572 void DicomDirWriter::EnableExtendedSopClass(bool enable) |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
573 { |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
574 pimpl_->EnableExtendedSopClass(enable); |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
575 } |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
576 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
577 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
578 bool DicomDirWriter::IsExtendedSopClass() const |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
579 { |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
580 return pimpl_->IsExtendedSopClass(); |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
581 } |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
582 } |