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

osg::IntersectAction Class Reference
[Action]

IntersectAction class. More...

#include <OSGIntersectAction.h>

Inheritance diagram for osg::IntersectAction:

osg::Action List of all members.

Public Types

typedef ArgsCollector< Action * > FunctorArgs
typedef TypedFunctor2Base<
ResultE, CPtrRefCallArg<
CNodePtr >, FunctorArgs
Functor
enum  ResultE { Continue, Skip, Quit }

Public Member Functions

IntersectActionoperator= (const IntersectAction &source)
virtual ~IntersectAction (void)
 Destructor.
void setLine (const Line &line, const Real32 maxdist=Inf)
const LinegetLine (void) const
 Constructor Destructor.
Real32 getMaxDist (void) const
bool didHit (void) const
Real32 getHitT (void) const
Pnt3f getHitPoint (void) const
Vec3f getHitNormal (void) const
NodePtr getHitObject (void) const
Int32 getHitTriangle (void) const
Action::ResultE setEnterLeave (Real32 enter, Real32 leave)
void setHit (Real32 t, NodePtr obj, Int32 triIndex, Vec3f &normal)
void scale (Real32 s)
bool operator< (const IntersectAction &other) const
 assignment assignment
bool operator== (const IntersectAction &other) const
 equal
bool operator!= (const IntersectAction &other) const
 unequal
void registerEnterFunction (const FieldContainerType &type, const Functor &func)
void registerLeaveFunction (const FieldContainerType &type, const Functor &func)
virtual ResultE apply (std::vector< NodePtr >::iterator begin, std::vector< NodePtr >::iterator end)
virtual ResultE apply (NodePtr node)
NodePtr getActNode (void)
UInt32 getNNodes (void) const
const NodePtr getNode (int index)
void addNode (NodePtr node)
void useNodeList (void)
void printTable (void)
UInt32 getTravMask (void) const
void setTravMask (UInt32 val)
bool operator< (const Action &other)
 assignment
bool operator== (const Action &other)
 equal
bool operator!= (const Action &other)
 unequal

Static Public Member Functions

static const char * getClassname (void)
static IntersectActioncreate (void)
 create a new action
static IntersectActioncreate (const Line &line, const Real32 maxdist=Inf)
 create a new action
static void setPrototype (IntersectAction *proto)
static IntersectActiongetPrototype (void)
static void registerEnterDefault (const FieldContainerType &type, const Action::Functor &func)
static void registerLeaveDefault (const FieldContainerType &type, const Action::Functor &func)
static void setPrototype (Action *proto)

Protected Member Functions

 IntersectAction (void)
 Constructor.
 IntersectAction (const IntersectAction &source)
virtual Action::ResultE start (void)
virtual std::vector< Functor > * getDefaultEnterFunctors (void)
virtual std::vector< Functor > * getDefaultLeaveFunctors (void)
ResultE callEnter (NodePtr node)
ResultE callLeave (NodePtr node)
virtual ResultE stop (ResultE res)
ResultE recurse (NodePtr node)
ResultE callNewList (void)
void setActNode (NodePtr node)

Static Protected Member Functions

static ResultE _defaultEnterFunction (CNodePtr &node, Action *action)
static ResultE _defaultLeaveFunction (CNodePtr &node, Action *action)

Protected Attributes

std::vector< Functor_enterFunctors
std::vector< Functor_leaveFunctors

Private Types

typedef Action Inherited

Private Attributes

Line _line
Real32 _maxdist
bool _hit
Real32 _enterT
Real32 _leaveT
Real32 _hitT
NodePtr _hitObject
Int32 _hitTriangle
Vec3f _hitNormal

Static Private Attributes

static char cvsid [] = "@(#)$Id: OSGIntersectAction.cpp,v 1.10 2001/10/15 04:52:15 vossg Exp $"
static IntersectAction_prototype = NULL
static std::vector< Functor > * _defaultEnterFunctors
static std::vector< Functor > * _defaultLeaveFunctors

Detailed Description

The intersect action class.

Definition at line 74 of file OSGIntersectAction.h.


Member Typedef Documentation

typedef Action osg::IntersectAction::Inherited [private]
 

