37 bot_left (INT16_MAX, INT16_MAX), top_right (-INT16_MAX, -INT16_MAX) {
45 int16_t left, int16_t bottom, int16_t right, int16_t top);
51 return ((left () >= right ()) || (top () <= bottom ()));
55 return bot_left == other.bot_left && top_right == other.top_right;
59 return top_right.y ();
80 return top_right.x ();
86 return (bot_left.x() + top_right.x()) / 2;
89 return (bot_left.y() + top_right.y()) / 2;
97 return ICOORD (top_right.x (), bot_left.y ());
101 return ICOORD (bot_left.x (), top_right.y ());
110 return top_right.y () - bot_left.y ();
117 return top_right.x () - bot_left.x ();
124 return width () * height ();
131 void pad(
int xpad,
int ypad) {
139 bot_left +=
ICOORD (0, y);
144 bot_left +=
ICOORD (x, 0);
149 top_right +=
ICOORD (x, 0);
154 top_right +=
ICOORD (0, y);
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())));
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)));
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())));
198 bot_left.rotate (vec);
199 top_right.rotate (vec);
200 *
this =
TBOX (bot_left, top_right);
205 void rotate_large(
const FCOORD& vec);
211 const TBOX &box)
const;
214 const TBOX &box)
const;
217 const TBOX &box)
const;
220 bool x_overlap(
const TBOX &box)
const;
226 return std::max(bot_left.x(), box.bot_left.
x()) -
227 std::min(top_right.x(), box.top_right.
x());
234 return std::max(bot_left.y(), box.bot_left.
y()) -
235 std::min(top_right.y(), box.top_right.
y());
240 bool major_x_overlap(
const TBOX &box)
const;
243 bool y_overlap(
const TBOX &box)
const;
247 bool major_y_overlap(
const TBOX &box)
const;
250 double overlap_fraction(
const TBOX &box)
const;
253 double x_overlap_fraction(
const TBOX& box)
const;
256 double y_overlap_fraction(
const TBOX& box)
const;
259 bool x_almost_equal(
const TBOX &box,
int tolerance)
const;
262 bool almost_equal(
const TBOX &box,
int tolerance)
const;
265 const TBOX &box)
const;
268 const TBOX &box)
const;
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);
279 tprintf(
"Bounding box=(%d,%d)->(%d,%d)\n",
280 left(), bottom(), right(), top());
283 void print_to_str(
STRING *str)
const;
285 #ifndef GRAPHICS_DISABLED 288 fd->
Rectangle(bot_left.x (), bot_left.y (), top_right.x (),
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())),
324 static_cast<int16_t
>(std::ceil(pt.
y())));
334 return ((pt.
x () >= bot_left.
x ()) &&
335 (pt.
x () <= top_right.
x ()) &&
336 (pt.
y () >= bot_left.
y ()) && (pt.
y () <= top_right.
y ()));
356 const TBOX &box)
const {
357 return ((box.bot_left.
x () <= top_right.
x ()) &&
358 (box.top_right.
x () >= bot_left.
x ()) &&
359 (box.bot_left.
y () <= top_right.
y ()) &&
360 (box.top_right.
y () >= bot_left.
y ()));
369 const TBOX &box)
const {
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());
376 overlap -= std::max(box.bot_left.
y(), bot_left.
y());
389 double fraction = 0.0;
402 return ((box.bot_left.
x() <= top_right.
x()) &&
403 (box.top_right.
x() >= bot_left.
x()));
429 return ((box.bot_left.
y() <= top_right.
y()) &&
430 (box.top_right.
y() >= bot_left.
y()));
444 if (this->
top() < box.
top()) {
458 int low = std::max(
left(), other.
left());
463 if (other.
left() <= x && x <= other.
right())
468 return std::max(0.0, static_cast<double>(high - low) /
width);
481 int high = std::min(
top(), other.
top());
485 if (other.
bottom() <= y && y <= other.
top())
490 return std::max(0.0, static_cast<double>(high - low) /
height);
ICOORD & operator+=(ICOORD &op1, const ICOORD &op2)
const ICOORD & topright() const
bool major_y_overlap(const TBOX &box) const
void move_right_edge(const int16_t x)
void rotate(const FCOORD &vec)
TBOX intersection(const TBOX &box) const
int y_gap(const TBOX &box) const
int16_t y() const
access_function
bool x_overlap(const TBOX &box) const
void scale(const FCOORD vec)
int x_gap(const TBOX &box) const
double y_overlap_fraction(const TBOX &box) const
bool Serialize(FILE *fp, const char *data, size_t n)
void set_to_given_coords(int x_min, int y_min, int x_max, int y_max)
void scale(const float f)
void move(const ICOORD vec)
double x_overlap_fraction(const TBOX &box) const
double overlap_fraction(const TBOX &box) const
void move_bottom_edge(const int16_t y)
void plot(ScrollView *fd) const
int16_t x() const
access function
bool major_overlap(const TBOX &box) const
bool major_x_overlap(const TBOX &box) const
DLLSYM void tprintf(const char *format,...)
void move_top_edge(const int16_t y)
void move(const FCOORD vec)
const ICOORD & botleft() const
bool overlap(const TBOX &box) const
bool y_overlap(const TBOX &box) const
bool contains(const FCOORD pt) const
void Rectangle(int x1, int y1, int x2, int y2)
void move_left_edge(const int16_t x)
TBOX & operator &=(TBOX &op1, const TBOX &op2)
bool DeSerialize(FILE *fp, char *data, size_t n)
bool operator==(const TBOX &other) const
void pad(int xpad, int ypad)