#include <rect.h>
|
| TBOX () |
|
| TBOX (const ICOORD pt1, const ICOORD pt2) |
|
| TBOX (int16_t left, int16_t bottom, int16_t right, int16_t top) |
|
| TBOX (const FCOORD pt) |
|
bool | null_box () const |
|
bool | operator== (const TBOX &other) const |
|
int16_t | top () const |
|
void | set_top (int y) |
|
int16_t | bottom () const |
|
void | set_bottom (int y) |
|
int16_t | left () const |
|
void | set_left (int x) |
|
int16_t | 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_t | height () const |
|
int16_t | width () const |
|
int32_t | area () const |
|
void | pad (int xpad, int ypad) |
|
void | move_bottom_edge (const int16_t y) |
|
void | move_left_edge (const int16_t x) |
|
void | move_right_edge (const int16_t x) |
|
void | move_top_edge (const int16_t 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 33 of file rect.h.
◆ TBOX() [1/4]
Definition at line 35 of file rect.h.
37 bot_left (INT16_MAX, INT16_MAX), top_right (-INT16_MAX, -INT16_MAX) {
◆ TBOX() [2/4]
Definition at line 30 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 ());
◆ TBOX() [3/4]
TBOX::TBOX |
( |
int16_t |
left, |
|
|
int16_t |
bottom, |
|
|
int16_t |
right, |
|
|
int16_t |
top |
|
) |
| |
◆ TBOX() [4/4]
Definition at line 316 of file rect.h.
321 bot_left =
ICOORD(static_cast<int16_t>(std::floor(pt.
x())),
322 static_cast<int16_t>(std::floor(pt.
y())));
323 top_right =
ICOORD(static_cast<int16_t>(std::ceil(pt.
x())),
◆ almost_equal()
bool TBOX::almost_equal |
( |
const TBOX & |
box, |
|
|
int |
tolerance |
|
) |
| const |
◆ area()
int32_t TBOX::area |
( |
| ) |
const |
|
inline |
◆ botleft()
const ICOORD& TBOX::botleft |
( |
| ) |
const |
|
inline |
◆ botright()
ICOORD TBOX::botright |
( |
| ) |
const |
|
inline |
Definition at line 95 of file rect.h.
97 return ICOORD (top_right.
x (), bot_left.
y ());
◆ bottom()
int16_t TBOX::bottom |
( |
| ) |
const |
|
inline |
◆ bounding_union()
TBOX TBOX::bounding_union |
( |
const TBOX & |
box | ) |
const |
Definition at line 124 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 ())
◆ contains() [1/2]
bool TBOX::contains |
( |
const FCOORD |
pt | ) |
const |
|
inline |
Definition at line 330 of file rect.h.
334 return ((pt.
x () >= bot_left.
x ()) &&
◆ contains() [2/2]
bool TBOX::contains |
( |
const TBOX & |
box | ) |
const |
|
inline |
◆ DeSerialize()
bool TBOX::DeSerialize |
( |
bool |
swap, |
|
|
FILE * |
fp |
|
) |
| |
◆ height()
int16_t TBOX::height |
( |
| ) |
const |
|
inline |
Definition at line 107 of file rect.h.
110 return top_right.
y () - bot_left.
y ();
◆ intersection()
TBOX TBOX::intersection |
( |
const TBOX & |
box | ) |
const |
Definition at line 83 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 ();
104 if (box.bot_left.
y () > bot_left.
y ())
109 if (box.top_right.
y () < top_right.
y ())
110 top = box.top_right.
y ();
112 top = top_right.
y ();
◆ left()
int16_t TBOX::left |
( |
| ) |
const |
|
inline |
◆ major_overlap()
bool TBOX::major_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 362 of file rect.h.
370 int overlap = std::min(box.top_right.
x(), top_right.
x());
371 overlap -= std::max(box.bot_left.
x(), bot_left.
x());
375 overlap = std::min(box.top_right.
y(), top_right.
y());
◆ major_x_overlap()
bool TBOX::major_x_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
◆ major_y_overlap()
bool TBOX::major_y_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 428 of file rect.h.
429 return ((box.bot_left.
y() <= top_right.
y()) &&
430 (box.top_right.
y() >= bot_left.
y()));
◆ move() [1/2]
void TBOX::move |
( |
const FCOORD |
vec | ) |
|
|
inline |
Definition at line 162 of file rect.h.
165 bot_left.
set_x(static_cast<int16_t>(std::floor(bot_left.
x() + vec.
x())));
167 bot_left.
set_y(static_cast<int16_t>(std::floor(bot_left.
y() + vec.
y())));
169 top_right.
set_x(static_cast<int16_t>(std::ceil(top_right.
x() + vec.
x())));
171 top_right.
set_y(static_cast<int16_t>(std::ceil(top_right.
y() + vec.
y())));
◆ move() [2/2]
void TBOX::move |
( |
const ICOORD |
vec | ) |
|
|
inline |
◆ move_bottom_edge()
void TBOX::move_bottom_edge |
( |
const int16_t |
y | ) |
|
|
inline |
◆ move_left_edge()
void TBOX::move_left_edge |
( |
const int16_t |
x | ) |
|
|
inline |
◆ move_right_edge()
void TBOX::move_right_edge |
( |
const int16_t |
x | ) |
|
|
inline |
◆ move_top_edge()
void TBOX::move_top_edge |
( |
const int16_t |
y | ) |
|
|
inline |
◆ null_box()
bool TBOX::null_box |
( |
| ) |
const |
|
inline |
◆ operator==()
bool TBOX::operator== |
( |
const TBOX & |
other | ) |
const |
|
inline |
Definition at line 53 of file rect.h.
55 return bot_left == other.bot_left && top_right == other.top_right;
◆ overlap()
bool TBOX::overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
◆ overlap_fraction()
double TBOX::overlap_fraction |
( |
const TBOX & |
box | ) |
const |
|
inline |
◆ pad()
void TBOX::pad |
( |
int |
xpad, |
|
|
int |
ypad |
|
) |
| |
|
inline |
◆ plot() [1/2]
◆ plot() [2/2]
◆ print()
void TBOX::print |
( |
| ) |
const |
|
inline |
Definition at line 277 of file rect.h.
279 tprintf(
"Bounding box=(%d,%d)->(%d,%d)\n",
◆ print_to_str()
void TBOX::print_to_str |
( |
STRING * |
str | ) |
const |
◆ right()
int16_t TBOX::right |
( |
| ) |
const |
|
inline |
Definition at line 78 of file rect.h.
80 return top_right.
x ();
◆ rotate()
void TBOX::rotate |
( |
const FCOORD & |
vec | ) |
|
|
inline |
Definition at line 196 of file rect.h.
200 *
this =
TBOX (bot_left, top_right);
◆ rotate_large()
void TBOX::rotate_large |
( |
const FCOORD & |
vec | ) |
|
Definition at line 69 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);
◆ scale() [1/2]
void TBOX::scale |
( |
const FCOORD |
vec | ) |
|
|
inline |
Definition at line 185 of file rect.h.
188 bot_left.
set_x(static_cast<int16_t>(std::floor(bot_left.
x() * vec.
x())));
189 bot_left.
set_y(static_cast<int16_t>(std::floor(bot_left.
y() * vec.
y())));
190 top_right.
set_x(static_cast<int16_t>(std::ceil(top_right.
x() * vec.
x())));
191 top_right.
set_y(static_cast<int16_t>(std::ceil(top_right.
y() * vec.
y())));
◆ scale() [2/2]
void TBOX::scale |
( |
const float |
f | ) |
|
|
inline |
Definition at line 174 of file rect.h.
178 bot_left.
set_x(static_cast<int16_t>(std::floor(bot_left.
x() * f)));
180 bot_left.
set_y(static_cast<int16_t>(std::floor(bot_left.
y() * f)));
182 top_right.
set_x(static_cast<int16_t>(std::ceil(top_right.
x() * f)));
184 top_right.
set_y(static_cast<int16_t>(std::ceil(top_right.
y() * f)));
◆ Serialize()
bool TBOX::Serialize |
( |
FILE * |
fp | ) |
const |
◆ set_bottom()
void TBOX::set_bottom |
( |
int |
y | ) |
|
|
inline |
◆ set_left()
void TBOX::set_left |
( |
int |
x | ) |
|
|
inline |
◆ set_right()
void TBOX::set_right |
( |
int |
x | ) |
|
|
inline |
◆ 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 270 of file rect.h.
272 bot_left.
set_x(x_min);
273 bot_left.
set_y(y_min);
274 top_right.
set_x(x_max);
275 top_right.
set_y(y_max);
◆ set_top()
void TBOX::set_top |
( |
int |
y | ) |
|
|
inline |
◆ top()
int16_t TBOX::top |
( |
| ) |
const |
|
inline |
Definition at line 57 of file rect.h.
59 return top_right.
y ();
◆ topleft()
ICOORD TBOX::topleft |
( |
| ) |
const |
|
inline |
Definition at line 99 of file rect.h.
101 return ICOORD (bot_left.
x (), top_right.
y ());
◆ topright()
const ICOORD& TBOX::topright |
( |
| ) |
const |
|
inline |
◆ width()
int16_t TBOX::width |
( |
| ) |
const |
|
inline |
Definition at line 114 of file rect.h.
117 return top_right.
x () - bot_left.
x ();
◆ 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 224 of file rect.h.
226 return std::max(bot_left.
x(), box.bot_left.
x()) -
227 std::min(top_right.
x(), box.top_right.
x());
◆ x_middle()
int TBOX::x_middle |
( |
| ) |
const |
|
inline |
Definition at line 84 of file rect.h.
86 return (bot_left.
x() + top_right.
x()) / 2;
◆ x_overlap()
bool TBOX::x_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
◆ x_overlap_fraction()
double TBOX::x_overlap_fraction |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 445 of file rect.h.
458 int low = std::max(
left(), other.left());
◆ y_gap()
int TBOX::y_gap |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 232 of file rect.h.
234 return std::max(bot_left.
y(), box.bot_left.
y()) -
235 std::min(top_right.
y(), box.top_right.
y());
◆ y_middle()
int TBOX::y_middle |
( |
| ) |
const |
|
inline |
Definition at line 87 of file rect.h.
89 return (bot_left.
y() + top_right.
y()) / 2;
◆ y_overlap()
bool TBOX::y_overlap |
( |
const TBOX & |
box | ) |
const |
|
inline |
◆ y_overlap_fraction()
double TBOX::y_overlap_fraction |
( |
const TBOX & |
box | ) |
const |
|
inline |
Definition at line 466 of file rect.h.
468 return std::max(0.0, static_cast<double>(high - low) /
width);
◆ operator&=
Definition at line 222 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 ());
◆ operator+=
Definition at line 198 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 ())
The documentation for this class was generated from the following files: