Logo ROOT   6.12/07
Reference Guide
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
TGLBoundingBox Class Reference

Concrete class describing an orientated (free) or axis aligned box of 8 vertices.

Supports methods for setting aligned or orientated boxes, find volume, axes, extents, centers, face planes etc. Also tests for overlap testing of planes and other bounding boxes, with fast sphere approximation.

Definition at line 30 of file TGLBoundingBox.h.

Public Types

enum  EFace {
  kFaceLowX, kFaceHighX, kFaceLowY, kFaceHighY,
  kFaceLowZ, kFaceHighZ, kFaceCount
}
 

Public Member Functions

 TGLBoundingBox ()
 Construct an empty bounding box. More...
 
 TGLBoundingBox (const TGLVertex3 vertex[8])
 Construct a bounding box from provided 8 vertices. More...
 
 TGLBoundingBox (const Double_t vertex[8][3])
 Construct a bounding box from provided 8 vertices. More...
 
 TGLBoundingBox (const TGLVertex3 &lowVertex, const TGLVertex3 &highVertex)
 Construct an global axis ALIGNED bounding box from provided low/high vertex pair. More...
 
 TGLBoundingBox (const TGLBoundingBox &other)
 Construct a bounding box as copy of existing one. More...
 
virtual ~TGLBoundingBox ()
 Destroy bounding box. More...
 
const TGLVector3Axis (UInt_t i, Bool_t normalised=kTRUE) const
 
TGLVertex3 Center () const
 
Double_t Diagonal () const
 
void Draw (Bool_t solid=kFALSE) const
 Draw the bounding box as either wireframe (default) of solid using current GL color. More...
 
void Dump () const
 Output to std::cout the vertices, center and volume of box. More...
 
void ExpandAligned (const TGLVertex3 &point)
 Expand current bbox so that it includes the point. More...
 
TGLVector3 Extents () const
 
const std::vector< UInt_t > & FaceVertices (EFace face) const
 return a vector of face vertices y | | |________x / 3----—2 / /| /| z 7----—6 | | 0--—|-1 |/ |/ 4----—5 More...
 
TGLPlane GetNearPlane () const
 Return the near-plane. More...
 
Bool_t IsEmpty () const
 
TGLVertex3 MaxAAVertex () const
 Find maximum vertex values. More...
 
void MergeAligned (const TGLBoundingBox &other)
 Expand current bbox so that it includes other's bbox. More...
 
TGLVertex3 MinAAVertex () const
 Find minimum vertex values. More...
 
Int_t NumVertices () const
 
TGLBoundingBoxoperator= (const TGLBoundingBox &other)
 
const TGLVertex3operator[] (UInt_t index) const
 
Rgl::EOverlap Overlap (const TGLPlane &plane) const
 Find overlap (Inside, Outside, Partial) of plane c.f. bounding box. More...
 
Rgl::EOverlap Overlap (const TGLBoundingBox &box) const
 Find overlap (Inside, Outside, Partial) of other bounding box c.f. us. More...
 
void PlaneSet (TGLPlaneSet_t &planeSet) const
 Fill out supplied plane set vector with TGLPlane objects representing six faces of box. More...
 
void Scale (Double_t factor)
 Isotropically scale bounding box along it's LOCAL axes, preserving center. More...
 
void Scale (Double_t xFactor, Double_t yFactor, Double_t zFactor)
 Asymmetrically scale box along it's LOCAL x,y,z axes, preserving center. More...
 
void Set (const TGLVertex3 vertex[8])
 Set a bounding box from provided 8 vertices. More...
 
void Set (const Double_t vertex[8][3])
 Set a bounding box from provided 8 vertices. More...
 
void Set (const TGLBoundingBox &other)
 Set a bounding box from vertices of other. More...
 
void SetAligned (const TGLVertex3 &lowVertex, const TGLVertex3 &highVertex)
 Set ALIGNED box from two low/high vertices. More...
 
void SetAligned (UInt_t nbPnts, const Double_t *pnts)
 Set ALIGNED box from one or more points. More...
 
void SetEmpty ()
 Set bounding box empty - all vertices at (0,0,0) More...
 
void Transform (const TGLMatrix &matrix)
 Transform all vertices with matrix. More...
 
