Public Types | Public Member Functions | Protected Attributes | Related Functions | List of all members
vgl_bbox_2d< Type > Class Template Reference

vgl_rtree Class C for V=vgl_box_2d<T>, B = vgl_rbox_2d<T>. More...

#include <vgl_rtree_c.h>

Inheritance diagram for vgl_bbox_2d< Type >:
Inheritance graph
[legend]

Public Types

enum  point_type { centre =0, min_pos, max_pos }
 

Public Member Functions

 vgl_bbox_2d ()=default
 Default constructor (creates empty box). More...
 
 vgl_bbox_2d (Type const min_position[2], Type const max_position[2])
 Construct using two corner points. More...
 
 vgl_bbox_2d (vgl_point_2d< Type > const &min_pos, vgl_point_2d< Type > const &max_pos)
 Construct using two corner points. More...
 
 vgl_bbox_2d (Type xmin, Type xmax, Type ymin, Type ymax)
 Construct using ranges in x (first two args) and y (last two). More...
 
bool operator== (vgl_bbox_2d< Type > const &b) const
 Equality test. More...
 
bool operator== (vgl_box_2d< Type > const &b) const
 Equality test. More...
 
Type width () const
 Get width of this box (= x dimension). More...
 
Type height () const
 Get height of this box (= y dimension). More...
 
Type volume () const
 Get "volume" (=area) of this box. More...
 
Type min_x () const
 Get min x. More...
 
Type min_y () const
 Get min y. More...
 
Type max_x () const
 Get max x. More...
 
Type max_y () const
 Get max y. More...
 
vgl_point_2d< Type > centroid () const
 Get the centroid point. More...
 
Type centroid_x () const
 Get x component of centroid. More...
 
Type centroid_y () const
 Get y component of centroid. More...
 
vgl_point_2d< Type > min_point () const
 Return lower left corner of box. More...
 
vgl_point_2d< Type > max_point () const
 Return upper right corner of box. More...
 
bool is_empty () const
 Return true if this box is empty. More...
 
void add (vgl_point_2d< Type > const &p)
 Add a point to this box. More...
 
void add (vgl_box_2d< Type > const &b)
 Make the convex union of two boxes. More...
 
bool contains (vgl_point_2d< Type > const &p) const
 Return true iff the point p is inside this box. More...
 
bool contains (vgl_box_2d< Type > const &b) const
 Return true iff the corner points of b are inside this box. More...
 
bool contains (Type const &x, Type const &y) const
 Return true if (x,y) inside box, ie x_min <= x <= x_max etc. More...
 
void empty ()
 Make the box empty. More...
 
void set_min_x (Type m)
 Set left side of box (other side ordinates unchanged). More...
 
void set_min_y (Type m)
 Set bottom of box (other side ordinates unchanged). More...
 
void set_max_x (Type m)
 Set right side (other side ordinates unchanged). More...
 
void set_max_y (Type m)
 Set top (other side ordinates unchanged). More...
 
void set_centroid_x (Type cx)
 Move box so centroid lies at cx (width and height unchanged). More...
 
void set_centroid_y (Type cy)
 Move box so centroid lies at cy (width and height unchanged). More...
 
void set_width (Type width)
 Modify width, retaining centroid at current position. More...
 
void set_height (Type height)
 Modify height, retaining centroid at current position. More...
 
void expand_about_centroid (Type expand)
 Add to width and height, centroid unchanged. More...
 
void scale_about_centroid (double s)
 Scale width and height, centroid unchanged. More...
 
void scale_about_origin (double s)
 Scale width and height, keeping scaled position of origin unchanged. More...
 
void setmin_position (Type const min_position[2])
 Modify bottom left. Top right only changed if necessary to avoid empty box. More...
 
void setmax_position (Type const max_position[2])
 Modify top right. Bottom left only changed if necessary to avoid empty box. More...
 
void set_min_point (vgl_point_2d< Type > const &min_pt)
 Modify bottom left. Top right only changed if necessary to avoid empty box. More...
 