Definition at line 212 of file OSGIntersectAction.h.

typedef ArgsCollector<Action *> osg::Action::FunctorArgs [inherited]
 

Definition at line 95 of file OSGAction.h.

typedef TypedFunctor2Base<ResultE, CPtrRefCallArg<CNodePtr>, FunctorArgs > osg::Action::Functor [inherited]
 

Definition at line 99 of file OSGAction.h.


Member Enumeration Documentation

enum osg::Action::ResultE [inherited]
 

Enumerator:
Continue 
Skip 
Quit 

Definition at line 87 of file OSGAction.h.

00088     {   
00089         Continue,   // continue with my children
00090         Skip,       // skip my children
00091         // really needed? Cancel, // skip my brothers, go one step up
00092         Quit        // forget it, you're done
00093     };


Constructor & Destructor Documentation

IntersectAction::~IntersectAction void   )  [virtual]
 

Definition at line 226 of file OSGIntersectAction.cpp.

00227 {
00228 }

IntersectAction::IntersectAction void   )  [protected]
 

Definition at line 166 of file OSGIntersectAction.cpp.

References _defaultEnterFunctors, _defaultLeaveFunctors, osg::Action::_enterFunctors, and osg::Action::_leaveFunctors.

Referenced by create().

00166                                      :
00167     _line(), _maxdist(), 
00168     _hit(false), _enterT(-1), _leaveT(-1), _hitT(-1), _hitObject(),
00169     _hitTriangle(-1)
00170 {
00171     if ( _defaultEnterFunctors )
00172         _enterFunctors = *_defaultEnterFunctors;
00173 
00174     if ( _defaultLeaveFunctors )
00175         _leaveFunctors = *_defaultLeaveFunctors;
00176 }

IntersectAction::IntersectAction const IntersectAction source  )  [protected]
 

Definition at line 179 of file OSGIntersectAction.cpp.

00179                                                                 :
00180     Inherited( source ),
00181     _line( source._line ), _maxdist( source._maxdist ), 
00182     _hit(source._hit), _enterT(source._enterT), _leaveT(source._leaveT), 
00183     _hitT(source._hitT), _hitObject(source._hitObject),
00184     _hitTriangle(source._hitTriangle)
00185 {
00186 }


Member Function Documentation

static const char* osg::IntersectAction::getClassname void   )  [inline, static]
 

Reimplemented from osg::Action.

Definition at line 90 of file OSGIntersectAction.h.

00090 { return "IntersectAction"; };

IntersectAction * IntersectAction::create void   )  [static]
 

Reimplemented from osg::Action.

Definition at line 192 of file OSGIntersectAction.cpp.

References _prototype, and IntersectAction().

Referenced by osg::Navigator::buttonRelease(), osg::Navigator::getIntersectionPoint(), and osg::WalkNavigator::WalkNavigator().

00193 {
00194     IntersectAction * act;
00195     
00196     if ( _prototype )
00197         act = new IntersectAction( *_prototype );
00198     else
00199         act = new IntersectAction();
00200     
00201     return act;
00202 }

IntersectAction * IntersectAction::create const Line line,
const Real32  maxdist = Inf
[static]
 

Definition at line 208 of file OSGIntersectAction.cpp.

References _prototype, IntersectAction(), and setLine().

00210 {
00211     IntersectAction * act;
00212     
00213     if ( _prototype )
00214         act = new IntersectAction( *_prototype );
00215     else
00216         act = new IntersectAction();
00217     
00218     act->setLine( line, maxdist );
00219 
00220     return act;
00221 }

void IntersectAction::setPrototype IntersectAction proto  )  [static]
 

Definition at line 132 of file OSGIntersectAction.cpp.

References _prototype.

00133 {
00134     _prototype = proto;
00135 }

IntersectAction * IntersectAction::getPrototype void   )  [static]
 

Reimplemented from osg::Action.

Definition at line 137 of file OSGIntersectAction.cpp.

References _prototype.

00138 {
00139     return _prototype;
00140 }

IntersectAction& osg::IntersectAction::operator= const IntersectAction source  ) 
 

void IntersectAction::setLine const Line line,
const Real32  maxdist = Inf
 

