ITK  4.6.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  VoxBoCUBImageIO(const Self &); //purposely not implemented
95  void operator=(const Self &); //purposely not implemented
96 
97  bool CheckExtension(const char *, bool & isCompressed);
98 
99  GenericCUBFileAdaptor * CreateReader(const char *filename);
100 
101  GenericCUBFileAdaptor * CreateWriter(const char *filename);
102 
103  GenericCUBFileAdaptor *m_Reader, *m_Writer;
104 
105  // Initialize the orientation map (from strings to ITK)
107 
108  // Orientation stuff
110  typedef std::map< std::string, OrientationFlags > OrientationMap;
111  typedef std::map< OrientationFlags, std::string > InverseOrientationMap;
112 
113  OrientationMap m_OrientationMap;
114  InverseOrientationMap m_InverseOrientationMap;
115 
116  // Method to swap bytes in read buffer
117  void SwapBytesIfNecessary(void *buffer, BufferSizeType numberOfBytes);
118 
119  // Strings used in VoxBo files
120  static const char *m_VB_IDENTIFIER_SYSTEM;
121  static const char *m_VB_IDENTIFIER_FILETYPE;
122  static const char *m_VB_DIMENSIONS;
123  static const char *m_VB_SPACING;
124  static const char *m_VB_ORIGIN;
125  static const char *m_VB_DATATYPE;
126  static const char *m_VB_BYTEORDER;
127  static const char *m_VB_ORIENTATION;
128  static const char *m_VB_BYTEORDER_MSB;
129  static const char *m_VB_BYTEORDER_LSB;
130  static const char *m_VB_DATATYPE_BYTE;
131  static const char *m_VB_DATATYPE_INT;
132  static const char *m_VB_DATATYPE_FLOAT;
133  static const char *m_VB_DATATYPE_DOUBLE;
134 };
135 } // end namespace itk
136 
137 #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 Write(const void *buffer) ITK_OVERRIDE
Abstract superclass defines image IO interface.
SmartPointer< Self > Pointer
bool CheckExtension(const char *, bool &isCompressed)
virtual bool CanWriteFile(const char *) ITK_OVERRIDE
virtual void ReadImageInformation() ITK_OVERRIDE
GenericCUBFileAdaptor * CreateWriter(const char *filename)
OrientationMap m_OrientationMap
virtual bool CanReadFile(const char *) ITK_OVERRIDE
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
virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
GenericCUBFileAdaptor * m_Reader
static const char * m_VB_ORIENTATION
std::map< OrientationFlags, std::string > InverseOrientationMap
Read VoxBoCUBImage file format.
virtual void WriteImageInformation() ITK_OVERRIDE
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 void Read(void *buffer) ITK_OVERRIDE
Base class for most ITK classes.
Definition: itkObject.h:57