EMAN2
Public Member Functions | Public Attributes
EMAN::Region Class Reference

Region defines a 2D or 3D rectangular region specified by its origin coordinates and all edges' sizes. More...

#include <geometry.h>

Collaboration diagram for EMAN::Region:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Region ()
 Construct a null region with its origin at coordinate origins and its sizes to be 0.
 Region (int x, int xsize)
 Construct a 1D integer region.
 Region (int x, int y, int xsize, int ysize)
 Construct a 2D integer region.
 Region (int x, int y, int z, int xsize, int ysize, int zsize)
 Construct a 3D integer region.
 Region (float x, float xsize)
 Construct a 1D floating-number region.
 Region (float x, float y, float xsize, float ysize)
 Construct a 2D floating-number region.
 Region (float x, float y, float z, float xsize, float ysize, float zsize)
 Construct a 3D floating-number region.
 Region (double x, double xsize)
 Construct a 1D floating-number region.
 Region (double x, double y, double xsize, double ysize)
 Construct a 2D floating-number region.
 Region (double x, double y, double z, double xsize, double ysize, double zsize)
 Construct a 3D floating-number region.
 Region (const FloatPoint &o, const FloatSize &s)
 Construct a region given's orginal point and edge sizes.
 Region (const Region &r)
 ~Region ()
bool inside_region () const
 to check whether a point is inside this region
bool inside_region (const FloatPoint &p) const
bool inside_region (float x) const
bool inside_region (float x, float y) const
bool inside_region (float x, float y, float z) const
float get_width () const
 get the width
float get_height () const
 get the height
float get_depth () const
 get the depth
void set_width (const float &v)
 set the width
void set_height (const float &v)
 set the height
void set_depth (const float &v)
 set the depth
float x_origin () const
 get the x element of the origin
float y_origin () const
 get the y element of the origin
float z_origin () const
 get the z element of the origin
vector< float > get_size () const
 get the size of each dimension as a vector
vector< float > get_origin () const
 get the origin as a vector
void set_origin (const vector< float > &v)
 set the origin using a vector
bool is_region_in_box (const FloatSize &box) const
 To check whether 'this' region is inside a given box assuming the box's origins are (0,0,0).
int get_ndim () const
 Get the region's dimension.
string get_string () const
 Get the description of this region in a string.

Public Attributes

FloatPoint origin
FloatSize size

Detailed Description

Region defines a 2D or 3D rectangular region specified by its origin coordinates and all edges' sizes.

The coordinates and edge sizes can be integer or floating numbers.

Definition at line 500 of file geometry.h.


Constructor & Destructor Documentation

EMAN::Region::Region ( ) [inline]

Construct a null region with its origin at coordinate origins and its sizes to be 0.

Definition at line 506 of file geometry.h.

References origin, and size.

                {
                        origin = FloatPoint ();
                        size = FloatSize();
                }
EMAN::Region::Region ( int  x,
int  xsize 
) [inline]

Construct a 1D integer region.

Definition at line 514 of file geometry.h.

References origin, and size.

                {
                        origin = FloatPoint (x);
                        size = FloatSize(xsize);
                }
EMAN::Region::Region ( int  x,
int  y,
int  xsize,
int  ysize 
) [inline]

Construct a 2D integer region.

Definition at line 522 of file geometry.h.

References origin, and size.

                {
                        origin = FloatPoint (x, y);
                        size = FloatSize(xsize, ysize);
                }
EMAN::Region::Region ( int  x,
int  y,
int  z,
int  xsize,
int  ysize,
int  zsize 
) [inline]

Construct a 3D integer region.

Definition at line 530 of file geometry.h.

References origin, and size.

                {
                        origin = FloatPoint(x, y, z);
                        size = FloatSize(xsize, ysize, zsize);
                }
EMAN::Region::Region ( float  x,
float  xsize 
) [inline]

Construct a 1D floating-number region.

Definition at line 538 of file geometry.h.

References origin, and size.

                {
                        origin = FloatPoint (x);
                        size = FloatSize(xsize);
                }
EMAN::Region::Region ( float  x,
float  y,
float  xsize,
float  ysize 
) [inline]

Construct a 2D floating-number region.

Definition at line 546 of file geometry.h.

