ITK  6.0.0
Insight Toolkit
itkVoxBoCUBImageIO.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 itkVoxBoCUBImageIO_h
19 #define itkVoxBoCUBImageIO_h
20 
21 
22 #include <fstream>
23 #include <string>
24 #include <map>
25 #include "itkImageIOBase.h"
26 #include "itkSpatialOrientation.h"
27 #include <cstdio>
28 
29 namespace itk
30 {
31 // Forward declaration
32 class GenericCUBFileAdaptor;
33 
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_MOVE(VoxBoCUBImageIO);
54 
59 
61  itkNewMacro(Self);
62 
64  itkOverrideGetNameOfClassMacro(VoxBoCUBImageIO);
65 
66  /*-------- This part of the interfaces deals with reading data. ----- */
67 
70  bool
71  CanReadFile(const char *) override;
72 
74  void
75  ReadImageInformation() override;
76 
78  void
79  Read(void * buffer) override;
80 
81  /*-------- This part of the interfaces deals with writing data. ----- */
82 
85  bool
86  CanWriteFile(const char *) override;
87 
89  void
90  WriteImageInformation() override;
91 
94  void
95  Write(const void * buffer) override;
96 
98  ~VoxBoCUBImageIO() override;
99  void
100  PrintSelf(std::ostream & os, Indent indent) const override;
101 
102 private:
103  bool
104  CheckExtension(const char *, bool & isCompressed);
105 
106  GenericCUBFileAdaptor *
107  CreateReader(const char * filename);
108 
109  GenericCUBFileAdaptor *
110  CreateWriter(const char * filename);
111 
112  GenericCUBFileAdaptor *m_Reader, *m_Writer;
113 
114  // Initialize the orientation map (from strings to ITK)
115  void
117 
118  // Orientation stuff
120  using OrientationMap = std::map<std::string, OrientationFlags>;
121  using InverseOrientationMap = std::map<OrientationFlags, std::string>;
122 
125 
126  // Method to swap bytes in read buffer
127  void
128  SwapBytesIfNecessary(void * buffer, BufferSizeType numberOfBytes);
129 
130  // Strings used in VoxBo files
131  static const char * m_VB_IDENTIFIER_SYSTEM;
132  static const char * m_VB_IDENTIFIER_FILETYPE;
133  static const char * m_VB_DIMENSIONS;
134  static const char * m_VB_SPACING;
135  static const char * m_VB_ORIGIN;
136  static const char * m_VB_DATATYPE;
137  static const char * m_VB_BYTEORDER;
138  static const char * m_VB_ORIENTATION;
139  static const char * m_VB_BYTEORDER_MSB;
140  static const char * m_VB_BYTEORDER_LSB;
141  static const char * m_VB_DATATYPE_BYTE;
142  static const char * m_VB_DATATYPE_INT;
143  static const char * m_VB_DATATYPE_FLOAT;
144  static const char * m_VB_DATATYPE_DOUBLE;
145 };
146 } // end namespace itk
147 
148 #endif // itkVoxBoCUBImageIO_h
itk::ImageIOBase
Abstract superclass defines image IO interface.
Definition: itkImageIOBase.h:77
itk::VoxBoCUBImageIO::Read
void Read(void *buffer) override
itk::ImageIOBase::ImageIOBase
ImageIOBase()
itk::VoxBoCUBImageIO::ReadImageInformation
void ReadImageInformation() override
itk::VoxBoCUBImageIO::m_VB_SPACING
static const char * m_VB_SPACING
Definition: itkVoxBoCUBImageIO.h:134
itk::VoxBoCUBImageIO::m_VB_DATATYPE
static const char * m_VB_DATATYPE
Definition: itkVoxBoCUBImageIO.h:136
itk::VoxBoCUBImageIO::m_Reader
GenericCUBFileAdaptor * m_Reader
Definition: itkVoxBoCUBImageIO.h:112
itk::VoxBoCUBImageIO::CreateWriter
GenericCUBFileAdaptor * CreateWriter(const char *filename)
itk::VoxBoCUBImageIO::m_VB_IDENTIFIER_SYSTEM
static const char * m_VB_IDENTIFIER_SYSTEM
Definition: itkVoxBoCUBImageIO.h:131
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::VoxBoCUBImageIO::WriteImageInformation
void WriteImageInformation() override
itk::ImageIOBase::BufferSizeType
itk::OffsetValueType BufferSizeType
Definition: itkImageIOBase.h:399
itk::VoxBoCUBImageIO::CheckExtension
bool CheckExtension(const char *, bool &isCompressed)
itk::VoxBoCUBImageIO::InverseOrientationMap
std::map< OrientationFlags, std::string > InverseOrientationMap
Definition: itkVoxBoCUBImageIO.h:121
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::VoxBoCUBImageIO::VoxBoCUBImageIO
VoxBoCUBImageIO()
itk::VoxBoCUBImageIO::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::VoxBoCUBImageIO::m_VB_DATATYPE_BYTE
static const char * m_VB_DATATYPE_BYTE
Definition: itkVoxBoCUBImageIO.h:141
itk::VoxBoCUBImageIO::m_VB_BYTEORDER_LSB
static const char * m_VB_BYTEORDER_LSB
Definition: itkVoxBoCUBImageIO.h:140
itk::VoxBoCUBImageIO::OrientationMap
std::map< std::string, OrientationFlags > OrientationMap
Definition: itkVoxBoCUBImageIO.h:120
itk::VoxBoCUBImageIO::m_VB_DATATYPE_FLOAT
static const char * m_VB_DATATYPE_FLOAT
Definition: itkVoxBoCUBImageIO.h:143
itk::VoxBoCUBImageIO::SwapBytesIfNecessary
void SwapBytesIfNecessary(void *buffer, BufferSizeType numberOfBytes)
itk::VoxBoCUBImageIO::m_VB_IDENTIFIER_FILETYPE
static const char * m_VB_IDENTIFIER_FILETYPE
Definition: itkVoxBoCUBImageIO.h:132
itk::VoxBoCUBImageIO::InitializeOrientationMap
void InitializeOrientationMap()
itk::VoxBoCUBImageIO::CreateReader
GenericCUBFileAdaptor * CreateReader(const char *filename)
itkSpatialOrientation.h
itk::VoxBoCUBImageIO
Read VoxBoCUBImage file format.
Definition: itkVoxBoCUBImageIO.h:50
itk::VoxBoCUBImageIO::CanReadFile
bool CanReadFile(const char *) override
itkImageIOBase.h
itk::SpatialOrientationEnums::ValidCoordinateOrientations
ValidCoordinateOrientations
Definition: itkSpatialOrientation.h:111
itk::VoxBoCUBImageIO::m_VB_DATATYPE_INT
static const char * m_VB_DATATYPE_INT
Definition: itkVoxBoCUBImageIO.h:142
itk::VoxBoCUBImageIO::m_VB_DIMENSIONS
static const char * m_VB_DIMENSIONS
Definition: itkVoxBoCUBImageIO.h:133
itk::VoxBoCUBImageIO::m_VB_ORIENTATION
static const char * m_VB_ORIENTATION
Definition: itkVoxBoCUBImageIO.h:138
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::VoxBoCUBImageIO::m_Writer
GenericCUBFileAdaptor * m_Writer
Definition: itkVoxBoCUBImageIO.h:112
itk::VoxBoCUBImageIO::Write
void Write(const void *buffer) override
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::VoxBoCUBImageIO::~VoxBoCUBImageIO
~VoxBoCUBImageIO() override
itk::VoxBoCUBImageIO::m_VB_BYTEORDER
static const char * m_VB_BYTEORDER
Definition: itkVoxBoCUBImageIO.h:137
itk::VoxBoCUBImageIO::m_OrientationMap
OrientationMap m_OrientationMap
Definition: itkVoxBoCUBImageIO.h:123
itk::VoxBoCUBImageIO::m_VB_DATATYPE_DOUBLE
static const char * m_VB_DATATYPE_DOUBLE
Definition: itkVoxBoCUBImageIO.h:144
itk::VoxBoCUBImageIO::m_InverseOrientationMap
InverseOrientationMap m_InverseOrientationMap
Definition: itkVoxBoCUBImageIO.h:124
itk::VoxBoCUBImageIO::m_VB_BYTEORDER_MSB
static const char * m_VB_BYTEORDER_MSB
Definition: itkVoxBoCUBImageIO.h:139
itk::VoxBoCUBImageIO::m_VB_ORIGIN
static const char * m_VB_ORIGIN
Definition: itkVoxBoCUBImageIO.h:135
itk::VoxBoCUBImageIO::CanWriteFile
bool CanWriteFile(const char *) override