ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkDCMTKImageIO.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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 <cstdio>
25#include "itkImageIOBase.h"
26
27class DicomImage;
28
29namespace itk
30{
58// Define how to print enumeration
59extern ITKIODCMTK_EXPORT std::ostream &
60 operator<<(std::ostream & out, const DCMTKImageIOEnums::LogLevel value);
61
71class ITKIODCMTK_EXPORT DCMTKImageIO : public ImageIOBase
72{
73public:
74 ITK_DISALLOW_COPY_AND_MOVE(DCMTKImageIO);
75
80
82 itkNewMacro(Self);
83
85 itkOverrideGetNameOfClassMacro(DCMTKImageIO);
86
88#if !defined(ITK_LEGACY_REMOVE)
90 static constexpr LogLevelEnum TRACE_LOG_LEVEL = LogLevelEnum::TRACE_LOG_LEVEL;
91 static constexpr LogLevelEnum DEBUG_LOG_LEVEL = LogLevelEnum::DEBUG_LOG_LEVEL;
92 static constexpr LogLevelEnum INFO_LOG_LEVEL = LogLevelEnum::INFO_LOG_LEVEL;
93 static constexpr LogLevelEnum WARN_LOG_LEVEL = LogLevelEnum::WARN_LOG_LEVEL;
94 static constexpr LogLevelEnum ERROR_LOG_LEVEL = LogLevelEnum::ERROR_LOG_LEVEL;
95 static constexpr LogLevelEnum FATAL_LOG_LEVEL = LogLevelEnum::FATAL_LOG_LEVEL;
96 static constexpr LogLevelEnum OFF_LOG_LEVEL = LogLevelEnum::OFF_LOG_LEVEL;
97#endif
98
100 void
101 SetDicomImagePointer(DicomImage * UserProvided)
102 {
103 m_DImage = UserProvided;
105 }
106
107 /*-------- This part of the interfaces deals with reading data. ----- */
108
111 bool
112 CanReadFile(const char *) override;
113
115 void
117
119 void
120 Read(void * buffer) override;
121
122 /*-------- This part of the interfaces deals with writing data. ----- */
123
126 bool
127 CanWriteFile(const char *) override;
128
130 void
132
135 void
136 Write(const void * buffer) override;
137
139 void
143 GetLogLevel() const;
144
146 ~DCMTKImageIO() override;
147 void
148 PrintSelf(std::ostream & os, Indent indent) const override;
149
150private:
151 void
153
155 void
156 ReorderRGBValues(void * buffer, const void * data, size_t count, unsigned int voxel_size);
162 template <typename T>
163 void
164 ReorderRGBValues(void * buffer, const void * data, size_t count, unsigned int voxel_size)
165 {
166 auto * output_buffer = static_cast<T *>(buffer);
167 const auto ** input_buffer = static_cast<const T **>(const_cast<void *>(data));
168 for (size_t pos = 0; pos < count; ++pos)
169 {
170 for (unsigned int color = 0; color < voxel_size; ++color)
171 {
172 *(output_buffer++) = input_buffer[color][pos];
173 }
174 }
175 }
176
177 /*----- internal helpers --------------------------------------------*/
181
182 DicomImage * m_DImage{};
183
185
188 std::string m_LastFileName{};
189};
190
191// Define how to print enumeration
192extern ITKIODCMTK_EXPORT std::ostream &
193 operator<<(std::ostream & out, DCMTKImageIO::LogLevelEnum value);
194
195} // end namespace itk
196
197#endif // itkDCMTKImageIO_h
Enums used by the DCMTKImageIO class.
void SetDicomImagePointer(DicomImage *UserProvided)
ImageIOBase Superclass
std::string m_LastFileName
void WriteImageInformation() override
void ReorderRGBValues(void *buffer, const void *data, vcl_size_t count, unsigned int voxel_size)
DCMTKImageIOEnums::LogLevel LogLevelEnum
bool CanReadFile(const char *) override
LogLevelEnum GetLogLevel() const
void Read(void *buffer) override
DicomImage * m_DImage
~DCMTKImageIO() override
void Write(const void *buffer) override
void ReadImageInformation() override
void PrintSelf(std::ostream &os, Indent indent) const override
bool CanWriteFile(const char *) override
void ReorderRGBValues(void *buffer, const void *data, vcl_size_t count, unsigned int voxel_size)
void SetLogLevel(LogLevelEnum level)
SmartPointer< Self > Pointer
Control indentation during Print() invocation.
Definition itkIndent.h:53
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, AnatomicalOrientation::CoordinateEnum value)