void Translate (const TGLVector3 &offset)
 Translate all vertices by offset. More...
 
const TGLVertex3Vertex (UInt_t index) const
 
const TGLVertex3Vertices () const
 
Double_t Volume () const
 
Double_t XMax () const
 
Double_t XMin () const
 
Double_t YMax () const
 
Double_t YMin () const
 
Double_t ZMax () const
 
Double_t ZMin () const
 

Private Member Functions

Double_t Max (UInt_t index) const
 Find maximum vertex value for axis of index X(0), Y(1), Z(2) More...
 
Double_t Min (UInt_t index) const
 Find minimum vertex value for axis of index X(0), Y(1), Z(2) More...
 
void UpdateCache ()
 normalised box axes in global frame - cached for speed More...
 
Bool_t ValidIndex (UInt_t index) const
 

Private Attributes

TGLVector3 fAxes [3]
 max box diagonal - cached for speed More...
 
TGLVector3 fAxesNorm [3]
 box axes in global frame - cached for speed More...
 
Double_t fDiagonal
 box volume - cached for speed More...
 
TGLVertex3 fVertex [8]
 
Double_t fVolume
 the 8 bounding box vertices More...
 

#include <TGLBoundingBox.h>

Member Enumeration Documentation

◆ EFace

Enumerator
kFaceLowX 
kFaceHighX 
kFaceLowY 
kFaceHighY 
kFaceLowZ 
kFaceHighZ 
kFaceCount 

Definition at line 111 of file TGLBoundingBox.h.

Constructor & Destructor Documentation

◆ TGLBoundingBox() [1/5]

TGLBoundingBox::TGLBoundingBox ( )

Construct an empty bounding box.

Definition at line 33 of file TGLBoundingBox.cxx.

◆ TGLBoundingBox() [2/5]

TGLBoundingBox::TGLBoundingBox ( const TGLVertex3  vertex[8])

Construct a bounding box from provided 8 vertices.

Definition at line 41 of file TGLBoundingBox.cxx.

◆ TGLBoundingBox() [3/5]

TGLBoundingBox::TGLBoundingBox ( const Double_t  vertex[8][3])

Construct a bounding box from provided 8 vertices.

Definition at line 49 of file TGLBoundingBox.cxx.

◆ TGLBoundingBox() [4/5]

TGLBoundingBox::TGLBoundingBox ( const TGLVertex3 lowVertex,
const TGLVertex3 highVertex 
)

Construct an global axis ALIGNED bounding box from provided low/high vertex pair.

Definition at line 57 of file TGLBoundingBox.cxx.

◆ TGLBoundingBox() [5/5]

TGLBoundingBox::TGLBoundingBox ( const TGLBoundingBox other)

Construct a bounding box as copy of existing one.

Definition at line 65 of file TGLBoundingBox.cxx.

◆ ~TGLBoundingBox()

TGLBoundingBox::~TGLBoundingBox ( )
virtual

Destroy bounding box.

Definition at line 73 of file TGLBoundingBox.cxx.

Member Function Documentation

◆ Axis()

const TGLVector3 & TGLBoundingBox::Axis ( UInt_t  i,
Bool_t  normalised = kTRUE 
) const
inline

Definition at line 181 of file TGLBoundingBox.h.

◆ Center()

TGLVertex3 TGLBoundingBox::Center ( ) const
inline

Definition at line 172 of file TGLBoundingBox.h.

◆ Diagonal()

Double_t TGLBoundingBox::Diagonal ( ) const
inline

Definition at line 120 of file TGLBoundingBox.h.

◆ Draw()

void TGLBoundingBox::Draw ( Bool_t  solid = kFALSE) const

Draw the bounding box as either wireframe (default) of solid using current GL color.

Definition at line 652 of file TGLBoundingBox.cxx.

◆ Dump()

void TGLBoundingBox::Dump ( ) const

Output to std::cout the vertices, center and volume of box.

Definition at line 777 of file TGLBoundingBox.cxx.

◆ ExpandAligned()

void TGLBoundingBox::ExpandAligned ( const TGLVertex3 point)

Expand current bbox so that it includes the point.

This make the bbox axis-aligned.

Definition at line 273 of file TGLBoundingBox.cxx.

