Physsim::CollisionDetection Class Reference

Defines an abstract collision detection mechanism. More...

#include <CollisionDetection.h>

Inheritance diagram for Physsim::CollisionDetection:

Physsim::Base Physsim::PQPCollisionDetection Physsim::ADFCollisionDetection List of all members.

Public Member Functions

virtual void clone (BasePtr &cloned, bimap< BasePtr, BasePtr > *obj_map=NULL) const
 Clones this object.
virtual bool is_struct_identical (BaseConstPtr object) const
 Verifies that structure is identical.
virtual void load_state (BaseConstPtr object, bimap< BasePtr, BasePtr > *correspondence=NULL)
 Loads the state of this object.
virtual void save_state (BasePtr object, bimap< BasePtr, BasePtr > *correspondence=NULL) const
 Saves the state of this object.
void add_dynamic_body (DynamicBodyPtr body)
 Adds the given dynamic body to the collision detector.
void operator= (const CollisionDetection *source)
virtual void load_from_xml (XMLTreeConstPtr node, std::map< std::string, BasePtr > &id_map)
 Implements Base::load_from_xml().
virtual void save_to_xml (XMLTreePtr node, std::list< BaseConstPtr > &shared_objects) const
 Implements Base::save_to_xml().
virtual void remove_collision_geometry (CollisionGeometryPtr geom)
 Removes a collision geometry from the collision detector, if present.
virtual void remove_all_collision_geometries ()
 Removes all geometries from the collision detector.
virtual void add_rigid_body (RigidBodyPtr body)
 Adds a rigid body to the collision detector.
virtual void add_articulated_body (ArticulatedBodyPtr abody, bool disable_adjacent)
virtual void output_object_state (std::ostream &out) const
 Outputs this class data to the stream.
void set_enabled (BasePtr b1, BasePtr b2, bool enabled)
 Sets a pair of objects to enabled/disabled in the collision detector.
void set_enabled (BasePtr b, bool enabled)
 Sets an object to enabled/disabled in the collision detector.
bool is_checked (CollisionGeometryPtr cg1, CollisionGeometryPtr cg2) const
 Determines whether a pair of geometries is checked for collision detection.
virtual void add_collision_geometry (CollisionGeometryPtr geom)
 Adds the specified geometry to the set of geometries checked for collision.
const std::set< CollisionGeometryPtr > & get_collision_geometries () const
 Gets the set of geometries checked by this collision detector.
bool is_enabled (CollisionGeometryPtr g1, CollisionGeometryPtr g2) const
 Determines whether collision checking for the specified pair is enabled.
bool is_enabled (CollisionGeometryPtr g) const
 Determines whether collision checking for the specified geometry is enabled.
virtual bool is_collision (Real epsilon=0.0)=0
 Determines whether there is a collision at the current simulation state with the given tolerance.
virtual Real calc_distances ()=0
 Calculates the distance between each pair of geometries and returns the minimum distance.
const std::map< sorted_pair<
CollisionGeometryPtr >, QueryPtr > & 
get_colliding_pairs () const
 Gets the pairs of collision geometries in collision after a call to is_collision().
const std::map< sorted_pair<
CollisionGeometryPtr >, QueryPtr > & 
get_distances () const
 Gets the pairs of collision geometries and respective distances after a call to calc_distance().
const std::set< sorted_pair<
CollisionGeometryPtr > > & 
get_disabled_pairs () const
 Gets the set of disabled pairs.
const std::set< CollisionGeometryPtr > & get_disabled () const
 Gets the set of disabled singletons.
void add_articulated_body (ArticulatedBodyPtr abody)
 Adds an articulated body to the bodies checked for collision.
virtual std::list< ContactPtr > find_contacts (CollisionGeometryPtr g1, CollisionGeometryPtr g2)=0
 Gets the contact(s) between two CollisionGeometry objects.

Public Attributes

bool _disable_adjacent_default
 The default setting for disabling adjacent links in added articulated bodies.

Protected Member Functions

virtual void save_query_results (BasePtr object, bimap< BasePtr, BasePtr > *correspondence) const
 Saves any query results.
virtual void clone_query_results (BasePtr &cloned, bimap< BasePtr, BasePtr > *object_map) const
 Clones any query results.
virtual void load_query_results (BaseConstPtr object, bimap< BasePtr, BasePtr > *correspondence)
 Loads any query results.
bool collinear (const std::list< Vector3 > &points) const
 Determines whether a list of points is collinear.

Protected Attributes