References origin, and size.

                {
                        origin = FloatPoint (x, y);
                        size = FloatSize(xsize, ysize);
                }
EMAN::Region::Region ( float  x,
float  y,
float  z,
float  xsize,
float  ysize,
float  zsize 
) [inline]

Construct a 3D floating-number region.

Definition at line 554 of file geometry.h.

References origin, and size.

                {
                        origin = FloatPoint(x, y, z);
                        size = FloatSize(xsize, ysize, zsize);
                }
EMAN::Region::Region ( double  x,
double  xsize 
) [inline]

Construct a 1D floating-number region.

Definition at line 562 of file geometry.h.

References origin, and size.

                {
                        origin = FloatPoint (x);
                        size = FloatSize(xsize);
                }
EMAN::Region::Region ( double  x,
double  y,
double  xsize,
double  ysize 
) [inline]

Construct a 2D floating-number region.

Definition at line 570 of file geometry.h.

References origin, and size.

                {
                        origin = FloatPoint (x, y);
                        size = FloatSize(xsize, ysize);
                }
EMAN::Region::Region ( double  x,
double  y,
double  z,
double  xsize,
double  ysize,
double  zsize 
) [inline]

Construct a 3D floating-number region.

Definition at line 578 of file geometry.h.

References origin, and size.

                {
                        origin = FloatPoint(x, y, z);
                        size = FloatSize(xsize, ysize, zsize);
                }
EMAN::Region::Region ( const FloatPoint o,
const FloatSize s 
) [inline]

Construct a region given's orginal point and edge sizes.

Definition at line 586 of file geometry.h.

                                                                :origin(o), size(s)
                {
                }
EMAN::Region::Region ( const Region r) [inline]

Definition at line 590 of file geometry.h.

References origin, and size.

                {
                        origin = r.origin;
                        size = r.size;
                }
EMAN::Region::~Region ( ) [inline]

Definition at line 597 of file geometry.h.

                          {
                }

Member Function Documentation

float EMAN::Region::get_depth ( ) const [inline]

get the depth

Definition at line 614 of file geometry.h.

References size.

Referenced by EMAN::EMData::extract_box(), and EMAN::EMData::read_image().

{ return size[2]; }
float EMAN::Region::get_height ( ) const [inline]

get the height

Definition at line 612 of file geometry.h.

References size.

Referenced by EMAN::EMData::extract_box(), and EMAN::EMData::read_image().

{ return size[1]; }
int EMAN::Region::get_ndim ( ) const [inline]

Get the region's dimension.

Returns:
The region's dimension.

Definition at line 648 of file geometry.h.

References EMAN::FloatPoint::get_ndim(), and origin.

Referenced by EMAN::ImageIO::check_region(), EMAN::EMData::get_clip(), EMAN::EMUtil::get_region_dims(), EMAN::EMUtil::get_region_origins(), EMAN::EMUtil::process_region_io(), and EMAN::MrcIO::read_mrc_header().

                {
                        return origin.get_ndim();
                }
vector<float> EMAN::Region::get_origin ( ) const [inline]

get the origin as a vector

Definition at line 633 of file geometry.h.

References origin.

Referenced by EMAN::EMUtil::process_region_io().

{ return origin; }
vector<float> EMAN::Region::get_size ( ) const [inline]

get the size of each dimension as a vector

Definition at line 631 of file geometry.h.

References size.

Referenced by EMAN::EMUtil::get_region_dims(), and EMAN::EMUtil::process_region_io().

{ return size; }
string Region::get_string ( ) const

Get the description of this region in a string.

Returns:
the description of this region in a string.

Definition at line 142 of file geometry.cpp.

References EMAN::FloatPoint::get_ndim(), origin, and size.

Referenced by EMAN::ImageIO::check_region().

{
        char str[1028];
        int ndim = origin.get_ndim();

        if (ndim == 2) {
                sprintf(str, "(%2.1f, %2.1f; %2.1f, %2.1f)",
                                origin[0], origin[1], size[0], size[1]);
        }
        else if (ndim == 3) {
                sprintf(str, "(%2.1f, %2.1f, %2.1f; %2.1f, %2.1f, %2.1f)",
                                origin[0], origin[1], origin[2], size[0], size[1], size[2]);
        }

        return string(str);
}
float EMAN::Region::get_width ( ) const [inline]