Definition at line 234 of file OSGIntersectAction.cpp.

References _line, and _maxdist.

Referenced by osg::Navigator::buttonRelease(), create(), osg::WalkNavigator::forward(), osg::Navigator::getIntersectionPoint(), osg::Transform::intersectEnter(), osg::InverseTransform::intersectEnter(), osg::Billboard::intersectEnter(), osg::Transform::intersectLeave(), osg::InverseTransform::intersectLeave(), osg::Billboard::intersectLeave(), and osg::WalkNavigator::right().

00235 {
00236     _line = line;
00237     _maxdist = maxdist;
00238 }

const Line & osg::IntersectAction::getLine void   )  const [inline]
 

Definition at line 103 of file OSGIntersectAction.inl.

References _line.

Referenced by osg::Group::intersect(), osg::Geometry::intersect(), osg::DVRVolume::intersect(), osg::Transform::intersectEnter(), osg::InverseTransform::intersectEnter(), osg::Billboard::intersectEnter(), osg::Transform::intersectLeave(), osg::InverseTransform::intersectLeave(), and osg::Billboard::intersectLeave().

00104 {
00105     return _line;
00106 }

Real32 osg::IntersectAction::getMaxDist void   )  const [inline]
 

Definition at line 108 of file OSGIntersectAction.inl.

References _maxdist.

Referenced by osg::Transform::intersectEnter(), osg::InverseTransform::intersectEnter(), osg::Billboard::intersectEnter(), osg::Transform::intersectLeave(), osg::InverseTransform::intersectLeave(), and osg::Billboard::intersectLeave().

00109 {
00110     return _maxdist;
00111 }

bool osg::IntersectAction::didHit void   )  const [inline]
 

Definition at line 113 of file OSGIntersectAction.inl.

References _hit.

Referenced by osg::Navigator::buttonRelease(), osg::WalkNavigator::forward(), getHitNormal(), getHitObject(), getHitPoint(), getHitT(), getHitTriangle(), osg::Navigator::getIntersectionPoint(), and osg::WalkNavigator::right().

00114 {
00115     return _hit;
00116 }

Real32 osg::IntersectAction::getHitT void   )  const [inline]
 

Definition at line 118 of file OSGIntersectAction.inl.

References _hitT, and didHit().

Referenced by osg::WalkNavigator::forward(), getHitPoint(), and osg::WalkNavigator::right().

00119 {
00120     if ( ! didHit() )
00121         return -1;
00122     return _hitT;
00123 }

Pnt3f osg::IntersectAction::getHitPoint void   )  const [inline]
 

Definition at line 125 of file OSGIntersectAction.inl.

References _line, didHit(), osg::Line::getDirection(), getHitT(), osg::Line::getPosition(), and osg::PointInterface< Real32, VecStorage3 >::Null.

Referenced by osg::Navigator::buttonRelease(), and osg::Navigator::getIntersectionPoint().

00126 {
00127     if ( ! didHit() )
00128         return Pnt3f::Null;
00129     
00130     Pnt3f res;
00131     res = _line.getPosition() + getHitT() * _line.getDirection();
00132     return res;
00133 }

Vec3f osg::IntersectAction::getHitNormal void   )  const [inline]
 

Definition at line 135 of file OSGIntersectAction.inl.

References _hitNormal, didHit(), and osg::VectorInterface< Real32, VecStorage3 >::Null.

00136 {
00137     if ( ! didHit() )
00138         return Vec3f::Null;
00139     
00140     return _hitNormal;
00141 }

NodePtr osg::IntersectAction::getHitObject void   )  const [inline]
 

Definition at line 143 of file OSGIntersectAction.inl.

References _hitObject, didHit(), and osg::NullFC.

00144 {
00145     if ( ! didHit() )
00146         return NullFC;
00147 
00148     return _hitObject;
00149 }

Int32 osg::IntersectAction::getHitTriangle void   )  const [inline]
 

Definition at line 151 of file OSGIntersectAction.inl.

References _hitTriangle, and didHit().

00152 {
00153     if ( ! didHit() )
00154         return -1;
00155     return _hitTriangle;
00156 }

