#include <rect.h>
|
| 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) |
|
int | x_middle () const |
|
int | y_middle () const |
|
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 | print_to_str (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) |
|
Definition at line 30 of file rect.h.
◆ TBOX() [1/4]
◆ TBOX() [2/4]
Definition at line 32 of file rect.cpp.
36 if (pt1.
x () <= pt2.
x ()) {
37 if (pt1.
y () <= pt2.
y ()) {
42 bot_left =
ICOORD (pt1.
x (), pt2.
y ());
43 top_right =
ICOORD (pt2.
x (), pt1.
y ());
47 if (pt1.
y () <= pt2.
y ()) {
48 bot_left =
ICOORD (pt2.
x (), pt1.
y ());
49 top_right =
ICOORD (pt1.
x (), pt2.
y ());
inT16 x() const
access function
inT16 y() const
access_function
◆ TBOX() [3/4]
◆ TBOX() [4/4]
◆ almost_equal()
bool TBOX::almost_equal |
( |
const TBOX & |
box, |
|
|
int |
tolerance |
|
) |
| const |
Definition at line 258 of file rect.cpp.
259 return (abs(
left() - box.
left()) <= tolerance &&
261 abs(
top() - box.
top()) <= tolerance &&
◆ area()
inT32 TBOX::area |
( |
| ) |
const |
|
inline |
◆ botleft()
const ICOORD& TBOX::botleft |
( |
| ) |
const |
|
inline |
◆ botright()
ICOORD TBOX::botright |
( |
| ) |
const |
|
inline |
Definition at line 92 of file rect.h.
93 return ICOORD (top_right.
x (), bot_left.
y ());
inT16 x() const
access function
inT16 y() const
access_function
◆ bottom()
inT16 TBOX::bottom |
( |
| ) |
const |
|
inline |
Definition at line 61 of file rect.h.
inT16 y() const
access_function
◆ bounding_union()
TBOX TBOX::bounding_union |
( |
const TBOX & |
box | ) |
const |
Definition at line 129 of file rect.cpp.
134 if (box.bot_left.
x () < bot_left.
x ())
135 bl.
set_x (box.bot_left.
x ());
139 if (box.top_right.
x () > top_right.
x ())
140 tr.
set_x (box.top_right.
x ());
142 tr.
set_x (top_right.
x ());
144 if (box.bot_left.
y () < bot_left.
y ())
145 bl.
set_y (box.bot_left.
y ());
149 if (box.top_right.
y () > top_right.
y ())
150 tr.
set_y (box.top_right.
y ());
152 tr.
set_y (top_right.
y ());
153 return TBOX (bl, tr);
void set_x(inT16 xin)
rewrite function
inT16 x() const
access function
inT16 y() const
access_function
void set_y(inT16 yin)
rewrite function
◆ contains() [1/2]
bool TBOX::contains |
( |
const FCOORD |
pt | ) |
const |
|
inline |
Definition at line 323 of file rect.h.
324 return ((pt.
x () >= bot_left.
x ()) &&
325 (pt.
x () <= top_right.
x ()) &&
326 (pt.
y () >= bot_left.
y ()) && (pt.
y () <= top_right.
y ()));
inT16 x() const
access function
inT16 y() const
access_function
◆ contains() [2/2]
bool TBOX::contains |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 335 of file rect.h.
bool contains(const FCOORD pt) const
◆ DeSerialize()
bool TBOX::DeSerialize |
( |
bool |
swap, |
|
|
FILE * |
fp |
|
) |
| |
Definition at line 192 of file rect.cpp.
194 if (!top_right.
DeSerialize(swap, fp))
return false;
bool DeSerialize(bool swap, FILE *fp)
◆ height()
inT16 TBOX::height |
( |
| ) |
const |
|
inline |
Definition at line 104 of file rect.h.
106 return top_right.
y () - bot_left.
y ();
inT16 y() const
access_function
◆ intersection()
TBOX TBOX::intersection |
( |
const TBOX & |
box | ) |
const |
Definition at line 87 of file rect.cpp.
94 if (box.bot_left.
x () > bot_left.
x ())
95 left = box.bot_left.
x ();
99 if (box.top_right.
x () < top_right.
x ())
100 right = box.top_right.
x ();
102 right = top_right.
x ();
104 if (box.bot_left.
y () > bot_left.
y ())
105 bottom = box.bot_left.
y ();
107 bottom = bot_left.
y ();
109 if (box.top_right.
y () < top_right.
y ())
110 top = box.top_right.
y ();
112 top = top_right.
y ();
120 return TBOX (left, bottom, right, top);
bool overlap(const TBOX &box) const
inT16 x() const
access function
inT16 y() const
access_function
◆ left()
inT16 TBOX::left |
( |
| ) |
const |
|
inline |
Definition at line 68 of file rect.h.
inT16 x() const
access function
◆ major_overlap()
bool TBOX::major_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 358 of file rect.h.
361 overlap -=
MAX(box.bot_left.
x(), bot_left.
x());
365 overlap =
MIN(box.top_right.
y(), top_right.
y());
366 overlap -=
MAX(box.bot_left.
y(), bot_left.
y());
bool overlap(const TBOX &box) const
inT16 x() const
access function
inT16 y() const
access_function
◆ major_x_overlap()
bool TBOX::major_x_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 402 of file rect.h.
405 overlap -= this->
left() - box.
left();
410 return (overlap >= box.
width() / 2 || overlap >= this->
width() / 2);
bool overlap(const TBOX &box) const
◆ major_y_overlap()
bool TBOX::major_y_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 429 of file rect.h.
434 if (this->
top() < box.
top()) {
435 overlap -= box.
top() - this->
top();
437 return (overlap >= box.
height() / 2 || overlap >= this->
height() / 2);
bool overlap(const TBOX &box) const
◆ move() [1/2]
void TBOX::move |
( |
const ICOORD |
vec | ) |
|
|
inline |
◆ move() [2/2]
void TBOX::move |
( |
const FCOORD |
vec | ) |
|
|
inline |
Definition at line 159 of file rect.h.
161 bot_left.
set_x ((
inT16) floor (bot_left.
x () + vec.
x ()));
163 bot_left.
set_y ((
inT16) floor (bot_left.
y () + vec.
y ()));
165 top_right.
set_x ((
inT16) ceil (top_right.
x () + vec.
x ()));
167 top_right.
set_y ((
inT16) ceil (top_right.
y () + vec.
y ()));
void set_x(inT16 xin)
rewrite function
inT16 x() const
access function
inT16 y() const
access_function
void set_y(inT16 yin)
rewrite function
◆ move_bottom_edge()
void TBOX::move_bottom_edge |
( |
const inT16 |
y | ) |
|
|
inline |
◆ move_left_edge()
void TBOX::move_left_edge |
( |
const inT16 |
x | ) |
|
|
inline |
◆ move_right_edge()
void TBOX::move_right_edge |
( |
const inT16 |
x | ) |
|
|
inline |
◆ move_top_edge()
void TBOX::move_top_edge |
( |
const inT16 |
y | ) |
|
|
inline |
◆ null_box()
bool TBOX::null_box |
( |
| ) |
const |
|
inline |
◆ operator==()
bool TBOX::operator== |
( |
const TBOX & |
other | ) |
const |
|
inline |
Definition at line 50 of file rect.h.
51 return bot_left == other.bot_left && top_right == other.top_right;
◆ overlap()
bool TBOX::overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 345 of file rect.h.
347 return ((box.bot_left.
x () <= top_right.
x ()) &&
348 (box.top_right.
x () >= bot_left.
x ()) &&
349 (box.bot_left.
y () <= top_right.
y ()) &&
350 (box.top_right.
y () >= bot_left.
y ()));
inT16 x() const
access function
inT16 y() const
access_function
◆ overlap_fraction()
double TBOX::overlap_fraction |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 378 of file rect.h.
379 double fraction = 0.0;
TBOX intersection(const TBOX &box) const
◆ pad()
void TBOX::pad |
( |
int |
xpad, |
|
|
int |
ypad |
|
) |
| |
|
inline |
Definition at line 127 of file rect.h.
void pad(int xpad, int ypad)
◆ plot() [1/2]
Definition at line 278 of file rect.h.
280 fd->
Rectangle(bot_left.
x (), bot_left.
y (), top_right.
x (),
inT16 x() const
access function
void Rectangle(int x1, int y1, int x2, int y2)
inT16 y() const
access_function
◆ plot() [2/2]
Definition at line 163 of file rect.cpp.
168 fd->
Brush(fill_colour);
169 fd->
Pen(border_colour);
void plot(ScrollView *fd) const
◆ print()
void TBOX::print |
( |
| ) |
const |
|
inline |
Definition at line 270 of file rect.h.
271 tprintf(
"Bounding box=(%d,%d)->(%d,%d)\n",
◆ print_to_str()
void TBOX::print_to_str |
( |
STRING * |
str | ) |
const |
Definition at line 175 of file rect.cpp.
void add_str_int(const char *str, int number)
◆ right()
inT16 TBOX::right |
( |
| ) |
const |
|
inline |
Definition at line 75 of file rect.h.
76 return top_right.
x ();
inT16 x() const
access function
◆ rotate()
void TBOX::rotate |
( |
const FCOORD & |
vec | ) |
|
|
inline |
Definition at line 189 of file rect.h.
192 *
this =
TBOX (bot_left, top_right);
void rotate(const FCOORD &vec)
◆ rotate_large()
void TBOX::rotate_large |
( |
const FCOORD & |
vec | ) |
|
Definition at line 72 of file rect.cpp.
73 ICOORD top_left(bot_left.
x(), top_right.
y());
74 ICOORD bottom_right(top_right.
x(), bot_left.
y());
76 bottom_right.rotate(vec);
78 TBOX box2(top_left, bottom_right);
void rotate(const FCOORD &vec)
inT16 x() const
access function
inT16 y() const
access_function
void rotate(const FCOORD &vec)
◆ scale() [1/2]
void TBOX::scale |
( |
const float |
f | ) |
|
|
inline |
Definition at line 171 of file rect.h.
173 bot_left.
set_x ((
inT16) floor (bot_left.
x () * f));
174 bot_left.
set_y ((
inT16) floor (bot_left.
y () * f));
175 top_right.
set_x ((
inT16) ceil (top_right.
x () * f));
176 top_right.
set_y ((
inT16) ceil (top_right.
y () * f));
void set_x(inT16 xin)
rewrite function
inT16 x() const
access function
inT16 y() const
access_function
void set_y(inT16 yin)
rewrite function
◆ scale() [2/2]
void TBOX::scale |
( |
const FCOORD |
vec | ) |
|
|
inline |
Definition at line 178 of file rect.h.
180 bot_left.
set_x ((
inT16) floor (bot_left.
x () * vec.
x ()));
181 bot_left.
set_y ((
inT16) floor (bot_left.
y () * vec.
y ()));
182 top_right.
set_x ((
inT16) ceil (top_right.
x () * vec.
x ()));
183 top_right.
set_y ((
inT16) ceil (top_right.
y () * vec.
y ()));
void set_x(inT16 xin)
rewrite function
inT16 x() const
access function
inT16 y() const
access_function
void set_y(inT16 yin)
rewrite function
◆ Serialize()
bool TBOX::Serialize |
( |
FILE * |
fp | ) |
const |
Definition at line 185 of file rect.cpp.
186 if (!bot_left.
Serialize(fp))
return false;
187 if (!top_right.
Serialize(fp))
return false;
bool Serialize(FILE *fp) const
◆ set_bottom()
void TBOX::set_bottom |
( |
int |
y | ) |
|
|
inline |
Definition at line 64 of file rect.h.
void set_y(inT16 yin)
rewrite function
◆ set_left()
void TBOX::set_left |
( |
int |
x | ) |
|
|
inline |
Definition at line 71 of file rect.h.
void set_x(inT16 xin)
rewrite function
◆ set_right()
void TBOX::set_right |
( |
int |
x | ) |
|
|
inline |
Definition at line 78 of file rect.h.
void set_x(inT16 xin)
rewrite function
◆ set_to_given_coords()
void TBOX::set_to_given_coords |
( |
int |
x_min, |
|
|
int |
y_min, |
|
|
int |
x_max, |
|
|
int |
y_max |
|
) |
| |
|
inline |
Definition at line 263 of file rect.h.
264 bot_left.
set_x(x_min);
265 bot_left.
set_y(y_min);
266 top_right.
set_x(x_max);
267 top_right.
set_y(y_max);
void set_x(inT16 xin)
rewrite function
void set_y(inT16 yin)
rewrite function
◆ set_top()
void TBOX::set_top |
( |
int |
y | ) |
|
|
inline |
Definition at line 57 of file rect.h.
void set_y(inT16 yin)
rewrite function
◆ top()
inT16 TBOX::top |
( |
| ) |
const |
|
inline |
Definition at line 54 of file rect.h.
55 return top_right.
y ();
inT16 y() const
access_function
◆ topleft()
ICOORD TBOX::topleft |
( |
| ) |
const |
|
inline |
Definition at line 96 of file rect.h.
97 return ICOORD (bot_left.
x (), top_right.
y ());
inT16 x() const
access function
inT16 y() const
access_function
◆ topright()
const ICOORD& TBOX::topright |
( |
| ) |
const |
|
inline |
◆ width()
inT16 TBOX::width |
( |
| ) |
const |
|
inline |
Definition at line 111 of file rect.h.
113 return top_right.
x () - bot_left.
x ();
inT16 x() const
access function
◆ x_almost_equal()
bool TBOX::x_almost_equal |
( |
const TBOX & |
box, |
|
|
int |
tolerance |
|
) |
| const |
◆ x_gap()
int TBOX::x_gap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 217 of file rect.h.
218 return MAX(bot_left.
x(), box.bot_left.
x()) -
219 MIN(top_right.
x(), box.top_right.
x());
inT16 x() const
access function
◆ x_middle()
int TBOX::x_middle |
( |
| ) |
const |
|
inline |
Definition at line 81 of file rect.h.
82 return (bot_left.
x() + top_right.
x()) / 2;
inT16 x() const
access function
◆ x_overlap()
bool TBOX::x_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 391 of file rect.h.
392 return ((box.bot_left.
x() <= top_right.
x()) &&
393 (box.top_right.
x() >= bot_left.
x()));
inT16 x() const
access function
◆ x_overlap_fraction()
double TBOX::x_overlap_fraction |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 447 of file rect.h.
448 int low =
MAX(
left(), other.left());
449 int high =
MIN(
right(), other.right());
453 if (other.left() <= x && x <= other.right())
458 return MAX(0, static_cast<double>(high - low) / width);
◆ y_gap()
int TBOX::y_gap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 225 of file rect.h.
226 return MAX(bot_left.
y(), box.bot_left.
y()) -
227 MIN(top_right.
y(), box.top_right.
y());
inT16 y() const
access_function
◆ y_middle()
int TBOX::y_middle |
( |
| ) |
const |
|
inline |
Definition at line 84 of file rect.h.
85 return (bot_left.
y() + top_right.
y()) / 2;
inT16 y() const
access_function
◆ y_overlap()
bool TBOX::y_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 418 of file rect.h.
419 return ((box.bot_left.
y() <= top_right.
y()) &&
420 (box.top_right.
y() >= bot_left.
y()));
inT16 y() const
access_function
◆ y_overlap_fraction()
double TBOX::y_overlap_fraction |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 469 of file rect.h.
471 int high =
MIN(
top(), other.top());
475 if (other.bottom() <= y && y <= other.top())
480 return MAX(0, static_cast<double>(high - low) / height);
◆ operator &=
Definition at line 230 of file rect.cpp.
232 if (op2.bot_left.
x () > op1.bot_left.
x ())
233 op1.bot_left.
set_x (op2.bot_left.
x ());
235 if (op2.top_right.
x () < op1.top_right.
x ())
236 op1.top_right.
set_x (op2.top_right.
x ());
238 if (op2.bot_left.
y () > op1.bot_left.
y ())
239 op1.bot_left.
set_y (op2.bot_left.
y ());
241 if (op2.top_right.
y () < op1.top_right.
y ())
242 op1.top_right.
set_y (op2.top_right.
y ());
bool overlap(const TBOX &box) const
void set_x(inT16 xin)
rewrite function
inT16 x() const
access function
inT16 y() const
access_function
void set_y(inT16 yin)
rewrite function
◆ operator+=
Definition at line 205 of file rect.cpp.
208 if (op2.bot_left.
x () < op1.bot_left.
x ())
209 op1.bot_left.
set_x (op2.bot_left.
x ());
211 if (op2.top_right.
x () > op1.top_right.
x ())
212 op1.top_right.
set_x (op2.top_right.
x ());
214 if (op2.bot_left.
y () < op1.bot_left.
y ())
215 op1.bot_left.
set_y (op2.bot_left.
y ());
217 if (op2.top_right.
y () > op1.top_right.
y ())
218 op1.top_right.
set_y (op2.top_right.
y ());
void set_x(inT16 xin)
rewrite function
inT16 x() const
access function
inT16 y() const
access_function
void set_y(inT16 yin)
rewrite function
The documentation for this class was generated from the following files:
- /home/stefan/src/github/tesseract-ocr/tesseract/ccstruct/rect.h
- /home/stefan/src/github/tesseract-ocr/tesseract/ccstruct/rect.cpp