#include <vgl_box_2d.h>
Inheritance diagram for vgl_box_2d< Type >:

A 2d box with sides aligned with the x and y axes. Also supports operations required of a bounding box for geometric region tests.
A box can be empty; this is what the default constructor creates, or what is left after applying the empty() method. Use the add() methods to enlarge a box, and use the contains() methods to check for inclusion of a point or an other box.
To make the convex union of two boxes, use box1.add(box2).
MaxPosition
O-------------O
| |
| |
| Centroid |
| o |
| |
Y | |
| | |
| O-------------O
| MinPosition
O------X
O------X
| MinPosition
| O-------------O
| | |
Y | |
| Centroid |
| o |
| |
| |
| |
O-------------O
MaxPosition
Definition at line 77 of file vgl_box_2d.h.
Public Types | |
| enum | point_type { centre = 0, min_pos, max_pos } |
Public Member Functions | |
| vgl_box_2d () | |
| Default constructor (creates empty box). | |
| vgl_box_2d (Type const min_position[2], Type const max_position[2]) | |
| Construct using two corner points. | |
| vgl_box_2d (vgl_point_2d< Type > const &min_pos, vgl_point_2d< Type > const &max_pos) | |
| Construct using two corner points. | |
| vgl_box_2d (Type xmin, Type xmax, Type ymin, Type ymax) | |
| Construct using ranges in x (first two args) and y (last two). | |
| vgl_box_2d (Type const ref_point[2], Type width, Type height, point_type) | |
| Construct a box sized width x height at a given reference point. | |
| vgl_box_2d (vgl_point_2d< Type > const &ref_point, Type width, Type height, point_type) | |
| Construct a box sized width x height at a given reference point. | |
| bool | operator== (vgl_box_2d< Type > const &b) const |
| Equality test. | |
| Type | width () const |
| Get width of this box (= x dimension). | |
| Type | height () const |
| Get height of this box (= y dimension). | |
| Type | area () const |
| Get "volume" (=area) of this box. | |
| Type | volume () const |
| Get "volume" (=area) of this box. | |
| Type | min_x () const |
| Get min x. | |
| Type | min_y () const |
| Get min y. | |
| Type | max_x () const |
| Get max x. | |
| Type | max_y () const |
| Get max y. | |
| vgl_point_2d< Type > | centroid () const |
| Get the centroid point. | |
| Type | centroid_x () const |
| Get x component of centroid. | |
| Type | centroid_y () const |
| Get y component of centroid. | |
| vgl_point_2d< Type > | min_point () const |
| Return lower left corner of box. | |
| vgl_point_2d< Type > | max_point () const |
| Return upper right corner of box. | |
| bool | is_empty () const |
| Return true if this box is empty. | |
| void | add (vgl_point_2d< Type > const &p) |
| Add a point to this box. | |
| void | add (vgl_box_2d< Type > const &b) |
| Make the convex union of two boxes. | |
| bool | contains (vgl_point_2d< Type > const &p) const |
| Return true iff the point p is inside this box. | |
| bool | contains (vgl_box_2d< Type > const &b) const |
| Return true iff the corner points of b are inside this box. | |
| bool | contains (Type const &x, Type const &y) const |
| Return true if (x,y) inside box, ie x_min <= x <= x_max etc. | |
| void | empty () |
| Make the box empty. | |
| void | set_min_x (Type m) |
| Set left side of box (other side ordinates unchanged). | |
| void | set_min_y (Type m) |
| Set bottom of box (other side ordinates unchanged). | |
| void | set_max_x (Type m) |
| Set right side (other side ordinates unchanged). | |
| void | set_max_y (Type m) |
| Set top (other side ordinates unchanged). | |
| void | set_centroid_x (Type cx) |
| Move box so centroid lies at cx (width and height unchanged). | |
| void | set_centroid_y (Type cy) |
| Move box so centroid lies at cy (width and height unchanged). | |
| void | set_width (Type width) |
| Modify width, retaining centroid at current position. | |
| void | set_height (Type height) |
| Modify height, retaining centroid at current position. | |
| void | expand_about_centroid (Type expand) |
| Add to width and height, centroid unchanged. | |
| void | scale_about_centroid (double s) |
| Scale width and height, centroid unchanged. | |
| void | scale_about_origin (double s) |
| Scale width and height, keeping scaled position of origin unchanged. | |
| void | setmin_position (Type const min_position[2]) |
| Modify bottom left. Top right only changed if necessary to avoid empty box. | |
| void | setmax_position (Type const max_position[2]) |
| Modify top right. Bottom left only changed if necessary to avoid empty box. | |
| void | set_min_point (vgl_point_2d< Type > const &min_pt) |
| Modify bottom left. Top right only changed if necessary to avoid empty box. | |
| void | set_max_point (vgl_point_2d< Type > const &max_pt) |
| Modify top right. Bottom left only changed if necessary to avoid empty box. | |
| void | set_centroid (Type const c[2]) |
| Move box so centroid lies at c (width, height unchanged). | |
| void | set_centroid (vgl_point_2d< Type > const &c) |
| Move box so centroid lies at c (width, height unchanged). | |
| vcl_ostream & | print (vcl_ostream &) const |
| Write "<vgl_box_2d x0,y0 to x1,y1>" to stream. | |
| vcl_ostream & | write (vcl_ostream &) const |
| Write "x0 y0 x1 y1(endl)" to stream. | |
| vcl_istream & | read (vcl_istream &) |
| Read x0,y0,x1,y1 from stream. | |
Protected Attributes | |
| Type | min_pos_ [2] |
| Type | max_pos_ [2] |
Related Functions | |
| (Note that these are not member functions.) | |
| vcl_ostream & | operator<< (vcl_ostream &s, vgl_box_2d< Type > const &p) |
| Write box to stream. | |
| vcl_istream & | operator>> (vcl_istream &is, vgl_box_2d< Type > &p) |
| Read box from stream. | |
| vgl_box_2d< Type > | vgl_intersection (vgl_box_2d< Type > const &a, vgl_box_2d< Type > const &b) |
| Return box defining intersection between boxes a and b. | |
| vgl_line_segment_2d< T > | vgl_clip_line_to_box (vgl_line_2d< T > const &l, vgl_box_2d< T > const &b) |
| clip given line to given box, and return resulting line segment. | |
|
|||||
|
Definition at line 95 of file vgl_box_2d.h. |
|
|||||||||
|
Default constructor (creates empty box).
Definition at line 17 of file vgl_box_2d.txx. |
|
||||||||||||||||
|
Construct using two corner points.
Definition at line 24 of file vgl_box_2d.txx. |
|
||||||||||||||||
|
Construct using two corner points.
Definition at line 33 of file vgl_box_2d.txx. |
|
||||||||||||||||||||||||
|
Construct using ranges in x (first two args) and y (last two).
Definition at line 42 of file vgl_box_2d.txx. |
|
||||||||||||||||||||||||
|
Construct a box sized width x height at a given reference point. The box will either be centered at ref_point or will have ref_point as its min-position or max-position, as specified by the 4th argument. |
|
||||||||||||||||||||||||
|
Construct a box sized width x height at a given reference point. The box will either be centered at ref_point or will have ref_point as its min-position or max-position, as specified by the 4th argument. |
|
||||||||||
|
Make the convex union of two boxes. Do this by possibly enlarging this box so that the corner points of the given box just fall within the box. Adding an empty box does not change the current box. Definition at line 348 of file vgl_box_2d.txx. |
|
||||||||||
|
Add a point to this box. Do this by possibly enlarging the box so that the point just falls within the box. Adding a point to an empty box makes it a size zero box only containing p. Definition at line 327 of file vgl_box_2d.txx. |
|
|||||||||
|
Get "volume" (=area) of this box.
Definition at line 127 of file vgl_box_2d.h. |
|
|||||||||
|
Get the centroid point.
Definition at line 150 of file vgl_box_2d.txx. |
|
|||||||||
|
Get x component of centroid.
Definition at line 110 of file vgl_box_2d.txx. |
|
|||||||||
|
Get y component of centroid.
Definition at line 117 of file vgl_box_2d.txx. |
|
||||||||||||||||
|
Return true if (x,y) inside box, ie x_min <= x <= x_max etc.
Definition at line 178 of file vgl_box_2d.h. |
|
||||||||||
|
Return true iff the corner points of b are inside this box.
Definition at line 364 of file vgl_box_2d.txx. |
|
||||||||||
|
Return true iff the point p is inside this box.
Definition at line 357 of file vgl_box_2d.txx. |
|
|||||||||
|
Make the box empty.
Definition at line 373 of file vgl_box_2d.txx. |
|
||||||||||
|
Add to width and height, centroid unchanged.
Will move each side by Definition at line 219 of file vgl_box_2d.txx. |
|
|||||||||
|
Get height of this box (= y dimension).
Definition at line 130 of file vgl_box_2d.txx. |
|
|||||||||
|
Return true if this box is empty.
Definition at line 156 of file vgl_box_2d.h. |
|
|||||||||
|
Return upper right corner of box.
Definition at line 143 of file vgl_box_2d.txx. |
|
|||||||||
|
Get max x.
Definition at line 136 of file vgl_box_2d.h. |
|
|||||||||
|
Get max y.
Definition at line 138 of file vgl_box_2d.h. |
|
|||||||||
|
Return lower left corner of box.
Definition at line 136 of file vgl_box_2d.txx. |
|
|||||||||
|
Get min x.
Definition at line 132 of file vgl_box_2d.h. |
|
|||||||||
|
Get min y.
Definition at line 134 of file vgl_box_2d.h. |
|
||||||||||
|
Equality test.
Definition at line 112 of file vgl_box_2d.h. |
|
||||||||||
|
Write "<vgl_box_2d x0,y0 to x1,y1>" to stream.
Definition at line 285 of file vgl_box_2d.txx. |
|
||||||||||
|
Read x0,y0,x1,y1 from stream.
Definition at line 303 of file vgl_box_2d.txx. |
|
||||||||||
|
Scale width and height, centroid unchanged.
Definition at line 228 of file vgl_box_2d.txx. |
|
||||||||||
|
Scale width and height, keeping scaled position of origin unchanged.
Definition at line 238 of file vgl_box_2d.txx. |
|
||||||||||
|
Move box so centroid lies at c (width, height unchanged).
Definition at line 233 of file vgl_box_2d.h. |
|
||||||||||
|
Move box so centroid lies at c (width, height unchanged).
Definition at line 231 of file vgl_box_2d.h. |
|
||||||||||
|
Move box so centroid lies at cx (width and height unchanged).
Definition at line 157 of file vgl_box_2d.txx. |
|
||||||||||
|
Move box so centroid lies at cy (width and height unchanged).
Definition at line 166 of file vgl_box_2d.txx. |
|
||||||||||
|
Modify height, retaining centroid at current position. For integer types, centroid might change slightly, but repeat calls to set_height will not cause centroid drift. Definition at line 209 of file vgl_box_2d.txx. |
|
||||||||||
|
Modify top right. Bottom left only changed if necessary to avoid empty box.
Definition at line 278 of file vgl_box_2d.txx. |
|
||||||||||
|
Set right side (other side ordinates unchanged).
Definition at line 199 of file vgl_box_2d.h. |
|
||||||||||
|
Set top (other side ordinates unchanged).
Definition at line 201 of file vgl_box_2d.h. |
|
||||||||||
|
Modify bottom left. Top right only changed if necessary to avoid empty box.
Definition at line 271 of file vgl_box_2d.txx. |
|
||||||||||
|
Set left side of box (other side ordinates unchanged).
Definition at line 195 of file vgl_box_2d.h. |
|
||||||||||
|
Set bottom of box (other side ordinates unchanged).
Definition at line 197 of file vgl_box_2d.h. |
|
||||||||||
|
Modify width, retaining centroid at current position. For integer types, centroid might change slightly, but repeat calls to set_height will not cause centroid drift. Definition at line 199 of file vgl_box_2d.txx. |
|
||||||||||
|
Modify top right. Bottom left only changed if necessary to avoid empty box.
Definition at line 260 of file vgl_box_2d.txx. |
|
||||||||||
|
Modify bottom left. Top right only changed if necessary to avoid empty box.
Definition at line 247 of file vgl_box_2d.txx. |
|
|||||||||
|
Get "volume" (=area) of this box.
Definition at line 129 of file vgl_box_2d.h. |
|
|||||||||
|
Get width of this box (= x dimension).
Definition at line 124 of file vgl_box_2d.txx. |
|
||||||||||
|
Write "x0 y0 x1 y1(endl)" to stream.
Definition at line 296 of file vgl_box_2d.txx. |
|
||||||||||||||||
|
Write box to stream.
Definition at line 381 of file vgl_box_2d.txx. |
|
||||||||||||||||
|
Read box from stream.
Definition at line 388 of file vgl_box_2d.txx. |
|
||||||||||||||||
|
clip given line to given box, and return resulting line segment.
Definition at line 52 of file vgl_clip.h. |
|
||||||||||||||||
|
Return box defining intersection between boxes a and b. Empty box returned if no intersection. Definition at line 310 of file vgl_box_2d.txx. |
|
|||||
|
Definition at line 250 of file vgl_box_2d.h. |
|
|||||
|
Definition at line 249 of file vgl_box_2d.h. |
1.4.4