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

osg::SphereVolume Class Reference
[Volume]

#include <OSGSphereVolume.h>

Inheritance diagram for osg::SphereVolume:

osg::Volume List of all members.

Public Member Functions

bool operator== (const Volume &other) const
bool operator!= (const Volume &other) const
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
Constructor
SphereVolume (void)
 SphereVolume (const SphereVolume &obj)
 SphereVolume (const Pnt3f &c, Real32 r)
Destructor
~SphereVolume (void)
Set Values
*void setValue (const Pnt3f &c, Real32 r)
void setCenter (const Pnt3f &c)
void setRadius (Real32 r)
Get Values
*const Pnt3fgetCenter (void) const
Real32 getRadius (void) const
virtual void getCenter (Pnt3f &center) const
virtual Real32 getScalarVolume (void) const
virtual void getBounds (Pnt3f &min, Pnt3f &max) const
Extending
*virtual void extendBy (const Pnt3f &pt)
virtual void extendBy (const Volume &volume)
void extendBy (const SphereVolume &bb)
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
bool intersect (const SphereVolume &sphere) const
virtual bool isOnSurface (const Pnt3f &point) const
Transformation
*virtual void transform (const Matrix &mat)
Output
*virtual void dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const
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

Pnt3f _center
Real32 _radius

Detailed Description

Sphere in 3D space defined by center and radius.

Definition at line 53 of file OSGSphereVolume.h.


Constructor & Destructor Documentation

osg::SphereVolume::SphereVolume void   )  [inline]
 

Definition at line 50 of file OSGSphereVolume.inl.

00050                                : 
00051      Volume(             ),
00052     _center(0.f, 0.f, 0.f),
00053     _radius(0            ) 
00054 {
00055 }

osg::SphereVolume::SphereVolume const SphereVolume obj  )  [inline]
 

Definition at line 58 of file OSGSphereVolume.inl.

References osg::Volume::setEmpty().

00058                                                   :
00059      Volume(           ),    
00060     _center(obj._center), 
00061     _radius(obj._radius) 
00062 {
00063     setEmpty(false);
00064 }

osg::SphereVolume::SphereVolume const Pnt3f c,
Real32  r
[inline]
 

Definition at line 67 of file OSGSphereVolume.inl.

References osg::Volume::setEmpty().

00067                                                    :
00068      Volume( ), 
00069     _center(c), 
00070     _radius(r)
00071 {
00072     setEmpty(false);
00073 }

osg::SphereVolume::~SphereVolume void   )  [inline]
 

Definition at line 76 of file OSGSphereVolume.inl.

00077 {
00078 }


Member Function Documentation

void osg::SphereVolume::setValue const Pnt3f c,
Real32  r
[inline]
 

Change the center and radius

Definition at line 85 of file OSGSphereVolume.inl.

References _center, _radius, and osg::Volume::setEmpty().

Referenced by osg::DynamicVolume::morphToType().

00086 {
00087     setEmpty(false);
00088 
00089     _center = c;
00090     _radius = r;
00091 }

void osg::SphereVolume::setCenter const Pnt3f c  )  [inline]
 

set just the center

Definition at line 97 of file OSGSphereVolume.inl.

References _center.

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

00098 {
00099     _center = c;
00100 }

void osg::SphereVolume::setRadius Real32  r  )  [inline]
 

set just the radius

Definition at line 105 of file OSGSphereVolume.inl.

References _radius.

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

00106 {
00107     _radius = r;
00108 }

const Pnt3f & osg::SphereVolume::getCenter void   )  const [inline]
 

Returns the center

Definition at line 115 of file OSGSphereVolume.inl.

References _center.

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

00116 {
00117     return _center;
00118 }

Real32 osg::SphereVolume::getRadius void   )  const [inline]
 

Returns the radius

Definition at line 123 of file OSGSphereVolume.inl.

References _radius.

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

00124 {
00125     return _radius;
00126 }

void SphereVolume::getCenter Pnt3f center  )  const [virtual]
 

Returns the center

Implements osg::Volume.

Definition at line 72 of file OSGSphereVolume.cpp.

References _center.

00073 {
00074     center = _center;
00075 }

Real32 SphereVolume::getScalarVolume void   )  const [virtual]
 

Returns the center

Implements osg::Volume.

Definition at line 78 of file OSGSphereVolume.cpp.

References _radius, osg::Volume::isEmpty(), and osg::Pi.

00079 {
00080     return isEmpty() ? 0.0f : (4.f / 3.f * Pi * _radius * _radius * _radius);
00081 }

void SphereVolume::getBounds Pnt3f min,
Pnt3f max
const [virtual]
 

Returns the center

Implements osg::Volume.

Definition at line 84 of file OSGSphereVolume.cpp.

References _center, _radius, and osg::VecStorage3< ValueTypeT >::setValues().

00085 {
00086     min.setValues(_center[0] - _radius,
00087                   _center[1] - _radius,
00088                   _center[2] - _radius);
00089     max.setValues(_center[0] + _radius,
00090                   _center[1] + _radius,
00091                   _center[2] + _radius);
00092 }

void SphereVolume::extendBy const Pnt3f pt  )  [virtual]
 

Implements osg::Volume.

