#include <omapio.h>
Inheritance diagram for EMAN::OmapIO:
Public Member Functions | |
OmapIO (const string &omapname, IOMode rw_mode=READ_ONLY) | |
~OmapIO () | |
Static Public Member Functions | |
static bool | is_valid (const void *first_block, off_t file_size=0) |
Public Attributes | |
DEFINE_IMAGEIO_FUNC | |
Private Attributes | |
string | filename |
IOMode | rw_mode |
FILE * | omapfile |
OmapHeader | omaph |
bool | is_big_endian |
bool | initialized |
bool | is_new_file |
Classes | |
struct | OmapHeader |
The data in the header is composed of 256 short integers. More... |
The first is a header which contains all the information required to intercept the rest of the file. The subsequent bricks contain blocks of electron density. Each density sample is one byte in size. The order of the samples within a brick is "x fast, y medium, and z slow". http://www.uoxray.uoregon.edu/tnt/manual/node104.html
Definition at line 54 of file omapio.h.
OmapIO::OmapIO | ( | const string & | omapname, | |
IOMode | rw_mode = READ_ONLY | |||
) | [explicit] |
Definition at line 41 of file omapio.cpp.
References is_big_endian, EMAN::ByteOrder::is_host_big_endian(), and omaph.
00041 : 00042 filename(omapname), rw_mode(rw), omapfile(0), 00043 is_big_endian(false), initialized(false), is_new_file(false) 00044 { 00045 memset(&omaph, 0, sizeof(OmapHeader)); 00046 is_big_endian = ByteOrder::is_host_big_endian(); 00047 }
OmapIO::~OmapIO | ( | ) |
bool OmapIO::is_valid | ( | const void * | first_block, | |
off_t | file_size = 0 | |||
) | [static] |
Definition at line 240 of file omapio.cpp.
References data, ENTERFUNC, EXITFUNC, EMAN::ByteOrder::is_host_big_endian(), nx, ny, and EMAN::ByteOrder::swap_bytes().
Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type().
00241 { 00242 ENTERFUNC; 00243 00244 if (!first_block) { 00245 return false; 00246 } 00247 00248 const short *data = static_cast < const short *>(first_block); 00249 short xstart = data[0]; 00250 short ystart = data[1]; 00251 short zstart = data[2]; 00252 short nx = data[3]; 00253 short ny = data[4]; 00254 short nz = data[5]; 00255 short const_value = data[18]; 00256 00257 if(!ByteOrder::is_host_big_endian()) { 00258 ByteOrder::swap_bytes(&xstart); 00259 ByteOrder::swap_bytes(&ystart); 00260 ByteOrder::swap_bytes(&zstart); 00261 ByteOrder::swap_bytes(&nx); 00262 ByteOrder::swap_bytes(&ny); 00263 ByteOrder::swap_bytes(&nz); 00264 ByteOrder::swap_bytes(&const_value); 00265 } 00266 00267 if(const_value != 100) return false; 00268 if(nx<=0 || ny<=0 || nz<=0 || nx>10000 || ny>10000 || nz>10000) return false; 00269 00270 EXITFUNC; 00271 return true; 00272 }
string EMAN::OmapIO::filename [private] |
bool EMAN::OmapIO::initialized [private] |
bool EMAN::OmapIO::is_big_endian [private] |
bool EMAN::OmapIO::is_new_file [private] |
FILE* EMAN::OmapIO::omapfile [private] |
OmapHeader EMAN::OmapIO::omaph [private] |
IOMode EMAN::OmapIO::rw_mode [private] |