comparison PalanthirServer/FromDcmtkBridge.h @ 45:33d67e1ab173

r
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Sep 2012 13:24:59 +0200
parents PalantirServer/FromDcmtkBridge.h@ea48f38afe5f
children a15e90e5d6fc
comparison
equal deleted inserted replaced
43:9be852ad33d2 45:33d67e1ab173
1 /**
2 * Palantir - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
4 * Belgium
5 *
6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20
21 #pragma once
22
23 #include "../Core/DicomFormat/DicomMap.h"
24 #include <dcmtk/dcmdata/dcdatset.h>
25 #include <json/json.h>
26
27 namespace Palantir
28 {
29 enum ImageExtractionMode
30 {
31 ImageExtractionMode_Preview,
32 ImageExtractionMode_UInt8,
33 ImageExtractionMode_UInt16
34 };
35
36 class FromDcmtkBridge
37 {
38 public:
39 static void Convert(DicomMap& target, DcmDataset& dataset);
40
41 static DicomTag GetTag(const DcmElement& element);
42
43 static DicomValue* ConvertLeafElement(DcmElement& element);
44
45 static void ToJson(Json::Value& target,
46 DcmDataset& dataset,
47 unsigned int maxStringLength = 256);
48
49 static void ToJson(Json::Value& target,
50 const std::string& path,
51 unsigned int maxStringLength = 256);
52
53 static void ExtractPngImage(std::string& result,
54 DcmDataset& dataset,
55 ImageExtractionMode mode);
56
57 static void ExtractPngImage(std::string& result,
58 const std::string& dicomContent,
59 ImageExtractionMode mode);
60
61 static std::string GetName(const DicomTag& tag);
62
63 static DicomTag FindTag(const char* name);
64
65 static DicomTag FindTag(const std::string& name)
66 {
67 return FindTag(name.c_str());
68 }
69
70 static bool HasTag(const DicomMap& fields,
71 const std::string& tagName)
72 {
73 return fields.HasTag(FindTag(tagName));
74 }
75
76 static const DicomValue& GetValue(const DicomMap& fields,
77 const std::string& tagName)
78 {
79 return fields.GetValue(FindTag(tagName));
80 }
81
82 static void SetValue(DicomMap& target,
83 const std::string& tagName,
84 DicomValue* value)
85 {
86 target.SetValue(FindTag(tagName), value);
87 }
88
89 static void Print(FILE* fp,
90 const DicomMap& m);
91
92 static void ToJson(Json::Value& result,
93 const DicomMap& values);
94 };
95 }