#include <rect.h>
|
| TBOX () |
|
| TBOX (const ICOORD pt1, const ICOORD pt2) |
|
| TBOX (TDimension left, TDimension bottom, TDimension right, TDimension top) |
|
| TBOX (const FCOORD pt) |
|
bool | null_box () const |
|
bool | operator== (const TBOX &other) const |
|
TDimension | top () const |
|
void | set_top (int y) |
|
TDimension | bottom () const |
|
void | set_bottom (int y) |
|
TDimension | left () const |
|
void | set_left (int x) |
|
TDimension | 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 |
|
TDimension | height () const |
|
TDimension | width () const |
|
int32_t | area () const |
|
void | pad (int xpad, int ypad) |
|
void | move_bottom_edge (const TDimension y) |
|
void | move_left_edge (const TDimension x) |
|
void | move_right_edge (const TDimension x) |
|
void | move_top_edge (const TDimension 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 (std::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 | Serialize (TFile *fp) const |
|
bool | DeSerialize (bool swap, FILE *fp) |
|
bool | DeSerialize (TFile *fp) |
|
Definition at line 37 of file rect.h.
◆ TBOX() [1/4]
tesseract::TBOX::TBOX |
( |
| ) |
|
|
inline |
Definition at line 39 of file rect.h.
41 bot_left(INT16_MAX, INT16_MAX)
42 , top_right(-INT16_MAX, -INT16_MAX) {}
◆ TBOX() [2/4]
tesseract::TBOX::TBOX |
( |
const ICOORD |
pt1, |
|
|
const ICOORD |
pt2 |
|
) |
| |
Definition at line 35 of file rect.cpp.
39 if (pt1.x() <= pt2.x()) {
40 if (pt1.y() <= pt2.y()) {
44 bot_left = ICOORD(pt1.x(), pt2.y());
45 top_right = ICOORD(pt2.x(), pt1.y());
48 if (pt1.y() <= pt2.y()) {
49 bot_left = ICOORD(pt2.x(), pt1.y());
50 top_right = ICOORD(pt1.x(), pt2.y());
◆ TBOX() [3/4]
Definition at line 53 of file rect.h.
TDimension bottom() const
◆ TBOX() [4/4]
tesseract::TBOX::TBOX |
( |
const FCOORD |
pt | ) |
|
|
inline |
◆ almost_equal()
bool tesseract::TBOX::almost_equal |
( |
const TBOX & |
box, |
|
|
int |
tolerance |
|
) |
| const |
Definition at line 272 of file rect.cpp.
273 return (abs(
left() - box.left()) <= tolerance && abs(
right() - box.right()) <= tolerance &&
274 abs(
top() - box.top()) <= tolerance && abs(
bottom() - box.bottom()) <= tolerance);
◆ area()
int32_t tesseract::TBOX::area |
( |
| ) |
const |
|
inline |
Definition at line 134 of file rect.h.
TDimension height() const
◆ botleft()
const ICOORD& tesseract::TBOX::botleft |
( |
| ) |
const |
|
inline |
◆ botright()
ICOORD tesseract::TBOX::botright |
( |
| ) |
const |
|
inline |
Definition at line 106 of file rect.h.
107 return ICOORD(top_right.
x(), bot_left.
y());
TDimension y() const
access_function
TDimension x() const
access function
◆ bottom()
◆ bounding_union()
TBOX tesseract::TBOX::bounding_union |
( |
const TBOX & |
box | ) |
const |
Definition at line 128 of file rect.cpp.
133 if (box.bot_left.x() < bot_left.
x()) {
134 bl.set_x(box.bot_left.x());
136 bl.set_x(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());
145 if (box.bot_left.y() < bot_left.
y()) {
146 bl.set_y(box.bot_left.y());
148 bl.set_y(bot_left.
y());
151 if (box.top_right.y() > top_right.
y()) {
152 tr.set_y(box.top_right.y());
154 tr.set_y(top_right.
y());
◆ contains() [1/2]
bool tesseract::TBOX::contains |
( |
const FCOORD |
pt | ) |
const |
|
inline |
Definition at line 344 of file rect.h.
345 return ((pt.x() >= bot_left.
x()) && (pt.x() <= top_right.
x()) && (pt.y() >= bot_left.
y()) &&
346 (pt.y() <= top_right.
y()));
◆ contains() [2/2]
bool tesseract::TBOX::contains |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 354 of file rect.h.
bool contains(const FCOORD pt) const
◆ DeSerialize() [1/2]
bool tesseract::TBOX::DeSerialize |
( |
bool |
swap, |
|
|
FILE * |
fp |
|
) |
| |
Definition at line 198 of file rect.cpp.
bool DeSerialize(TFile *f)
◆ DeSerialize() [2/2]
bool tesseract::TBOX::DeSerialize |
( |
TFile * |
fp | ) |
|
◆ height()
Definition at line 118 of file rect.h.
120 return top_right.
y() - bot_left.
y();
◆ intersection()
TBOX tesseract::TBOX::intersection |
( |
const TBOX & |
box | ) |
const |
Definition at line 84 of file rect.cpp.
91 if (box.bot_left.x() > bot_left.
x()) {
92 left = box.bot_left.x();
97 if (box.top_right.x() < top_right.
x()) {
98 right = box.top_right.x();
103 if (box.bot_left.y() > bot_left.
y()) {
104 bottom = box.bot_left.y();
109 if (box.top_right.y() < top_right.
y()) {
110 top = box.top_right.y();
bool overlap(const TBOX &box) const
◆ left()
◆ major_overlap()
bool tesseract::TBOX::major_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 374 of file rect.h.
376 int overlap = std::min(box.top_right.x(), top_right.
x());
377 overlap -= std::max(box.bot_left.x(), bot_left.
x());
382 overlap = std::min(box.top_right.y(), top_right.
y());
383 overlap -= std::max(box.bot_left.y(), bot_left.
y());
◆ major_x_overlap()
bool tesseract::TBOX::major_x_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 419 of file rect.h.
421 if (this->
left() > box.left()) {
424 if (this->
right() < box.right()) {
427 return (overlap >= box.width() / 2 ||
overlap >= this->width() / 2);
◆ major_y_overlap()
bool tesseract::TBOX::major_y_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 445 of file rect.h.
447 if (this->
bottom() > box.bottom()) {
450 if (this->
top() < box.top()) {
453 return (overlap >= box.height() / 2 ||
overlap >= this->height() / 2);
◆ move() [1/2]
void tesseract::TBOX::move |
( |
const FCOORD |
vec | ) |
|
|
inline |
Definition at line 176 of file rect.h.
178 bot_left.
set_x(
static_cast<TDimension>(std::floor(bot_left.
x() + vec.x())));
180 bot_left.
set_y(
static_cast<TDimension>(std::floor(bot_left.
y() + vec.y())));
182 top_right.
set_x(
static_cast<TDimension>(std::ceil(top_right.
x() + vec.x())));
184 top_right.
set_y(
static_cast<TDimension>(std::ceil(top_right.
y() + vec.y())));
void set_x(TDimension xin)
rewrite function
void set_y(TDimension yin)
rewrite function
◆ move() [2/2]
void tesseract::TBOX::move |
( |
const ICOORD |
vec | ) |
|
|
inline |
◆ move_bottom_edge()
void tesseract::TBOX::move_bottom_edge |
( |
const TDimension |
y | ) |
|
|
inline |
Definition at line 150 of file rect.h.
152 bot_left += ICOORD(0, y);
◆ move_left_edge()
void tesseract::TBOX::move_left_edge |
( |
const TDimension |
x | ) |
|
|
inline |
Definition at line 155 of file rect.h.
157 bot_left += ICOORD(x, 0);
◆ move_right_edge()
void tesseract::TBOX::move_right_edge |
( |
const TDimension |
x | ) |
|
|
inline |
Definition at line 160 of file rect.h.
162 top_right += ICOORD(x, 0);
◆ move_top_edge()
void tesseract::TBOX::move_top_edge |
( |
const TDimension |
y | ) |
|
|
inline |
Definition at line 165 of file rect.h.
167 top_right += ICOORD(0, y);
◆ null_box()
bool tesseract::TBOX::null_box |
( |
| ) |
const |
|
inline |
◆ operator==()
bool tesseract::TBOX::operator== |
( |
const TBOX & |
other | ) |
const |
|
inline |
Definition at line 64 of file rect.h.
65 return bot_left == other.bot_left && top_right == other.top_right;
◆ overlap()
bool tesseract::TBOX::overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 363 of file rect.h.
365 return ((box.bot_left.x() <= top_right.
x()) && (box.top_right.x() >= bot_left.
x()) &&
366 (box.bot_left.y() <= top_right.
y()) && (box.top_right.y() >= bot_left.
y()));
◆ overlap_fraction()
double tesseract::TBOX::overlap_fraction |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 396 of file rect.h.
397 double fraction = 0.0;
TBOX intersection(const TBOX &box) const
◆ pad()
void tesseract::TBOX::pad |
( |
int |
xpad, |
|
|
int |
ypad |
|
) |
| |
|
inline |
Definition at line 144 of file rect.h.
145 ICOORD
pad(xpad, ypad);
void pad(int xpad, int ypad)
◆ plot() [1/2]
void tesseract::TBOX::plot |
( |
ScrollView * |
fd | ) |
const |
|
inline |
Definition at line 296 of file rect.h.
298 fd->Rectangle(bot_left.
x(), bot_left.
y(), top_right.
x(), top_right.
y());
◆ plot() [2/2]
Definition at line 165 of file rect.cpp.
170 fd->Brush(fill_colour);
171 fd->Pen(border_colour);
void plot(ScrollView *fd) const
◆ print()
void tesseract::TBOX::print |
( |
| ) |
const |
|
inline |
Definition at line 289 of file rect.h.
void tprintf(const char *format,...)
◆ print_to_str()
void tesseract::TBOX::print_to_str |
( |
std::string & |
str | ) |
const |
Definition at line 177 of file rect.cpp.
179 str +=
"(" + std::to_string(
left());
180 str +=
"," + std::to_string(
bottom());
181 str +=
")->(" + std::to_string(
right());
182 str +=
"," + std::to_string(
top());
◆ right()
◆ rotate()
void tesseract::TBOX::rotate |
( |
const FCOORD & |
vec | ) |
|
|
inline |
Definition at line 210 of file rect.h.
213 *
this =
TBOX(bot_left, top_right);
void rotate(const FCOORD &vec)
◆ rotate_large()
void tesseract::TBOX::rotate_large |
( |
const FCOORD & |
vec | ) |
|
Definition at line 69 of file rect.cpp.
70 ICOORD top_left(bot_left.
x(), top_right.
y());
71 ICOORD bottom_right(top_right.
x(), bot_left.
y());
73 bottom_right.rotate(vec);
75 TBOX box2(top_left, bottom_right);
void rotate(const FCOORD &vec)
◆ scale() [1/2]
void tesseract::TBOX::scale |
( |
const FCOORD |
vec | ) |
|
|
inline |
◆ scale() [2/2]
void tesseract::TBOX::scale |
( |
const float |
f | ) |
|
|
inline |
◆ Serialize() [1/2]
bool tesseract::TBOX::Serialize |
( |
FILE * |
fp | ) |
const |
Definition at line 187 of file rect.cpp.
bool Serialize(TFile *f) const
◆ Serialize() [2/2]
bool tesseract::TBOX::Serialize |
( |
TFile * |
fp | ) |
const |
◆ set_bottom()
void tesseract::TBOX::set_bottom |
( |
int |
y | ) |
|
|
inline |
◆ set_left()
void tesseract::TBOX::set_left |
( |
int |
x | ) |
|
|
inline |
◆ set_right()
void tesseract::TBOX::set_right |
( |
int |
x | ) |
|
|
inline |
◆ set_to_given_coords()
void tesseract::TBOX::set_to_given_coords |
( |
int |
x_min, |
|
|
int |
y_min, |
|
|
int |
x_max, |
|
|
int |
y_max |
|
) |
| |
|
inline |
Definition at line 282 of file rect.h.
283 bot_left.
set_x(x_min);
284 bot_left.
set_y(y_min);
285 top_right.
set_x(x_max);
286 top_right.
set_y(y_max);
◆ set_top()
void tesseract::TBOX::set_top |
( |
int |
y | ) |
|
|
inline |
◆ top()
◆ topleft()
ICOORD tesseract::TBOX::topleft |
( |
| ) |
const |
|
inline |
Definition at line 110 of file rect.h.
111 return ICOORD(bot_left.
x(), top_right.
y());
◆ topright()
const ICOORD& tesseract::TBOX::topright |
( |
| ) |
const |
|
inline |
◆ width()
Definition at line 126 of file rect.h.
128 return top_right.
x() - bot_left.
x();
◆ x_almost_equal()
bool tesseract::TBOX::x_almost_equal |
( |
const TBOX & |
box, |
|
|
int |
tolerance |
|
) |
| const |
Definition at line 268 of file rect.cpp.
269 return (abs(
left() - box.left()) <= tolerance && abs(
right() - box.right()) <= tolerance);
◆ x_gap()
int tesseract::TBOX::x_gap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 238 of file rect.h.
239 return std::max(bot_left.
x(), box.bot_left.x()) - std::min(top_right.
x(), box.top_right.x());
◆ x_middle()
int tesseract::TBOX::x_middle |
( |
| ) |
const |
|
inline |
Definition at line 95 of file rect.h.
96 return (bot_left.
x() + top_right.
x()) / 2;
◆ x_overlap()
bool tesseract::TBOX::x_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 409 of file rect.h.
410 return ((box.bot_left.x() <= top_right.
x()) && (box.top_right.x() >= bot_left.
x()));
◆ x_overlap_fraction()
double tesseract::TBOX::x_overlap_fraction |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 463 of file rect.h.
464 int low = std::max(
left(), other.left());
465 int high = std::min(
right(), other.right());
469 if (other.left() <= x && x <= other.right()) {
475 return std::max(0.0,
static_cast<double>(high - low) /
width);
◆ y_gap()
int tesseract::TBOX::y_gap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 245 of file rect.h.
246 return std::max(bot_left.
y(), box.bot_left.y()) - std::min(top_right.
y(), box.top_right.y());
◆ y_middle()
int tesseract::TBOX::y_middle |
( |
| ) |
const |
|
inline |
Definition at line 98 of file rect.h.
99 return (bot_left.
y() + top_right.
y()) / 2;
◆ y_overlap()
bool tesseract::TBOX::y_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 435 of file rect.h.
436 return ((box.bot_left.y() <= top_right.
y()) && (box.top_right.y() >= bot_left.
y()));
◆ y_overlap_fraction()
double tesseract::TBOX::y_overlap_fraction |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 486 of file rect.h.
487 int low = std::max(
bottom(), other.bottom());
488 int high = std::min(
top(), other.top());
492 if (other.bottom() <= y && y <= other.top()) {
498 return std::max(0.0,
static_cast<double>(high - low) /
height);
◆ operator&=
Definition at line 242 of file rect.cpp.
243 if (op1.overlap(op2)) {
244 if (op2.bot_left.x() > op1.bot_left.x()) {
245 op1.bot_left.set_x(op2.bot_left.x());
248 if (op2.top_right.x() < op1.top_right.x()) {
249 op1.top_right.set_x(op2.top_right.x());
252 if (op2.bot_left.y() > op1.bot_left.y()) {
253 op1.bot_left.set_y(op2.bot_left.y());
256 if (op2.top_right.y() < op1.top_right.y()) {
257 op1.top_right.set_y(op2.top_right.y());
260 op1.bot_left.set_x(INT16_MAX);
261 op1.bot_left.set_y(INT16_MAX);
262 op1.top_right.set_x(-INT16_MAX);
263 op1.top_right.set_y(-INT16_MAX);
◆ operator+=
Definition at line 214 of file rect.cpp.
217 if (op2.bot_left.x() < op1.bot_left.x()) {
218 op1.bot_left.set_x(op2.bot_left.x());
221 if (op2.top_right.x() > op1.top_right.x()) {
222 op1.top_right.set_x(op2.top_right.x());
225 if (op2.bot_left.y() < op1.bot_left.y()) {
226 op1.bot_left.set_y(op2.bot_left.y());
229 if (op2.top_right.y() > op1.top_right.y()) {
230 op1.top_right.set_y(op2.top_right.y());
The documentation for this class was generated from the following files: