SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svkDcmtkAdapter.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2009-2014 The Regents of the University of California.
3  * All Rights Reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * • Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * • Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * • None of the names of any campus of the University of California, the name
13  * "The Regents of the University of California," or the names of any of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26  * OF SUCH DAMAGE.
27  */
28 
29 
30 
31 /*
32  * $URL$
33  * $Rev$
34  * $Author$
35  * $Date$
36  *
37  * Authors:
38  * Jason C. Crane, Ph.D.
39  * Beck Olson
40  */
41 
42 
43 #ifndef SVK_DCMTK_ADAPTER_H
44 #define SVK_DCMTK_ADAPTER_H
45 #define HEADER_MAX_READ_LENGTH 256
46 
47 
48 #include <vtkObjectFactory.h>
49 #include <vtkObject.h>
50 #include <svkDcmHeader.h>
51 #include <svkDcmtkIod.h>
52 #include <dcmtk/dcmdata/dctk.h>
53 #include <dcmtk/dcmdata/dctag.h>
54 
55 
56 namespace svk {
57 
58 
59 using namespace svk;
60 
61 
66 {
67 
68  public:
69 
70  static svkDcmtkAdapter* New();
72 
73 
74  protected:
75 
78 
79  // Methods:
80  virtual void CreateIOD(DcmIodType iodType);
81  virtual void SetSOPClassUID(DcmIodType iodType);
82 
83  virtual void PrintDcmHeader();
84  virtual void PrintDcmHeader(ostream& os);
85 
86  virtual void InsertEmptyElement( const char* name );
87  virtual void InsertUniqueUID( const char* name);
88  string GenerateUniqueUID();
89 
90  virtual void SetValue(const char* name, int value);
91  virtual void SetValue(const char* name, float value);
92  virtual void SetValue(const char* name, double value);
93  virtual void SetValue(const char* name, string value, bool setMetaInfo = false);
94  virtual void SetValue(const char* name, unsigned char* values, int numValues);
95  virtual void SetValue(const char* name, unsigned short* values, int numValues);
96  virtual void SetValue(const char* name, signed short* values, int numValues);
97  virtual void SetValue(const char* name, float* values, int numValues);
98  virtual void ModifyValueRecursive(const char* name, string value);
99 
100 
101  virtual void GetByteValue(const char* name, char* values, long unsigned int numValues);
102  virtual void GetShortValue(const char* name, short* values, long unsigned int numValues);
103  virtual unsigned short GetShortValue(const char* name, long unsigned int position );
104  virtual unsigned short GetPixelValue(long unsigned int position);
105  virtual int GetIntValue(const char *name);
106  virtual float GetFloatValue(const char *name);
107  virtual void GetFloatValue(const char* name, float* values, long unsigned int numValues);
108  virtual double GetDoubleValue(const char *name);
109  virtual string GetStringValue(const char *name);
110  virtual string GetStringValue(const char *name, int pos);
111 
112  virtual void AddSequenceItemElement(
113  const char* parentSeqName,
114  int parentSeqItemPosition,
115  const char* elementName
116  );
117  virtual void AddSequenceItemElement(
118  const char* seqName,
119  int seqItemPosition,
120  const char* elementName,
121  string value,
122  const char* parentSeqName = NULL,
123  int parentSeqItemPosition = 0
124  );
125  virtual void AddSequenceItemElement(
126  const char* seqName,
127  int seqItemPosition,
128  const char* elementName,
129  char* values,
130  int numValues,
131  const char* parentSeqName = NULL,
132  int parentSeqItemPosition = 0
133  );
134  virtual void AddSequenceItemElement(
135  const char* seqName,
136  int seqItemPosition,
137  const char* elementName,
138  unsigned short* values,
139  int numValues,
140  const char* parentSeqName = NULL,
141  int parentSeqItemPosition = 0
142  );
143  virtual void AddSequenceItemElement(
144  const char* seqName,
145  int seqItemPosition,
146  const char* elementName,
147  unsigned int* values,
148  int numValues,
149  const char* parentSeqName = NULL,
150  int parentSeqItemPosition = 0
151  );
152  virtual void AddSequenceItemElement(
153  const char* seqName,
154  int seqItemPosition,
155  const char* elementName,
156  float* values,
157  unsigned long int numValues,
158  const char* parentSeqName = NULL,
159  int parentSeqItemPosition = 0
160  );
161  virtual void AddSequenceItemElement(
162  const char* seqName,
163  int seqItemPosition,
164  const char* elementName,
165  int value,
166  const char* parentSeqName = NULL,
167  int parentSeqItemPosition = 0
168  );
169  virtual void AddSequenceItemElement(
170  const char* seqName,
171  int seqItemPosition,
172  const char* elementName,
173  long int value,
174  const char* parentSeqName = NULL,
175  int parentSeqItemPosition = 0
176  );
177  virtual void AddSequenceItemElement(
178  const char* seqName,
179  int seqItemPosition,
180  const char* elementName,
181  float value,
182  const char* parentSeqName = NULL,
183  int parentSeqItemPosition = 0
184  );
185  virtual void AddSequenceItemElement(
186  const char* seqName,
187  int seqItemPosition,
188  const char* elementName,
189  double value,
190  const char* parentSeqName = NULL,
191  int parentSeqItemPosition = 0
192  );
193 
194  virtual int GetSequenceItemElementLength(
195  const char* seqName,
196  int seqItemPosition,
197  const char* elementName,
198  const char* parentSeqName,
199  int parentSeqItemPosition);
200 
201  virtual void CopySequence( svkDcmHeader* target, const char* seqName );
202 
203  virtual void ClearSequence( const char* seqName );
204 
205  virtual void ClearElement(const char* elementName);
206 
207  virtual void RemoveElement(const char* elementName);
208 
209  virtual int GetIntSequenceItemElement(
210  const char* seqName,
211  int seqItemPosition,
212  const char* elementName,
213  const char* parentSeqName = NULL,
214  int parentSeqItemPosition = 0,
215  int pos = 0
216  );
217  virtual long int GetLongIntSequenceItemElement(
218  const char* seqName,
219  int seqItemPosition,
220  const char* elementName,
221  const char* parentSeqName = NULL,
222  int parentSeqItemPosition = 0,
223  int pos = 0
224  );
225  virtual float GetFloatSequenceItemElement(
226  const char* seqName,
227  int seqItemPosition,
228  const char* elementName,
229  const char* parentSeqName = NULL,
230  int parentSeqItemPosition = 0,
231  int pos = 0
232  );
233  virtual void GetFloatSequenceItemElement(
234  const char* seqName,
235  int seqItemPosition,
236  const char* elementName,
237  float* values,
238  int numValues,
239  const char* parentSeqName = NULL,
240  int parentSeqItemPosition = 0
241  );
242  virtual double GetDoubleSequenceItemElement(
243  const char* seqName,
244  int seqItemPosition,
245  const char* elementName,
246  const char* parentSeqName = NULL,
247  int parentSeqItemPosition = 0
248  );
249  virtual string GetStringSequenceItemElement(
250  const char* seqName,
251  int seqItemPosition,
252  const char* elementName,
253  const char* parentSeqName = NULL,
254  int parentSeqItemPosition = 0
255  );
256  virtual string GetStringSequenceItemElement(
257  const char* seqName,
258  int seqItemPosition,
259  const char* elementName,
260  int pos,
261  const char* parentSeqName = NULL,
262  int parentSeqItemPosition = 0
263  );
264 
265  virtual int GetNumberOfElements( const char* elementName );
266  virtual int GetNumberOfItemsInSequence( const char* seqName );
267  virtual int GetNumberOfItemsInSequence(
268  const char* seqName,
269  const char* parentSeqName,
270  int parentSeqItemPosition
271  );
272 
273 
274  virtual void WriteDcmFile(string fileName);
275  virtual void WriteDcmFileCompressed(string fileName);
276  virtual int ReadDcmFile(string fileName, unsigned int maxLength );
277  virtual int ReadDcmFileHeaderOnly(string fileName );
278  virtual int GetOriginalXFerSyntax();
279 
280 
281  virtual void CopyDcmHeader(svkDcmHeader* headerCopy);
282 
283  virtual bool ElementExists(const char* elementName, const char* parentSeqName);
284 
285  virtual void ReplaceOldElements( bool replaceElements );
286 
287  virtual void HandleTagNotFoundException( const svkTagNotFound& e);
288  virtual string GetDcmNameFromTag( string groupElementString );
289 
290 
291  private:
292 
293  // Methods:
294  const DcmDictEntry* FindEntry( const char* name );
295  DcmTag GetDcmTag(const char* name);
296  DcmTagKey GetDcmTagKey(const char* name);
297  DcmItem* GetDcmItem(DcmItem* dataset, const char* seqName, int itemPosition);
298  DcmSequenceOfItems* GetDcmSequence(const char* seqName);
299  void SetPrivateDictionaryElements();
300  void SetGEPrivateDictionaryElements();
301  E_TransferSyntax originalXferSyntax;
302 
303 
304 
305  // Members:
306  svkDcmtkIod* dcmFile;
307  OFBool replaceOldElements;
308  DcmDataDictionary* privateDic;
309  // For performance we store some entries from the dictionary.
310  map<string, const DcmDictEntry*> foundEntries;
311  DcmElement* pixelDataElement;
312 
313  // Static Members:
314  static bool privateElementsAdded;
315 
316 
317 
318 };
319 
320 
321 } //svk
322 
323 
324 #endif //SVK_DCMTK_ADAPTER_H
325 
virtual void GetByteValue(const char *name, char *values, long unsigned int numValues)
Definition: svkDcmtkAdapter.cc:852
virtual unsigned short GetPixelValue(long unsigned int position)
Definition: svkDcmtkAdapter.cc:925
DcmIodType
Definition: svkDcmHeader.h:78
Definition: svkDcmHeader.h:66
virtual void ModifyValueRecursive(const char *name, string value)
Definition: svkDcmtkAdapter.cc:775
Definition: svkDcmtkAdapter.h:65
virtual int GetNumberOfElements(const char *elementName)
Definition: svkDcmtkAdapter.cc:1865
virtual int ReadDcmFileHeaderOnly(string fileName)
Definition: svkDcmtkAdapter.cc:2072
virtual void ClearSequence(const char *seqName)
Definition: svkDcmtkAdapter.cc:1381
vtkTypeMacro(svkDcmtkAdapter, svkDcmHeader)
virtual long int GetLongIntSequenceItemElement(const char *seqName, int seqItemPosition, const char *elementName, const char *parentSeqName=NULL, int parentSeqItemPosition=0, int pos=0)
Definition: svkDcmtkAdapter.cc:1521
virtual void HandleTagNotFoundException(const svkTagNotFound &e)
Definition: svkDcmtkAdapter.cc:2174
virtual void ClearElement(const char *elementName)
Definition: svkDcmtkAdapter.cc:1402
Definition: svkDcmtkException.h:71
virtual void CopyDcmHeader(svkDcmHeader *headerCopy)
Definition: svkDcmtkAdapter.cc:2095
virtual string GetStringValue(const char *name)
Definition: svkDcmtkAdapter.cc:967
virtual void SetValue(const char *name, int value)
Definition: svkDcmtkAdapter.cc:632
virtual void InsertEmptyElement(const char *name)
Definition: svkDcmtkAdapter.cc:587
virtual void WriteDcmFileCompressed(string fileName)
Definition: svkDcmtkAdapter.cc:1999
virtual int GetIntSequenceItemElement(const char *seqName, int seqItemPosition, const char *elementName, const char *parentSeqName=NULL, int parentSeqItemPosition=0, int pos=0)
Definition: svkDcmtkAdapter.cc:1492
virtual string GetStringSequenceItemElement(const char *seqName, int seqItemPosition, const char *elementName, const char *parentSeqName=NULL, int parentSeqItemPosition=0)
Definition: svkDcmtkAdapter.cc:1648
virtual void CopySequence(svkDcmHeader *target, const char *seqName)
Definition: svkDcmtkAdapter.cc:1349
static svkDcmtkAdapter * New()
virtual bool ElementExists(const char *elementName, const char *parentSeqName)
Definition: svkDcmtkAdapter.cc:2114
virtual int GetIntValue(const char *name)
Definition: svkDcmtkAdapter.cc:800
virtual int ReadDcmFile(string fileName, unsigned int maxLength)
Definition: svkDcmtkAdapter.cc:2023
svkDcmtkAdapter()
Definition: svkDcmtkAdapter.cc:63
virtual void RemoveElement(const char *elementName)
Definition: svkDcmtkAdapter.cc:1415
virtual void PrintDcmHeader()
Definition: svkDcmtkAdapter.cc:565
virtual void CreateIOD(DcmIodType iodType)
Definition: svkDcmtkAdapter.cc:497
virtual void ReplaceOldElements(bool replaceElements)
Definition: svkDcmtkAdapter.cc:2160
virtual void AddSequenceItemElement(const char *parentSeqName, int parentSeqItemPosition, const char *elementName)
Definition: svkDcmtkAdapter.cc:1009
virtual double GetDoubleValue(const char *name)
Definition: svkDcmtkAdapter.cc:954
virtual void InsertUniqueUID(const char *name)
Definition: svkDcmtkAdapter.cc:601
~svkDcmtkAdapter()
Definition: svkDcmtkAdapter.cc:96
virtual float GetFloatValue(const char *name)
Definition: svkDcmtkAdapter.cc:813
virtual int GetSequenceItemElementLength(const char *seqName, int seqItemPosition, const char *elementName, const char *parentSeqName, int parentSeqItemPosition)
Definition: svkDcmtkAdapter.cc:1886
virtual int GetOriginalXFerSyntax()
Definition: svkDcmtkAdapter.cc:2082
Definition: svkDcmtkIod.h:64
virtual void SetSOPClassUID(DcmIodType iodType)
Definition: svkDcmtkAdapter.cc:507
string GenerateUniqueUID()
Definition: svkDcmtkAdapter.cc:616
virtual string GetDcmNameFromTag(string groupElementString)
Definition: svkDcmtkAdapter.cc:1728
virtual float GetFloatSequenceItemElement(const char *seqName, int seqItemPosition, const char *elementName, const char *parentSeqName=NULL, int parentSeqItemPosition=0, int pos=0)
Definition: svkDcmtkAdapter.cc:1555
virtual void GetShortValue(const char *name, short *values, long unsigned int numValues)
Definition: svkDcmtkAdapter.cc:881
virtual void WriteDcmFile(string fileName)
Definition: svkDcmtkAdapter.cc:1981
virtual int GetNumberOfItemsInSequence(const char *seqName)
Definition: svkDcmtkAdapter.cc:1923
virtual double GetDoubleSequenceItemElement(const char *seqName, int seqItemPosition, const char *elementName, const char *parentSeqName=NULL, int parentSeqItemPosition=0)
Definition: svkDcmtkAdapter.cc:1621