EMAN2
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
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]

Classes

struct  OmapHeader
 The data in the header is composed of 256 short integers. More...
 

Public Member Functions

 OmapIO (const string &fname, IOMode rw_mode=READ_ONLY)
 
 ~OmapIO ()
 
- Public Member Functions inherited from EMAN::ImageIO
 ImageIO (const string &fname, IOMode rw)
 
virtual ~ImageIO ()
 
virtual int read_header (Dict &dict, int image_index=0, const Region *area=0, bool is_3d=false)=0
 Read the header from an image. More...
 
virtual int write_header (const Dict &dict, int image_index=0, const Region *area=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true)=0
 Write a header to an image. More...
 
virtual int read_data (float *data, int image_index=0, const Region *area=0, bool is_3d=false)=0
 Read the data from an image. More...
 
virtual int read_data_8bit (unsigned char *data, int image_index=0, const Region *area=0, bool is_3d=false, float minval=0.0f, float maxval=0.0f)
 Read the data from an image as an 8 bit array, regardless of format. More...
 
virtual int write_data (float *data, int image_index=0, const Region *area=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true)=0
 Write data to an image. More...
 
virtual int read_ctf (Ctf &ctf, int image_index=0)
 Read CTF data from this image. More...
 
virtual void write_ctf (const Ctf &ctf, int image_index=0)
 Write CTF data to this image. More...
 
virtual void flush ()=0
 Flush the IO buffer. More...
 
virtual int get_nimg ()
 Return the number of images in this image file. More...
 
virtual bool is_complex_mode ()=0
 Is this an complex image or not. More...
 
virtual bool is_image_big_endian ()=0
 Is this image in big endian or not. More...
 
virtual bool is_single_image_format () const
 Is this image format only storing 1 image or not. More...
 
template<class T >
void become_host_endian (T *data, size_t n=1)
 Convert data of this image into host endian format. More...
 
string get_filename () const
 

Static Public Member Functions

static bool is_valid (const void *first_block, off_t file_size=0)
 

Public Attributes

 DEFINE_IMAGEIO_FUNC
 

Private Attributes

OmapHeader omaph
 
bool is_big_endian
 
bool is_new_file
 

Additional Inherited Members

- Public Types inherited from EMAN::ImageIO
enum  IOMode { READ_ONLY = 1 , READ_WRITE = 2 , WRITE_ONLY = 3 }
 
- Protected Member Functions inherited from EMAN::ImageIO
virtual void init ()=0
 Do some initialization before doing the read/write. More...
 
void check_read_access (int image_index)
 Validate 'image_index' in file reading. More...
 
void check_read_access (int image_index, const float *data)
 Validate 'image_index' and 'data' in file reading. More...
 
void check_write_access (IOMode rw_mode, int image_index, int max_nimg=0)
 Validate rw_mode and image_index in file writing. More...
 
void check_write_access (IOMode rw_mode, int image_index, int max_nimg, const float *data)
 Validate rw_mode, image_index, and data pointer in file writing. More...
 
void check_region (const Region *area, const FloatSize &max_size, bool is_new_file=false, bool inbounds_only=true)
 Validate image I/O region. More...
 
void check_region (const Region *area, const IntSize &max_size, bool is_new_file=false, bool inbounds_only=true)
 Validate image I/O region. More...
 
FILE * sfopen (const string &filename, IOMode mode, bool *is_new=0, bool overwrite=false)
 Run fopen safely. More...
 
- Protected Attributes inherited from EMAN::ImageIO
string filename
 
IOMode rw_mode
 
FILE * file = nullptr
 
bool initialized = false
 

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 50 of file omapio.h.

Constructor & Destructor Documentation

◆ OmapIO()

OmapIO::OmapIO ( const string &  fname,
IOMode  rw_mode = READ_ONLY 
)
explicit

Definition at line 37 of file omapio.cpp.

37 :
38 ImageIO(fname, rw),
39 is_big_endian(false), is_new_file(false)
40{
41 memset(&omaph, 0, sizeof(OmapHeader));
43}
static bool is_host_big_endian()
Definition: byteorder.cpp:40
ImageIO(const string &fname, IOMode rw)
Definition: imageio.cpp:40
OmapHeader omaph
Definition: omapio.h:92
bool is_big_endian
Definition: omapio.h:94
bool is_new_file
Definition: omapio.h:95

References is_big_endian, EMAN::ByteOrder::is_host_big_endian(), and omaph.

◆ ~OmapIO()

OmapIO::~OmapIO ( )

Definition at line 45 of file omapio.cpp.

46{
47 if (file) {
48 fclose(file);
49 file = 0;
50 }
51}
FILE * file
Definition: imageio.h:354

References EMAN::ImageIO::file.

Member Function Documentation

◆ is_valid()

bool OmapIO::is_valid ( const void *  first_block,
off_t  file_size = 0 
)
static

Definition at line 236 of file omapio.cpp.

237{
238 ENTERFUNC;
239
240 if (!first_block) {
241 return false;
242 }
243
244 const short *data = static_cast < const short *>(first_block);
245 short xstart = data[0];
246 short ystart = data[1];
247 short zstart = data[2];
248 short nx = data[3];
249 short ny = data[4];
250 short nz = data[5];
251 short const_value = data[18];
252
254 ByteOrder::swap_bytes(&xstart);
255 ByteOrder::swap_bytes(&ystart);
256 ByteOrder::swap_bytes(&zstart);
260 ByteOrder::swap_bytes(&const_value);
261 }
262
263 if(const_value != 100) return false;
264 if(nx<=0 || ny<=0 || nz<=0 || nx>10000 || ny>10000 || nz>10000) return false;
265
266 EXITFUNC;
267 return true;
268}
static void swap_bytes(T *data, size_t n=1)
swap the byte order of data with 'n' T-type elements.
Definition: byteorder.h:131
#define ENTERFUNC
Definition: log.h:48
#define EXITFUNC
Definition: log.h:49

References ENTERFUNC, EXITFUNC, EMAN::ByteOrder::is_host_big_endian(), and EMAN::ByteOrder::swap_bytes().

Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type().

Member Data Documentation

◆ DEFINE_IMAGEIO_FUNC

EMAN::OmapIO::DEFINE_IMAGEIO_FUNC

Definition at line 56 of file omapio.h.

◆ is_big_endian

bool EMAN::OmapIO::is_big_endian
private

Definition at line 94 of file omapio.h.

Referenced by OmapIO().

◆ is_new_file

bool EMAN::OmapIO::is_new_file
private

Definition at line 95 of file omapio.h.

◆ omaph

OmapHeader EMAN::OmapIO::omaph
private

Definition at line 92 of file omapio.h.

Referenced by OmapIO().


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