Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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)

Protected Attributes

UInt16 _state

Private Attributes

Type _type
Real64 _volumeMem [5]

Detailed Description

Definition at line 53 of file OSGDynamicVolume.h.


Member Enumeration Documentation

enum osg::DynamicVolume::Type
 

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]
 

Definition at line 60 of file OSGDynamicVolume.inl.

References _volumeMem.

Referenced by osg::FieldDataTraits< DynamicVolume >::copyFromBin(), osg::FieldDataTraits< DynamicVolume >::copyToBin(), osg::drawVolume(), dump(), extendBy(), getBounds(), getCenter(), osg::FieldDataTraits< DynamicVolume >::getFromString(), getScalarVolume(), instanceChanged(), intersect(), isOnSurface(), osg::FieldDataTraits< DynamicVolume >::putToString(), transform(), and osg::Node::updateVolume().

00061 { 
00062     return *(reinterpret_cast<const OSG::Volume *>(_volumeMem)); 
00063 }

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]
 

Definition at line 80 of file OSGDynamicVolume.inl.

References osg::Volume::_state, getInstance(), and osg::Volume::getState().

Referenced by extendBy(), osg::FieldDataTraits< DynamicVolume >::getFromString(), morphToType(), operator=(), setVolumeType(), transform(), and osg::Node::updateVolume().

00081 {
00082     _state = getInstance().getState(); 
00083 }

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

Definition at line 74 of file OSGDynamicVolume.inl.

References _type.

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

00075 {
00076     return static_cast<Type>(_type); 
00077 }

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::FieldDataTraits< DynamicVolume >::copyFromBin(), DynamicVolume(), and 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(), osg::VecStorage3< ValueTypeT >::setValues(), SPHERE_VOLUME, osg::VecStorage3< ValueTypeT >::x(), osg::VecStorage3< ValueTypeT >::y(), and osg::VecStorage3< ValueTypeT >::z().

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]
 

gives the boundaries of the volume

Implements osg::Volume.

Definition at line 163 of file OSGDynamicVolume.cpp.

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

Referenced by osg::calcVertexTexCoords(), osg::ImageComposer::getScreenAlignedBBox(), osg::PruneGraphOp::getSize(), morphToType(), osg::FieldDataTraits< DynamicVolume >::putToString(), osg::SimpleSceneManager::updateHighlight(), and osg::TileGeometryLoad::updateView().

00164 {
00165     getInstance().getBounds(min,max);
00166 }

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]
 

transform the volume bye the given matrix

Implements osg::Volume.

Definition at line 226 of file OSGDynamicVolume.cpp.

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

Referenced by osg::ImageComposer::getScreenAlignedBBox(), osg::Node::getWorldVolume(), osg::RenderAction::isVisible(), osg::RenderAction::pushVisibility(), and osg::TileGeometryLoad::updateView().

00227 {
00228     getInstance    ().transform(matrix);
00229     instanceChanged();
00230 }

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]
 

set the volume to be valid

Definition at line 82 of file OSGVolume.inl.

References osg::Volume::_state, osg::Volume::isStatic(), and osg::Volume::OSGVALID.

Referenced by osg::Surface::adjustVolume(), osg::Slices::adjustVolume(), osg::ProxyGroup::adjustVolume(), osg::Particles::adjustVolume(), osg::Geometry::adjustVolume(), osg::DVRVolume::adjustVolume(), osg::Node::invalidateVolume(), osg::BoxVolume::setBounds(), and osg::BoxVolume::setBoundsByCenterAndSize().

00083 {
00084     if(!isStatic())
00085     {
00086         if(value == true)
00087             _state |=  OSGVALID;
00088         else
00089             _state &= ~OSGVALID;
00090     }
00091 }

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::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]
 

set the volume to contain nothing

Definition at line 104 of file OSGVolume.inl.

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

Referenced by osg::Surface::adjustVolume(), osg::Slices::adjustVolume(), osg::ProxyGroup::adjustVolume(), osg::Particles::adjustVolume(), osg::Geometry::adjustVolume(), osg::DVRVolume::adjustVolume(), osg::BoxVolume::BoxVolume(), osg::CylinderVolume::CylinderVolume(), osg::ParticleBSPTree::doBuild(), osg::SphereVolume::extendBy(), osg::BoxVolume::extendBy(), osg::BoxVolume::setBounds(), osg::BoxVolume::setBoundsByCenterAndSize(), osg::SphereVolume::setValue(), osg::SphereVolume::SphereVolume(), and osg::Node::updateVolume().

00105 {
00106     if(value == true)
00107     {
00108         _state |=  OSGEMPTY;
00109         _state |=  OSGVALID;
00110         _state &= ~OSGINFINITE;
00111     }
00112     else
00113     {
00114         _state &= ~OSGEMPTY;
00115     }
00116 }

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

Checks if the volume is empty

Definition at line 121 of file OSGVolume.inl.

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

Referenced by osg::SphereVolume::extendBy(), osg::BoxVolume::extendBy(), osg::BoxVolume::getCenter(), osg::SphereVolume::getScalarVolume(), osg::CylinderVolume::getScalarVolume(), osg::BoxVolume::getScalarVolume(), osg::BoxVolume::intersect(), and osg::BoxVolume::transform().

00122 {
00123     return (_state & OSGEMPTY) ? true : false;
00124 }

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::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::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.

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::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::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().

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

Type osg::DynamicVolume::_type [private]
 

Definition at line 156 of file OSGDynamicVolume.h.

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

Real64 osg::DynamicVolume::_volumeMem[5] [private]
 

Definition at line 157 of file OSGDynamicVolume.h.

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

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

Definition at line 149 of file OSGVolume.h.

Referenced by osg::Volume::getState(), instanceChanged(), osg::Volume::isEmpty(), osg::Volume::isInfinite(), osg::Volume::isStatic(), osg::Volume::isUntouchable(), osg::Volume::isValid(), osg::FrustumVolume::operator=(), osg::BoxVolume::operator=(), osg::Volume::operator==(), osg::Volume::setEmpty(), osg::Volume::setInfinite(), osg::Volume::setState(), osg::Volume::setStatic(), and osg::Volume::setValid().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:12:33 2005 for OpenSG by  doxygen 1.4.3