Action::ResultE IntersectAction::setEnterLeave Real32  enter,
Real32  leave
 

Definition at line 240 of file OSGIntersectAction.cpp.

References _hit, _hitT, _maxdist, osg::Action::Continue, and osg::Action::Skip.

00241 {
00242     if ( leave < 0 || enter > _maxdist ||
00243         ( _hit && enter > _hitT ) )
00244         return Action::Skip;
00245 
00246     return Action::Continue;
00247 }

void IntersectAction::setHit Real32  t,
NodePtr  obj,
Int32  triIndex,
Vec3f normal
 

Definition at line 249 of file OSGIntersectAction.cpp.

References _hit, _hitNormal, _hitObject, _hitT, _hitTriangle, and _maxdist.

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

00251 {
00252     if ( t < 0 || t > _hitT || t > _maxdist)
00253         return;
00254         
00255     _hitT = t;
00256     _hitObject = obj;
00257     _hitTriangle = triIndex;
00258     _hitNormal = normal;
00259     _hit = true;
00260 }

void IntersectAction::scale Real32  s  ) 
 

Definition at line 262 of file OSGIntersectAction.cpp.

References _hitT, and _maxdist.

Referenced by osg::Transform::intersectEnter(), osg::InverseTransform::intersectEnter(), osg::Billboard::intersectEnter(), osg::Transform::intersectLeave(), osg::InverseTransform::intersectLeave(), and osg::Billboard::intersectLeave().

00263 {
00264     _hitT    *= s;
00265     _maxdist *= s;
00266 }

bool IntersectAction::operator< const IntersectAction other  )  const
 

Definition at line 310 of file OSGIntersectAction.cpp.

00311 {
00312     return this < &other;
00313 }

bool IntersectAction::operator== const IntersectAction other  )  const
 

Definition at line 318 of file OSGIntersectAction.cpp.

00320 {
00321     return false;
00322 }

bool IntersectAction::operator!= const IntersectAction other  )  const
 

Definition at line 327 of file OSGIntersectAction.cpp.

00328 {
00329     return ! (*this == other);
00330 }

void IntersectAction::registerEnterDefault const FieldContainerType type,
const Action::Functor func
[static]
 

Reimplemented from osg::Action.

Definition at line 95 of file OSGIntersectAction.cpp.

References osg::Action::_defaultEnterFunction(), _defaultEnterFunctors, osg::TypeBase::getId(), and osg::osgTypedFunctionFunctor2CPtrRef().

Referenced by osg::Transform::initMethod(), osg::Switch::initMethod(), osg::Surface::initMethod(), osg::Slices::initMethod(), osg::InverseTransform::initMethod(), osg::Group::initMethod(), osg::Geometry::initMethod(), osg::DVRVolume::initMethod(), osg::ComponentTransform::initMethod(), and osg::Billboard::initMethod().

00097 {
00098     if ( ! _defaultEnterFunctors )
00099         _defaultEnterFunctors = new std::vector<Action::Functor>;
00100 
00101     while(type.getId() >= _defaultEnterFunctors->size())
00102     {
00103         _defaultEnterFunctors->push_back( 
00104             osgTypedFunctionFunctor2CPtrRef<ResultE, 
00105                                             CNodePtr,
00106                                             Action *>(
00107                     &IntersectAction::_defaultEnterFunction));
00108     }
00109     
00110     (*_defaultEnterFunctors)[ type.getId() ] = func;
00111 }

void IntersectAction::registerLeaveDefault const FieldContainerType type,
const Action::Functor func
[static]
 

Reimplemented from osg::Action.

Definition at line 113 of file OSGIntersectAction.cpp.

References osg::Action::_defaultLeaveFunction(), _defaultLeaveFunctors, osg::TypeBase::getId(), and osg::osgTypedFunctionFunctor2CPtrRef().

Referenced by osg::Transform::initMethod(), osg::InverseTransform::initMethod(), osg::ComponentTransform::initMethod(), and osg::Billboard::initMethod().

