ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkAnalyzeImageIO.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  *=========================================================================*/
30 #ifndef __itkAnalyzeImageIO_h
31 #define __itkAnalyzeImageIO_h
32 #if !defined( ITK_LEGACY_REMOVE )
33 
34 
35 #include <fstream>
36 #include "itkImageIOBase.h"
37 #include "itkAnalyzeDbh.h"
38 
39 namespace itk
40 {
94 class ITK_EXPORT AnalyzeImageIO:public ImageIOBase
95 {
96 public:
98  typedef AnalyzeImageIO Self;
99  typedef ImageIOBase Superclass;
100  typedef SmartPointer< Self > Pointer;
101 
103  itkNewMacro(Self);
104 
106  itkTypeMacro(AnalyzeImageIO, Superclass);
107 
108  /*-------- This part of the interfaces deals with reading data. ----- */
109 
116  virtual bool CanReadFile(const char *FileNameToRead);
117 
119  virtual void ReadImageInformation();
120 
122  virtual void Read(void *buffer);
123 
124  /*-------- This part of the interfaces deals with writing data. ----- */
125 
132  virtual bool CanWriteFile(const char *FileNameToWrite);
133 
135  virtual void WriteImageInformation();
136 
139  virtual void Write(const void *buffer);
140 
142  virtual std::vector< double > GetDirection(unsigned int i) const;
143 
146  virtual std::vector< double > GetDefaultDirection(unsigned int i) const;
147 
148 protected:
149  AnalyzeImageIO();
150  ~AnalyzeImageIO();
151  void PrintSelf(std::ostream & os, Indent indent) const;
152 
153 private:
169  typedef enum {
170 
187  } ValidAnalyzeOrientationFlags;
188 
189  AnalyzeImageIO(const Self &); //purposely not implemented
190  void operator=(const Self &); //purposely not implemented
191 
192  void SwapBytesIfNecessary(void *buffer, SizeType numberOfPixels);
193 
200  void SwapHeaderBytesIfNecessary(struct dsr *const imageheader);
201 
207  void DefineHeaderObjectDataType(void);
208 
209 #if defined( REORIENT_IMAGES )
210  void ReorientIfNecessary(char *p);
211 
212  struct ipl_dimensions {
213  unsigned int slicestride;
214  unsigned int rowstride;
215  unsigned int componentstride; x
216  unsigned int pixelsize;
217  //
218  // xsize,ysize,zsize == size in each direction in pixesls
219  unsigned int xsize;
220  unsigned int ysize;
221  unsigned int zsize;
222  };
230  void GetAllDimensions(ipl_dimensions & dim);
231 
232  ipl_dimensions m_OldDim, m_NewDim;
233 #endif
234 
240  ImageIOBase::ByteOrder CheckAnalyzeEndian(const struct dsr & temphdr);
241 
243  struct dsr m_Hdr;
244  ImageIOBase::ByteOrder m_MachineByteOrder;
245 };
246 extern const char *const ANALYZE_ScanNumber;
247 extern const char *const ANALYZE_O_MAX;
248 extern const char *const ANALYZE_O_MIN;
249 extern const char *const ANALYZE_S_MAX;
250 extern const char *const ANALYZE_S_MIN;
251 extern const char *const ANALYZE_CAL_MAX;
252 extern const char *const ANALYZE_CAL_MIN;
253 extern const char *const ANALYZE_GLMAX;
254 extern const char *const ANALYZE_GLMIN;
255 extern const char *const ANALYZE_AUX_FILE_NAME;
256 extern const char *const ANALYZE_CALIBRATIONUNITS;
257 } // end namespace itk
258 
259 #endif //#if !defined( ITK_LEGACY_REMOVE )
260 #endif // __itkAnalyzeImageIO_h
261