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

osg::CylinderVolume Class Reference
[Volume]

#include <OSGCylinderVolume.h>

Inheritance diagram for osg::CylinderVolume:

osg::Volume List of all members.

Public Member Functions

bool operator== (const Volume &other) const
bool operator!= (const Volume &other) const
Constructors
CylinderVolume (void)
 CylinderVolume (const Pnt3f &p, const Vec3f &d, Real32 r)
 CylinderVolume (const CylinderVolume &c)
Destructors
~CylinderVolume (void)
Get
*void getAxis (Pnt3f &apos, Vec3f &adir) const
Real32 getRadius (void) const
virtual void getCenter (Pnt3f &center) const
virtual Real32 getScalarVolume (void) const
virtual void getBounds (Pnt3f &min, Pnt3f &max) const
Set
*void setValue (const Pnt3f &p, const Vec3f &d, Real32 r)
void setAxis (const Pnt3f &p, const Vec3f &d)
void setRadius (Real32 r)
Extend
*virtual void extendBy (const Pnt3f &pt)
virtual void extendBy (const Volume &volume)
void extendBy (const CylinderVolume &obj)
Intersect
*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 CylinderVolume &volume) const
virtual bool isOnSurface (const Pnt3f &point) const
Transform
*virtual void transform (const Matrix &mat)
Output
*virtual void dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const
 print the volume

Protected Attributes

UInt16 _state

Private Attributes

Pnt3f _axisPos
Vec3f _axisDir
Real32 _radius

Detailed Description

3D cylinder in space defined by axis and radius.

Definition at line 54 of file OSGCylinderVolume.h.


Constructor & Destructor Documentation

osg::CylinderVolume::CylinderVolume void   )  [inline]
 

Definition at line 51 of file OSGCylinderVolume.inl.

00051                                    : 
00052     Volume()
00053 {
00054 }

osg::CylinderVolume::CylinderVolume const Pnt3f p,
const Vec3f d,
Real32  r
[inline]
 

Definition at line 58 of file OSGCylinderVolume.inl.

References osg::Volume::setEmpty().

00060                                                 : 
00061      Volume ( ),    
00062     _axisPos(p), 
00063     _axisDir(d), 
00064     _radius (r) 
00065 { 
00066     setEmpty(false);
00067 }

osg::CylinderVolume::CylinderVolume const CylinderVolume c  )  [inline]
 

Definition at line 71 of file OSGCylinderVolume.inl.

00071                                                      : 
00072      Volume (c         ),
00073     _axisPos(c._axisPos), 
00074     _axisDir(c._axisDir), 
00075     _radius (c._radius )
00076 {
00077 }

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

Definition at line 81 of file OSGCylinderVolume.inl.

00082 {
00083 }


Member Function Documentation

void osg::CylinderVolume::getAxis Pnt3f apos,
Vec3f adir
const [inline]
 

Definition at line 87 of file OSGCylinderVolume.inl.

References _axisDir, and _axisPos.

Referenced by osg::Line::intersect().

00088 {
00089     adir = _axisDir;
00090     apos = _axisPos;
00091 }

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

Definition at line 95 of file OSGCylinderVolume.inl.

References _radius.

Referenced by osg::Line::intersect().

00096 {
00097     return _radius;
00098 }

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

Implements osg::Volume.

Definition at line 56 of file OSGCylinderVolume.cpp.

References _axisDir, and _axisPos.

00057 {
00058     center = _axisPos + _axisDir * .5;
00059 }

Real32 CylinderVolume::getScalarVolume void   )  const [virtual]
 

Implements osg::Volume.

Definition at line 62 of file OSGCylinderVolume.cpp.

References _axisDir, _radius, osg::Volume::isEmpty(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::length(), and osg::Pi.

00063 {
00064     return isEmpty() ? 0.0f : (_radius * _radius * Pi * _axisDir.length());
00065 }

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

gives the boundaries of the volume

Implements osg::Volume.

Definition at line 69 of file OSGCylinderVolume.cpp.

References _axisDir, _axisPos, and _radius.

00070 {
00071     // this is rather simpleminded, but good enough for now
00072 
00073     if(_axisDir[0] < 0)
00074     {
00075         min[0] = _axisPos[0] + _axisDir[0] - _radius;
00076         max[0] = _axisPos[0] - _axisDir[0] + _radius;
00077     }
00078     else
00079     {
00080         min[0] = _axisPos[0] - _axisDir[0] - _radius;
00081         max[0] = _axisPos[0] + _axisDir[0] + _radius;
00082     }
00083 
00084     if(_axisDir[1] < 0)
00085     {
00086         min[1] = _axisPos[1] + _axisDir[1] - _radius;
00087         max[1] = _axisPos[1] - _axisDir[1] + _radius;
00088     }
00089     else
00090     {
00091         min[1] = _axisPos[1] - _axisDir[1] - _radius;
00092         max[1] = _axisPos[1] + _axisDir[1] + _radius;
00093     }
00094 
00095     if(_axisDir[2] < 0)
00096     {
00097         min[2] = _axisPos[2] + _axisDir[2] - _radius;
00098         max[2] = _axisPos[2] - _axisDir[2] + _radius;
00099     }
00100     else
00101     {
00102         min[2] = _axisPos[2] - _axisDir[2] - _radius;
00103         max[2] = _axisPos[2] + _axisDir[2] + _radius;
00104     }
00105 }

void osg::CylinderVolume::setValue const Pnt3f p,
const Vec3f d,
Real32  r
[inline]
 

Definition at line 102 of file OSGCylinderVolume.inl.

References _axisDir, _axisPos, and _radius.

00103 {
00104     _axisPos = p;
00105     _axisDir = d;
00106     _radius = r;
00107 }

void osg::CylinderVolume::setAxis const Pnt3f p,
const Vec3f d
[inline]
 

Definition at line 111 of file OSGCylinderVolume.inl.

References _axisDir, and _axisPos.

00112 {
00113     _axisPos = p;
00114     _axisDir = d;
00115 }

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

Definition at line 119 of file OSGCylinderVolume.inl.

References _radius.

00120 {
00121     _radius = r;
00122 }

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

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

Implements osg::Volume.

Definition at line 115 of file OSGCylinderVolume.cpp.

00116 {
00117     assert(false);
00118 }

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

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

Implements osg::Volume.

Definition at line 121 of file OSGCylinderVolume.cpp.

References osg::extend().

00122 {
00123   OSG::extend(*this, volume);
00124 }

void osg::CylinderVolume::extendBy const CylinderVolume obj  )  [inline]
 

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

