ITK  4.2.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 
33 
34 #include <fstream>
35 #include "itkImageIOBase.h"
36 #include "itkAnalyzeDbh.h"
37 
38 namespace itk
39 {
92 class ITK_EXPORT AnalyzeImageIO:public ImageIOBase
93 {
94 public:
99 
101  itkNewMacro(Self);
102 
104  itkTypeMacro(AnalyzeImageIO, Superclass);
105 
106  /*-------- This part of the interfaces deals with reading data. ----- */
107 
114  virtual bool CanReadFile(const char *FileNameToRead);
115 
117  virtual void ReadImageInformation();
118 
120  virtual void Read(void *buffer);
121 
122  /*-------- This part of the interfaces deals with writing data. ----- */
123 
130  virtual bool CanWriteFile(const char *FileNameToWrite);
131 
133  virtual void WriteImageInformation();
134 
137  virtual void Write(const void *buffer);
138 
140  virtual std::vector< double > GetDirection(unsigned int i) const;
141 
144  virtual std::vector< double > GetDefaultDirection(unsigned int i) const;
145 
146 protected:
147  AnalyzeImageIO();
148  ~AnalyzeImageIO();
149  void PrintSelf(std::ostream & os, Indent indent) const;
150 
151 private:
167  typedef enum {
168 
185  } ValidAnalyzeOrientationFlags;
186 
187  AnalyzeImageIO(const Self &); //purposely not implemented
188  void operator=(const Self &); //purposely not implemented
189 
190  void SwapBytesIfNecessary(void *buffer, SizeType numberOfPixels);
191 
198  void SwapHeaderBytesIfNecessary(struct dsr *const imageheader);
199 
205  void DefineHeaderObjectDataType(void);
206 
207 #if defined( REORIENT_IMAGES )
208  void ReorientIfNecessary(char *p);
209 
210  struct ipl_dimensions {
211  unsigned int slicestride;
212  unsigned int rowstride;
213  unsigned int componentstride; x
214  unsigned int pixelsize;
215  //
216  // xsize,ysize,zsize == size in each direction in pixesls
217  unsigned int xsize;
218  unsigned int ysize;
219  unsigned int zsize;
220  };
228  void GetAllDimensions(ipl_dimensions & dim);
229 
230  ipl_dimensions m_OldDim, m_NewDim;
231 #endif
232 
238  ImageIOBase::ByteOrder CheckAnalyzeEndian(const struct dsr & temphdr);
239 
241  struct dsr m_Hdr;
243 };
244 extern const char *const ANALYZE_ScanNumber;
245 extern const char *const ANALYZE_O_MAX;
246 extern const char *const ANALYZE_O_MIN;
247 extern const char *const ANALYZE_S_MAX;
248 extern const char *const ANALYZE_S_MIN;
249 extern const char *const ANALYZE_CAL_MAX;
250 extern const char *const ANALYZE_CAL_MIN;
251 extern const char *const ANALYZE_GLMAX;
252 extern const char *const ANALYZE_GLMIN;
253 extern const char *const ANALYZE_AUX_FILE_NAME;
254 extern const char *const ANALYZE_CALIBRATIONUNITS;
255 } // end namespace itk
256 
257 #endif // __itkAnalyzeImageIO_h
258