core/vnl/vnl_matlab_header.h

Go to the documentation of this file.
00001 // This is core/vnl/vnl_matlab_header.h
00002 #ifndef vnl_matlab_header_h_
00003 #define vnl_matlab_header_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 //  \file
00009 //  \brief MATLAB header structure
00010 //  \author fsm
00011 // \verbatim
00012 //  Modifications
00013 //   21 Apr 2009 Kent Williams - Taking care of the byte ordering of the MAT file
00014 // \endverbatim
00015 
00016 #include <vxl_config.h>
00017 
00018 struct vnl_matlab_header
00019 {
00020   vxl_int_32 type; // sum of one byte order, one storage specifier and one precision specifier
00021   vxl_int_32 rows;
00022   vxl_int_32 cols;
00023   vxl_int_32 imag;
00024   vxl_int_32 namlen;
00025 
00026   enum type_t {
00027     // precision specifier
00028     vnl_DOUBLE_PRECISION = 0,
00029     vnl_SINGLE_PRECISION = 10,
00030     // storage specifier
00031     vnl_COLUMN_WISE = 0,
00032     vnl_ROW_WISE    = 100,
00033     // byte order
00034     vnl_LITTLE_ENDIAN = 0,
00035     vnl_BIG_ENDIAN    = 1000,
00036     //
00037     vnl_none = 0
00038   };
00039 };
00040 
00041 namespace byteswap // byteswap routines, stolen from ITK
00042 {
00043  inline void
00044  swap32(void *ptr)
00045  {
00046   char one_byte;
00047   char *p = reinterpret_cast<char *>(ptr);
00048   one_byte = p[0]; p[0] = p[3]; p[3] = one_byte;
00049   one_byte = p[1]; p[1] = p[2]; p[2] = one_byte;
00050  }
00051  inline void
00052  swap64(void *ptr)
00053  {
00054   char one_byte;
00055   char *p = reinterpret_cast<char *>(ptr);
00056   one_byte = p[0]; p[0] = p[7]; p[7] = one_byte;
00057   one_byte = p[1]; p[1] = p[6]; p[6] = one_byte;
00058   one_byte = p[2]; p[2] = p[5]; p[5] = one_byte;
00059   one_byte = p[3]; p[3] = p[4]; p[4] = one_byte;
00060  }
00061 }
00062 
00063 #endif // vnl_matlab_header_h_

Generated on Mon Mar 8 05:06:45 2010 for core/vnl by  doxygen 1.5.1