osg::DynamicVolume Class Reference
[Volume]

#include <OSGDynamicVolume.h>

Inheritance diagram for osg::DynamicVolume:

osg::Volume

List of all members.

Public Types

enum  Type { BOX_VOLUME, SPHERE_VOLUME }

Public Member Functions

bool operator== (const Volume &other) const
bool operator!= (const Volume &other) const
Constructors


 DynamicVolume (Type type=BOX_VOLUME)
 DynamicVolume (const DynamicVolume &obj)
Destructors


virtual ~DynamicVolume (void)
Class Specific


const VolumegetInstance (void) const
VolumegetInstance (void)
void instanceChanged (void)
Type getType (void) const
void setVolumeType (Type type)
void morphToType (Type type)
Get


virtual void getCenter (Pnt3f &center) const
virtual Real32 getScalarVolume (void) const
virtual void getBounds (Pnt3f &min, Pnt3f &max) const
Extend


virtual void extendBy (const Pnt3f &pt)
virtual void extendBy (const Volume &volume)
Intersection


virtual bool intersect (const Pnt3f &point) const
virtual bool intersect (const Line &line) const
virtual bool intersect (const Line &line, Real32 &enter, Real32 &exit) const
virtual bool intersect (const Volume &volume) const
virtual bool isOnSurface (const Pnt3f &point) const
Transform


virtual void transform (const Matrix &matrix)
Output


virtual void dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const
Operators


bool operator== (const DynamicVolume &other) const
DynamicVolumeoperator= (const DynamicVolume &source)
State


void setValid (const bool value=true)
bool isValid (void) const
void setEmpty (const bool value=true)
bool isEmpty (void) const
void setStatic (const bool value=true)
bool isStatic (void) const
void setInfinite (const bool value=true)
bool isInfinite (void) const
bool isUntouchable (void) const
UInt16 getState (void) const
void setState (UInt16 state)
Get Values


Pnt3f getMin (void) const
Pnt3f getMax (void) const

Protected Attributes

UInt16 _state

Private Attributes

Type _type
Real64 _volumeMem [5]


Detailed Description

Definition at line 53 of file OSGDynamicVolume.h.


Member Enumeration Documentation

Enumerator:
BOX_VOLUME 
SPHERE_VOLUME 

Definition at line 59 of file OSGDynamicVolume.h.

00060     { 
00061         BOX_VOLUME, 
00062         SPHERE_VOLUME 
00063     };


Constructor & Destructor Documentation

DynamicVolume::DynamicVolume ( Type  type = BOX_VOLUME  ) 

Definition at line 59 of file OSGDynamicVolume.cpp.

References setVolumeType().

00059                                       :
00060     Volume()
00061 {
00062     setVolumeType(type);
00063 }

DynamicVolume::DynamicVolume ( const DynamicVolume obj  ) 

Definition at line 65 of file OSGDynamicVolume.cpp.

References _type, _volumeMem, BOX_VOLUME, and SPHERE_VOLUME.

00065                                                      :
00066      Volume(obj      ),
00067     _type  (obj._type)
00068 {
00069     switch(_type) 
00070     {
00071         case BOX_VOLUME:
00072             new (_volumeMem) 
00073                 BoxVolume   (*((OSG::BoxVolume    *)(obj._volumeMem)));
00074             break;
00075 
00076         case SPHERE_VOLUME:
00077             new (_volumeMem) 
00078                 SphereVolume(*((OSG::SphereVolume *)(obj._volumeMem)));
00079             break;
00080     }
00081 }

osg::DynamicVolume::~DynamicVolume ( void   )  [inline, virtual]

Definition at line 54 of file OSGDynamicVolume.inl.

00055 {
00056 }


Member Function Documentation

const Volume & osg::DynamicVolume::getInstance ( void   )  const [inline]

Volume & osg::DynamicVolume::getInstance ( void   )  [inline]

Definition at line 67 of file OSGDynamicVolume.inl.

References _volumeMem.

00068 { 
00069     return *(reinterpret_cast<OSG::Volume *>(_volumeMem)); 
00070 }

void osg::DynamicVolume::instanceChanged ( void   )  [inline]

DynamicVolume::Type osg::DynamicVolume::getType ( void   )  const [inline]

void DynamicVolume::setVolumeType ( Type  type  ) 