00115 {
00116     if ( ! _defaultLeaveFunctors )
00117         _defaultLeaveFunctors = new std::vector<Action::Functor>;
00118 
00119     while(type.getId() >= _defaultLeaveFunctors->size())
00120     {
00121         _defaultLeaveFunctors->push_back( 
00122             osgTypedFunctionFunctor2CPtrRef<ResultE, 
00123                                             CNodePtr,
00124                                             Action *>(
00125                 &IntersectAction::_defaultLeaveFunction));
00126     }
00127     
00128     (*_defaultLeaveFunctors)[ type.getId() ] = func;
00129 }

Action::ResultE IntersectAction::start void   )  [protected, virtual]
 

Reimplemented from osg::Action.

Definition at line 271 of file OSGIntersectAction.cpp.

References _hit, _hitObject, _hitT, _hitTriangle, osg::Action::Continue, osg::Inf, and osg::NullFC.

00272 {
00273     _hitT = Inf;
00274     _hitObject = NullFC;
00275     _hitTriangle = -1;
00276     _hit = false;
00277     return Continue;
00278 }

std::vector< IntersectAction::Functor > * IntersectAction::getDefaultEnterFunctors void   )  [protected, virtual]
 

Reimplemented from osg::Action.

Definition at line 339 of file OSGIntersectAction.cpp.

References _defaultEnterFunctors.

00340 {
00341     return _defaultEnterFunctors;
00342 }

std::vector< IntersectAction::Functor > * IntersectAction::getDefaultLeaveFunctors void   )  [protected, virtual]
 

Reimplemented from osg::Action.

Definition at line 345 of file OSGIntersectAction.cpp.

References _defaultLeaveFunctors.

00346 {
00347     return _defaultLeaveFunctors;
00348 }

void Action::setPrototype Action proto  )  [static, inherited]
 

Definition at line 119 of file OSGAction.cpp.

References osg::Action::_prototype.

00120 {
00121     _prototype = proto;
00122 }

void Action::registerEnterFunction const FieldContainerType type,
const Functor func
[inherited]
 

Definition at line 201 of file OSGAction.cpp.

References osg::Action::_defaultEnterFunction(), osg::Action::_enterFunctors, osg::TypeBase::getId(), and osg::osgTypedFunctionFunctor2CPtrRef().

00203 {
00204     while ( type.getId() >= _enterFunctors.size() )
00205     {
00206         _enterFunctors.push_back(
00207             osgTypedFunctionFunctor2CPtrRef<
00208                 ResultE, 
00209                 CNodePtr,
00210                 Action *                   >(&Action::_defaultEnterFunction));
00211     }
00212     
00213     _enterFunctors[ type.getId() ] = func;
00214 }

void Action::registerLeaveFunction const FieldContainerType type,
const Functor func
[inherited]
 

Definition at line 216 of file OSGAction.cpp.

References osg::Action::_defaultLeaveFunction(), osg::Action::_leaveFunctors, osg::TypeBase::getId(), and osg::osgTypedFunctionFunctor2CPtrRef().

00218 {
00219     while ( type.getId() >= _leaveFunctors.size() )
00220     {
00221         _leaveFunctors.push_back(
00222             osgTypedFunctionFunctor2CPtrRef<
00223                 ResultE, 
00224                 CNodePtr,
00225                 Action *                   >(&Action::_defaultLeaveFunction));
00226     }
00227     
00228     _leaveFunctors[ type.getId() ] = func;
00229 }

Action::ResultE Action::apply std::vector< NodePtr >::iterator  begin,
std::vector< NodePtr >::iterator  end
[virtual, inherited]
 

Reimplemented in osg::VRMLWriteAction.

Definition at line 235 of file OSGAction.cpp.

References osg::Action::callStart(), osg::Action::callStop(), osg::Action::Continue, osg::NullFC, osg::Action::Quit, osg::Action::recurse(), and SWARNING.

Referenced by osg::VRMLWriteAction::apply(), osg::Action::apply(), osg::Navigator::buttonRelease(), osg::Viewport::draw(), osg::PassiveViewport::draw(), osg::WalkNavigator::forward(), osg::Navigator::getIntersectionPoint(), osg::Viewport::render(), osg::PassiveViewport::render(), osg::WalkNavigator::right(), and osg::VRMLWriteAction::write().

