ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkAnalyzeImageIO.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00030 #ifndef __itkAnalyzeImageIO_h
00031 #define __itkAnalyzeImageIO_h
00032 
00033 
00034 #include <fstream>
00035 #include "itkImageIOBase.h"
00036 #include "itkAnalyzeDbh.h"
00037 
00038 namespace itk
00039 {
00092 class ITK_EXPORT AnalyzeImageIO:public ImageIOBase
00093 {
00094 public:
00096   typedef AnalyzeImageIO       Self;
00097   typedef ImageIOBase          Superclass;
00098   typedef SmartPointer< Self > Pointer;
00099 
00101   itkNewMacro(Self);
00102 
00104   itkTypeMacro(AnalyzeImageIO, Superclass);
00105 
00106   /*-------- This part of the interfaces deals with reading data. ----- */
00107 
00114   virtual bool CanReadFile(const char *FileNameToRead);
00115 
00117   virtual void ReadImageInformation();
00118 
00120   virtual void Read(void *buffer);
00121 
00122   /*-------- This part of the interfaces deals with writing data. ----- */
00123 
00130   virtual bool CanWriteFile(const char *FileNameToWrite);
00131 
00133   virtual void WriteImageInformation();
00134 
00137   virtual void Write(const void *buffer);
00138 
00140   virtual std::vector< double > GetDirection(unsigned int i) const;
00141 
00144   virtual std::vector< double > GetDefaultDirection(unsigned int i) const;
00145 
00146 protected:
00147   AnalyzeImageIO();
00148   ~AnalyzeImageIO();
00149   void PrintSelf(std::ostream & os, Indent indent) const;
00150 
00151 private:
00167   typedef enum {
00168 
00185     } ValidAnalyzeOrientationFlags;
00186 
00187   AnalyzeImageIO(const Self &); //purposely not implemented
00188   void operator=(const Self &); //purposely not implemented
00189 
00190   void SwapBytesIfNecessary(void *buffer, SizeType numberOfPixels);
00191 
00198   void SwapHeaderBytesIfNecessary(struct dsr *const imageheader);
00199 
00205   void  DefineHeaderObjectDataType(void);
00206 
00207 #if defined( REORIENT_IMAGES )
00208   void ReorientIfNecessary(char *p);
00209 
00210   struct ipl_dimensions {
00211     unsigned int slicestride;
00212     unsigned int rowstride;
00213     unsigned int componentstride; x
00214     unsigned int pixelsize;
00215     //
00216     // xsize,ysize,zsize == size in each direction in pixesls
00217     unsigned int xsize;
00218     unsigned int ysize;
00219     unsigned int zsize;
00220   };
00228   void GetAllDimensions(ipl_dimensions & dim);
00229 
00230   ipl_dimensions m_OldDim, m_NewDim;
00231 #endif
00232 
00238   ImageIOBase::ByteOrder CheckAnalyzeEndian(const struct dsr & temphdr);
00239 
00241   struct dsr             m_Hdr;
00242   ImageIOBase::ByteOrder m_MachineByteOrder;
00243 };
00244 extern const char *const ANALYZE_ScanNumber;
00245 extern const char *const ANALYZE_O_MAX;
00246 extern const char *const ANALYZE_O_MIN;
00247 extern const char *const ANALYZE_S_MAX;
00248 extern const char *const ANALYZE_S_MIN;
00249 extern const char *const ANALYZE_CAL_MAX;
00250 extern const char *const ANALYZE_CAL_MIN;
00251 extern const char *const ANALYZE_GLMAX;
00252 extern const char *const ANALYZE_GLMIN;
00253 extern const char *const ANALYZE_AUX_FILE_NAME;
00254 extern const char *const ANALYZE_CALIBRATIONUNITS;
00255 } // end namespace itk
00256 
00257 #endif // __itkAnalyzeImageIO_h
00258