get the width

Definition at line 610 of file geometry.h.

References size.

Referenced by EMAN::EMData::extract_box(), and EMAN::EMData::read_image().

{ return size[0]; }
bool Region::inside_region ( const FloatPoint p) const

Definition at line 77 of file geometry.cpp.

References EMAN::FloatPoint::get_ndim(), and inside_region().

{
        if (p.get_ndim() == 1) {
                return inside_region(p[0]);
        }


        if (p.get_ndim() == 2) {
                return inside_region(p[0], p[1]);
        }

        return inside_region(p[0], p[1], p[2]);
}
bool Region::inside_region ( float  x,
float  y 
) const

Definition at line 101 of file geometry.cpp.

References origin, and size.

{
        if (size[0] >= 0 && size[1] >= 0 &&
                origin[0] <= x && origin[1] <= y &&
                (origin[0] + size[0]) > x && (origin[1] + size[1]) > y) {
                return true;
        }
        return false;
}
bool Region::inside_region ( float  x,
float  y,
float  z 
) const

Definition at line 115 of file geometry.cpp.

References origin, and size.

{
        if (size[0] >= 0 && size[1] >= 0 && size[2] >= 0 &&
                origin[0] <= x && origin[1] <= y && origin[2] <= z &&
                (origin[0] + size[0]) > x &&
                (origin[1] + size[1]) > y && (origin[2] + size[2]) > z) {
                return true;
        }
        return false;
}
bool Region::inside_region ( float  x) const

Definition at line 91 of file geometry.cpp.

References origin, and size.

{
        if (size[0] >= 0 && origin[0] <= x &&
                (origin[0] + size[0]) > x ) {
                return true;
        }
        return false;
}
bool Region::inside_region ( ) const

to check whether a point is inside this region

Definition at line 68 of file geometry.cpp.

References size.

Referenced by inside_region().

{
        if (size[0] >= 0 && size[1] >= 0 && size[2] >= 0) {
                return true;
        }

        return false;
}
bool Region::is_region_in_box ( const FloatSize box) const

To check whether 'this' region is inside a given box assuming the box's origins are (0,0,0).

Parameters:
boxThe nD rectangular box.
Returns:
True if 'this' region is inside the box; Otherwise, false.

Definition at line 127 of file geometry.cpp.

References origin, and size.

Referenced by EMAN::ImageIO::check_region().

{
        if (size[0] >= 0 && size[1] >= 0 && size[2] >= 0 &&
                origin[0] >= 0 && origin[1] >= 0 && origin[2] >= 0 &&
                (origin[0] + size[0]) <= box[0] &&
                (origin[1] + size[1]) <= box[1] &&
                (origin[2] + size[2]) <= box[2]) {
                return true;
        }

        return false;
}
void EMAN::Region::set_depth ( const float &  v) [inline]

set the depth

Definition at line 621 of file geometry.h.

References size, and v.

{ size[2] = v; }
void EMAN::Region::set_height ( const float &  v) [inline]

set the height

Definition at line 619 of file geometry.h.

References size, and v.

{ size[1] = v; }
void EMAN::Region::set_origin ( const vector< float > &  v) [inline]

set the origin using a vector

Definition at line 635 of file geometry.h.

References origin, and v.

{ origin = v; }
void EMAN::Region::set_width ( const float &  v) [inline]

set the width

Definition at line 617 of file geometry.h.

References size, and v.

{ size[0] = v; }
float EMAN::Region::x_origin ( ) const [inline]

get the x element of the origin

Definition at line 624 of file geometry.h.

References origin.

Referenced by EMAN::EMData::extract_box().

{ return origin[0]; }
float EMAN::Region::y_origin ( ) const [inline]

get the y element of the origin

Definition at line 626 of file geometry.h.

References origin.

Referenced by EMAN::EMData::extract_box().

{ return origin[1]; }
float EMAN::Region::z_origin ( ) const [inline]

get the z element of the origin

Definition at line 628 of file geometry.h.

References origin.

Referenced by EMAN::EMData::extract_box().

{ return origin[2]; }

Member Data Documentation


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