comparison OrthancServer/FromDcmtkBridge.h @ 948:e57e08ed510f dicom-rt

integration mainline -> dicom-rt
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Jun 2014 13:57:05 +0200
parents 8cfc6119a5bd 87791ebc1f50
children
comparison
equal deleted inserted replaced
767:c19552f604d5 948:e57e08ed510f
30 **/ 30 **/
31 31
32 32
33 #pragma once 33 #pragma once
34 34
35 #include "../Core/DicomFormat/DicomInstanceHasher.h" 35 #include "ServerEnumerations.h"
36 #include "../Core/RestApi/RestApiOutput.h" 36
37 #include "../Core/Toolbox.h" 37 #include "../Core/DicomFormat/DicomMap.h"
38 38
39 #include <dcmtk/dcmdata/dcdatset.h> 39 #include <dcmtk/dcmdata/dcdatset.h>
40 #include <dcmtk/dcmdata/dcfilefo.h>
41 #include <json/json.h> 40 #include <json/json.h>
42 #include <memory>
43 41
44 namespace Orthanc 42 namespace Orthanc
45 { 43 {
46 enum DicomRootLevel
47 {
48 DicomRootLevel_Patient,
49 DicomRootLevel_Study,
50 DicomRootLevel_Series,
51 DicomRootLevel_Instance
52 };
53
54 enum DicomReplaceMode
55 {
56 DicomReplaceMode_InsertIfAbsent,
57 DicomReplaceMode_ThrowIfAbsent,
58 DicomReplaceMode_IgnoreIfAbsent
59 };
60
61 class ParsedDicomFile : public IDynamicObject
62 {
63 private:
64 std::auto_ptr<DcmFileFormat> file_;
65
66 ParsedDicomFile(DcmFileFormat& other) :
67 file_(dynamic_cast<DcmFileFormat*>(other.clone()))
68 {
69 }
70
71 void Setup(const char* content,
72 size_t size);
73
74 public:
75 typedef std::list< std::pair<DicomTag, unsigned int> > SequencePath;
76
77 ParsedDicomFile(const char* content,
78 size_t size)
79 {
80 Setup(content, size);
81 }
82
83 ParsedDicomFile(const std::string& content)
84 {
85 if (content.size() == 0)
86 Setup(NULL, 0);
87 else
88 Setup(&content[0], content.size());
89 }
90
91 DcmFileFormat& GetDicom()
92 {
93 return *file_;
94 }
95
96 ParsedDicomFile* Clone()
97 {
98 return new ParsedDicomFile(*file_);
99 }
100
101 void SendPathValue(RestApiOutput& output,
102 const UriComponents& uri);
103
104 void Answer(RestApiOutput& output);
105
106 void Remove(const DicomTag& tag);
107
108 void Insert(const DicomTag& tag,
109 const std::string& value);
110
111 void Replace(const DicomTag& tag,
112 const std::string& value,
113 DicomReplaceMode mode);
114
115 void RemovePrivateTags();
116
117 bool GetTagValue(std::string& value,
118 const DicomTag& tag);
119
120 bool GetTagValue(std::string& value,
121 const SequencePath& path,
122 const DicomTag& tag);
123
124 DicomInstanceHasher GetHasher();
125 };
126
127 class FromDcmtkBridge 44 class FromDcmtkBridge
128 { 45 {
129 public: 46 public:
130 static void Convert(DicomMap& target, DcmDataset& dataset); 47 static void Convert(DicomMap& target, DcmDataset& dataset);
131 48
138 unsigned int maxStringLength = 256); 55 unsigned int maxStringLength = 256);
139 56
140 static void ToJson(Json::Value& target, 57 static void ToJson(Json::Value& target,
141 const std::string& path, 58 const std::string& path,
142 unsigned int maxStringLength = 256); 59 unsigned int maxStringLength = 256);
143
144 static void ExtractPngImage(std::string& result,
145 DcmDataset& dataset,
146 unsigned int frame,
147 ImageExtractionMode mode);
148
149 static void ExtractPngImage(std::string& result,
150 const std::string& dicomContent,
151 unsigned int frame,
152 ImageExtractionMode mode);
153 60
154 static std::string GetName(const DicomTag& tag); 61 static std::string GetName(const DicomTag& tag);
155 62
156 static DicomTag ParseTag(const char* name); 63 static DicomTag ParseTag(const char* name);
157 64
183 const DicomMap& m); 90 const DicomMap& m);
184 91
185 static void ToJson(Json::Value& result, 92 static void ToJson(Json::Value& result,
186 const DicomMap& values); 93 const DicomMap& values);
187 94
188 static std::string GenerateUniqueIdentifier(DicomRootLevel level); 95 static std::string GenerateUniqueIdentifier(ResourceType level);
189 96
190 static bool SaveToMemoryBuffer(std::string& buffer, 97 static bool SaveToMemoryBuffer(std::string& buffer,
191 DcmDataset* dataSet); 98 DcmDataset* dataSet);
192 }; 99 };
193 } 100 }