#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 169 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().
00170 { 00171 ENTERFUNC; 00172 00173 if (!first_block) { 00174 return false; 00175 } 00176 00177 const short *data = static_cast < const short *>(first_block); 00178 short xstart = data[0]; 00179 short ystart = data[1]; 00180 short zstart = data[2]; 00181 short nx = data[3]; 00182 short ny = data[4]; 00183 short nz = data[5]; 00184 short const_value = data[18]; 00185 00186 if(!ByteOrder::is_host_big_endian()) { 00187 ByteOrder::swap_bytes(&xstart); 00188 ByteOrder::swap_bytes(&ystart); 00189 ByteOrder::swap_bytes(&zstart); 00190 ByteOrder::swap_bytes(&nx); 00191 ByteOrder::swap_bytes(&ny); 00192 ByteOrder::swap_bytes(&nz); 00193 ByteOrder::swap_bytes(&const_value); 00194 } 00195 00196 std::cout << "const_value = " << const_value 00197 << ", xstart = " << xstart 00198 << ", ystart = " << ystart 00199 << ", zstart = " << zstart 00200 << ", nx = " << nx 00201 << ", ny = " << ny 00202 << ", nz = " << nz 00203 << std::endl; 00204 00205 if(const_value != 100) return false; 00206 if(nx<=0 || ny<=0 || nz<=0 || nx>10000 || ny>10000 || nz>10000) return false; 00207 00208 EXITFUNC; 00209 return true; 00210 }
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] |