Definition at line 126 of file OSGCylinderVolume.inl.

References osg::extend().

00127 {
00128     OSG::extend(*this, volume);
00129 }

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

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

Implements osg::Volume.

Definition at line 137 of file OSGCylinderVolume.cpp.

References _axisDir, _axisPos, _radius, and osg::Plane::isInHalfSpace().

00138 {
00139     Real32 dist = Line(_axisPos, _axisDir).distance(point);
00140 
00141     if(dist > _radius)
00142         return false;
00143 
00144     Plane bottom( _axisDir, _axisPos           );
00145     Plane top   (-_axisDir, _axisPos + _axisDir);
00146 
00147     bool inspace = bottom.isInHalfSpace(point) && top.isInHalfSpace(point);
00148 
00149     return inspace;
00150 }

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

intersect the CylinderVolume with the given Line

Implements osg::Volume.

Definition at line 155 of file OSGCylinderVolume.cpp.

References osg::Line::intersect().

00156 {
00157     return line.intersect(*this);
00158 }

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

intersect the volume with the given Line

Implements osg::Volume.

Definition at line 162 of file OSGCylinderVolume.cpp.

References osg::Line::intersect().

00165 {
00166     return line.intersect(*this, enter, exit);
00167 }

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

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

Implements osg::Volume.

Definition at line 169 of file OSGCylinderVolume.cpp.

References osg::intersect().

00170 {
00171     return OSG::intersect(*this,volume);
00172 }

bool osg::CylinderVolume::intersect const CylinderVolume volume  )  const [inline]
 

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

Definition at line 133 of file OSGCylinderVolume.inl.

References osg::intersect().

00134 {
00135   return OSG::intersect(*this, volume);
00136 }

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

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

Implements osg::Volume.

Definition at line 175 of file OSGCylinderVolume.cpp.

References _axisDir, _axisPos, _radius, osg::Eps, osg::Plane::isOnPlane(), and osg::osgabs().

00176 {
00177     Real32 dist = Line(_axisPos, _axisDir).distance(point);
00178 
00179     if(dist > _radius)
00180         return false;
00181     
00182     Plane bottom(-_axisDir, _axisPos           );
00183     Plane top   ( _axisDir, _axisPos + _axisDir);
00184 
00185     bool onplane = bottom.isOnPlane(point) || top.isOnPlane(point);
00186 
00187     return  ( onplane &&  dist <= _radius            ) ||
00188             (!onplane && osgabs(dist - _radius) < Eps);
00189 }

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

transform volume by the given matrix

Implements osg::Volume.

Definition at line 199 of file OSGCylinderVolume.cpp.

00200 {
00201     assert(false);
00202 }

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

Implements osg::Volume.

Definition at line 210 of file OSGCylinderVolume.cpp.

References _axisDir, _axisPos, _radius, and PLOG.

00212 {
00213     PLOG << "Cylinder(" 
00214          << _axisPos 
00215          << "|" 
00216          << _axisDir
00217          << "|" 
00218          << _radius
00219          << ")";
00220 }

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(), 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(), 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 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::CylinderVolume::_axisPos [private]
 

Definition at line 148 of file OSGCylinderVolume.h.

Referenced by dump(), getAxis(), getBounds(), getCenter(), intersect(), isOnSurface(), setAxis(), and setValue().

Vec3f osg::CylinderVolume::_axisDir [private]
 

Definition at line 149 of file OSGCylinderVolume.h.

Referenced by dump(), getAxis(), getBounds(), getCenter(), getScalarVolume(), intersect(), isOnSurface(), setAxis(), and setValue().

Real32 osg::CylinderVolume::_radius [private]
 

Definition at line 150 of file OSGCylinderVolume.h.

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

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:33 2005 for OpenSG by  doxygen 1.4.3