#include <vgl_box_3d.h>
A 3d box with sides aligned with x, y and z axes. Supports operations required of a bounding box for geometric volume 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
|<--width-->|
O-----------O ---
/ /| ^
/ / | |
O-----------O | height
| o | | |
| centroid | | v
| | O ---
Y | | / /_____depth
| Z | |/ /
| / O-----------O ---
| / MinPosition
O-----X
Definition at line 64 of file vgl_box_3d.h.
Public Types | |
| enum | point_type { centre = 0, min_pos, max_pos } |
Public Member Functions | |
| vgl_box_3d () | |
| Default constructor (creates empty box). | |
| vgl_box_3d (Type const corner1[3], Type const corner2[3]) | |
| Construct using two corner points. | |
| vgl_box_3d (vgl_point_3d< Type > const &corner1, vgl_point_3d< Type > const &corner2) | |
| Construct using two corner points. | |
| vgl_box_3d (Type xmin, Type ymin, Type zmin, Type xmax, Type ymax, Type zmax) | |
| Construct from ranges in x,y,z (take care with order of inputs). | |
| vgl_box_3d (Type const ref_point[3], Type width, Type height, Type depth, point_type) | |
| Construct a box sized width x height x depth at a given reference point. | |
| vgl_box_3d (vgl_point_3d< Type > const &ref_point, Type width, Type height, Type depth, point_type) | |
| Construct a box sized width x height x depth at a given reference point. | |
| bool | operator== (vgl_box_3d< 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 | depth () const |
| Get depth of this box (= z dimension). | |
| Type | volume () const |
| Get volume of this box. | |
| Type | min_x () const |
| Get min x. | |
| Type | min_y () const |
| Get min y. | |
| Type | min_z () const |
| Get min z. | |
| Type | max_x () const |
| Get max x. | |
| Type | max_y () const |
| Get max y. | |
| Type | max_z () const |
| Get max z. | |
| vgl_point_3d< 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. | |
| Type | centroid_z () const |
| Get z component of centroid. | |
| vgl_point_3d< Type > | min_point () const |
| Return lower left corner of box. | |
| vgl_point_3d< 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_3d< Type > const &p) |
| Add a point to this box. | |
| void | add (vgl_box_3d< Type > const &b) |
| Make the convex union of two boxes. | |
| bool | contains (vgl_point_3d< Type > const &p) const |
| Return true iff the point p is inside this box. | |
| bool | contains (vgl_box_3d< Type > const &b) const |
| Return true iff the corner points of b are inside this box. | |
| bool | contains (Type const &x, Type const &y, Type const &z) const |
| Return true if (x,y,z) is inside this box, ie x_min <= x <= x_max etc. | |
| void | empty () |
| Make the box empty. | |
| void | set_min_x (Type m) |
| Set min x ordinate of box (other sides unchanged). | |
| void | set_min_y (Type m) |
| Set min y ordinate of box (other sides unchanged). | |
| void | set_min_z (Type m) |
| Set min z ordinate of box (other sides unchanged). | |
| void | set_max_x (Type m) |
| Set max x ordinate of box (other sides unchanged). | |
| void | set_max_y (Type m) |
| Set max y ordinate of box (other sides unchanged). | |
| void | set_max_z (Type m) |
| Set max z ordinate of box (other sides unchanged). | |
| void | set_centroid_x (Type cx) |
| Move box so centroid lies at cx (size unchanged). | |
| void | set_centroid_y (Type cy) |
| Move box so centroid lies at cy (size unchanged). | |
| void | set_centroid_z (Type cz) |
| Move box so centroid lies at cz (size unchanged). | |
| void | set_width (Type width) |
| Set width (x), centroid unchanged. | |
| void | set_height (Type height) |
| Set height (y), centroid unchanged. | |
| void | set_depth (Type depth) |
| Set depth (z), centroid unchanged. | |
| void | expand_about_centroid (Type expand) |
| Add to width and height, centroid unchanged. | |
| void | scale_about_centroid (double s) |
| Scale width, height and depth, centroid unchanged. | |
| void | scale_about_origin (double s) |
| Scale width, height and depth, keeping scaled position of origin unchanged. | |
| void | set_min_position (Type const m[3]) |
| Modify min corner point. Max corner point only changed if necessary to avoid empty box. | |
| void | set_max_position (Type const m[3]) |
| Modify max corner point. Min corner point only changed if necessary to avoid empty box. | |
| void | set_min_point (vgl_point_3d< Type > const &min_pt) |
| Modify min corner point. Max corner point only changed if necessary to avoid empty box. | |
| void | set_max_point (vgl_point_3d< Type > const &max_pt) |
| Modify max corner point. Min corner point only changed if necessary to avoid empty box. | |
| void | set_centroid (Type const c[3]) |
| Move box so centroid lies at c (size unchanged). | |
| void | set_centroid (vgl_point_3d< Type > const &c) |
| Move box so centroid lies at c (size unchanged). | |
| vcl_ostream & | print (vcl_ostream &) const |
| Write "<vgl_box_3d x0,y0,z0 to x1,y1,z1>" to stream. | |
| vcl_ostream & | write (vcl_ostream &) const |
| Write "x0 y0 z0 x1 y1 z1(endl)" to stream. | |
| vcl_istream & | read (vcl_istream &) |
| Read x0,y0,z0,x1,y1,z1 from stream. | |
Protected Attributes | |
| Type | min_pos_ [3] |
| Type | max_pos_ [3] |
Related Functions | |
| (Note that these are not member functions.) | |
| bool | vgl_intersection (vgl_box_3d< T > const &b, vcl_list< vgl_point_3d< T > > &p) |
| Return true if the box and polygon intersect in 3-d, regions include boundaries. | |
| vcl_ostream & | operator<< (vcl_ostream &s, vgl_orient_box_3d< Type > const &p) |
| Write box to stream. | |
| vcl_istream & | operator>> (vcl_istream &is, vgl_orient_box_3d< Type > &p) |
| Read box from stream. | |
| vcl_ostream & | operator<< (vcl_ostream &s, vgl_box_3d< Type > const &p) |
| Write box to stream. | |
| vcl_istream & | operator>> (vcl_istream &is, vgl_box_3d< Type > &p) |
| Read box from stream. | |
| bool | vgl_intersection (vgl_box_3d< T > const &b, vgl_point_3d< T > const &p) |
| Return true if the point lies inside the box. | |
| bool | vgl_intersection (vgl_point_3d< T > const &p, vgl_box_3d< T > const &b) |
| Return true if the point lies inside the box. | |
| bool | vgl_intersection (vgl_box_3d< T > const &b, vgl_plane_3d< T > const &plane) |
| Return true if a box and plane intersect in 3D. | |
| vgl_box_3d< T > | vgl_intersection (vgl_box_3d< T > const &, vgl_box_3d< T > const &) |
| Return the intersection of two boxes (which is itself either a box, or empty). | |
| vcl_vector< vgl_point_3d< T > > | vgl_intersection (vgl_box_3d< T > const &b, vcl_vector< vgl_point_3d< T > > const &p) |
| Return the points from the list that lie inside the box. | |
| vcl_vector< vgl_point_3d< T > > | vgl_intersection (vcl_vector< vgl_point_3d< T > > const &p, vgl_box_3d< T > const &b) |
| Return the points from the list that lie inside the box. | |
| enum vgl_box_3d::point_type |
| vgl_box_3d< Type >::vgl_box_3d | ( | ) |
| vgl_box_3d< Type >::vgl_box_3d | ( | Type const | corner1[3], | |
| Type const | corner2[3] | |||
| ) |
| vgl_box_3d< Type >::vgl_box_3d | ( | vgl_point_3d< Type > const & | corner1, | |
| vgl_point_3d< Type > const & | corner2 | |||
| ) |
| vgl_box_3d< Type >::vgl_box_3d | ( | Type | xmin, | |
| Type | ymin, | |||
| Type | zmin, | |||
| Type | xmax, | |||
| Type | ymax, | |||
| Type | zmax | |||
| ) |
Construct from ranges in x,y,z (take care with order of inputs).
The x range is given by the 1st and 4th coordinates, the y range is given by the 2nd and 5th coordinates, the z range is given by the 3rd and 6th coordinates.
Definition at line 44 of file vgl_box_3d.txx.
| vgl_box_3d< Type >::vgl_box_3d | ( | Type const | ref_point[3], | |
| Type | width, | |||
| Type | height, | |||
| Type | depth, | |||
| point_type | ||||
| ) |
Construct a box sized width x height x depth 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 5th argument.
| vgl_box_3d< Type >::vgl_box_3d | ( | vgl_point_3d< Type > const & | ref_point, | |
| Type | width, | |||
| Type | height, | |||
| Type | depth, | |||
| point_type | ||||
| ) |
Construct a box sized width x height x depth 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 5th argument.
| bool vgl_box_3d< Type >::operator== | ( | vgl_box_3d< Type > const & | b | ) | const [inline] |
| Type vgl_box_3d< Type >::width | ( | ) | const |
| Type vgl_box_3d< Type >::height | ( | ) | const |
| Type vgl_box_3d< Type >::depth | ( | ) | const |
| Type vgl_box_3d< Type >::volume | ( | ) | const [inline] |
| Type vgl_box_3d< Type >::min_x | ( | ) | const [inline] |
| Type vgl_box_3d< Type >::min_y | ( | ) | const [inline] |
| Type vgl_box_3d< Type >::min_z | ( | ) | const [inline] |
| Type vgl_box_3d< Type >::max_x | ( | ) | const [inline] |
| Type vgl_box_3d< Type >::max_y | ( | ) | const [inline] |
| Type vgl_box_3d< Type >::max_z | ( | ) | const [inline] |
| vgl_point_3d< Type > vgl_box_3d< Type >::centroid | ( | ) | const |
| Type vgl_box_3d< Type >::centroid_x | ( | ) | const |
| Type vgl_box_3d< Type >::centroid_y | ( | ) | const |
| Type vgl_box_3d< Type >::centroid_z | ( | ) | const |
| vgl_point_3d< Type > vgl_box_3d< Type >::min_point | ( | ) | const |
| vgl_point_3d< Type > vgl_box_3d< Type >::max_point | ( | ) | const |
| bool vgl_box_3d< Type >::is_empty | ( | ) | const [inline] |
| void vgl_box_3d< Type >::add | ( | vgl_point_3d< Type > const & | p | ) |
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 354 of file vgl_box_3d.txx.
| void vgl_box_3d< Type >::add | ( | vgl_box_3d< Type > const & | b | ) |
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 378 of file vgl_box_3d.txx.
| bool vgl_box_3d< Type >::contains | ( | vgl_point_3d< Type > const & | p | ) | const |
| bool vgl_box_3d< Type >::contains | ( | vgl_box_3d< Type > const & | b | ) | const |
Return true iff the corner points of b are inside this box.
Definition at line 394 of file vgl_box_3d.txx.
| bool vgl_box_3d< Type >::contains | ( | Type const & | x, | |
| Type const & | y, | |||
| Type const & | z | |||
| ) | const [inline] |
Return true if (x,y,z) is inside this box, ie x_min <= x <= x_max etc.
Definition at line 176 of file vgl_box_3d.h.
| void vgl_box_3d< Type >::empty | ( | ) |
| void vgl_box_3d< Type >::set_min_x | ( | Type | m | ) | [inline] |
| void vgl_box_3d< Type >::set_min_y | ( | Type | m | ) | [inline] |
| void vgl_box_3d< Type >::set_min_z | ( | Type | m | ) | [inline] |
| void vgl_box_3d< Type >::set_max_x | ( | Type | m | ) | [inline] |
| void vgl_box_3d< Type >::set_max_y | ( | Type | m | ) | [inline] |
| void vgl_box_3d< Type >::set_max_z | ( | Type | m | ) | [inline] |
| void vgl_box_3d< Type >::set_centroid_x | ( | Type | cx | ) |
| void vgl_box_3d< Type >::set_centroid_y | ( | Type | cy | ) |
| void vgl_box_3d< Type >::set_centroid_z | ( | Type | cz | ) |
| void vgl_box_3d< Type >::set_width | ( | Type | width | ) |
| void vgl_box_3d< Type >::set_height | ( | Type | height | ) |
| void vgl_box_3d< Type >::set_depth | ( | Type | depth | ) |
| void vgl_box_3d< Type >::expand_about_centroid | ( | Type | expand | ) |
Add to width and height, centroid unchanged.
Will move each side by expand / 2.
Definition at line 243 of file vgl_box_3d.txx.
| void vgl_box_3d< Type >::scale_about_centroid | ( | double | s | ) |
| void vgl_box_3d< Type >::scale_about_origin | ( | double | s | ) |
Scale width, height and depth, keeping scaled position of origin unchanged.
Definition at line 263 of file vgl_box_3d.txx.
| void vgl_box_3d< Type >::set_min_position | ( | Type const | m[3] | ) |
Modify min corner point. Max corner point only changed if necessary to avoid empty box.
Definition at line 274 of file vgl_box_3d.txx.
| void vgl_box_3d< Type >::set_max_position | ( | Type const | m[3] | ) |
Modify max corner point. Min corner point only changed if necessary to avoid empty box.
Definition at line 285 of file vgl_box_3d.txx.
| void vgl_box_3d< Type >::set_min_point | ( | vgl_point_3d< Type > const & | min_pt | ) |
Modify min corner point. Max corner point only changed if necessary to avoid empty box.
Definition at line 296 of file vgl_box_3d.txx.
| void vgl_box_3d< Type >::set_max_point | ( | vgl_point_3d< Type > const & | max_pt | ) |
Modify max corner point. Min corner point only changed if necessary to avoid empty box.
Definition at line 304 of file vgl_box_3d.txx.
| void vgl_box_3d< Type >::set_centroid | ( | Type const | c[3] | ) | [inline] |
| void vgl_box_3d< Type >::set_centroid | ( | vgl_point_3d< Type > const & | c | ) | [inline] |
| vcl_ostream & vgl_box_3d< Type >::print | ( | vcl_ostream & | ) | const |
| vcl_ostream & vgl_box_3d< Type >::write | ( | vcl_ostream & | ) | const |
| vcl_istream & vgl_box_3d< Type >::read | ( | vcl_istream & | ) |
| bool vgl_intersection | ( | vgl_box_3d< T > const & | b, | |
| vcl_list< vgl_point_3d< T > > & | p | |||
| ) | [related] |
Return true if the box and polygon intersect in 3-d, regions include boundaries.
Polygon is represented as an ordered vector of 3-d points
| vcl_ostream & operator<< | ( | vcl_ostream & | s, | |
| vgl_orient_box_3d< Type > const & | p | |||
| ) | [related] |
Write box to stream.
| vcl_istream & operator>> | ( | vcl_istream & | is, | |
| vgl_orient_box_3d< Type > & | p | |||
| ) | [related] |
Read box from stream.
| vcl_ostream & operator<< | ( | vcl_ostream & | s, | |
| vgl_box_3d< Type > const & | p | |||
| ) | [related] |
Write box to stream.
| vcl_istream & operator>> | ( | vcl_istream & | is, | |
| vgl_box_3d< Type > & | p | |||
| ) | [related] |
Read box from stream.
| bool vgl_intersection | ( | vgl_box_3d< T > const & | b, | |
| vgl_point_3d< T > const & | p | |||
| ) | [related] |
| bool vgl_intersection | ( | vgl_point_3d< T > const & | p, | |
| vgl_box_3d< T > const & | b | |||
| ) | [related] |
| bool vgl_intersection | ( | vgl_box_3d< T > const & | b, | |
| vgl_plane_3d< T > const & | plane | |||
| ) | [related] |
Return true if a box and plane intersect in 3D.
Definition at line 165 of file vgl_intersection.txx.
| vgl_box_3d< T > vgl_intersection | ( | vgl_box_3d< T > const & | , | |
| vgl_box_3d< T > const & | ||||
| ) | [related] |
Return the intersection of two boxes (which is itself either a box, or empty).
Definition at line 197 of file vgl_intersection.txx.
| vcl_vector< vgl_point_3d< T > > vgl_intersection | ( | vgl_box_3d< T > const & | b, | |
| vcl_vector< vgl_point_3d< T > > const & | p | |||
| ) | [related] |
Return the points from the list that lie inside the box.
Definition at line 901 of file vgl_intersection.txx.
| vcl_vector< vgl_point_3d< T > > vgl_intersection | ( | vcl_vector< vgl_point_3d< T > > const & | p, | |
| vgl_box_3d< T > const & | b | |||
| ) | [related] |
Return the points from the list that lie inside the box.
Definition at line 915 of file vgl_intersection.txx.
Type vgl_box_3d< Type >::min_pos_[3] [protected] |
Definition at line 249 of file vgl_box_3d.h.
Type vgl_box_3d< Type >::max_pos_[3] [protected] |
Definition at line 250 of file vgl_box_3d.h.
1.5.1