std::set< sorted_pair< CollisionGeometryPtr > > _disabled_pairs
 The set of disabled pairs of CollisionGeometry objects.
std::set< CollisionGeometryPtr > _disabled
 The set of disabled CollisionGeometry objects.
std::map< sorted_pair< CollisionGeometryPtr >,
QueryPtr > 
_colliding_pairs
 The map of geometries to collision results (from last call to is_collision()).
std::map< sorted_pair< CollisionGeometryPtr >,
QueryPtr > 
_distances
 The map of geometries to distances.
std::set< CollisionGeometryPtr > _geoms
 The set of geometries checked by the collision detector.

Detailed Description

Defines an abstract collision detection mechanism.


Member Function Documentation

void CollisionDetection::load_state ( BaseConstPtr  object,
bimap< BasePtr, BasePtr > *  correspondence = NULL 
) [virtual]

Loads the state of this object.

The underlying penalty resting contact method must have identical structure.

Reimplemented from Physsim::Base.

Reimplemented in Physsim::ADFCollisionDetection, and Physsim::PQPCollisionDetection.

void CollisionDetection::save_state ( BasePtr  object,
bimap< BasePtr, BasePtr > *  correspondence = NULL 
) const [virtual]

Saves the state of this object.

The underlying penalty resting contact method must have identical structure.

Reimplemented from Physsim::Base.

Reimplemented in Physsim::ADFCollisionDetection, and Physsim::PQPCollisionDetection.

void CollisionDetection::add_dynamic_body ( DynamicBodyPtr  db  ) 

Adds the given dynamic body to the collision detector.

Note:
if the body is articulated, then adjacent links are not disabled!

void CollisionDetection::save_to_xml ( XMLTreePtr  node,
std::list< BaseConstPtr > &  shared_objects 
) const [virtual]

Implements Base::save_to_xml().

Note:
neither the contact cache nor the pairs currently in collision are saved

Reimplemented from Physsim::Base.

Reimplemented in Physsim::ADFCollisionDetection, and Physsim::PQPCollisionDetection.

void CollisionDetection::remove_collision_geometry ( CollisionGeometryPtr  geom  )  [virtual]

Removes a collision geometry from the collision detector, if present.

remove the geometry

Reimplemented in Physsim::ADFCollisionDetection, and Physsim::PQPCollisionDetection.

void CollisionDetection::add_articulated_body ( ArticulatedBodyPtr  abody,
bool  disable_adjacent 
) [virtual]

Parameters:
abody the pointer to the specified body
disabled_adjacent if set to true collision checking for all adjacent links will be disabled

void CollisionDetection::output_object_state ( std::ostream &  out  )  const [virtual]

Outputs this class data to the stream.

This method outputs all of the low-level details to the stream; if serialization is desired, use save_to_xml() instead.

See also:
save_to_xml()

Reimplemented from Physsim::Base.

void CollisionDetection::set_enabled ( BasePtr  b1,
BasePtr  b2,
bool  enabled 
)

Sets a pair of objects to enabled/disabled in the collision detector.

If an object is a rigid body, all of its CollisionGeometry objects pairs are set to enabled/disabled. If an object is an articulated body, all of its RigidBody (and by extension, CollisionGeometry) object pairs are set to enabled/disabled.

void CollisionDetection::set_enabled ( BasePtr  b,
bool  enabled 
)

Sets an object to enabled/disabled in the collision detector.

If the object is a rigid body, all of its CollisionGeometry objects are set to enabled/disabled. If an object is an articulated body, all of its RigidBody (and by extension, CollisionGeometry) objects are set to enabled/disabled.

virtual void Physsim::CollisionDetection::add_collision_geometry ( CollisionGeometryPtr  geom  )  [inline, virtual]

Adds the specified geometry to the set of geometries checked for collision.

Note:
derived classes will generally need to provide an implementation of this method (and must call this method [CollisionGeometry::add_collision_geometry()] explicitly as well!)

Reimplemented in Physsim::ADFCollisionDetection, and Physsim::PQPCollisionDetection.

virtual bool Physsim::CollisionDetection::is_collision ( Real  epsilon = 0.0  )  [pure virtual]

Determines whether there is a collision at the current simulation state with the given tolerance.

Parameters:
epsilon the tolerance to check for collision; two bodies are considered to be in collision if the distance between the bodies is less than epsilon
Note:
implementing classes must store the colliding pairs in _colliding_pairs

Implemented in Physsim::PQPCollisionDetection.


The documentation for this class was generated from the following files:
Generated on Wed Oct 24 14:54:22 2007 for Physsim by  doxygen 1.5.1