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);
312 void setRealDummyMethod(
agx::
Real ) { }
317 template <typename T>
326 inline operator T () {
329 inline operator const T ()
const {
332 inline operator int ()
const {
348 typedef std::map<agx::Uuid, EventPrioHolder<SensorEventRef> >
SensorEvents;
378 agx::Physics::ParticleGeometryContactInstance contactIn,
379 agx::Physics::ParticleData& particleDataIn,
380 agx::Physics::GeometryData& geometryDataIn)
381 :t(tIn),contact(contactIn), particleData(particleDataIn), geometryData(geometryDataIn)
385 agx::Physics::ParticleGeometryContactInstance
contact;
427 agx::Physics::ParticleGeometryContactInstance contact,
428 agx::Physics::ParticleData& particleData,
429 agx::Physics::GeometryData& geometryData);
435 agx::Physics::ParticleGeometryContactInstance contact,
436 agx::Physics::ParticleData& particleData,
437 agx::Physics::GeometryData& geometryData);
441 agx::Physics::ParticleGeometryContactInstance contact,
442 agx::Physics::ParticleData& particleData,
443 agx::Physics::GeometryData& geometryData);
446 agx::Physics::ParticleGeometryContactInstance contact,
447 agx::Physics::ParticleData& particleData,
448 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
agxSDK::CollisionGroupFilter * getFilter()
const agxSDK::CollisionGroupFilter * getFilter() const
virtual ~ParticleContactListener()
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.
SensorEvent * getSensorEventFromName(const agx::Name &name)
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.
int m_triggerFlag
Flag for when the events are supposed to be executed during the time-step.
agx::List< EventPrioHolder< SensorEventRef > > SensorEventList
void tryTriggerEventsOnContact(const agx::TimeStamp &t, agxCollide::GeometryContact *cd)
SensorEvent * getSensorEvent(const agx::Uuid &uuid)
Returns a sensor event with the given uuid if there exists one in the sensor.
bool hasGroup(agx::UInt32 group)
void refreshParticlesInsideSensorData()
void triggerEventsOnContact(const agx::TimeStamp &t, agxCollide::GeometryContact *cd)
agxCollide::Geometry * getGeometry()
Get the geometry of the sensor.
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()
agx::HashSet< agx::UInt32 > m_particlesInSensor
Holds a set of the current particle id:s that are present in the sensor.
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...
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
ParticleContactQueue m_particleContactQueue
ParticleContactListenerRef m_particleContactListener
agx::Real getNumParticleParticleContactsInSensor()
agx::RigidBody * getContactingRigidBody(agxCollide::GeometryContact *cd) const
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.
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()
EventSensor()
Default constructor.
void triggerParticleEvents()
bool m_particleCollision
Flags for doing when there is a collision for a particle or geometry.
const ParticlePairContactVector & getParticlePairContactsInSensor()
Returns the current particle-particle contacts in the sensor geometry.
void setGeometry(agxCollide::Geometry *geometry)
Sets the geometry of the sensor.
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...
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
virtual void addNotification() override
This will execute when the sensor is inserted in the simulation.
agxCollide::Geometry * getGeometry() const
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)
bool hasGroup(const agx::Name &group)
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
ParticlePairContactVector m_particlePairContacts
int m_priority
Priority of the sensor over all the other sensors.
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.
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...
agx::SymmetricPair< agx::Physics::GeometryPtr > GeometryPair
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)