17#ifndef AGXCONTROL_EVENTSENSOR_H
18#define AGXCONTROL_EVENTSENSOR_H
19#include <agx/config.h>
111 agx::Physics::ParticleData& particleData,
112 agx::Physics::GeometryData& geometryData);
356 void registerRemovedParticle(
agx::Physics::ParticlePtr particle );
358 void registerRemovedBody(
agx::RigidBody* body );
361 void setRealDummyMethod(
agx::Real ) { }
366 template <typename T>
375 inline operator T () {
378 inline operator const T ()
const {
381 inline operator int ()
const {
397 typedef std::map<agx::Uuid, EventPrioHolder<SensorEventRef> >
SensorEvents;
427 agx::Physics::ParticleGeometryContactInstance contactIn,
428 agx::Physics::ParticleData& particleDataIn,
429 agx::Physics::GeometryData& geometryDataIn)
430 :t(tIn),contact(contactIn), particleData(particleDataIn), geometryData(geometryDataIn)
434 agx::Physics::ParticleGeometryContactInstance
contact;
476 agx::Physics::ParticleGeometryContactInstance contact,
477 agx::Physics::ParticleData& particleData,
478 agx::Physics::GeometryData& geometryData);
484 agx::Physics::ParticleGeometryContactInstance contact,
485 agx::Physics::ParticleData& particleData,
486 agx::Physics::GeometryData& geometryData);
490 agx::Physics::ParticleGeometryContactInstance contact,
491 agx::Physics::ParticleData& particleData,
492 agx::Physics::GeometryData& geometryData);
495 agx::Physics::ParticleGeometryContactInstance contact,
496 agx::Physics::ParticleData& particleData,
497 agx::Physics::GeometryData& geometryData);
#define AGX_DECLARE_POINTER_TYPES(type)
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
The geometry representation used by the collision detection engine.
EventPrioHolder(T obj, int priority)
const T sensorEvent() const
ParticleContactListener(EventSensor *sensor)
void setFilter(agxSDK::CollisionGroupFilter *filter)
virtual void contactCallback(agx::Physics::ParticleGeometryContactInstance contact, agx::Physics::ParticleData &particleData, agx::Physics::GeometryData &geometryData)
agxSDK::CollisionGroupFilter * m_filter
virtual ~ParticleContactListener()
const agxSDK::CollisionGroupFilter * getFilter() const
agxSDK::CollisionGroupFilter * getFilter()
This is a sensor class that can be attached to an geometry in the simulation.
SensorEventVector getSensorEvents()
Returns the SensorEvents currently active in the Sensor in the order of execution priority.
agx::Vector< ParticleContactInformation > ParticleContactQueue
bool contactIsValid(agxCollide::GeometryContact *cd)
void setTriggerFlag(int flag)
Set/get the trigger flag to control when the events will be executed during the time-step of contact ...
agxCollide::Geometry * m_geometry
The coupled geometry of the sensor.
bool addSensorEvent(SensorEvent *sEvent, int priority=0)
Sets a sensor event to the sensor with a priority.
virtual void pre(const agx::TimeStamp &time) override
Called before a step is taken in the simulation Implement this method in the derived class to get cal...
void removeGroup(agx::UInt32 group)
agx::HashSet< agx::UInt32 > m_particlesInsideSensor
Holds a set of the current particle id:s whose midpoint is inside the sensor.
bool wasParticleRemovedBySensor(agx::UInt32 particle)
Check if the particle has been marked as removed by any of the sensor's operations.
agx::UInt32Vector getRemovedParticles()
Get the particles removed by this sensor during the last timestep.
void tryTriggerParticleEventsOnContact(const agx::TimeStamp &t, agx::Physics::ParticleGeometryContactInstance contact, agx::Physics::ParticleData &particleData, agx::Physics::GeometryData &geometryData)
void clearContactInformation()
GeometryContactQueue m_geomContactQueue
Queues for the contacts.
SensorEvent * getSensorEventFromName(const agx::Name &name)
int m_triggerFlag
Flag for when the events are supposed to be executed during the time-step.
agx::List< EventPrioHolder< SensorEventRef > > SensorEventList
agx::HashSet< agx::UInt32 > m_removedBodies
Holds a set of the current particles and bodies that have been marked as removed by an Operation duri...
void tryTriggerEventsOnContact(const agx::TimeStamp &t, agxCollide::GeometryContact *cd)
bool hasGroup(agx::UInt32 group)
void refreshParticlesInsideSensorData()
void triggerEventsOnContact(const agx::TimeStamp &t, agxCollide::GeometryContact *cd)
void removeGroup(const agx::Name &group)
bool hasOnlyReference()
Checks if the sensor keeps the only reference to its internal contact listener. Used in unittest.
void triggerContactEvents()
agx::UInt32Vector getContactingParticleIds()
agxCollide::Geometry * getGeometry()
Get the geometry of the sensor.
agx::HashSet< agx::UInt32 > m_particlesInSensor
Holds a set of the current particle id:s that are present in the sensor.
agx::UInt m_numRemovedParticles
virtual void removeNotification() override
This function will execute when the sensor is removed form the simulation.
agx::HashSet< agx::RigidBody * > m_rigidBodiesContactingSensor
Holds pointers to the current rigid bodies (DEM Objects) in the sensor.
void setCollisionMask(int mask)
Set/get the collision mask for the sensor.
virtual void preCollide(const agx::TimeStamp &time) override
Called before collision detection is performed in the simulation Implement this method in the derived...
agx::UInt getNumRemovedBodies() const
std::map< agx::Uuid, EventPrioHolder< SensorEventRef > > SensorEvents
bool particleContactIsValid(const agx::TimeStamp &t, agx::Physics::ParticleGeometryContactInstance contact, agx::Physics::ParticleData &particleData, agx::Physics::GeometryData &geometryData)
void executeSensorEvents(const agx::TimeStamp &t)
static agxCollide::GeometryPtrVector g_forbiddenGeometries
GeometryContactEventListenerRef m_contactListener
Listeners that are coupled with the sensor.
agx::RigidBodyPtrVector getRigidBodiesInsideSensor(bool onlyRigidBodyDEM=false)
virtual void post(const agx::TimeStamp &time) override
Called after a step is taken in the simulation Implement this method in the derived class to get call...
agx::Vector< agx::Physics::ParticlePairContactPtr > ParticlePairContactVector
agx::Real m_removedBodyMass
ParticleContactQueue m_particleContactQueue
ParticleContactListenerRef m_particleContactListener
agx::Real getNumParticleParticleContactsInSensor()
SensorEvent * getSensorEvent(const agx::Uuid &uuid)
Returns a sensor event with the given uuid if there exists one in the sensor.
void refreshRigidBodiesInsideSensorData()
EventSensor(agxCollide::Geometry *geometry, int priority)
Constructor that takes the geometry to couple the sensor too.
EventSensor(agxCollide::Geometry *geometry)
Constructor that takes the geometry to couple the sensor too.
agx::Real getRemovedBodyMass() const
void triggerPostContactHandling()
void triggerEventAddNotification()
SensorEventList m_sensorEventList
bool m_isBlocker
True if the sensor should block the contact from other sensors in the scene under the same timestep.
bool containsSensorEvent(SensorEvent *sEvent)
Checks if a sensor event already exists in the sensor.
void triggerParticleEventsOnContact(const agx::TimeStamp &t, agx::Physics::ParticleGeometryContactInstance contact, agx::Physics::ParticleData &particleData, agx::Physics::GeometryData &geometryData)
agx::UInt32Vector getParticlesInsideSensor()
bool wasRigidBodyRemovedBySensor(agx::UInt32 rigidBody)
Check if the particle has been marked as removed by any of the sensor's operations.
EventSensor()
Default constructor.
void triggerParticleEvents()
bool m_particleCollision
Flags for doing when there is a collision for a particle or geometry.
agx::HashSet< agx::UInt32 > m_removedParticles
void setGeometry(agxCollide::Geometry *geometry)
Sets the geometry of the sensor.
agx::UInt getNumRemovedParticles() const
void setEnableBlocker(bool isBlocker)
Set the sensor to block the contact from other sensors.
TriggerEventStages
Defines the event execution states when the SensorEvents are executed during the timestep of the dete...
@ SENSOR_PRE_STEP
Triggered in a PRE solve/integration step.
EventSensor(int priority)
This constructor takes the priority of the internal contact sensors.
bool hasComputedParticlePairContactsInSensor
Vector that stores particle pair contacts. Will only be computed if the user asks for it (getParticle...
agxCollide::Geometry * getGeometry() const
agx::Real getNumParticlesInSensor() const
bool removeSensorEvent(SensorEvent *sEvent)
Removes a sensor event in the sensor.
int m_collisionMask
Get the collision mask for the sensor.
agx::Vector< ContactInformation > GeometryContactQueue
agx::Vector< agxControl::SensorEvent * > SensorEventVector
agx::Real getRemovedParticleMass() const
virtual void addNotification() override
This will execute when the sensor is inserted in the simulation.
void constructSortedEventList()
bool isForbiddenGeometry(agxCollide::Geometry *geom)
Check if the geometry is marked as forbidden by a sensor in this time step.
agx::HashSet< agx::RigidBody * > m_rigidBodiesInsideSensor
Holds pointers to the current rigid bodies (DEM Objects) where the midpoint is INSIDE the sensor.
void updateSensorEvents(const agx::TimeStamp &t)
void addGroup(agx::UInt32 group)
agxSDK::CollisionGroupFilterRef m_filter
The collision group filter coupled with the ContactEventListener.
void signalGeometryContact(const agx::TimeStamp &t, agxCollide::GeometryContact *cd)
agx::UInt m_numRemovedBodies
bool hasGroup(const agx::Name &group)
agx::Real m_removedParticleMass
void addGroup(const agx::Name &group)
Functions for adding and removing collision groups.
SensorEvents m_sensorEvents
bool isForbiddenParticle(agx::UInt32 particle)
Check if the particle is marked as forbidden by a sensor in this time step.
void signalParticleContact(const agx::TimeStamp &t, agx::Physics::ParticleGeometryContactInstance contact, agx::Physics::ParticleData &particleData, agx::Physics::GeometryData &geometryData)
static agx::UInt32Vector g_forbiddenParticles
agx::Real getTotalRemovedMass() const
ParticlePairContactVector m_particlePairContacts
int m_priority
Priority of the sensor over all the other sensors.
agx::RigidBody * getContactingRigidBody(agxCollide::GeometryContact *cd) const
const ParticlePairContactVector & getParticlePairContactsInSensor()
Returns the current particle-particle contacts in the sensor geometry.
virtual ~EventSensor()
Destructor.
A sensor event is an event triggered when the sensor is activated by a contact.
An ExecuteFilter that is used to filter out contacts matching a specified criteria based on Collision...
Derive from this class to implement a listener for simulation step events.
Inheritance with partial specialization due to bug with ref_ptr containers.
Representation of a name string.
This class is for detecting and handling particle collisions with geometries in the simulation.
The rigid body class, combining a geometric model and a frame of reference.
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Vector containing 'raw' data.
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
This namespace contains general operation and action classes which can be used to control a agxSDK::S...
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Placeholder for information regarding the particle contacts.
agx::Physics::ParticleGeometryContactInstance contact
agx::Physics::ParticleData & particleData
agx::Physics::GeometryData & geometryData
ParticleContactInformation(const agx::TimeStamp tIn, agx::Physics::ParticleGeometryContactInstance contactIn, agx::Physics::ParticleData &particleDataIn, agx::Physics::GeometryData &geometryDataIn)