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
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 _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::intersect(), osg::Line::intersect(), and transform().

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::intersect(), osg::Line::intersect(), and transform().

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.

Referenced by osg::extend().

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.

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

00070 {
00071     for(UInt32 i = 0; i < 3; i++) 
00072     {
00073         min[i] = _axisPos[i] - _radius;
00074         max[i] = _axisPos[i] + _radius;
00075         ((_axisDir[i] < 0) ? min[i] : max[i]) += _axisDir[i];
00076     }    
00077 }

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.

Referenced by osg::extend().

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.

Referenced by transform().

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.

Referenced by transform().

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 87 of file OSGCylinderVolume.cpp.

00088 {
00089     assert(false);
00090 }

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

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

Implements osg::Volume.

Definition at line 93 of file OSGCylinderVolume.cpp.

References osg::extend().

00094 {
00095   OSG::extend(*this, volume);
00096 }

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 109 of file OSGCylinderVolume.cpp.

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

00110 {
00111     Real32 dist = Line(_axisPos, _axisDir).distance(point);
00112 
00113     if(dist > _radius)
00114         return false;
00115 
00116     Plane bottom( _axisDir, _axisPos           );
00117     Plane top   (-_axisDir, _axisPos + _axisDir);
00118 
00119     bool inspace = bottom.isInHalfSpace(point) && top.isInHalfSpace(point);
00120 
00121     return inspace;
00122 }

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

intersect the CylinderVolume with the given Line

Implements osg::Volume.

Definition at line 127 of file OSGCylinderVolume.cpp.

References osg::Line::intersect().

00128 {
00129     return line.intersect(*this);
00130 }

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 134 of file OSGCylinderVolume.cpp.

References osg::Line::intersect().

00137 {
00138     return line.intersect(*this, enter, exit);
00139 }

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 141 of file OSGCylinderVolume.cpp.

References osg::intersect().

00142 {
00143     return OSG::intersect(*this,volume);
00144 }

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 147 of file OSGCylinderVolume.cpp.

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

00148 {
00149     Real32 dist = Line(_axisPos, _axisDir).distance(point);
00150 
00151     if(dist > _radius)
00152         return false;
00153     
00154     Plane bottom(-_axisDir, _axisPos           );
00155     Plane top   ( _axisDir, _axisPos + _axisDir);
00156 
00157     bool onplane = bottom.isOnPlane(point) || top.isOnPlane(point);
00158 
00159     return  ( onplane &&  dist <= _radius            ) ||
00160             (!onplane && osgabs(dist - _radius) < Eps);
00161 }

void CylinderVolume::transform ( const Matrix mtx  )  [virtual]

transform volume by the given matrix

Implements osg::Volume.

Definition at line 166 of file OSGCylinderVolume.cpp.

References osg::VectorInterface< ValueTypeT, StorageInterfaceT >::crossThis(), getAxis(), getRadius(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::length(), osg::TransformationMatrix< ValueTypeT >::mult(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::normalize(), p, setAxis(), and setRadius().

00167 {
00168      // get pos & axis
00169      Pnt3f p;
00170      Vec3f v, v2, v3;
00171      getAxis(p,v);
00172 
00173      // find perpendicular vector (to detect radius transformation)
00174      v2 = v;
00175      v2.normalize();
00176      v3 = v2.x() > 0.9 ? Vec3f(0,1,0) : Vec3f(1,0,0);
00177      v3.crossThis(v2);
00178 
00179      // transform
00180      mtx.mult(p);
00181      mtx.mult(v);
00182      mtx.mult(v3);
00183 
00184      // update
00185      setAxis(p,v);
00186      setRadius(getRadius() * v3.length());
00187 }

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

Implements osg::Volume.

Definition at line 195 of file OSGCylinderVolume.cpp.

References _axisDir, _axisPos, _radius, and PLOG.

00197 {
00198     PLOG << "Cylinder(" 
00199          << _axisPos 
00200          << "|" 
00201          << _axisDir
00202          << "|" 
00203          << _radius
00204          << ")";
00205 }

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

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


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

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