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

SoIntersectionDetectionAction Class Reference
[ActionsCollision detections between scene geometry]

#include <Inventor/collision/SoIntersectionDetectionAction.h>

Inheritance diagram for SoIntersectionDetectionAction:

SoAction List of all members.

Detailed Description

The SoIntersectionDetectionAction class is for detecting intersecting primitives in a scene.

Below is a simple usage example for this class. It was written as a stand-alone framework set up for profiling and optimization of the SoIntersectionDetectionAction. It tests intersection of all shapes against each other for the loaded file.

  #include <stdlib.h>
  #include <Inventor/SbTime.h>
  #include <Inventor/SoDB.h>
  #include <Inventor/SoInteraction.h>
  #include <Inventor/collision/SoIntersectionDetectionAction.h>
  #include <Inventor/errors/SoDebugError.h>
  #include <Inventor/nodekits/SoNodeKit.h>
  #include <Inventor/nodes/SoSeparator.h>
  
  static SoIntersectionDetectionAction::Resp
  intersectionCB(void * closure, 
                 const SoIntersectingPrimitive * pr1,
                 const SoIntersectingPrimitive * pr2)
  {
    (void)fprintf(stdout, "intersection hit!\n");
    return SoIntersectionDetectionAction::NEXT_PRIMITIVE;
  }
  
  int
  main(int argc, char ** argv)
  {
    SoDB::init();
    SoNodeKit::init();
    SoInteraction::init();
  
    if (argc != 2) {
      (void)fprintf(stderr, "\n\tUsage: testapp <filename.iv>\n\n");
      exit(1);
    }
  
    SoInput in;
    SbBool ok = in.openFile(argv[1]);
    assert(ok);
    SoSeparator * root = SoDB::readAll(&in);
    assert(root);
  
    root->ref();
  
    SoIntersectionDetectionAction ida;
    ida.addIntersectionCallback(intersectionCB, NULL);
    ida.setManipsEnabled(FALSE);
    ida.setDraggersEnabled(FALSE);
    ida.setIntersectionDetectionEpsilon(10.0f);
  
    SbTime starttime = SbTime::getTimeOfDay();
    SoDebugError::postInfo("main", "SoIntersectionDetectionAction::apply");
  
    ida.apply(root);
  
    SoDebugError::postInfo("main", "apply() done after %f seconds.",
                           (SbTime::getTimeOfDay() - starttime).getValue());
  
    root->unref();
  
    return 0;
  }

Since:
Coin 2.1

TGS Inventor 2.4


Public Types

typedef SoCallbackAction::Response SoIntersectionVisitationCB (void *closure, const SoPath *where)
typedef SbBool SoIntersectionFilterCB (void *closure, const SoPath *p1, const SoPath *p2)
typedef Resp SoIntersectionCB (void *closure, const SoIntersectingPrimitive *p1, const SoIntersectingPrimitive *p2)
enum  Resp { NEXT_PRIMITIVE, NEXT_SHAPE, ABORT }

Public Member Functions

void setIntersectionDetectionEpsilon (float epsilon)
float getIntersectionDetectionEpsilon (void) const
void setTypeEnabled (SoType type, SbBool enable)
SbBool isTypeEnabled (SoType type, SbBool checkgroups=FALSE) const
void setManipsEnabled (SbBool enable)
SbBool isManipsEnabled (void) const
void setDraggersEnabled (SbBool enable)
SbBool isDraggersEnabled (void) const
void setShapeInternalsEnabled (SbBool enable)
SbBool isShapeInternalsEnabled (void) const
void addVisitationCallback (SoType type, SoIntersectionVisitationCB *cb, void *closure)
void removeVisitationCallback (SoType type, SoIntersectionVisitationCB *cb, void *closure)
virtual void apply (SoNode *node)
virtual void apply (SoPath *path)
virtual void apply (const SoPathList &paths, SbBool obeysRules=FALSE)
virtual void setFilterCallback (SoIntersectionFilterCB *cb, void *closure=NULL)
virtual void addIntersectionCallback (SoIntersectionCB *cb, void *closure=NULL)
virtual void removeIntersectionCallback (SoIntersectionCB *cb, void *closure=NULL)

Static Public Member Functions

void initClass (void)
void setIntersectionEpsilon (float epsilon)
float getIntersectionEpsilon (void)


Member Function Documentation

void SoIntersectionDetectionAction::initClass void   )  [static]
 

Initializes the run-time type system for this class, and sets up the enabled elements and action method list.

Reimplemented from SoAction.

void SoIntersectionDetectionAction::setIntersectionDetectionEpsilon float  epsilon  ) 
 

Sets the intersection detection distance epsilon value for the action object. This overrides the global value.

See also SoIntersectionDetectionAction::setIntersectionEpsilon() for important information about how this setting influences performance.

float SoIntersectionDetectionAction::getIntersectionDetectionEpsilon void   )  const
 

Returns the set intersection detection distance epsilon value for the action object.

void SoIntersectionDetectionAction::setIntersectionEpsilon float  epsilon  )  [static]
 

Sets the global intersection detection distance epsilon value. This will affect all intersection detection action objects in use that don't have a locally set value.

The epsilon value is a worldspace value.

Be aware that increasing the epsilon value can dramatically increase the number of primitive intersection tests being done to decide intersections. Increasing the epsilon value can therefore cause serious slow-downs in the running time of the intersections checks.

Epsilon is not supported yet.

float SoIntersectionDetectionAction::getIntersectionEpsilon void   )  [static]
 

Returns the globally set intersection detection distance epsilon value.

void SoIntersectionDetectionAction::setTypeEnabled SoType  type,
SbBool  enable
 

