ITK  4.2.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 <stdio.h>
28 
29 namespace itk
30 {
31 // Forward declaration
32 class GenericCUBFileAdaptor;
33 
50 class ITK_EXPORT VoxBoCUBImageIO:public ImageIOBase
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 *);
69 
71  virtual void ReadImageInformation();
72 
74  virtual void Read(void *buffer);
75 
76  /*-------- This part of the interfaces deals with writing data. ----- */
77 
80  virtual bool CanWriteFile(const char *);
81 
83  virtual void WriteImageInformation();
84 
87  virtual void Write(const void *buffer);
88 
90  ~VoxBoCUBImageIO();
91  void PrintSelf(std::ostream & os, Indent indent) const;
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)
106  void InitializeOrientationMap();
107 
108  // Orientation stuff
110  typedef std::map< std::string, OrientationFlags > OrientationMap;
111  typedef std::map< OrientationFlags, std::string > InverseOrientationMap;
112 
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
138