Definition at line 95 of file OSGSphereVolume.cpp.

References _center, _radius, osg::Volume::isEmpty(), osg::Volume::isUntouchable(), and osg::Volume::setEmpty().

00096 {
00097     if(isUntouchable() == true)
00098         return;
00099     
00100     if(isEmpty() == true)
00101     {
00102         _center = pt;
00103         _radius = 0.f;
00104         
00105         setEmpty(false);
00106     }
00107     else
00108     {
00109         Real32 d = (_center - pt).length();
00110         
00111         if(d > _radius)
00112             _radius = d;
00113     }
00114 }

void SphereVolume::extendBy const Volume volume  )  [virtual]
 

Implements osg::Volume.

Definition at line 117 of file OSGSphereVolume.cpp.

References osg::extend().

00118 {
00119     OSG::extend(*this, volume);
00120 }

void osg::SphereVolume::extendBy const SphereVolume bb  )  [inline]
 

Definition at line 131 of file OSGSphereVolume.inl.

References osg::extend().

00132 {
00133     OSG::extend(*this, volume);
00134 }

bool SphereVolume::intersect const Pnt3f point  )  const [virtual]
 

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

Implements osg::Volume.

Definition at line 126 of file OSGSphereVolume.cpp.

References _center, and _radius.

00127 {
00128     Real32 d = (_center - point).length();
00129 
00130     if(d <= _radius)
00131         return true;
00132     else
00133         return false;
00134 }

bool SphereVolume::intersect const Line line  )  const [virtual]
 

intersect the SphereVolume with the given Line

Implements osg::Volume.

Definition at line 138 of file OSGSphereVolume.cpp.

References osg::Line::intersect().

00139 {
00140     return line.intersect(*this);
00141 }

bool SphereVolume::intersect const Line line,
Real32 enter,
Real32 exit
const [virtual]
 

intersect the SphereVolume with the given Line

Implements osg::Volume.

Definition at line 145 of file OSGSphereVolume.cpp.

References osg::Line::intersect().

00148 {
00149     return line.intersect(*this, enter, exit);
00150 }

bool SphereVolume::intersect const Volume volume  )  const [virtual]
 

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

Implements osg::Volume.

Definition at line 153 of file OSGSphereVolume.cpp.

References osg::intersect().

00154 {
00155     return OSG::intersect(*this, volume);
00156 }

bool osg::SphereVolume::intersect const SphereVolume sphere  )  const [inline]
 

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

Definition at line 139 of file OSGSphereVolume.inl.

References osg::intersect().

00140 {
00141     return OSG::intersect(*this, volume);
00142 }

bool SphereVolume::isOnSurface const Pnt3f point  )  const [virtual]
 

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

Implements osg::Volume.

Definition at line 159 of file OSGSphereVolume.cpp.

References _center, _radius, osg::Eps, and osg::osgabs().

00160 {
00161     if(osgabs((point - _center).length() - _radius) < Eps)
00162         return true;
00163     else
00164         return false;
00165 }

void SphereVolume::transform const Matrix mat  )  [virtual]
 

Implements osg::Volume.

Definition at line 174 of file OSGSphereVolume.cpp.

References _center, _radius, and osg::TransformationMatrix< ValueTypeT >::mult().

00175 {
00176     // assume uniform scaling, otherways we get an ellipsoid
00177     Pnt3f hull(_center);
00178     hull += Vec3f(0, _radius, 0);
00179 
00180     mat.mult(_center);
00181     mat.mult(hull);
00182     _radius = (hull - _center).length();
00183 
00184 /*
00185     Vec3f translation, scaleFactor;
00186     Quaternion rotation, scaleOrientation;
00187     
00188     mat.mult(_center);
00189     mat.getTransform(translation, rotation, scaleFactor, scaleOrientation);
00190     _radius *= scaleFactor[0];
00191 */
00192 }

void SphereVolume::dump UInt32  uiIndent = 0,
const BitVector  bvFlags = 0
const [virtual]
 

print the volume

Implements osg::Volume.

Definition at line 199 of file OSGSphereVolume.cpp.

References _center, _radius, and PLOG.

00201 {
00202     PLOG << "Sphere(" << _center << "|" << _radius << ")";
00203 }

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(), extendBy(), osg::BoxVolume::extendBy(), osg::BoxVolume::setBounds(), osg::BoxVolume::setBoundsByCenterAndSize(), setValue(), 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 extendBy(), osg::BoxVolume::extendBy(), osg::BoxVolume::getCenter(), 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 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 osg::DynamicVolume::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

Pnt3f osg::SphereVolume::_center [private]
 

Definition at line 144 of file OSGSphereVolume.h.

Referenced by dump(), extendBy(), getBounds(), getCenter(), intersect(), isOnSurface(), setCenter(), setValue(), and transform().

Real32 osg::SphereVolume::_radius [private]
 

Definition at line 145 of file OSGSphereVolume.h.

Referenced by dump(), extendBy(), getBounds(), getRadius(), getScalarVolume(), intersect(), isOnSurface(), setRadius(), setValue(), and transform().

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

Definition at line 149 of file OSGVolume.h.

Referenced by osg::Volume::getState(), osg::DynamicVolume::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:36 2005 for OpenSG by  doxygen 1.4.3