void set_max_point (vgl_point_2d< Type > const &max_pt)
 Modify top right. Bottom left only changed if necessary to avoid empty box. More...
 
void set_centroid (Type const c[2])
 Move box so centroid lies at c (width, height unchanged). More...
 
void set_centroid (vgl_point_2d< Type > const &c)
 Move box so centroid lies at c (width, height unchanged). More...
 
std::ostream & print (std::ostream &) const
 Write "<vgl_box_2d x0,y0 to x1,y1>" to stream. More...
 
std::ostream & write (std::ostream &) const
 Write "x0 y0 x1 y1(endl)" to stream. More...
 
std::istream & read (std::istream &)
 Read x0,y0,x1,y1 from stream. More...
 

Protected Attributes

Type min_pos_ [2]
 
Type max_pos_ [2]
 

Related Functions

(Note that these are not member functions.)

template<class Type >
std::ostream & operator<< (std::ostream &s, vgl_box_2d< Type > const &p)
 Write box to stream. More...
 
template<class Type >
std::istream & operator>> (std::istream &is, vgl_box_2d< Type > &p)
 Read box from stream. More...
 
template<class T >
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. More...
 
template<class T >
bool vgl_intersection (vgl_box_2d< T > const &b, vgl_point_2d< T > const &p)
 Return true if the point lies inside the box. More...
 
template<class T >
bool vgl_intersection (vgl_point_2d< T > const &p, vgl_box_2d< T > const &b)
 Return true if the point lies inside the box. More...
 
template<class T >
vgl_box_2d< T > vgl_intersection (vgl_box_2d< T > const &, vgl_box_2d< T > const &)
 Return the intersection of two boxes (which is itself either a box, or empty). More...
 
template<class T >
bool vgl_intersection (vgl_box_2d< T > const &b, vgl_polygon< T > const &poly)
 Return true if the box and polygon regions intersect, regions include boundaries. More...
 
template<class T >
std::vector< vgl_point_2d< T > > vgl_intersection (vgl_box_2d< T > const &b, std::vector< vgl_point_2d< T > > const &p)
 Return the points from the list that lie inside the box. More...
 
template<class T >
std::vector< vgl_point_2d< T > > vgl_intersection (std::vector< vgl_point_2d< T > > const &p, vgl_box_2d< T > const &b)
 Return the points from the list that lie inside the box. More...
 

Detailed Description

template<class Type>
class vgl_bbox_2d< Type >

vgl_rtree Class C for V=vgl_box_2d<T>, B = vgl_rbox_2d<T>.

Need to distinguish bounds type from stored element type, so create minimal subclass of vgl_box_2d

Definition at line 72 of file vgl_rtree_c.h.

Member Enumeration Documentation

◆ point_type

template<class Type>
enum vgl_box_2d::point_type
inherited
Enumerator
centre 
min_pos 
max_pos 

Definition at line 97 of file vgl_box_2d.h.

Constructor & Destructor Documentation

◆ vgl_bbox_2d() [1/4]

template<class Type>
vgl_bbox_2d< Type >::vgl_bbox_2d ( )
default

Default constructor (creates empty box).

◆ vgl_bbox_2d() [2/4]

template<class Type>
vgl_bbox_2d< Type >::vgl_bbox_2d ( Type const  min_position[2],
Type const  max_position[2] 
)
inline

Construct using two corner points.

Definition at line 79 of file vgl_rtree_c.h.

◆ vgl_bbox_2d() [3/4]

template<class Type>
vgl_bbox_2d< Type >::vgl_bbox_2d ( vgl_point_2d< Type > const &  min_pos,
vgl_point_2d< Type > const &  max_pos 
)
inline

Construct using two corner points.

Definition at line 84 of file vgl_rtree_c.h.

◆ vgl_bbox_2d() [4/4]

template<class Type>
vgl_bbox_2d< Type >::vgl_bbox_2d ( Type  xmin,
Type  xmax,
Type  ymin,
Type  ymax 
)
inline

Construct using ranges in x (first two args) and y (last two).

Definition at line 89 of file vgl_rtree_c.h.

Member Function Documentation

◆ add() [1/2]

