ROOT  6.06/09
Reference Guide
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 32 of file TGLBoundingBox.h.

Public Types

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

Public Member Functions

 TGLBoundingBox ()
 
 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...
 
TGLBoundingBoxoperator= (const TGLBoundingBox &other)
 
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 SetEmpty ()
 Set bounding box empty - all vertices at (0,0,0) 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 MergeAligned (const TGLBoundingBox &other)
 Expand current bbox so that it includes other's bbox. More...
 
void ExpandAligned (const TGLVertex3 &point)
 Expand current bbox so that it includes the point. More...
 
void Transform (const TGLMatrix &matrix)
 Transform all vertices with matrix. 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 Translate (const TGLVector3 &offset)
 Translate all vertices by offset. More...
 
const TGLVertex3operator[] (UInt_t index) const
 
const TGLVertex3Vertex (UInt_t index) const
 
Double_t XMin () const
 
Double_t XMax () const
 
Double_t YMin () const
 
Double_t YMax () const
 
Double_t ZMin () const
 
Double_t ZMax () const
 
TGLVertex3 MinAAVertex () const
 Find minimum vertex values. More...
 
TGLVertex3 MaxAAVertex () const
 Find maximum vertex values. More...
 
const TGLVertex3Vertices () const
 
Int_t NumVertices () 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...
 
TGLVertex3 Center () const
 
TGLVector3 Extents () const
 
const TGLVector3Axis (UInt_t i, Bool_t normalised=kTRUE) const
 
Bool_t IsEmpty () const
 
Double_t Volume () const
 
Double_t Diagonal () const
 
void PlaneSet (TGLPlaneSet_t &planeSet) const
 Fill out supplied plane set vector with TGLPlane objects representing six faces of box. More...
 
TGLPlane GetNearPlane () const
 Return the near-plane. More...
 
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 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...
 
 ClassDef (TGLBoundingBox, 0)
 

Private Member Functions

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

Private Attributes

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

#include <TGLBoundingBox.h>

+ Collaboration diagram for TGLBoundingBox:

Member Enumeration Documentation

Enumerator
kFaceLowX 
kFaceHighX 
kFaceLowY 
kFaceHighY 
kFaceLowZ 
kFaceHighZ 
kFaceCount 

Definition at line 113 of file TGLBoundingBox.h.

Constructor & Destructor Documentation

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

Construct a bounding box from provided 8 vertices.

Definition at line 41 of file TGLBoundingBox.cxx.

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::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::TGLBoundingBox ( const TGLBoundingBox other)

Construct a bounding box as copy of existing one.

Definition at line 65 of file TGLBoundingBox.cxx.

TGLBoundingBox::~TGLBoundingBox ( )
virtual

Destroy bounding box.

Definition at line 73 of file TGLBoundingBox.cxx.

Member Function Documentation

const TGLVector3 & TGLBoundingBox::Axis ( UInt_t  i,
Bool_t  normalised = kTRUE 
) const
inline
TGLVertex3 TGLBoundingBox::Center ( ) const
inline
TGLBoundingBox::ClassDef ( TGLBoundingBox  ,
 
)
Double_t TGLBoundingBox::Diagonal ( ) const
inline
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.

Referenced by TGLCamera::DrawDebugAids(), TGLViewer::DrawDebugInfo(), TGLUtil::DrawLine(), and TGLManipSet::Render().

void TGLBoundingBox::Dump ( ) const

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

Definition at line 777 of file TGLBoundingBox.cxx.

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.

TGLVector3 TGLBoundingBox::Extents ( ) const
inline
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.

Referenced by TGLCamera::ViewportRect().

TGLPlane TGLBoundingBox::GetNearPlane ( ) const

Return the near-plane.

Definition at line 440 of file TGLBoundingBox.cxx.

Referenced by TGLClipPlane::PlaneSet(), and TGLClipPlane::Setup().

Bool_t TGLBoundingBox::IsEmpty ( ) const
inline
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.

Referenced by XMax(), YMax(), and ZMax().

TGLVertex3 TGLBoundingBox::MaxAAVertex ( ) const

Find maximum vertex values.

Definition at line 769 of file TGLBoundingBox.cxx.

Referenced by 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.

