#include <xplorio.h>
Inheritance diagram for EMAN::XplorIO:
Public Member Functions | |
XplorIO (const string &filename, IOMode rw_mode=READ_ONLY) | |
~XplorIO () | |
Static Public Member Functions | |
static bool | is_valid (const void *first_block) |
Public Attributes | |
DEFINE_IMAGEIO_FUNC | |
Private Attributes | |
string | filename |
IOMode | rw_mode |
FILE * | xplor_file |
bool | is_big_endian |
bool | initialized |
bool | is_new_file |
int | nlines_in_header |
int | nx |
int | ny |
int | nz |
float | apix_x |
float | apix_y |
float | apix_z |
float | cell_alpha |
float | cell_beta |
float | cell_gama |
Static Private Attributes | |
static const string | SECTION_MODE = "ZYX" |
static const int | NFLOAT_PER_LINE = 6 |
static const int | INTEGER_SIZE = 8 |
static const int | FLOAT_SIZE = 12 |
static const char * | OUTFORMAT = "%12.5E" |
1. header: (note: each integer takes 8 Bytes space, each float is 12.5E format.) line 1: empty line 2: int: number of lines for title (ntitle) next ntitle lines: string: titles line ntitle+3: 9 int: nx, xmin, xmax, ny, ymin, ymax, nz, zmin, zmax line ntitle+4: 6 float: cell size (x, y, z), cell angles (alpha, beta, gamma) line ntitle+5: string: ZYX (this is the section mode. always ZYX)
2. data
for zindex = 1 to nz: zindex nx*ny floats. each line has 6 floats. each float is in 12.5E format.
A XPLOR file contains one 2D or 3D image.
Definition at line 64 of file xplorio.h.
XplorIO::XplorIO | ( | const string & | filename, | |
IOMode | rw_mode = READ_ONLY | |||
) | [explicit] |
Definition at line 60 of file xplorio.cpp.
References apix_x, apix_y, apix_z, cell_alpha, cell_beta, cell_gama, is_big_endian, EMAN::ByteOrder::is_host_big_endian(), is_new_file, nlines_in_header, nx, ny, and nz.
00061 : filename(file), rw_mode(rw), xplor_file(0), initialized(false) 00062 { 00063 is_big_endian = ByteOrder::is_host_big_endian(); 00064 is_new_file = false; 00065 nlines_in_header = 0; 00066 00067 nx = 0; 00068 ny = 0; 00069 nz = 0; 00070 00071 apix_x = 0; 00072 apix_y = 0; 00073 apix_z = 0; 00074 00075 cell_alpha = 0; 00076 cell_beta = 0; 00077 cell_gama = 0; 00078 }
XplorIO::~XplorIO | ( | ) |
Definition at line 80 of file xplorio.cpp.
References xplor_file.
00081 { 00082 if (xplor_file) { 00083 fclose(xplor_file); 00084 xplor_file = 0; 00085 } 00086 }
bool XplorIO::is_valid | ( | const void * | first_block | ) | [static] |
Definition at line 152 of file xplorio.cpp.
References ENTERFUNC, EXITFUNC, EMAN::Util::get_line_from_string(), INTEGER_SIZE, and SECTION_MODE.
Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type().
00153 { 00154 ENTERFUNC; 00155 if (!first_block) { 00156 return false; 00157 } 00158 char *buf = (char *)(first_block); 00159 string line1 = Util::get_line_from_string(&buf); 00160 bool result = true; 00161 00162 if (line1.size() != 0) { 00163 result = false; 00164 } 00165 else { 00166 string line2 = Util::get_line_from_string(&buf); 00167 int ntitle = 0; 00168 00169 if ((int)line2.size() != INTEGER_SIZE) { 00170 result = false; 00171 } 00172 else { 00173 ntitle = atoi(line2.c_str()); 00174 if (ntitle < 0 || ntitle > 50) { 00175 result = false; 00176 } 00177 00178 else { 00179 for (int i = 0; i < ntitle+2; i++) { 00180 Util::get_line_from_string(&buf); 00181 } 00182 00183 string modeline = Util::get_line_from_string(&buf); 00184 if (modeline != SECTION_MODE) { 00185 result = false; 00186 } 00187 } 00188 } 00189 } 00190 00191 EXITFUNC; 00192 return result; 00193 }
float EMAN::XplorIO::apix_x [private] |
float EMAN::XplorIO::apix_y [private] |
float EMAN::XplorIO::apix_z [private] |
float EMAN::XplorIO::cell_alpha [private] |
float EMAN::XplorIO::cell_beta [private] |
float EMAN::XplorIO::cell_gama [private] |
string EMAN::XplorIO::filename [private] |
const int XplorIO::FLOAT_SIZE = 12 [static, private] |
bool EMAN::XplorIO::initialized [private] |
const int XplorIO::INTEGER_SIZE = 8 [static, private] |
bool EMAN::XplorIO::is_big_endian [private] |
bool EMAN::XplorIO::is_new_file [private] |
const int XplorIO::NFLOAT_PER_LINE = 6 [static, private] |
int EMAN::XplorIO::nlines_in_header [private] |
int EMAN::XplorIO::nx [private] |
int EMAN::XplorIO::ny [private] |
int EMAN::XplorIO::nz [private] |
const char * XplorIO::OUTFORMAT = "%12.5E" [static, private] |
IOMode EMAN::XplorIO::rw_mode [private] |
const string XplorIO::SECTION_MODE = "ZYX" [static, private] |
FILE* EMAN::XplorIO::xplor_file [private] |