Sets whether nodes of specific types (including derived objects) should be tested for intersection or not.

See also:
isTypeEnabled(), setManipsEnabled(), setDraggersEnabled()

SbBool SoIntersectionDetectionAction::isTypeEnabled SoType  type,
SbBool  checkgroups = FALSE
const
 

Returns whether nodes of specific types are enabled or not. The checkgroups argument can be set to TRUE if you wan't the return value to reflect whether the node will be implicit enabled/disabled through the settings controlled by the setManipsEnabled() and setDraggersEnabled() functions.

The default is that all node types are enabled.

Note that derivation checks are not performed - the type needs to be the exact same type as has been disabled with setTypeEnabled()

See also:
setTypeEnabled()

void SoIntersectionDetectionAction::setManipsEnabled SbBool  enable  ) 
 

Sets whether manipulators in the scene graph should be tested for intersection with other geometry or not.

Note that when draggers are disabled with setDraggersEnabled(), this setting has no effect - manipulators are disabled too.

See also:
isManipsEnabled(), setDraggersEnabled(), setTypeEnabled()

SbBool SoIntersectionDetectionAction::isManipsEnabled void   )  const
 

Returns whether the actions is set up to test intersection on manipulators in the scene or not.

Note that when draggers are disabled with setDraggersEnabled(), this setting has no effect - manipulators are disabled too.

The default is that manipulators are enabled for intersection testing with other geometry in the scene.

See also:
setManipsEnabled()

void SoIntersectionDetectionAction::setDraggersEnabled SbBool  enable  ) 
 

Sets whether draggers in the scene graph should be tested for intersection with other geometry or not.

Note that when you disable draggers, manipulators are also automatically disabled, although the isManipsDisabled() setting might reflect otherwise.

See also:
isDraggersEnabled(), setManipsEnabled(), setTypeEnabled()

SbBool SoIntersectionDetectionAction::isDraggersEnabled void   )  const
 

Returns whether the actions is set up to test intersection on draggers in the scene or not.

The default is that draggers are enabled for intersection testing with other geometry in the scene.

See also:
setDraggersEnabled()

void SoIntersectionDetectionAction::setShapeInternalsEnabled SbBool  enable  ) 
 

Sets whether nodes in the scene graph should be checked for intersecting primitives within themselves.

Default is FALSE.

See also:
isShapeInternalsEnabled()

SbBool SoIntersectionDetectionAction::isShapeInternalsEnabled void   )  const
 

Returns whether nodes in the scene graph will be checked for intersecting primitives within themselves.

The default value for this setting is FALSE.

See also:
setShapeInternalsEnabled()

void SoIntersectionDetectionAction::addVisitationCallback SoType  type,
SoIntersectionVisitationCB *  cb,
void *  closure
 

The scene graph traversal can be controlled with callbacks which you set with this method. Use just like you would use SoCallbackAction::addPreCallback().

See also:
SoCallbackAction::addPreCallback()

void SoIntersectionDetectionAction::removeVisitationCallback SoType  type,
SoIntersectionVisitationCB *  cb,
void *  closure
 

The scene graph traversal can be controlled with callbacks which you remove with this method. Use just like you would use SoCallbackAction::removePreCallback().

See also:
SoCallbackAction::removePreCallback()

void SoIntersectionDetectionAction::apply SoNode node  )  [virtual]
 

Applies the action to the scene graph rooted at root.

Note that you should not apply an action to a node with a zero reference count. The behavior in that case is undefined.

Reimplemented from SoAction.

void SoIntersectionDetectionAction::apply SoPath path  )  [virtual]
 

Applies the action to the parts of the graph defined by path.

If the path ends in an SoGroup node, the action will also traverse the tail node's children.

Reimplemented from SoAction.

void SoIntersectionDetectionAction::apply const SoPathList paths,
SbBool  obeysRules = FALSE
[virtual]
 

Applies action to the graphs defined by pathlist. If obeysrules is set to TRUE, pathlist must obey the following four conditions (which is the case for path lists returned from search actions for non-group nodes and path lists returned from picking actions):

All paths must start at the same head node. All paths must be sorted in traversal order. The paths must be unique. No path can continue through the end point of another path.

Reimplemented from SoAction.

void SoIntersectionDetectionAction::setFilterCallback SoIntersectionFilterCB *  cb,
void *  closure = NULL
[virtual]
 

This callback is called when two shapes are found to have intersecting bounding boxes, and are about to be checked for real intersection between their primitives.

When intersection epsilon values are in use, bounding box intersection testing is done approximately and will trigger the filter callback on boxes that are further from each other than the epsilon length.

If the callback returns TRUE, the intersection test will be performed. If the callback returns FALSE, the intersection testing will be skipped.

The API allows only one filter callback.

void SoIntersectionDetectionAction::addIntersectionCallback SoIntersectionCB *  cb,
void *  closure = NULL
[virtual]
 

Adds a callback to be called when two intersecting primitives are found in the scene.

If the callback returns ABORT, the intersection detection is aborted. If the callback returns NEXT_SHAPE, the intersection detection between these two shapes are aborted and the action continues checking other shapes. If the callback returns NEXT_PRIMITIVE, the intersection detection testing continues checking the other primitives in these two shapes.

See also:
removeIntersectionCallback()

void SoIntersectionDetectionAction::removeIntersectionCallback SoIntersectionCB *  cb,
void *  closure = NULL
[virtual]
 

Removes a callback set with addIntersectionCallback().

See also:
addIntersectionCallback()


The documentation for this class was generated from the following files:
Generated on Sun Dec 14 15:50:34 2003 for Coin by doxygen 1.3.3