ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkVoxBoCUBImageIO.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 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_ASSIGN(VoxBoCUBImageIO);
54 
59 
61  itkNewMacro(Self);
62 
64  itkTypeMacro(VoxBoCUBImageIO, Superclass);
65 
66  /*-------- This part of the interfaces deals with reading data. ----- */
67 
70  bool CanReadFile(const char *) override;
71 
73  void ReadImageInformation() override;
74 
76  void Read(void *buffer) override;
77 
78  /*-------- This part of the interfaces deals with writing data. ----- */
79 
82  bool CanWriteFile(const char *) override;
83 
85  void WriteImageInformation() override;
86 
89  void Write(const void *buffer) override;
90 
92  ~VoxBoCUBImageIO() override;
93  void PrintSelf(std::ostream & os, Indent indent) const override;
94 
95 private:
96  bool CheckExtension(const char *, bool & isCompressed);
97 
98  GenericCUBFileAdaptor * CreateReader(const char *filename);
99 
100  GenericCUBFileAdaptor * CreateWriter(const char *filename);
101 
102  GenericCUBFileAdaptor *m_Reader, *m_Writer;
103 
104  // Initialize the orientation map (from strings to ITK)
106 
107  // Orientation stuff
109  using OrientationMap = std::map< std::string, OrientationFlags >;
110  using InverseOrientationMap = std::map< OrientationFlags, std::string >;
111 
114 
115  // Method to swap bytes in read buffer
116  void SwapBytesIfNecessary(void *buffer, BufferSizeType numberOfBytes);
117 
118  // Strings used in VoxBo files
119  static const char *m_VB_IDENTIFIER_SYSTEM;
120  static const char *m_VB_IDENTIFIER_FILETYPE;
121  static const char *m_VB_DIMENSIONS;
122  static const char *m_VB_SPACING;
123  static const char *m_VB_ORIGIN;
124  static const char *m_VB_DATATYPE;
125  static const char *m_VB_BYTEORDER;
126  static const char *m_VB_ORIENTATION;
127  static const char *m_VB_BYTEORDER_MSB;
128  static const char *m_VB_BYTEORDER_LSB;
129  static const char *m_VB_DATATYPE_BYTE;
130  static const char *m_VB_DATATYPE_INT;
131  static const char *m_VB_DATATYPE_FLOAT;
132  static const char *m_VB_DATATYPE_DOUBLE;
133 };
134 } // end namespace itk
135 
136 #endif // itkVoxBoCUBImageIO_h
static const char * m_VB_BYTEORDER
Light weight base class for most itk classes.
static const char * m_VB_DATATYPE_BYTE
bool CanReadFile(const char *) override
static const char * m_VB_DATATYPE
static const char * m_VB_DATATYPE_DOUBLE
Abstract superclass defines image IO interface.
bool CheckExtension(const char *, bool &isCompressed)
std::map< OrientationFlags, std::string > InverseOrientationMap
GenericCUBFileAdaptor * CreateWriter(const char *filename)
OrientationMap m_OrientationMap
bool CanWriteFile(const char *) override
static const char * m_VB_BYTEORDER_LSB
::itk::OffsetValueType BufferSizeType
static const char * m_VB_DIMENSIONS
std::map< std::string, OrientationFlags > OrientationMap
static const char * m_VB_SPACING
static const char * m_VB_IDENTIFIER_FILETYPE
void SwapBytesIfNecessary(void *buffer, BufferSizeType numberOfBytes)
GenericCUBFileAdaptor * CreateReader(const char *filename)
static const char * m_VB_DATATYPE_INT
InverseOrientationMap m_InverseOrientationMap
void InitializeOrientationMap()
void PrintSelf(std::ostream &os, Indent indent) const override
GenericCUBFileAdaptor * m_Writer
static const char * m_VB_IDENTIFIER_SYSTEM
GenericCUBFileAdaptor * m_Reader
static const char * m_VB_ORIENTATION
~VoxBoCUBImageIO() override
Read VoxBoCUBImage file format.
static const char * m_VB_ORIGIN
static const char * m_VB_DATATYPE_FLOAT
static const char * m_VB_BYTEORDER_MSB
void ReadImageInformation() override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for most ITK classes.
Definition: itkObject.h:60
void Read(void *buffer) override
void Write(const void *buffer) override
void WriteImageInformation() override