Panda3D
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends

BoundingBox Class Reference

An axis-aligned bounding box; that is, a minimum and maximum coordinate triple. More...

#include "boundingBox.h"

Inheritance diagram for BoundingBox:
FiniteBoundingVolume GeometricBoundingVolume BoundingVolume TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase

List of all members.

Public Member Functions

 BoundingBox ()
 Constructs an empty box object.
 BoundingBox (const LPoint3 &min, const LPoint3 &max)
 Constructs a specific box object.
virtual const BoundingBoxas_bounding_box () const
 Virtual downcast method.
virtual TypeHandle force_init_type ()
virtual LPoint3 get_approx_center () const
virtual LPoint3 get_max () const
const LPoint3get_maxq () const
 An inline accessor for the maximum value.
virtual LPoint3 get_min () const
const LPoint3get_minq () const
 An inline accessor for the minimum value.
int get_num_planes () const
 Returns 6: the number of faces of a rectangular solid.
int get_num_points () const
 Returns 8: the number of vertices of a rectangular solid.
LPlane get_plane (int n) const
 Returns the nth face of the rectangular solid.
LPoint3 get_point (int n) const
 Returns the nth vertex of the rectangular solid.
virtual TypeHandle get_type () const
virtual PN_stdfloat get_volume () const
virtual BoundingVolumemake_copy () const
 MAKE_SEQ (get_planes, get_num_planes, get_plane)
 MAKE_SEQ (get_points, get_num_points, get_point)
virtual void output (ostream &out) const
virtual void xform (const LMatrix4 &mat)

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96.

Protected Member Functions

virtual bool around_finite (const BoundingVolume **first, const BoundingVolume **last)
 Generic handler for a FiniteBoundingVolume.
virtual bool around_other (BoundingVolume *other, const BoundingVolume **first, const BoundingVolume **last) const
virtual bool around_points (const LPoint3 *first, const LPoint3 *last)
 Puts the volume around the indicated list of points, identified by an STL-style begin/end list.
virtual int contains_box (const BoundingBox *box) const
 Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a box.
virtual int contains_finite (const FiniteBoundingVolume *volume) const
 Generic handler for a FiniteBoundingVolume.
virtual int contains_hexahedron (const BoundingHexahedron *hexahedron) const
 Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a hexahedron.
virtual int contains_line (const BoundingLine *line) const
 Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a line.
virtual int contains_lineseg (const LPoint3 &a, const LPoint3 &b) const
 Tests whether the volume contains the indicated line segment.
virtual int contains_other (const BoundingVolume *other) const
virtual int contains_plane (const BoundingPlane *plane) const
 Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a plane.
virtual int contains_point (const LPoint3 &point) const
 Tests whether the volume contains the indicated point.
virtual bool extend_by_box (const BoundingBox *box)
 Double-dispatch support: called by extend_other() when the type we're extending by is known to be a box.
virtual bool extend_by_finite (const FiniteBoundingVolume *volume)
 Generic handler for a FiniteBoundingVolume.
virtual bool extend_by_point (const LPoint3 &point)
 Extends the volume to include the indicated point.
virtual bool extend_other (BoundingVolume *other) const

Friends

class BoundingSphere

Detailed Description

An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.

This box is always axis-aligned. If you need a more general bounding box, try BoundingHexahedron.

Definition at line 31 of file boundingBox.h.


Constructor & Destructor Documentation

BoundingBox::BoundingBox ( ) [inline]

Constructs an empty box object.

Definition at line 22 of file boundingBox.I.

BoundingBox::BoundingBox ( const LPoint3 min,
const LPoint3 max 
) [inline]

Constructs a specific box object.

Definition at line 31 of file boundingBox.I.

References LVecBase3f::is_nan().


Member Function Documentation

bool BoundingBox::around_finite ( const BoundingVolume **  first,
const BoundingVolume **  last 
) [protected, virtual]

Generic handler for a FiniteBoundingVolume.

Reimplemented from BoundingVolume.

Definition at line 336 of file boundingBox.cxx.

bool BoundingBox::around_points ( const LPoint3 first,
const LPoint3 last 
) [protected, virtual]

Puts the volume around the indicated list of points, identified by an STL-style begin/end list.

Reimplemented from GeometricBoundingVolume.

Definition at line 267 of file boundingBox.cxx.

References LVecBase3f::is_nan().

const BoundingBox * BoundingBox::as_bounding_box ( ) const [virtual]

Virtual downcast method.

Returns this object as a pointer of the indicated type, if it is in fact that type. Returns NULL if it is not that type.

Reimplemented from BoundingVolume.

Definition at line 147 of file boundingBox.cxx.

int BoundingBox::contains_box ( const BoundingBox box) const [protected, virtual]

Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a box.

Reimplemented from BoundingVolume.

Definition at line 496 of file boundingBox.cxx.

References get_maxq(), get_minq(), BoundingVolume::is_empty(), and BoundingVolume::is_infinite().