◆ Extents()

TGLVector3 TGLBoundingBox::Extents ( ) const
inline

Definition at line 163 of file TGLBoundingBox.h.

◆ FaceVertices()

const std::vector< UInt_t > & TGLBoundingBox::FaceVertices ( EFace  face) const

return a vector of face vertices y | | |________x / 3----—2 / /| /| z 7----—6 | | 0--—|-1 |/ |/ 4----—5

Definition at line 369 of file TGLBoundingBox.cxx.

◆ GetNearPlane()

TGLPlane TGLBoundingBox::GetNearPlane ( ) const

Return the near-plane.

Definition at line 440 of file TGLBoundingBox.cxx.

◆ IsEmpty()

Bool_t TGLBoundingBox::IsEmpty ( ) const
inline

Definition at line 205 of file TGLBoundingBox.h.

◆ Max()

Double_t TGLBoundingBox::Max ( UInt_t  index) const
private

Find maximum vertex value for axis of index X(0), Y(1), Z(2)

Definition at line 747 of file TGLBoundingBox.cxx.

◆ MaxAAVertex()

TGLVertex3 TGLBoundingBox::MaxAAVertex ( ) const

Find maximum vertex values.

Definition at line 769 of file TGLBoundingBox.cxx.

◆ MergeAligned()

void TGLBoundingBox::MergeAligned ( const TGLBoundingBox other)

Expand current bbox so that it includes other's bbox.

This make the bbox axis-aligned.

Definition at line 251 of file TGLBoundingBox.cxx.

◆ Min()

Double_t TGLBoundingBox::Min ( UInt_t  index) const
private

Find minimum vertex value for axis of index X(0), Y(1), Z(2)

Definition at line 733 of file TGLBoundingBox.cxx.

◆ MinAAVertex()

TGLVertex3 TGLBoundingBox::MinAAVertex ( ) const

Find minimum vertex values.

Definition at line 761 of file TGLBoundingBox.cxx.

◆ NumVertices()

Int_t TGLBoundingBox::NumVertices ( ) const
inline

Definition at line 109 of file TGLBoundingBox.h.

◆ operator=()

TGLBoundingBox & TGLBoundingBox::operator= ( const TGLBoundingBox other)
inline

Definition at line 135 of file TGLBoundingBox.h.

◆ operator[]()

const TGLVertex3 & TGLBoundingBox::operator[] ( UInt_t  index) const
inline

Definition at line 145 of file TGLBoundingBox.h.

◆ Overlap() [1/2]

Rgl::EOverlap TGLBoundingBox::Overlap ( const TGLPlane plane) const

Find overlap (Inside, Outside, Partial) of plane c.f. bounding box.

Definition at line 448 of file TGLBoundingBox.cxx.

◆ Overlap() [2/2]

Rgl::EOverlap TGLBoundingBox::Overlap ( const TGLBoundingBox box) const

Find overlap (Inside, Outside, Partial) of other bounding box c.f. us.

Definition at line 478 of file TGLBoundingBox.cxx.

◆ PlaneSet()

void TGLBoundingBox::PlaneSet ( TGLPlaneSet_t planeSet) const

Fill out supplied plane set vector with TGLPlane objects representing six faces of box.

Definition at line 413 of file TGLBoundingBox.cxx.

◆ Scale() [1/2]

void TGLBoundingBox::Scale ( Double_t  factor)

Isotropically scale bounding box along it's LOCAL axes, preserving center.

Definition at line 287 of file TGLBoundingBox.cxx.

◆ Scale() [2/2]

void TGLBoundingBox::Scale ( Double_t  xFactor,
Double_t  yFactor,
Double_t  zFactor 
)

Asymmetrically scale box along it's LOCAL x,y,z axes, preserving center.

Definition at line 297 of file TGLBoundingBox.cxx.

◆ Set() [1/3]

void TGLBoundingBox::Set ( const TGLVertex3  vertex[8])

Set a bounding box from provided 8 vertices.

Definition at line 134 of file TGLBoundingBox.cxx.

◆ Set() [2/3]

void TGLBoundingBox::Set ( const Double_t  vertex[8][3])

Set a bounding box from provided 8 vertices.