template<class Type>
void vgl_box_2d< Type >::add ( vgl_point_2d< Type > const &  p)
inherited

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 317 of file vgl_box_2d.hxx.

◆ add() [2/2]

template<class Type>
void vgl_box_2d< Type >::add ( vgl_box_2d< Type > const &  b)
inherited

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 338 of file vgl_box_2d.hxx.

◆ centroid()

template<class Type >
vgl_point_2d< Type > vgl_box_2d< Type >::centroid ( ) const
inherited

Get the centroid point.

Definition at line 154 of file vgl_box_2d.hxx.

◆ centroid_x()

template<class Type >
Type vgl_box_2d< Type >::centroid_x ( ) const
inherited

Get x component of centroid.

Definition at line 114 of file vgl_box_2d.hxx.

◆ centroid_y()

template<class Type >
Type vgl_box_2d< Type >::centroid_y ( ) const
inherited

Get y component of centroid.

Definition at line 121 of file vgl_box_2d.hxx.

◆ contains() [1/3]

template<class Type>
bool vgl_box_2d< Type >::contains ( vgl_point_2d< Type > const &  p) const
inherited

Return true iff the point p is inside this box.

Definition at line 347 of file vgl_box_2d.hxx.

◆ contains() [2/3]

template<class Type>
bool vgl_box_2d< Type >::contains ( vgl_box_2d< Type > const &  b) const
inherited

Return true iff the corner points of b are inside this box.

Definition at line 354 of file vgl_box_2d.hxx.

◆ contains() [3/3]

template<class Type>
bool vgl_box_2d< Type >::contains ( Type const &  x,
Type const &  y 
) const
inlineinherited

Return true if (x,y) inside box, ie x_min <= x <= x_max etc.

Definition at line 178 of file vgl_box_2d.h.

◆ empty()

template<class Type >
void vgl_box_2d< Type >::empty ( )
inherited

Make the box empty.

Definition at line 363 of file vgl_box_2d.hxx.

◆ expand_about_centroid()

template<class Type>
void vgl_box_2d< Type >::expand_about_centroid ( Type  expand)
inherited

Add to width and height, centroid unchanged.

Will move each side by expand / 2.

Definition at line 223 of file vgl_box_2d.hxx.

◆ height()

template<class Type >
Type vgl_box_2d< Type >::height ( ) const
inherited

Get height of this box (= y dimension).

Definition at line 134 of file vgl_box_2d.hxx.

◆ is_empty()

template<class Type>
bool vgl_box_2d< Type >::is_empty ( ) const
inlineinherited

Return true if this box is empty.

Definition at line 156 of file vgl_box_2d.h.

◆ max_point()

template<class Type >
vgl_point_2d< Type > vgl_box_2d< Type >::max_point ( ) const
inherited

Return upper right corner of box.

Definition at line 147 of file vgl_box_2d.hxx.

◆ max_x()

template<class Type>
Type vgl_box_2d< Type >::max_x ( ) const
inlineinherited

Get max x.

Definition at line 136 of file vgl_box_2d.h.

◆ max_y()

template<class Type>
Type vgl_box_2d< Type >::max_y ( ) const
inlineinherited

Get max y.

Definition at line 138 of file vgl_box_2d.h.

◆ min_point()

template<class Type >
vgl_point_2d< Type > vgl_box_2d< Type >::min_point ( ) const
inherited

Return lower left corner of box.

Definition at line 140 of file vgl_box_2d.hxx.

◆ min_x()

template<class Type>
Type vgl_box_2d< Type >::min_x ( ) const
inlineinherited

Get min x.

Definition at line 132 of file vgl_box_2d.h.

◆ min_y()

template<class Type>
Type vgl_box_2d< Type >::min_y ( ) const
inlineinherited

Get min y.

Definition at line 134 of file vgl_box_2d.h.

◆ operator==() [1/2]

template<class Type>
bool vgl_bbox_2d< Type >::operator== ( vgl_bbox_2d< Type > const &  b) const
inline

Equality test.

Definition at line 93 of file vgl_rtree_c.h.

◆ operator==() [2/2]