Definition at line 83 of file OSGDynamicVolume.cpp.

References _type, _volumeMem, BOX_VOLUME, instanceChanged(), and SPHERE_VOLUME.

Referenced by osg::osg::FieldDataTraits< DynamicVolume >::copyFromBin(), DynamicVolume(), and osg::osg::FieldDataTraits< DynamicVolume >::getFromString().

00084 {
00085     _type = type;
00086 
00087     switch(type)
00088     {
00089         case BOX_VOLUME:
00090             new (_volumeMem) BoxVolume;
00091             break;
00092         case SPHERE_VOLUME:
00093             new (_volumeMem) SphereVolume;
00094             break;
00095     }
00096 
00097     instanceChanged();
00098 }

void DynamicVolume::morphToType ( Type  type  ) 

Definition at line 100 of file OSGDynamicVolume.cpp.

References _type, _volumeMem, BOX_VOLUME, getBounds(), instanceChanged(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::length(), osg::BoxVolume::setBounds(), osg::SphereVolume::setValue(), and SPHERE_VOLUME.

00101 {
00102     Pnt3f         min;
00103     Pnt3f         max;
00104     Vec3f         vec;
00105     BoxVolume    *bv;
00106     SphereVolume *sv;
00107 
00108     if(type == _type)
00109     {
00110         return;
00111     }
00112     else
00113     {
00114         switch(type) 
00115         {
00116             case BOX_VOLUME:
00117 
00118                 getBounds(min, max);
00119 
00120                 bv = new (_volumeMem) BoxVolume;
00121 
00122                 bv->setBounds(min,max);
00123 
00124                 break;
00125 
00126             case SPHERE_VOLUME:
00127 
00128                 getBounds(min, max);
00129 
00130                 sv = new (_volumeMem) SphereVolume;
00131 
00132                 vec.setValues(max.x(), max.y(), max.z());
00133 
00134                 vec -= Vec3f(min.x(), min.y(), min.z());
00135 
00136                 sv->setValue(vec, vec.length()/2);
00137 
00138                 break;
00139         }
00140     }
00141 
00142     instanceChanged();
00143 }

void DynamicVolume::getCenter ( Pnt3f center  )  const [virtual]

gives the center of the volume

Implements osg::Volume.

Definition at line 147 of file OSGDynamicVolume.cpp.

References osg::Volume::getCenter(), and getInstance().

00148 {
00149     getInstance().getCenter(center);
00150 }

Real32 DynamicVolume::getScalarVolume ( void   )  const [virtual]

gives the scalar volume of the volume

Implements osg::Volume.

Definition at line 155 of file OSGDynamicVolume.cpp.

References getInstance(), and osg::Volume::getScalarVolume().

Referenced by osg::PruneGraphOp::getSize().

00156 {
00157     return getInstance().getScalarVolume();
00158 }

void DynamicVolume::getBounds ( Pnt3f min,
Pnt3f max 
) const [virtual]

void DynamicVolume::extendBy ( const Pnt3f pt  )  [virtual]

extends (if necessary) to contain the given 3D point

Implements osg::Volume.

Definition at line 171 of file OSGDynamicVolume.cpp.

References osg::Volume::extendBy(), getInstance(), and instanceChanged().

00172 {
00173     getInstance    ().extendBy(pt);
00174     instanceChanged();
00175 }

void DynamicVolume::extendBy ( const Volume volume  )  [virtual]

extend the volume by the given volume

Implements osg::Volume.

Definition at line 180 of file OSGDynamicVolume.cpp.

References osg::Volume::extendBy(), getInstance(), and instanceChanged().

00181 {
00182     getInstance    ().extendBy(volume);
00183     instanceChanged();
00184 }

bool DynamicVolume::intersect ( const Pnt3f point  )  const [virtual]

Returns true if intersection of given point and Volume is not empty

Implements osg::Volume.

Definition at line 189 of file OSGDynamicVolume.cpp.

References getInstance(), and osg::Volume::intersect().

Referenced by osg::Group::intersect(), osg::Geometry::intersect(), and osg::DVRVolume::intersect().

00190 {
00191     return getInstance().intersect(point);
00192 }

bool DynamicVolume::intersect ( const Line line  )  const [virtual]

intersect the volume with the given Line

Implements osg::Volume.

Definition at line 196 of file OSGDynamicVolume.cpp.

References getInstance(), and osg::Volume::intersect().

00197 {
00198     return getInstance().intersect(line);
00199 }

bool DynamicVolume::intersect ( const Line line,
Real32 enter,
Real32 exit 
) const [virtual]

intersect the volume with the given Line

Implements osg::Volume.

Definition at line 203 of file OSGDynamicVolume.cpp.

References getInstance(), and osg::Volume::intersect().

00206 {
00207     return getInstance().intersect(line, enter, exit);
00208 }

bool DynamicVolume::intersect ( const Volume volume  )  const [virtual]

intersect the volume with another volume

Implements osg::Volume.

Definition at line 212 of file OSGDynamicVolume.cpp.

References getInstance(), and osg::Volume::intersect().

00213 {
00214     return getInstance().intersect(volume);
00215 }

bool DynamicVolume::isOnSurface ( const Pnt3f point  )  const [virtual]

check if the point is on the volume's surface

Implements osg::Volume.

Definition at line 219 of file OSGDynamicVolume.cpp.

References getInstance(), and osg::Volume::isOnSurface().

00220 {
00221     return getInstance().isOnSurface(point);
00222 }

void DynamicVolume::transform ( const Matrix matrix  )  [virtual]

void DynamicVolume::dump ( UInt32  uiIndent = 0,
const BitVector  bvFlags = 0 
) const [virtual]

print the volume

Implements osg::Volume.

Definition at line 234 of file OSGDynamicVolume.cpp.

References osg::Volume::dump(), getInstance(), and PLOG.

00235 {
00236     PLOG << "Dyn:";
00237     
00238     getInstance().dump(uiIndent, bvFlags);
00239 }

bool DynamicVolume::operator== ( const DynamicVolume other  )  const

Definition at line 243 of file OSGDynamicVolume.cpp.

00244 {
00245     return false; 
00246 }

DynamicVolume & DynamicVolume::operator= ( const DynamicVolume source  ) 

Definition at line 249 of file OSGDynamicVolume.cpp.

References _type, _volumeMem, BOX_VOLUME, instanceChanged(), and SPHERE_VOLUME.

00250 {
00251     _type = source._type;
00252 
00253     switch(_type)
00254     {
00255         case BOX_VOLUME:
00256             new (_volumeMem)
00257                 BoxVolume   (*((OSG::BoxVolume    *)(source._volumeMem)));
00258             break;
00259 
00260         case SPHERE_VOLUME:
00261             new (_volumeMem)
00262                 SphereVolume(*((OSG::SphereVolume *)(source._volumeMem)));
00263             break;
00264     }
00265 
00266     instanceChanged();
00267 
00268     return *this;
00269 }

void osg::Volume::setValid ( const bool  value = true  )  [inline, inherited]

bool osg::Volume::isValid ( void   )  const [inline, inherited]

Checks if the volume is valid

Definition at line 96 of file OSGVolume.inl.

References osg::Volume::_state, and osg::Volume::OSGVALID.

Referenced by osg::extend(), osg::Group::intersect(), osg::Geometry::intersect(), osg::DVRVolume::intersect(), and osg::Node::invalidateVolume().

00097 {
00098     return (_state & OSGVALID) ? true : false;
00099 }

void osg::Volume::setEmpty ( const bool  value = true  )  [inline, inherited]

bool osg::Volume::isEmpty ( void   )  const [inline, inherited]

void osg::Volume::setStatic ( const bool  value = true  )  [inline, inherited]

set the volume to be static

Definition at line 63 of file OSGVolume.inl.

References osg::Volume::_state, and osg::Volume::OSGSTATIC.

00064 {
00065     if(value == true)
00066         _state |= OSGSTATIC;
00067     else
00068         _state &= ~OSGSTATIC;
00069 }

bool osg::Volume::isStatic ( void   )  const [inline, inherited]

Checks if the volume is static

Definition at line 74 of file OSGVolume.inl.

References osg::Volume::_state, and osg::Volume::OSGSTATIC.

Referenced by osg::extend(), osg::Node::invalidateVolume(), and osg::Volume::setValid().

00075 {
00076     return (_state & OSGSTATIC) ? true : false;
00077 }

void osg::Volume::setInfinite ( const bool  value = true  )  [inline, inherited]

set the volume to be infinite

Definition at line 129 of file OSGVolume.inl.

References osg::Volume::_state, osg::Volume::OSGEMPTY, osg::Volume::OSGINFINITE, and osg::Volume::OSGVALID.

Referenced by osg::extend(), osg::BoxVolume::setBounds(), and osg::BoxVolume::setBoundsByCenterAndSize().

00130 {
00131     if(value == true)
00132     {
00133         _state |=  OSGINFINITE;
00134         _state |=  OSGVALID;
00135         _state &= ~OSGEMPTY;
00136     }
00137     else
00138     {
00139         _state &= ~OSGINFINITE;
00140     }
00141 }

bool osg::Volume::isInfinite ( void   )  const [inline, inherited]

Checks if the volume is infinite

Definition at line 146 of file OSGVolume.inl.

References osg::Volume::_state, and osg::Volume::OSGINFINITE.

Referenced by osg::extend(), and osg::intersect().

00147 {
00148     return (_state & OSGINFINITE) ? true : false;
00149 }

bool osg::Volume::isUntouchable ( void   )  const [inline, inherited]

Checks if the volume is untouchable, i.e. it's values should not be changed. Mainly used internally to speed up early outs in extendBy().

Definition at line 157 of file OSGVolume.inl.

References osg::Volume::_state, osg::Volume::OSGINFINITE, osg::Volume::OSGSTATIC, and osg::Volume::OSGVALID.

Referenced by osg::SphereVolume::extendBy(), and osg::BoxVolume::extendBy().

00158 {
00159     return (_state & (OSGINFINITE | OSGVALID | OSGSTATIC)) != OSGVALID;
00160 }

UInt16 osg::Volume::getState ( void   )  const [inline, inherited]

get the volume's state

Definition at line 166 of file OSGVolume.inl.

References osg::Volume::_state.

Referenced by osg::osg::FieldDataTraits< DynamicVolume >::copyToBin(), and instanceChanged().

00167 {
00168     return _state;
00169 }

void osg::Volume::setState ( UInt16  val  )  [inline, inherited]

set the volume's state

Definition at line 174 of file OSGVolume.inl.

References osg::Volume::_state.

Referenced by osg::osg::FieldDataTraits< DynamicVolume >::copyFromBin().

00175 {
00176     _state = val;
00177 }

Pnt3f osg::Volume::getMin ( void   )  const [inline, inherited]

Return the lowest point of the volume. Just a convience wrapper for getBounds()

Reimplemented in osg::BoxVolume.

Definition at line 184 of file OSGVolume.inl.

References osg::Volume::getBounds().

00185 {
00186     Pnt3f pmin; 
00187     Pnt3f pmax;
00188 
00189     getBounds(pmin, pmax);
00190 
00191     return pmin;
00192 }

Pnt3f osg::Volume::getMax ( void   )  const [inline, inherited]

Return the highest point of the volume. Just a convience wrapper for getBounds()

Reimplemented in osg::BoxVolume.

Definition at line 199 of file OSGVolume.inl.

References osg::Volume::getBounds().

Referenced by osg::RenderAction::drawHierarchicalMultiFrameOcclusionBB(), osg::RenderAction::drawMultiFrameOcclusionBB(), and osg::RenderAction::dropFunctor().

00200 {
00201     Pnt3f pmin;
00202     Pnt3f pmax;
00203 
00204     getBounds(pmin, pmax);
00205 
00206     return pmax;
00207 }

bool Volume::operator== ( const Volume other  )  const [inherited]

Definition at line 53 of file OSGVolume.cpp.

References osg::Volume::_state.

00054 {
00055     return _state == other._state;
00056 }

bool Volume::operator!= ( const Volume other  )  const [inherited]

Definition at line 58 of file OSGVolume.cpp.

00059 {
00060     return !(*this == other);
00061 }


Member Data Documentation

Definition at line 156 of file OSGDynamicVolume.h.

Referenced by DynamicVolume(), getType(), morphToType(), operator=(), and setVolumeType().

Definition at line 157 of file OSGDynamicVolume.h.

Referenced by DynamicVolume(), getInstance(), morphToType(), operator=(), and setVolumeType().

UInt16 osg::Volume::_state [protected, inherited]


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

Generated on Mon Mar 17 12:03:13 2008 for OpenSG by  doxygen 1.5.5