Definition at line 146 of file TGLBoundingBox.cxx.

◆ Set() [3/3]

void TGLBoundingBox::Set ( const TGLBoundingBox other)

Set a bounding box from vertices of other.

Definition at line 160 of file TGLBoundingBox.cxx.

◆ SetAligned() [1/2]

void TGLBoundingBox::SetAligned ( const TGLVertex3 lowVertex,
const TGLVertex3 highVertex 
)

Set ALIGNED box from two low/high vertices.

Box axes are aligned with global frame axes that vertices are specified in.

Definition at line 185 of file TGLBoundingBox.cxx.

◆ SetAligned() [2/2]

void TGLBoundingBox::SetAligned ( UInt_t  nbPnts,
const Double_t pnts 
)

Set ALIGNED box from one or more points.

Box axes are aligned with global frame axes that points are specified in.

Definition at line 222 of file TGLBoundingBox.cxx.

◆ SetEmpty()

void TGLBoundingBox::SetEmpty ( )

Set bounding box empty - all vertices at (0,0,0)

Definition at line 172 of file TGLBoundingBox.cxx.

◆ Transform()

void TGLBoundingBox::Transform ( const TGLMatrix matrix)

Transform all vertices with matrix.

Definition at line 345 of file TGLBoundingBox.cxx.

◆ Translate()

void TGLBoundingBox::Translate ( const TGLVector3 offset)

Translate all vertices by offset.

Definition at line 333 of file TGLBoundingBox.cxx.

◆ UpdateCache()

void TGLBoundingBox::UpdateCache ( )
private

normalised box axes in global frame - cached for speed

Update the internally cached volume and axes vectors - these are retained for efficiency - many more reads than modifications.

Definition at line 81 of file TGLBoundingBox.cxx.

◆ ValidIndex()

Bool_t TGLBoundingBox::ValidIndex ( UInt_t  index) const
inlineprivate

Definition at line 64 of file TGLBoundingBox.h.

◆ Vertex()

const TGLVertex3 & TGLBoundingBox::Vertex ( UInt_t  index) const
inline

Definition at line 151 of file TGLBoundingBox.h.

◆ Vertices()

const TGLVertex3 * TGLBoundingBox::Vertices ( ) const
inline

Definition at line 157 of file TGLBoundingBox.h.

◆ Volume()

Double_t TGLBoundingBox::Volume ( ) const
inline

Definition at line 119 of file TGLBoundingBox.h.

◆ XMax()

Double_t TGLBoundingBox::XMax ( ) const
inline

Definition at line 99 of file TGLBoundingBox.h.

◆ XMin()

Double_t TGLBoundingBox::XMin ( ) const
inline

Definition at line 98 of file TGLBoundingBox.h.

◆ YMax()

Double_t TGLBoundingBox::YMax ( ) const
inline

Definition at line 101 of file TGLBoundingBox.h.

◆ YMin()

Double_t TGLBoundingBox::YMin ( ) const
inline

Definition at line 100 of file TGLBoundingBox.h.

◆ ZMax()

Double_t TGLBoundingBox::ZMax ( ) const
inline

Definition at line 103 of file TGLBoundingBox.h.

◆ ZMin()

Double_t TGLBoundingBox::ZMin ( ) const
inline

Definition at line 102 of file TGLBoundingBox.h.

Member Data Documentation

◆ fAxes

TGLVector3 TGLBoundingBox::fAxes[3]
private

max box diagonal - cached for speed

Definition at line 59 of file TGLBoundingBox.h.

◆ fAxesNorm

TGLVector3 TGLBoundingBox::fAxesNorm[3]
private

box axes in global frame - cached for speed

Definition at line 60 of file TGLBoundingBox.h.

◆ fDiagonal

Double_t TGLBoundingBox::fDiagonal
private

box volume - cached for speed

Definition at line 58 of file TGLBoundingBox.h.

◆ fVertex

TGLVertex3 TGLBoundingBox::fVertex[8]
private

Definition at line 56 of file TGLBoundingBox.h.

◆ fVolume

Double_t TGLBoundingBox::fVolume
private

the 8 bounding box vertices

Definition at line 57 of file TGLBoundingBox.h.

Libraries for TGLBoundingBox:
[legend]

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