Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

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

const string SECTION_MODE = "ZYX"
const int NFLOAT_PER_LINE = 6
const int INTEGER_SIZE = 8
const int FLOAT_SIZE = 12
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]
 

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 }


Member Function Documentation

bool XplorIO::is_valid const void *  first_block  )  [static]
 

Definition at line 152 of file xplorio.cpp.

References EMAN::Util::get_line_from_string().

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 }


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

EMAN::XplorIO::DEFINE_IMAGEIO_FUNC
 

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 57 of file xplorio.cpp.

bool EMAN::XplorIO::initialized [private]
 

Definition at line 79 of file xplorio.h.

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

Definition at line 56 of file xplorio.cpp.

bool EMAN::XplorIO::is_big_endian [private]
 

Definition at line 78 of file xplorio.h.

Referenced by XplorIO().

bool EMAN::XplorIO::is_new_file [private]
 

Definition at line 80 of file xplorio.h.

Referenced by XplorIO().

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

Definition at line 55 of file xplorio.cpp.

int EMAN::XplorIO::nlines_in_header [private]
 

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 58 of file xplorio.cpp.

IOMode EMAN::XplorIO::rw_mode [private]
 

Definition at line 75 of file xplorio.h.

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

Definition at line 54 of file xplorio.cpp.

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:
Generated on Tue Jun 11 13:43:15 2013 for EMAN2 by  doxygen 1.3.9.1