EMAN::OmapIO Class Reference

DSN6 MAP is composed of a series of records which are all 512 bytes long. More...

#include <omapio.h>

Inheritance diagram for EMAN::OmapIO:

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

Collaboration graph
[legend]
List of all members.

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

Detailed Description

DSN6 MAP is composed of a series of records which are all 512 bytes long.

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.


Constructor & Destructor Documentation

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

Definition at line 49 of file omapio.cpp.

References omapfile.

00050 {
00051         if (omapfile) {
00052                 fclose(omapfile);
00053                 omapfile = 0;
00054         }
00055 }


Member Function Documentation

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 }


Member Data Documentation

EMAN::OmapIO::DEFINE_IMAGEIO_FUNC

Definition at line 60 of file omapio.h.

string EMAN::OmapIO::filename [private]

Definition at line 91 of file omapio.h.

bool EMAN::OmapIO::initialized [private]

Definition at line 97 of file omapio.h.

bool EMAN::OmapIO::is_big_endian [private]

Definition at line 96 of file omapio.h.

Referenced by OmapIO().

bool EMAN::OmapIO::is_new_file [private]

Definition at line 98 of file omapio.h.

FILE* EMAN::OmapIO::omapfile [private]

Definition at line 93 of file omapio.h.

Referenced by ~OmapIO().

OmapHeader EMAN::OmapIO::omaph [private]

Definition at line 94 of file omapio.h.

Referenced by OmapIO().

IOMode EMAN::OmapIO::rw_mode [private]

Definition at line 92 of file omapio.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 17 12:45:42 2011 for EMAN2 by  doxygen 1.4.7