ITK  4.13.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 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) ITK_OVERRIDE;
117 
119  virtual void ReadImageInformation() ITK_OVERRIDE;
120 
122  virtual void Read(void *buffer) ITK_OVERRIDE;
123 
124  /*-------- This part of the interfaces deals with writing data. ----- */
125 
132  virtual bool CanWriteFile(const char *FileNameToWrite) ITK_OVERRIDE;
133 
135  virtual void WriteImageInformation() ITK_OVERRIDE;
136 
139  virtual void Write(const void *buffer) ITK_OVERRIDE;
140 
142  virtual std::vector< double > GetDirection(unsigned int i) const ITK_OVERRIDE;
143 
146  virtual std::vector< double > GetDefaultDirection(unsigned int i) const ITK_OVERRIDE;
147 
148 protected:
149  AnalyzeImageIO();
150  ~AnalyzeImageIO();
151  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
152 
153 private:
169  typedef enum {
170 
187  } ValidAnalyzeOrientationFlags;
188 
189  ITK_DISALLOW_COPY_AND_ASSIGN(AnalyzeImageIO);
190 
191  void SwapBytesIfNecessary(void *buffer, SizeType numberOfPixels);
192 
199  void SwapHeaderBytesIfNecessary(struct dsr *const imageheader);
200 
206  void DefineHeaderObjectDataType();
207 
208 #if defined( REORIENT_IMAGES )
209  void ReorientIfNecessary(char *p);
210 
211  struct ipl_dimensions {
212  unsigned int slicestride;
213  unsigned int rowstride;
214  unsigned int componentstride; x
215  unsigned int pixelsize;
216  //
217  // xsize,ysize,zsize == size in each direction in pixesls
218  unsigned int xsize;
219  unsigned int ysize;
220  unsigned int zsize;
221  };
229  void GetAllDimensions(ipl_dimensions & dim);
230 
231  ipl_dimensions m_OldDim, m_NewDim;
232 #endif
233 
239  ImageIOBase::ByteOrder CheckAnalyzeEndian(const struct dsr & temphdr);
240 
242  struct dsr m_Hdr;
243  ImageIOBase::ByteOrder m_MachineByteOrder;
244 };
245 extern const char *const ANALYZE_ScanNumber;
246 extern const char *const ANALYZE_O_MAX;
247 extern const char *const ANALYZE_O_MIN;
248 extern const char *const ANALYZE_S_MAX;
249 extern const char *const ANALYZE_S_MIN;
250 extern const char *const ANALYZE_CAL_MAX;
251 extern const char *const ANALYZE_CAL_MIN;
252 extern const char *const ANALYZE_GLMAX;
253 extern const char *const ANALYZE_GLMIN;
254 extern const char *const ANALYZE_AUX_FILE_NAME;
255 extern const char *const ANALYZE_CALIBRATIONUNITS;
256 } // end namespace itk
257 
258 #endif //#if !defined( ITK_LEGACY_REMOVE )
259 #endif // itkAnalyzeImageIO_h