Referenced by TGLViewerBase::MergeSceneBBoxes(), and TGLViewerBase::PreRender().

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.

Referenced by XMin(), YMin(), and ZMin().

TGLVertex3 TGLBoundingBox::MinAAVertex ( ) const

Find minimum vertex values.

Definition at line 761 of file TGLBoundingBox.cxx.

Referenced by MergeAligned().

Int_t TGLBoundingBox::NumVertices ( ) const
inline

Definition at line 111 of file TGLBoundingBox.h.

Referenced by TGLCamera::ViewportRect().

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

Definition at line 137 of file TGLBoundingBox.h.

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

Definition at line 147 of file TGLBoundingBox.h.

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.

Referenced by TGLCamera::FrustumOverlap(), TGLScene::IsOutside(), TGLCamera::OfInterest(), TGLCamera::UpdateInterest(), TGLSceneBase::UpdateSceneInfo(), and TGLScene::UpdateSceneInfo().

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.

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.

Referenced by TGLClipBox::PlaneSet().

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.

Referenced by TGLCamera::UpdateInterest().

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.

void TGLBoundingBox::Set ( const TGLVertex3  vertex[8])
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.

void TGLBoundingBox::Set ( const TGLBoundingBox other)

Set a bounding box from vertices of other.

Definition at line 160 of file TGLBoundingBox.cxx.

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.

Referenced by TGLScene::CalcBoundingBox(), TEveTextGL::DirectDraw(), TEveLegoEventHandler::Rotate(), TGLObject::SetAxisAlignedBBox(), and TGLLogicalShape::TGLLogicalShape().

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.

void TGLBoundingBox::SetEmpty ( )

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

Definition at line 172 of file TGLBoundingBox.cxx.

Referenced by TGLViewerBase::MergeSceneBBoxes(), TGLViewerBase::PreRender(), TGLCamera::ResetInterest(), and TEveTextGL::SetBBox().

void TGLBoundingBox::Transform ( const TGLMatrix matrix)

Transform all vertices with matrix.

Definition at line 345 of file TGLBoundingBox.cxx.

Referenced by TEveLegoEventHandler::Rotate(), and TGLPhysicalShape::UpdateBoundingBox().

void TGLBoundingBox::Translate ( const TGLVector3 offset)

Translate all vertices by offset.

Definition at line 333 of file TGLBoundingBox.cxx.

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.

Bool_t TGLBoundingBox::ValidIndex ( UInt_t  index) const
inlineprivate

Definition at line 66 of file TGLBoundingBox.h.

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

Definition at line 153 of file TGLBoundingBox.h.

Referenced by TGLCamera::ViewportRect().

const TGLVertex3 * TGLBoundingBox::Vertices ( ) const
inline

Definition at line 159 of file TGLBoundingBox.h.

Double_t TGLBoundingBox::Volume ( ) const
inline
Double_t TGLBoundingBox::XMax ( ) const
inline
Double_t TGLBoundingBox::XMin ( ) const
inline
Double_t TGLBoundingBox::YMax ( ) const
inline
Double_t TGLBoundingBox::YMin ( ) const
inline
Double_t TGLBoundingBox::ZMax ( ) const
inline
Double_t TGLBoundingBox::ZMin ( ) const
inline

Member Data Documentation

TGLVector3 TGLBoundingBox::fAxes[3]
private

max box diagonal - cached for speed

Definition at line 61 of file TGLBoundingBox.h.

Referenced by Axis().

TGLVector3 TGLBoundingBox::fAxesNorm[3]
private

box axes in global frame - cached for speed

Definition at line 62 of file TGLBoundingBox.h.

Referenced by Axis().

Double_t TGLBoundingBox::fDiagonal
private

box volume - cached for speed

Definition at line 60 of file TGLBoundingBox.h.

Referenced by Diagonal().

TGLVertex3 TGLBoundingBox::fVertex[8]
private

Definition at line 58 of file TGLBoundingBox.h.

Referenced by Center(), operator[](), Set(), Vertex(), and Vertices().

Double_t TGLBoundingBox::fVolume
private

the 8 bounding box vertices

Definition at line 59 of file TGLBoundingBox.h.

Referenced by Volume().


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