template<class Type>
bool vgl_box_2d< Type >::operator== ( vgl_box_2d< Type > const &  b) const
inlineinherited

Equality test.

Definition at line 114 of file vgl_box_2d.h.

◆ print()

template<class Type >
std::ostream & vgl_box_2d< Type >::print ( std::ostream &  s) const
inherited

Write "<vgl_box_2d x0,y0 to x1,y1>" to stream.

Definition at line 289 of file vgl_box_2d.hxx.

◆ read()

template<class Type >
std::istream & vgl_box_2d< Type >::read ( std::istream &  s)
inherited

Read x0,y0,x1,y1 from stream.

Definition at line 307 of file vgl_box_2d.hxx.

◆ scale_about_centroid()

template<class Type >
void vgl_box_2d< Type >::scale_about_centroid ( double  s)
inherited

Scale width and height, centroid unchanged.

Definition at line 232 of file vgl_box_2d.hxx.

◆ scale_about_origin()

template<class Type >
void vgl_box_2d< Type >::scale_about_origin ( double  s)
inherited

Scale width and height, keeping scaled position of origin unchanged.

Definition at line 242 of file vgl_box_2d.hxx.

◆ set_centroid() [1/2]

template<class Type>
void vgl_box_2d< Type >::set_centroid ( Type const  c[2])
inlineinherited

Move box so centroid lies at c (width, height unchanged).

Definition at line 222 of file vgl_box_2d.h.

◆ set_centroid() [2/2]

template<class Type>
void vgl_box_2d< Type >::set_centroid ( vgl_point_2d< Type > const &  c)
inlineinherited

Move box so centroid lies at c (width, height unchanged).

Definition at line 224 of file vgl_box_2d.h.

◆ set_centroid_x()

template<class Type>
void vgl_box_2d< Type >::set_centroid_x ( Type  cx)
inherited

Move box so centroid lies at cx (width and height unchanged).

Definition at line 161 of file vgl_box_2d.hxx.

◆ set_centroid_y()

template<class Type>
void vgl_box_2d< Type >::set_centroid_y ( Type  cy)
inherited

Move box so centroid lies at cy (width and height unchanged).

Definition at line 170 of file vgl_box_2d.hxx.

◆ set_height()

template<class Type>
void vgl_box_2d< Type >::set_height ( Type  h)
inherited

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 213 of file vgl_box_2d.hxx.

◆ set_max_point()

template<class Type>
void vgl_box_2d< Type >::set_max_point ( vgl_point_2d< Type > const &  max_pt)
inherited

Modify top right. Bottom left only changed if necessary to avoid empty box.

Definition at line 282 of file vgl_box_2d.hxx.

◆ set_max_x()

template<class Type>
void vgl_box_2d< Type >::set_max_x ( Type  m)
inlineinherited

Set right side (other side ordinates unchanged).

Definition at line 190 of file vgl_box_2d.h.

◆ set_max_y()

template<class Type>
void vgl_box_2d< Type >::set_max_y ( Type  m)
inlineinherited

Set top (other side ordinates unchanged).

Definition at line 192 of file vgl_box_2d.h.

◆ set_min_point()

template<class Type>
void vgl_box_2d< Type >::set_min_point ( vgl_point_2d< Type > const &  min_pt)
inherited

Modify bottom left. Top right only changed if necessary to avoid empty box.

Definition at line 275 of file vgl_box_2d.hxx.

◆ set_min_x()

template<class Type>
void vgl_box_2d< Type >::set_min_x ( Type  m)
inlineinherited

Set left side of box (other side ordinates unchanged).

Definition at line 186 of file vgl_box_2d.h.

◆ set_min_y()

template<class Type>
void vgl_box_2d< Type >::set_min_y ( Type  m)
inlineinherited

Set bottom of box (other side ordinates unchanged).

Definition at line 188 of file vgl_box_2d.h.

◆ set_width()

template<class Type>
void vgl_box_2d< Type >::set_width ( Type  w)
inherited

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 203 of file vgl_box_2d.hxx.

◆ setmax_position()

