ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkDCMTKImageIO.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkDCMTKImageIO_h
19 #define itkDCMTKImageIO_h
20 #include "ITKIODCMTKExport.h"
21 
22 
23 #include <fstream>
24 #include <stdio.h>
25 #include "itkImageIOBase.h"
26 
27 class DicomImage;
28 
29 namespace itk
30 {
39 class ITKIODCMTK_EXPORT DCMTKImageIO:public ImageIOBase
40 {
41 public:
43  typedef DCMTKImageIO Self;
46 
48  itkNewMacro(Self);
49 
51  itkTypeMacro(DCMTKImageIO, ImageIOBase);
52 
57  enum LogLevel
58  {
59  TRACE_LOG_LEVEL = 0,
66  };
67 
69  void SetDicomImagePointer( DicomImage* UserProvided)
70  {
71  m_DImage = UserProvided;
72  m_DicomImageSetByUser = true;
73  }
74 
75  /*-------- This part of the interfaces deals with reading data. ----- */
76 
79  virtual bool CanReadFile(const char *) ITK_OVERRIDE;
80 
82  virtual void ReadImageInformation() ITK_OVERRIDE;
83 
85  virtual void Read(void *buffer) ITK_OVERRIDE;
86 
87  /*-------- This part of the interfaces deals with writing data. ----- */
88 
91  virtual bool CanWriteFile(const char *) ITK_OVERRIDE;
92 
94  virtual void WriteImageInformation() ITK_OVERRIDE;
95 
98  virtual void Write(const void *buffer) ITK_OVERRIDE;
99 
101  void SetLogLevel(LogLevel level);
102 
104  LogLevel GetLogLevel() const;
105 
106  DCMTKImageIO();
107  ~DCMTKImageIO();
108  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
109 
110 private:
111  ITK_DISALLOW_COPY_AND_ASSIGN(DCMTKImageIO);
112 
113  void OpenDicomImage();
114 
116  void ReorderRGBValues(void *buffer, const void* data, unsigned long count, unsigned int voxel_size);
117 
123  template<typename T>
124  void
125  ReorderRGBValues(void *buffer, const void* data, unsigned long count, unsigned int voxel_size)
126  {
127  T* output_buffer = static_cast<T*>(buffer);
128  const T** input_buffer = static_cast<const T**>(const_cast<void *>(data));
129  for (unsigned long pos = 0; pos < count; ++pos)
130  {
131  for (unsigned int color = 0; color < voxel_size; ++color)
132  {
133  *(output_buffer++)=input_buffer[color][pos];
134  }
135  }
136  }
138 
139  /*----- internal helpers --------------------------------------------*/
143 
144  DicomImage* m_DImage;
145 
147 
150  std::string m_LastFileName;
151 };
152 } // end namespace itk
153 
154 #endif // itkDCMTKImageIO_h
DicomImage * m_DImage
Light weight base class for most itk classes.
std::string m_LastFileName
Abstract superclass defines image IO interface.
ImageIOBase Superclass
void SetDicomImagePointer(DicomImage *UserProvided)
SmartPointer< Self > Pointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
DCMTKImageIO Self
Read DICOM image file format.