ITK  4.13.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:
57 
59  itkNewMacro(Self);
60 
62  itkTypeMacro(VoxBoCUBImageIO, Superclass);
63 
64  /*-------- This part of the interfaces deals with reading data. ----- */
65 
68  virtual bool CanReadFile(const char *) ITK_OVERRIDE;
69 
71  virtual void ReadImageInformation() ITK_OVERRIDE;
72 
74  virtual void Read(void *buffer) ITK_OVERRIDE;
75 
76  /*-------- This part of the interfaces deals with writing data. ----- */
77 
80  virtual bool CanWriteFile(const char *) ITK_OVERRIDE;
81 
83  virtual void WriteImageInformation() ITK_OVERRIDE;
84 
87  virtual void Write(const void *buffer) ITK_OVERRIDE;
88 
90  ~VoxBoCUBImageIO();
91  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
92 
93 private:
94  ITK_DISALLOW_COPY_AND_ASSIGN(VoxBoCUBImageIO);
95 
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  typedef std::map< std::string, OrientationFlags > OrientationMap;
110  typedef std::map< OrientationFlags, std::string > InverseOrientationMap;
111 
112  OrientationMap m_OrientationMap;
113  InverseOrientationMap m_InverseOrientationMap;
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
static const char * m_VB_DATATYPE
static const char * m_VB_DATATYPE_DOUBLE
virtual void PrintSelf(std::ostream &os, Indent indent) const override
Abstract superclass defines image IO interface.
SmartPointer< Self > Pointer
bool CheckExtension(const char *, bool &isCompressed)
virtual void ReadImageInformation() override
virtual bool CanWriteFile(const char *) override
GenericCUBFileAdaptor * CreateWriter(const char *filename)
OrientationMap m_OrientationMap
static const char * m_VB_BYTEORDER_LSB
static const char * m_VB_DIMENSIONS
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()
std::map< std::string, OrientationFlags > OrientationMap
GenericCUBFileAdaptor * m_Writer
static const char * m_VB_IDENTIFIER_SYSTEM
GenericCUBFileAdaptor * m_Reader
virtual void Write(const void *buffer) override
static const char * m_VB_ORIENTATION
std::map< OrientationFlags, std::string > InverseOrientationMap
Read VoxBoCUBImage file format.
static const char * m_VB_ORIGIN
static const char * m_VB_DATATYPE_FLOAT
::itk::OffsetValueType BufferSizeType
static const char * m_VB_BYTEORDER_MSB
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual bool CanReadFile(const char *) override
Base class for most ITK classes.
Definition: itkObject.h:59
virtual void Read(void *buffer) override
virtual void WriteImageInformation() override