template<class Type>
void vgl_box_2d< Type >::setmax_position ( Type const  max_position[2])
inherited

Modify top right. Bottom left only changed if necessary to avoid empty box.

Definition at line 264 of file vgl_box_2d.hxx.

◆ setmin_position()

template<class Type>
void vgl_box_2d< Type >::setmin_position ( Type const  min_position[2])
inherited

Modify bottom left. Top right only changed if necessary to avoid empty box.

Definition at line 251 of file vgl_box_2d.hxx.

◆ volume()

template<class Type>
Type vgl_box_2d< Type >::volume ( ) const
inlineinherited

Get "volume" (=area) of this box.

Definition at line 129 of file vgl_box_2d.h.

◆ width()

template<class Type >
Type vgl_box_2d< Type >::width ( ) const
inherited

Get width of this box (= x dimension).

Definition at line 128 of file vgl_box_2d.hxx.

◆ write()

template<class Type >
std::ostream & vgl_box_2d< Type >::write ( std::ostream &  s) const
inherited

Write "x0 y0 x1 y1(endl)" to stream.

Definition at line 300 of file vgl_box_2d.hxx.

Friends And Related Function Documentation

◆ operator<<()

template<class Type >
std::ostream & operator<< ( std::ostream &  s,
vgl_box_2d< Type > const &  p 
)
related

Write box to stream.

◆ operator>>()

template<class Type >
std::istream & operator>> ( std::istream &  is,
vgl_box_2d< Type > &  p 
)
related

Read box from stream.

◆ vgl_clip_line_to_box()

template<class T >
vgl_line_segment_2d< T > vgl_clip_line_to_box ( vgl_line_2d< T > const &  l,
vgl_box_2d< T > const &  b 
)
related

clip given line to given box, and return resulting line segment.

Definition at line 55 of file vgl_clip.h.

◆ vgl_intersection() [1/6]

template<class T >
bool vgl_intersection ( vgl_box_2d< T > const &  b,
vgl_point_2d< T > const &  p 
)
related

Return true if the point lies inside the box.

Definition at line 210 of file vgl_intersection.h.

◆ vgl_intersection() [2/6]

template<class T >
bool vgl_intersection ( vgl_point_2d< T > const &  p,
vgl_box_2d< T > const &  b 
)
related

Return true if the point lies inside the box.

Definition at line 217 of file vgl_intersection.h.

◆ vgl_intersection() [3/6]

template<class T >
vgl_box_2d< T > vgl_intersection ( vgl_box_2d< T > const &  b1,
vgl_box_2d< T > const &  b2 
)
related

Return the intersection of two boxes (which is itself either a box, or empty).

Return the intersection of two boxes (which is itself is a box, possibly the empty box).

Definition at line 40 of file vgl_intersection.hxx.

◆ vgl_intersection() [4/6]

template<class T >
bool vgl_intersection ( vgl_box_2d< T > const &  b,
vgl_polygon< T > const &  poly 
)
related

Return true if the box and polygon regions intersect, regions include boundaries.

◆ vgl_intersection() [5/6]

template<class T >
std::vector< vgl_point_2d< T > > vgl_intersection ( vgl_box_2d< T > const &  b,
std::vector< vgl_point_2d< T > > const &  p 
)
related

Return the points from the list that lie inside the box.

Definition at line 1011 of file vgl_intersection.hxx.

◆ vgl_intersection() [6/6]

template<class T >
std::vector< vgl_point_2d< T > > vgl_intersection ( std::vector< vgl_point_2d< T > > const &  p,
vgl_box_2d< T > const &  b 
)
related

Return the points from the list that lie inside the box.

Definition at line 1025 of file vgl_intersection.hxx.

Member Data Documentation

◆ max_pos_

template<class Type>
Type vgl_box_2d< Type >::max_pos_[2]
protectedinherited

Definition at line 241 of file vgl_box_2d.h.

◆ min_pos_

template<class Type>
Type vgl_box_2d< Type >::min_pos_[2]
protectedinherited

Definition at line 240 of file vgl_box_2d.h.


The documentation for this class was generated from the following file: