EMAN2
Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | Static Private Attributes
EMAN::XplorIO Class Reference

XPLOR image format is in ASCII: More...

#include <xplorio.h>

Inheritance diagram for EMAN::XplorIO:
Inheritance graph
[legend]
Collaboration diagram for EMAN::XplorIO:
Collaboration graph
[legend]

List of all members.

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"

Detailed Description

XPLOR image format is in ASCII:

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.


Constructor & Destructor Documentation

XplorIO::XplorIO ( const string &  filename,
IOMode  rw_mode = READ_ONLY 
) [explicit]
XplorIO::~XplorIO ( )

Definition at line 80 of file xplorio.cpp.

References xplor_file.

{
        if (xplor_file) {
                fclose(xplor_file);
                xplor_file = 0;
        }
}

Member Function Documentation

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().

{
        ENTERFUNC;
        if (!first_block) {
                return false;
        }
        char *buf = (char *)(first_block);
        string line1 = Util::get_line_from_string(&buf);
        bool result = true;

        if (line1.size() != 0) {
                result = false;
        }
        else {
                string line2 = Util::get_line_from_string(&buf);
                int ntitle = 0;

                if ((int)line2.size() != INTEGER_SIZE) {
                        result = false;
                }
                else {
                        ntitle = atoi(line2.c_str());
                        if (ntitle < 0 || ntitle > 50) {
                                result = false;
                        }

                        else {
                                for (int i = 0; i < ntitle+2; i++) {
                                        Util::get_line_from_string(&buf);
                                }

                                string modeline = Util::get_line_from_string(&buf);
                                if (modeline != SECTION_MODE) {
                                        result = false;
                                }
                        }
                }
        }

        EXITFUNC;
        return result;
}

Member Data Documentation

float EMAN::XplorIO::apix_x [private]

Definition at line 87 of file xplorio.h.

Referenced by XplorIO().

float EMAN::XplorIO::apix_y [private]

Definition at line 88 of file xplorio.h.

Referenced by XplorIO().

float EMAN::XplorIO::apix_z [private]

Definition at line 89 of file xplorio.h.

Referenced by XplorIO().

float EMAN::XplorIO::cell_alpha [private]

Definition at line 91 of file xplorio.h.

Referenced by XplorIO().

float EMAN::XplorIO::cell_beta [private]

Definition at line 92 of file xplorio.h.

Referenced by XplorIO().

float EMAN::XplorIO::cell_gama [private]

Definition at line 93 of file xplorio.h.

Referenced by XplorIO().

Definition at line 70 of file xplorio.h.

string EMAN::XplorIO::filename [private]

Definition at line 74 of file xplorio.h.

const int XplorIO::FLOAT_SIZE = 12 [static, private]

Definition at line 98 of file xplorio.h.

Definition at line 79 of file xplorio.h.

const int XplorIO::INTEGER_SIZE = 8 [static, private]

Definition at line 97 of file xplorio.h.

Referenced by is_valid().

Definition at line 78 of file xplorio.h.

Referenced by XplorIO().

Definition at line 80 of file xplorio.h.

Referenced by XplorIO().

const int XplorIO::NFLOAT_PER_LINE = 6 [static, private]

Definition at line 96 of file xplorio.h.

Definition at line 81 of file xplorio.h.

Referenced by XplorIO().

int EMAN::XplorIO::nx [private]

Definition at line 83 of file xplorio.h.

Referenced by XplorIO().

int EMAN::XplorIO::ny [private]

Definition at line 84 of file xplorio.h.

Referenced by XplorIO().

int EMAN::XplorIO::nz [private]

Definition at line 85 of file xplorio.h.

Referenced by XplorIO().

const char * XplorIO::OUTFORMAT = "%12.5E" [static, private]

Definition at line 99 of file xplorio.h.

Definition at line 75 of file xplorio.h.

const string XplorIO::SECTION_MODE = "ZYX" [static, private]

Definition at line 95 of file xplorio.h.

Referenced by is_valid().

FILE* EMAN::XplorIO::xplor_file [private]

Definition at line 76 of file xplorio.h.

Referenced by ~XplorIO().


The documentation for this class was generated from the following files: