#include <rect.h>
List of all members.
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) |
Detailed Description
Definition at line 29 of file rect.h.
Constructor & Destructor Documentation
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 {
top_right =
ICOORD (pt2.
x (), pt1.
y ());
}
}
else {
if (pt1.
y () <= pt2.
y ()) {
top_right =
ICOORD (pt1.
x (), pt2.
y ());
}
else {
bot_left = pt2;
top_right = pt1;
}
}
}
Member Function Documentation
bool TBOX::almost_equal |
( |
const TBOX & |
box, |
|
|
int |
tolerance |
|
) |
| const |
Definition at line 249 of file rect.cpp.
{
return (abs(
left() - box.
left()) <= tolerance &&
abs(
top() - box.
top()) <= tolerance &&
}
void TBOX::append_debug |
( |
STRING * |
str | ) |
const |
|
inline |
Definition at line 270 of file rect.h.
{
char buffer[256];
sprintf(buffer, "Bounding box=(%d,%d)->(%d,%d)\n",
*str += buffer;
}
inT32 TBOX::area |
( |
| ) |
const |
|
inline |
const ICOORD& TBOX::botleft |
( |
| ) |
const |
|
inline |
ICOORD TBOX::botright |
( |
| ) |
const |
|
inline |
Definition at line 85 of file rect.h.
{
return ICOORD (top_right.
x (), bot_left.
y ());
}
inT16 TBOX::bottom |
( |
| ) |
const |
|
inline |
TBOX TBOX::bounding_union |
( |
const TBOX & |
box | ) |
const |
Definition at line 130 of file rect.cpp.
{
if (box.bot_left.
x () < bot_left.
x ())
else
if (box.top_right.
x () > top_right.
x ())
tr.
set_x (box.top_right.
x ());
else
if (box.bot_left.
y () < bot_left.
y ())
else
if (box.top_right.
y () > top_right.
y ())
tr.
set_y (box.top_right.
y ());
else
}
bool TBOX::contains |
( |
const FCOORD |
pt | ) |
const |
|
inline |
Definition at line 323 of file rect.h.
{
return ((pt.
x () >= bot_left.
x ()) &&
(pt.
x () <= top_right.
x ()) &&
(pt.
y () >= bot_left.
y ()) && (pt.
y () <= top_right.
y ()));
}
bool TBOX::contains |
( |
const TBOX & |
box | ) |
const |
|
inline |
bool TBOX::DeSerialize |
( |
bool |
swap, |
|
|
FILE * |
fp |
|
) |
| |
inT16 TBOX::height |
( |
| ) |
const |
|
inline |
Definition at line 97 of file rect.h.
{
return top_right.
y () - bot_left.
y ();
else
return 0;
}
TBOX TBOX::intersection |
( |
const TBOX & |
box | ) |
const |
Definition at line 88 of file rect.cpp.
{
if (box.bot_left.
x () > bot_left.
x ())
left = box.bot_left.
x ();
else
if (box.top_right.
x () < top_right.
x ())
right = box.top_right.
x ();
else
if (box.bot_left.
y () > bot_left.
y ())
bottom = box.bot_left.
y ();
else
if (box.top_right.
y () < top_right.
y ())
top = box.top_right.
y ();
else
}
else {
}
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.
{
overlap -=
MAX(box.bot_left.
x(), bot_left.
x());
return false;
overlap =
MIN(box.top_right.
y(), top_right.
y());
overlap -=
MAX(box.bot_left.
y(), bot_left.
y());
return false;
return true;
}
bool TBOX::major_x_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 402 of file rect.h.
{
}
}
return (overlap >= box.
width() / 2 || overlap >= this->
width() / 2);
}
bool TBOX::major_y_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 429 of file rect.h.
{
}
if (this->
top() < box.
top()) {
overlap -= box.
top() - this->
top();
}
return (overlap >= box.
height() / 2 || overlap >= this->
height() / 2);
}
void TBOX::move |
( |
const ICOORD |
vec | ) |
|
|
inline |
Definition at line 146 of file rect.h.
{
bot_left += vec;
top_right += vec;
}
void TBOX::move |
( |
const FCOORD |
vec | ) |
|
|
inline |
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 |
Definition at line 49 of file rect.h.
{
return bot_left == other.bot_left && top_right == other.top_right;
}
bool TBOX::overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 345 of file rect.h.
{
return ((box.bot_left.
x () <= top_right.
x ()) &&
(box.top_right.
x () >= bot_left.
x ()) &&
(box.bot_left.
y () <= top_right.
y ()) &&
(box.top_right.
y () >= bot_left.
y ()));
}
double TBOX::overlap_fraction |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 378 of file rect.h.
{
double fraction = 0.0;
}
return fraction;
}
void TBOX::pad |
( |
int |
xpad, |
|
|
int |
ypad |
|
) |
| |
|
inline |
void TBOX::print |
( |
| ) |
const |
|
inline |
Definition at line 263 of file rect.h.
{
tprintf(
"Bounding box=(%d,%d)->(%d,%d)\n",
}
inT16 TBOX::right |
( |
| ) |
const |
|
inline |
void TBOX::rotate |
( |
const FCOORD & |
vec | ) |
|
|
inline |
Definition at line 182 of file rect.h.
{
*
this =
TBOX (bot_left, top_right);
}
void TBOX::rotate_large |
( |
const FCOORD & |
vec | ) |
|
Definition at line 73 of file rect.cpp.
{
ICOORD top_left(bot_left.
x(), top_right.
y());
ICOORD bottom_right(top_right.
x(), bot_left.
y());
bottom_right.rotate(vec);
TBOX box2(top_left, bottom_right);
*this += box2;
}
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_left |
( |
int |
x | ) |
|
|
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 |
void TBOX::set_top |
( |
int |
y | ) |
|
|
inline |
inT16 TBOX::top |
( |
| ) |
const |
|
inline |
ICOORD TBOX::topleft |
( |
| ) |
const |
|
inline |
Definition at line 89 of file rect.h.
{
return ICOORD (bot_left.
x (), top_right.
y ());
}
const ICOORD& TBOX::topright |
( |
| ) |
const |
|
inline |
inT16 TBOX::width |
( |
| ) |
const |
|
inline |
Definition at line 104 of file rect.h.
{
return top_right.
x () - bot_left.
x ();
else
return 0;
}
bool TBOX::x_almost_equal |
( |
const TBOX & |
box, |
|
|
int |
tolerance |
|
) |
| const |
int TBOX::x_gap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 210 of file rect.h.
{
return MAX(bot_left.
x(), box.bot_left.
x()) -
MIN(top_right.
x(), box.top_right.
x());
}
bool TBOX::x_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 391 of file rect.h.
{
return ((box.bot_left.
x() <= top_right.
x()) &&
(box.top_right.
x() >= bot_left.
x()));
}
double TBOX::x_overlap_fraction |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 447 of file rect.h.
{
int low =
MAX(
left(), other.left());
if (width == 0) {
if (other.left() <= x && x <= other.right())
return 1.0;
else
return 0.0;
} else {
return MAX(0, static_cast<double>(high - low) / width);
}
}
int TBOX::y_gap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 218 of file rect.h.
{
return MAX(bot_left.
y(), box.bot_left.
y()) -
MIN(top_right.
y(), box.top_right.
y());
}
bool TBOX::y_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 418 of file rect.h.
{
return ((box.bot_left.
y() <= top_right.
y()) &&
(box.top_right.
y() >= bot_left.
y()));
}
double TBOX::y_overlap_fraction |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 469 of file rect.h.
{
int high =
MIN(
top(), other.top());
if (height == 0) {
if (other.bottom() <= y && y <= other.top())
return 1.0;
else
return 0.0;
} else {
return MAX(0, static_cast<double>(high - low) / height);
}
}
Friends And Related Function Documentation
Definition at line 221 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 ());
}
else {
}
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;
}
The documentation for this class was generated from the following files:
- /mnt/data/src/tesseract-ocr/ccstruct/rect.h
- /mnt/data/src/tesseract-ocr/ccstruct/rect.cpp