Tesseract
3.02
|
#include <rect.h>
Public Member Functions | |
TBOX () | |
TBOX (const ICOORD pt1, const ICOORD pt2) | |
TBOX (inT16 left, inT16 bottom, inT16 right, inT16 top) | |
TBOX (const FCOORD pt) | |
bool | null_box () const |
bool | operator== (const TBOX &other) const |
inT16 | top () const |
void | set_top (int y) |
inT16 | bottom () const |
void | set_bottom (int y) |
inT16 | left () const |
void | set_left (int x) |
inT16 | right () const |
void | set_right (int x) |
const ICOORD & | botleft () const |
ICOORD | botright () const |
ICOORD | topleft () const |
const ICOORD & | topright () const |
inT16 | height () const |
inT16 | width () const |
inT32 | area () const |
void | pad (int xpad, int ypad) |
void | move_bottom_edge (const inT16 y) |
void | move_left_edge (const inT16 x) |
void | move_right_edge (const inT16 x) |
void | move_top_edge (const inT16 y) |
void | move (const ICOORD vec) |
void | move (const FCOORD vec) |
void | scale (const float f) |
void | scale (const FCOORD vec) |
void | rotate (const FCOORD &vec) |
void | rotate_large (const FCOORD &vec) |
bool | contains (const FCOORD pt) const |
bool | contains (const TBOX &box) const |
bool | overlap (const TBOX &box) const |
bool | major_overlap (const TBOX &box) const |
bool | x_overlap (const TBOX &box) const |
int | x_gap (const TBOX &box) const |
int | y_gap (const TBOX &box) const |
bool | major_x_overlap (const TBOX &box) const |
bool | y_overlap (const TBOX &box) const |
bool | major_y_overlap (const TBOX &box) const |
double | overlap_fraction (const TBOX &box) const |
double | x_overlap_fraction (const TBOX &box) const |
double | y_overlap_fraction (const TBOX &box) const |
bool | x_almost_equal (const TBOX &box, int tolerance) const |
bool | almost_equal (const TBOX &box, int tolerance) const |
TBOX | intersection (const TBOX &box) const |
TBOX | bounding_union (const TBOX &box) const |
void | set_to_given_coords (int x_min, int y_min, int x_max, int y_max) |
void | print () const |
void | append_debug (STRING *str) const |
void | plot (ScrollView *fd) const |
void | plot (ScrollView *fd, ScrollView::Color fill_colour, ScrollView::Color border_colour) const |
bool | Serialize (FILE *fp) const |
bool | DeSerialize (bool swap, FILE *fp) |
Friends | |
TBOX & | operator+= (TBOX &, const TBOX &) |
TBOX & | operator&= (TBOX &, const TBOX &) |
TBOX::TBOX | ( | ) | [inline] |
Definition at line 33 of file rect.cpp.
{ if (pt1.x () <= pt2.x ()) { if (pt1.y () <= pt2.y ()) { bot_left = pt1; top_right = pt2; } else { bot_left = ICOORD (pt1.x (), pt2.y ()); top_right = ICOORD (pt2.x (), pt1.y ()); } } else { if (pt1.y () <= pt2.y ()) { bot_left = ICOORD (pt2.x (), pt1.y ()); top_right = ICOORD (pt1.x (), pt2.y ()); } else { bot_left = pt2; top_right = pt1; } } }
TBOX::TBOX | ( | const FCOORD | pt | ) | [inline] |
bool TBOX::almost_equal | ( | const TBOX & | box, |
int | tolerance | ||
) | const |
void TBOX::append_debug | ( | STRING * | str | ) | const [inline] |
inT32 TBOX::area | ( | ) | const [inline] |
const ICOORD& TBOX::botleft | ( | ) | const [inline] |
ICOORD TBOX::botright | ( | ) | const [inline] |
inT16 TBOX::bottom | ( | ) | const [inline] |
Definition at line 130 of file rect.cpp.
{ ICOORD bl; //bottom left ICOORD tr; //top right if (box.bot_left.x () < bot_left.x ()) bl.set_x (box.bot_left.x ()); else bl.set_x (bot_left.x ()); if (box.top_right.x () > top_right.x ()) tr.set_x (box.top_right.x ()); else tr.set_x (top_right.x ()); if (box.bot_left.y () < bot_left.y ()) bl.set_y (box.bot_left.y ()); else bl.set_y (bot_left.y ()); if (box.top_right.y () > top_right.y ()) tr.set_y (box.top_right.y ()); else tr.set_y (top_right.y ()); return TBOX (bl, tr); }
bool TBOX::contains | ( | const FCOORD | pt | ) | const [inline] |
bool TBOX::contains | ( | const TBOX & | box | ) | const [inline] |
bool TBOX::DeSerialize | ( | bool | swap, |
FILE * | fp | ||
) |
Definition at line 183 of file rect.cpp.
{ if (!bot_left.DeSerialize(swap, fp)) return false; if (!top_right.DeSerialize(swap, fp)) return false; return true; }
inT16 TBOX::height | ( | ) | const [inline] |
Definition at line 88 of file rect.cpp.
{ inT16 left; inT16 bottom; inT16 right; inT16 top; if (overlap (box)) { if (box.bot_left.x () > bot_left.x ()) left = box.bot_left.x (); else left = bot_left.x (); if (box.top_right.x () < top_right.x ()) right = box.top_right.x (); else right = top_right.x (); if (box.bot_left.y () > bot_left.y ()) bottom = box.bot_left.y (); else bottom = bot_left.y (); if (box.top_right.y () < top_right.y ()) top = box.top_right.y (); else top = top_right.y (); } else { left = MAX_INT16; bottom = MAX_INT16; top = -MAX_INT16; right = -MAX_INT16; } return TBOX (left, bottom, right, top); }
inT16 TBOX::left | ( | ) | const [inline] |
bool TBOX::major_overlap | ( | const TBOX & | box | ) | const [inline] |
Definition at line 358 of file rect.h.
{ int overlap = MIN(box.top_right.x(), top_right.x()); overlap -= MAX(box.bot_left.x(), bot_left.x()); overlap += overlap; if (overlap < MIN(box.width(), width())) return false; overlap = MIN(box.top_right.y(), top_right.y()); overlap -= MAX(box.bot_left.y(), bot_left.y()); overlap += overlap; if (overlap < MIN(box.height(), height())) return false; return true; }
bool TBOX::major_x_overlap | ( | const TBOX & | box | ) | const [inline] |
bool TBOX::major_y_overlap | ( | const TBOX & | box | ) | const [inline] |
void TBOX::move | ( | const ICOORD | vec | ) | [inline] |
void TBOX::move | ( | const FCOORD | vec | ) | [inline] |
Definition at line 152 of file rect.h.
{ // by float vector bot_left.set_x ((inT16) floor (bot_left.x () + vec.x ())); // round left bot_left.set_y ((inT16) floor (bot_left.y () + vec.y ())); // round down top_right.set_x ((inT16) ceil (top_right.x () + vec.x ())); // round right top_right.set_y ((inT16) ceil (top_right.y () + vec.y ())); // round up }
void TBOX::move_bottom_edge | ( | const inT16 | y | ) | [inline] |
void TBOX::move_left_edge | ( | const inT16 | x | ) | [inline] |
void TBOX::move_right_edge | ( | const inT16 | x | ) | [inline] |
void TBOX::move_top_edge | ( | const inT16 | y | ) | [inline] |
bool TBOX::null_box | ( | ) | const [inline] |
bool TBOX::operator== | ( | const TBOX & | other | ) | const [inline] |
bool TBOX::overlap | ( | const TBOX & | box | ) | const [inline] |
double TBOX::overlap_fraction | ( | const TBOX & | box | ) | const [inline] |
void TBOX::pad | ( | int | xpad, |
int | ypad | ||
) | [inline] |
void TBOX::plot | ( | ScrollView * | fd | ) | const [inline] |
void TBOX::plot | ( | ScrollView * | fd, |
ScrollView::Color | fill_colour, | ||
ScrollView::Color | border_colour | ||
) | const |
void TBOX::print | ( | ) | const [inline] |
inT16 TBOX::right | ( | ) | const [inline] |
void TBOX::rotate | ( | const FCOORD & | vec | ) | [inline] |
void TBOX::rotate_large | ( | const FCOORD & | vec | ) |
void TBOX::scale | ( | const float | f | ) | [inline] |
void TBOX::scale | ( | const FCOORD | vec | ) | [inline] |
bool TBOX::Serialize | ( | FILE * | fp | ) | const |
void TBOX::set_bottom | ( | int | y | ) | [inline] |
void TBOX::set_right | ( | int | x | ) | [inline] |
void TBOX::set_to_given_coords | ( | int | x_min, |
int | y_min, | ||
int | x_max, | ||
int | y_max | ||
) | [inline] |
inT16 TBOX::top | ( | ) | const [inline] |
ICOORD TBOX::topleft | ( | ) | const [inline] |
const ICOORD& TBOX::topright | ( | ) | const [inline] |
inT16 TBOX::width | ( | ) | const [inline] |
bool TBOX::x_almost_equal | ( | const TBOX & | box, |
int | tolerance | ||
) | const |
int TBOX::x_gap | ( | const TBOX & | box | ) | const [inline] |
bool TBOX::x_overlap | ( | const TBOX & | box | ) | const [inline] |
double TBOX::x_overlap_fraction | ( | const TBOX & | box | ) | const [inline] |
int TBOX::y_gap | ( | const TBOX & | box | ) | const [inline] |
bool TBOX::y_overlap | ( | const TBOX & | box | ) | const [inline] |
double TBOX::y_overlap_fraction | ( | const TBOX & | box | ) | const [inline] |
Definition at line 221 of file rect.cpp.
{ if (op1.overlap (op2)) { if (op2.bot_left.x () > op1.bot_left.x ()) op1.bot_left.set_x (op2.bot_left.x ()); if (op2.top_right.x () < op1.top_right.x ()) op1.top_right.set_x (op2.top_right.x ()); if (op2.bot_left.y () > op1.bot_left.y ()) op1.bot_left.set_y (op2.bot_left.y ()); if (op2.top_right.y () < op1.top_right.y ()) op1.top_right.set_y (op2.top_right.y ()); } else { op1.bot_left.set_x (MAX_INT16); op1.bot_left.set_y (MAX_INT16); op1.top_right.set_x (-MAX_INT16); op1.top_right.set_y (-MAX_INT16); } return op1; }
Definition at line 196 of file rect.cpp.
{ if (op2.bot_left.x () < op1.bot_left.x ()) op1.bot_left.set_x (op2.bot_left.x ()); if (op2.top_right.x () > op1.top_right.x ()) op1.top_right.set_x (op2.top_right.x ()); if (op2.bot_left.y () < op1.bot_left.y ()) op1.bot_left.set_y (op2.bot_left.y ()); if (op2.top_right.y () > op1.top_right.y ()) op1.top_right.set_y (op2.top_right.y ()); return op1; }