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

00241 {
00242         ENTERFUNC;
00243 
00244         if (!first_block) {
00245                 return false;
00246         }
00247 
00248         const short *data = static_cast < const short *>(first_block);
00249         short xstart = data[0];
00250         short ystart = data[1];
00251         short zstart = data[2];
00252         short nx = data[3];
00253         short ny = data[4];
00254         short nz = data[5];
00255         short const_value = data[18];
00256 
00257         if(!ByteOrder::is_host_big_endian()) {
00258                 ByteOrder::swap_bytes(&xstart);
00259                 ByteOrder::swap_bytes(&ystart);
00260                 ByteOrder::swap_bytes(&zstart);
00261                 ByteOrder::swap_bytes(&nx);
00262                 ByteOrder::swap_bytes(&ny);
00263                 ByteOrder::swap_bytes(&nz);
00264                 ByteOrder::swap_bytes(&const_value);
00265         }
00266 
00267         if(const_value != 100) return false;
00268         if(nx<=0 || ny<=0 || nz<=0 || nx>10000 || ny>10000 || nz>10000) return false;
00269 
00270         EXITFUNC;
00271         return true;
00272 }


Member Data Documentation

EMAN::OmapIO::DEFINE_IMAGEIO_FUNC

Definition at line 60 of file omapio.h.

string EMAN::OmapIO::filename [private]

Definition at line 96 of file omapio.h.

bool EMAN::OmapIO::initialized [private]

Definition at line 102 of file omapio.h.

bool EMAN::OmapIO::is_big_endian [private]

Definition at line 101 of file omapio.h.

Referenced by OmapIO().

bool EMAN::OmapIO::is_new_file [private]

Definition at line 103 of file omapio.h.

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

Definition at line 98 of file omapio.h.

Referenced by ~OmapIO().

OmapHeader EMAN::OmapIO::omaph [private]

Definition at line 99 of file omapio.h.

Referenced by OmapIO().

IOMode EMAN::OmapIO::rw_mode [private]

Definition at line 97 of file omapio.h.


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 12:43:18 2013 for EMAN2 by  doxygen 1.4.7