File mechanics/src/collision/native/SpaceFilter.hpp

Go to the source code of this file

Spatial filtering of interactions for 2D/3D objects.



Basic broad phase contact detection between 2D/3D mechanical systems.

algorithm description: Optimized Spatial Hashing for Collision Detection of Deformable Objects M. Teschner, B. Heidelberger, M. Mueller, D. Pomeranets, M. Gross Proceedings of VMV’03 Munich, Germany pp. 47-54 November 19-21, 2003

class SpaceFilter : public InteractionManager, public std::enable_shared_from_this<SpaceFilter>

Subclassed by OccSpaceFilter

Public Functions

SpaceFilter(unsigned int bboxfactor, unsigned int cellsize, SP::SiconosMatrix plans, SP::FMatrix moving_plans)
SpaceFilter(unsigned int bboxfactor, unsigned int cellsize, SP::SiconosMatrix plans)
void insert(SP::Disk, int, int, int)

2D/3D objects insertion

void insert(SP::Circle, int, int, int)
void insert(SP::SphereLDS, int, int, int)
void insert(SP::SphereNEDS, int, int, int)
void insert(SP::Hashed)

general hashed object

inline unsigned int bboxfactor()

get parameters

inline unsigned int cellsize()
inline void setBBoxfactor(unsigned int value)
inline void setCellsize(unsigned int value)
bool haveNeighbours(SP::Hashed h)

get the neighbours

Just test the presence of neighbours.


h – hashed component of a body.

double minDistance(SP::Hashed h)

Give the minimal distance.


h – hashed component of a body.

void updateInteractions(SP::Simulation simulation) override

Broadphase contact detection: add interactions in indexSet 0.


simulation – the current simulation setup

void insertLine(double a, double b, double c)
inline virtual ~SpaceFilter()



Protected Functions

void _PlanCircularFilter(SP::Simulation, double A, double B, double C, double xCenter, double yCenter, double width, SP::CircularDS ds)
void _MovingPlanCircularFilter(SP::Simulation, unsigned int i, SP::CircularDS ds, double time)
void _PlanSphereLDSFilter(SP::Simulation, double A, double B, double C, double D, SP::SphereLDS ds)
void _PlanSphereNEDSFilter(SP::Simulation, double A, double B, double C, double D, SP::SphereNEDS ds)

Protected Attributes

unsigned int _bboxfactor

the bounding box factor is multiplicated by the largest object dimension

unsigned int _cellsize

the cell size

SP::SiconosMatrix _plans


SP::FMatrix _moving_plans

moving plans

SP::space_hash _hash_table
SP::DiskDiskRDeclaredPool diskdisk_relations
SP::DiskPlanRDeclaredPool diskplan_relations
SP::CircleCircleRDeclaredPool circlecircle_relations


friend struct SpaceFilter::_CircularFilter
friend struct SpaceFilter::_SphereLDSFilter
friend struct SpaceFilter::_SphereNEDSFilter
friend struct SpaceFilter::_BodyHash
friend struct SpaceFilter::_FindInteractions
friend struct SpaceFilter::_IsSameDiskPlanR
friend struct SpaceFilter::_IsSameDiskMovingPlanR
friend struct SpaceFilter::_IsSameSpherePlanR
friend struct SpaceFilter::_DiskDistance