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

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.

00507                 {
00508                         origin = FloatPoint ();
00509                         size = FloatSize();
00510                 }

EMAN::Region::Region int  x,
int  xsize
[inline]
 

Construct a 1D integer region.

Definition at line 514 of file geometry.h.

References x.

00515                 {
00516                         origin = FloatPoint (x);
00517                         size = FloatSize(xsize);
00518                 }

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 x, and y.

00523                 {
00524                         origin = FloatPoint (x, y);
00525                         size = FloatSize(xsize, ysize);
00526                 }

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 x, and y.

00531                 {
00532                         origin = FloatPoint(x, y, z);
00533                         size = FloatSize(xsize, ysize, zsize);
00534                 }

EMAN::Region::Region float  x,
float  xsize
[inline]
 

Construct a 1D floating-number region.

Definition at line 538 of file geometry.h.

References x.

00539                 {
00540                         origin = FloatPoint (x);
00541                         size = FloatSize(xsize);
00542                 }

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 x, and y.

00547                 {
00548                         origin = FloatPoint (x, y);
00549                         size = FloatSize(xsize, ysize);
00550                 }

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 x, and y.

00555                 {
00556                         origin = FloatPoint(x, y, z);
00557                         size = FloatSize(xsize, ysize, zsize);
00558                 }

EMAN::Region::Region double  x,
double  xsize
[inline]
 

Construct a 1D floating-number region.

Definition at line 562 of file geometry.h.

References x.

00563                 {
00564                         origin = FloatPoint (x);
00565                         size = FloatSize(xsize);
00566                 }

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 x, and y.

00571                 {
00572                         origin = FloatPoint (x, y);
00573                         size = FloatSize(xsize, ysize);
00574                 }

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 x, and y.

00579                 {
00580                         origin = FloatPoint(x, y, z);
00581                         size = FloatSize(xsize, ysize, zsize);
00582                 }

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.

00586                                                                 :origin(o), size(s)
00587                 {
00588                 }

EMAN::Region::Region const Region r  )  [inline]
 

Definition at line 590 of file geometry.h.

References origin, and size.

00591                 {
00592                         origin = r.origin;
00593                         size = r.size;
00594                 }

EMAN::Region::~Region  )  [inline]
 

Definition at line 597 of file geometry.h.

00597                           {
00598                 }


Member Function Documentation

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

get the depth

Definition at line 614 of file geometry.h.

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

00614 { return size[2]; }

float EMAN::Region::get_height  )  const [inline]
 

get the height

Definition at line 612 of file geometry.h.

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

00612 { 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::FloatSize::get_ndim().

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

00649                 {
00650                         return origin.get_ndim();
00651                 }

vector<float> EMAN::Region::get_origin  )  const [inline]
 

get the origin as a vector

Definition at line 633 of file geometry.h.

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

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

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

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

00143 {
00144         char str[1028];
00145         int ndim = origin.get_ndim();
00146 
00147         if (ndim == 2) {
00148                 sprintf(str, "(%2.1f, %2.1f; %2.1f, %2.1f)",
00149                                 origin[0], origin[1], size[0], size[1]);
00150         }
00151         else if (ndim == 3) {
00152                 sprintf(str, "(%2.1f, %2.1f, %2.1f; %2.1f, %2.1f, %2.1f)",
00153                                 origin[0], origin[1], origin[2], size[0], size[1], size[2]);
00154         }
00155 
00156         return string(str);
00157 }

float EMAN::Region::get_width  )  const [inline]
 

get the width

Definition at line 610 of file geometry.h.

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

00610 { return size[0]; }

bool Region::inside_region float  x,
float  y,
float  z
const
 

Definition at line 115 of file geometry.cpp.

References origin, size, x, and y.

00116 {
00117         if (size[0] >= 0 && size[1] >= 0 && size[2] >= 0 &&
00118                 origin[0] <= x && origin[1] <= y && origin[2] <= z &&
00119                 (origin[0] + size[0]) > x &&
00120                 (origin[1] + size[1]) > y && (origin[2] + size[2]) > z) {
00121                 return true;
00122         }
00123         return false;
00124 }

bool Region::inside_region float  x,
float  y
const
 

Definition at line 101 of file geometry.cpp.

References origin, size, x, and y.

00102 {
00103         if (size[0] >= 0 && size[1] >= 0 &&
00104                 origin[0] <= x && origin[1] <= y &&
00105                 (origin[0] + size[0]) > x && (origin[1] + size[1]) > y) {
00106                 return true;
00107         }
00108         return false;
00109 }

bool Region::inside_region float  x  )  const
 

Definition at line 91 of file geometry.cpp.

References origin, size, and x.

00092 {
00093         if (size[0] >= 0 && origin[0] <= x &&
00094                 (origin[0] + size[0]) > x ) {
00095                 return true;
00096         }
00097         return false;
00098 }

bool Region::inside_region const FloatPoint p  )  const
 

Definition at line 77 of file geometry.cpp.

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

00078 {
00079         if (p.get_ndim() == 1) {
00080                 return inside_region(p[0]);
00081         }
00082 
00083 
00084         if (p.get_ndim() == 2) {
00085                 return inside_region(p[0], p[1]);
00086         }
00087 
00088         return inside_region(p[0], p[1], p[2]);
00089 }

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

00069 {
00070         if (size[0] >= 0 && size[1] >= 0 && size[2] >= 0) {
00071                 return true;
00072         }
00073 
00074         return false;
00075 }

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:
box The 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().

00128 {
00129         if (size[0] >= 0 && size[1] >= 0 && size[2] >= 0 &&
00130                 origin[0] >= 0 && origin[1] >= 0 && origin[2] >= 0 &&
00131                 (origin[0] + size[0]) <= box[0] &&
00132                 (origin[1] + size[1]) <= box[1] &&
00133                 (origin[2] + size[2]) <= box[2]) {
00134                 return true;
00135         }
00136 
00137         return false;
00138 }

void EMAN::Region::set_depth const float &  v  )  [inline]
 

set the depth

Definition at line 621 of file geometry.h.

00621 { size[2] = v; }

void EMAN::Region::set_height const float &  v  )  [inline]
 

set the height

Definition at line 619 of file geometry.h.

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

00635 { origin = v; }

void EMAN::Region::set_width const float &  v  )  [inline]
 

set the width

Definition at line 617 of file geometry.h.

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

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

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

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

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

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

00628 { return origin[2]; }


Member Data Documentation

FloatPoint EMAN::Region::origin
 

Definition at line 658 of file geometry.h.

Referenced by EMAN::EMData::clip_inplace(), EMAN::EMData::get_clip(), EMAN::EMUtil::get_region_origins(), get_string(), EMAN::EMData::insert_clip(), EMAN::TestTomoImage::insert_rectangle(), inside_region(), is_region_in_box(), EMAN::EMUtil::process_ascii_region_io(), EMAN::MrcIO::read_mrc_header(), and Region().

FloatSize EMAN::Region::size
 

Definition at line 659 of file geometry.h.

Referenced by EMAN::EMData::clip_inplace(), EMAN::EMData::get_clip(), get_string(), EMAN::EMData::insert_clip(), EMAN::TestTomoImage::insert_rectangle(), inside_region(), is_region_in_box(), and Region().


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:42:04 2013 for EMAN2 by  doxygen 1.3.9.1