00237 {
00238     Action::ResultE res = Continue;
00239     
00240     // call the start function and its' returns
00241     if ( ( res = callStart() ) != Continue )
00242         return res;     
00243     
00244     // call the given nodes
00245     
00246     for ( ; begin != end; begin ++ )
00247     {
00248         if ( *begin == NullFC )
00249         {
00250             SWARNING << "apply: encountered NullNode!" << std::endl;
00251             return Quit;            
00252         }
00253         else
00254         {
00255             res = recurse( *begin );
00256             
00257             if ( res != Continue )
00258                 break;
00259         }
00260     }
00261         
00262     // call the stop function and its' returns
00263     res = callStop( res );  
00264     
00265     return res;
00266 }

Action::ResultE Action::apply NodePtr  node  )  [virtual, inherited]
 

Reimplemented in osg::VRMLWriteAction.

Definition at line 268 of file OSGAction.cpp.

References osg::Action::apply(), osg::NullFC, osg::Action::Quit, and SWARNING.

00269 {
00270     if(node == NullFC)
00271     {
00272         SWARNING << "apply: node is Null!" << std::endl;
00273         return Quit;            
00274     }
00275 
00276     std::vector<NodePtr> nodeList;
00277 
00278     nodeList.push_back(node);
00279 
00280     return apply(nodeList.begin(), nodeList.end());
00281 }

NodePtr osg::Action::getActNode void   )  [inline, inherited]
 

Definition at line 55 of file OSGAction.inl.

References osg::Action::_actNode.

Referenced by osg::ClipPlaneChunk::activate(), osg::Particles::calcIndex(), osg::ClipPlaneChunk::changeFrom(), osg::ProxyGroup::draw(), drawViewerObjects< posTrait, colTrait, sizeTrait, geoTrait >::draw(), drawViewerQuads< posTrait, colTrait, texTrait, sizeTrait >::draw(), drawViewDirQuads< posTrait, colTrait, texTrait, sizeTrait >::draw(), osg::DVRVolume::draw(), osg::DistanceLOD::draw(), osg::MaterialGroup::drawEnter(), osg::Light::drawEnter(), osg::InverseTransform::drawEnter(), osg::Billboard::drawEnter(), drawViewerObjects< posTrait, colTrait, sizeTrait, geoTrait >::drawIndexed(), drawViewerQuads< posTrait, colTrait, texTrait, sizeTrait >::drawIndexed(), drawViewDirQuads< posTrait, colTrait, texTrait, sizeTrait >::drawIndexed(), osg::MaterialGroup::drawLeave(), osg::Slices::drawPrimitives(), osg::Particles::drawPrimitives(), osg::RenderAction::dropFunctor(), osg::RenderAction::dropGeometry(), osg::DVRIsoShader::getCoveredScreenRect(), osg::Slicer::getSlicingDirection(), osg::Group::intersect(), osg::Geometry::intersect(), osg::DVRVolume::intersect(), osg::RenderAction::pushVisibility(), osg::MaterialGroup::renderEnter(), osg::MaterialGroup::renderLeave(), and osg::Slicer::rotateToLocal().

00056 {
00057     return _actNode;
00058 }

UInt32 osg::Action::getNNodes void   )  const [inline, inherited]
 

Definition at line 92 of file OSGAction.inl.

References osg::Action::_actList, and osg::Action::_actNode.

Referenced by osg::Switch::draw(), osg::DistanceLOD::draw(), osg::Switch::intersect(), and osg::DrawActionBase::selectVisibles().

00093 {
00094     if ( ! _actList )
00095     {
00096         return _actNode->getNChildren();
00097     }
00098     else
00099     {
00100         return (*_actList).size();
00101     }
00102 }

const NodePtr osg::Action::getNode int  index  )  [inline, inherited]
 

Definition at line 67 of file OSGAction.inl.

References osg::Action::_actList, and osg::Action::_actNode.

Referenced by osg::Switch::draw(), osg::DistanceLOD::draw(), osg::Switch::intersect(), and osg::DrawActionBase::selectVisibles().

00068 {
00069     if ( ! _actList )
00070     {
00071         return _actNode->getChild( index );
00072     }
00073     else
00074     {
00075         return