int BoundingBox::contains_finite ( const FiniteBoundingVolume volume) const [protected, virtual]

Generic handler for a FiniteBoundingVolume.

Reimplemented from BoundingVolume.

Definition at line 572 of file boundingBox.cxx.

References BoundingVolume::is_empty(), and BoundingVolume::is_infinite().

Referenced by contains_hexahedron().

int BoundingBox::contains_hexahedron ( const BoundingHexahedron hexahedron) const [protected, virtual]

Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a hexahedron.

Reimplemented from BoundingVolume.

Definition at line 529 of file boundingBox.cxx.

References BoundingHexahedron::contains_box(), and contains_finite().

int BoundingBox::contains_line ( const BoundingLine line) const [protected, virtual]

Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a line.

Reimplemented from BoundingVolume.

Definition at line 550 of file boundingBox.cxx.

References BoundingLine::contains_box().

int BoundingBox::contains_lineseg ( const LPoint3 a,
const LPoint3 b 
) const [protected, virtual]

Tests whether the volume contains the indicated line segment.

Reimplemented from GeometricBoundingVolume.

Definition at line 403 of file boundingBox.cxx.

References contains_point(), BoundingVolume::is_empty(), BoundingVolume::is_infinite(), and LVecBase3f::is_nan().

int BoundingBox::contains_plane ( const BoundingPlane plane) const [protected, virtual]

Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a plane.

Reimplemented from BoundingVolume.

Definition at line 562 of file boundingBox.cxx.

References BoundingPlane::contains_box().

int BoundingBox::contains_point ( const LPoint3 point) const [protected, virtual]

Tests whether the volume contains the indicated point.

Reimplemented from GeometricBoundingVolume.

Definition at line 377 of file boundingBox.cxx.

References BoundingVolume::is_empty(), BoundingVolume::is_infinite(), and LVecBase3f::is_nan().

Referenced by contains_lineseg().

bool BoundingBox::extend_by_box ( const BoundingBox box) [protected, virtual]

Double-dispatch support: called by extend_other() when the type we're extending by is known to be a box.

Reimplemented from BoundingVolume.

Definition at line 212 of file boundingBox.cxx.

References BoundingVolume::is_empty(), and BoundingVolume::is_infinite().

bool BoundingBox::extend_by_finite ( const FiniteBoundingVolume volume) [protected, virtual]

Generic handler for a FiniteBoundingVolume.

Reimplemented from BoundingVolume.

Definition at line 238 of file boundingBox.cxx.

References BoundingVolume::is_empty(), and BoundingVolume::is_infinite().

bool BoundingBox::extend_by_point ( const LPoint3 point) [protected, virtual]

Extends the volume to include the indicated point.

Returns true if possible, false if not.

Reimplemented from GeometricBoundingVolume.

Definition at line 190 of file boundingBox.cxx.

References BoundingVolume::is_empty(), BoundingVolume::is_infinite(), and LVecBase3f::is_nan().

const LPoint3 & BoundingBox::get_maxq ( ) const [inline]

An inline accessor for the maximum value.

get_max() would also work, but it is a virtual non-inline method.

Definition at line 64 of file boundingBox.I.

References BoundingVolume::is_empty(), and BoundingVolume::is_infinite().

Referenced by BoundingLine::contains_box(), BoundingHexahedron::contains_box(), contains_box(), BoundingPlane::contains_box(), and BoundingSphere::extend_by_box().

const LPoint3 & BoundingBox::get_minq ( ) const [inline]

An inline accessor for the minimum value.

get_min() would also work, but it is a virtual non-inline method.

Definition at line 50 of file boundingBox.I.

References BoundingVolume::is_empty(), and BoundingVolume::is_infinite().

Referenced by BoundingLine::contains_box(), BoundingHexahedron::contains_box(), contains_box(), BoundingPlane::contains_box(), and BoundingSphere::extend_by_box().

int BoundingBox::get_num_planes ( ) const [inline]

Returns 6: the number of faces of a rectangular solid.

Definition at line 101 of file boundingBox.I.

int BoundingBox::get_num_points ( ) const [inline]

Returns 8: the number of vertices of a rectangular solid.

Definition at line 76 of file boundingBox.I.

LPlane BoundingBox::get_plane ( int  n) const [inline]

Returns the nth face of the rectangular solid.

Definition at line 111 of file boundingBox.I.

References get_point().

LPoint3 BoundingBox::get_point ( int  n) const [inline]

Returns the nth vertex of the rectangular solid.

Definition at line 86 of file boundingBox.I.

References LPoint3f::zero().

Referenced by BoundingPlane::contains_box(), BoundingHexahedron::contains_box(), BoundingSphere::extend_by_box(), and get_plane().

static void BoundingBox::init_type ( ) [inline, static]

This function is declared non-inline to work around a compiler bug in g++ 2.96.

Making it inline seems to cause problems in the optimizer.

Reimplemented from FiniteBoundingVolume.

Definition at line 100 of file boundingBox.h.

References FiniteBoundingVolume::init_type().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations