AGX Dynamics  2.37.3.2
RecordParticlesOperations.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXCONTROL_RECORDPARTICLESOPERATIONS_H
18 #define AGXCONTROL_RECORDPARTICLESOPERATIONS_H
19 
20 #include <agx/String.h>
21 #include <agxControl/EventSensor.h>
22 #include <agx/Journal.h>
23 
24 #ifndef SWIG
25 namespace agx
26 {
27  class Uuid;
28 }
29 #endif
30 
31 /*
32 This file contains SensorOperation classes that gives the sensor functionality to record colliding particles to separate journals.
33 The operations can be used for recording continuous flow of particles in a sensor or store single frame snapshots/states. The
34 created journals can later be loaded into the simulation by other operations.
35 This creates an easy way to create and load different types of precomputed particle states into other simulations.
36 */
37 namespace agxControl
38 {
39 
46  {
47  public:
48  BaseRecordParticleJournalOperation(const agx::Name& name, const agx::String& journalPath, agx::Frame * sourceOffset = nullptr);
49 
50  virtual void update(const agx::TimeStamp&) override;
51 
52  virtual void addNotification(EventSensor * sensor) override;
53 
54  virtual void triggerEvent(const agx::TimeStamp&,
57  agxControl::EventSensor*) override {}
58 
59  virtual void triggerParticleEvent(const agx::TimeStamp& ,
61  agx::Physics::ParticleGeometryContactInstance ,
62  agx::Physics::ParticleData& ,
63  agx::Physics::GeometryData& ,
64  agxControl::EventSensor*) override {}
65 
66  virtual void postContactHandling(agxSDK::Simulation *, EventSensor *) override {}
67 
69 
70  protected:
73 
74  void attachJournal(agxSDK::Simulation *simulation);
75 
76  void detachJournal();
77 
78  void initDataStructure(agxSDK::Simulation * simulation);
79 
80  void copyContactingParticlesToStorage(EventSensor * sensor);
81 
83  // Variables
85  protected:
92  };
93 
94 
95 
100  {
101  public:
102  RecordParticleJournalOperation(const agx::Name& name, const agx::String& journalPath, bool shouldAttachJournalOnContact = true, agx::Frame * sourceOffset = nullptr);
103 
104  void addNotification(EventSensor * sensor) override;
105 
106  void triggerEvent(const agx::TimeStamp& /*t*/,
107  agxSDK::Simulation * /*simulation*/,
109  agxControl::EventSensor* /*sensor*/) override;
110 
111  void triggerParticleEvent(const agx::TimeStamp& /*t*/,
112  agxSDK::Simulation* simulation,
113  agx::Physics::ParticleGeometryContactInstance /*contact*/,
114  agx::Physics::ParticleData& /*particleData*/,
115  agx::Physics::GeometryData& /*geometryData*/,
116  agxControl::EventSensor* /*sensor*/) override;
117 
118  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
119 
121 
122  protected:
125 
127  // Variables
129  protected:
131  };
132 
133 
134 
139  {
140  public:
141  RecordParticleShapshotJournalOperation(const agx::Name& name, const agx::String& journalPath, agx::Real snapShotTime = 0, agx::Frame * sourceOffset = nullptr);
142 
143  virtual void update(const agx::TimeStamp& /*t*/) override;
144 
145  virtual void addNotification(EventSensor * sensor) override;
146 
147  void triggerEvent(const agx::TimeStamp& /*t*/,
148  agxSDK::Simulation * /*simulation*/,
150  agxControl::EventSensor* /*sensor*/) override;
151 
152  void triggerParticleEvent(const agx::TimeStamp& /*t*/,
153  agxSDK::Simulation* simulation,
154  agx::Physics::ParticleGeometryContactInstance /*contact*/,
155  agx::Physics::ParticleData& /*particleData*/,
156  agx::Physics::GeometryData& /*geometryData*/,
157  agxControl::EventSensor* /*sensor*/) override;
158 
159  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
160 
162 
163  protected:
166 
168  // Variables
170  protected:
173  };
174 
175 
176 
182  {
183  public:
185  const agx::String& journalPath,
186  agx::Real startAfter = 0,
187  agx::Material* startMaterial = nullptr,
188  agx::Frame * targetOffsetFrame = nullptr);
189 
190  void addNotification(EventSensor * sensor) override;
191 
192  void triggerEvent(const agx::TimeStamp& /*t*/,
193  agxSDK::Simulation * /*simulation*/,
195  agxControl::EventSensor* /*sensor*/) override;
196 
197  void triggerParticleEvent(const agx::TimeStamp& /*t*/,
198  agxSDK::Simulation* /*simulation*/,
199  agx::Physics::ParticleGeometryContactInstance /*contact*/,
200  agx::Physics::ParticleData& /*particleData*/,
201  agx::Physics::GeometryData& /*geometryData*/,
202  agxControl::EventSensor* /*sensor*/) override;
203 
204  void postContactHandling(agxSDK::Simulation * simulation, agxControl::EventSensor *sensor) override;
205 
207 
208  protected:
210  virtual ~LoadParticleJournalOperation();
211 
212  void loadAndAttachJournal(EventSensor * sensor);
213 
214  bool loadParticleStorageFromSimulation(EventSensor * sensor);
215 
216  void loadParticlesFromStorage(EventSensor * sensor);
217 
219  // Variables
221  protected:
229  };
230 
231 
232 
237  {
238  public:
240  const agx::String& filepath,
241  agx::Real snapShotTime,
242  agx::Frame * sourceOffset = nullptr );
243 
244  virtual void update( const agx::TimeStamp& ) override;
245 
246  virtual void addNotification( EventSensor * sensor ) override;
247 
248  virtual void triggerEvent( const agx::TimeStamp&,
251  agxControl::EventSensor* ) override {}
252 
253  virtual void triggerParticleEvent( const agx::TimeStamp&,
255  agx::Physics::ParticleGeometryContactInstance,
256  agx::Physics::ParticleData&,
257  agx::Physics::GeometryData&,
258  agxControl::EventSensor* ) override {}
259 
260  void writeParticlesToFile( EventSensor * sensor );
261 
262  virtual void postContactHandling( agxSDK::Simulation *, EventSensor * ) override;
263 
265 
266  protected:
269 
271  // Variables
273  protected:
278  };
279 
280 
281 
286  {
287  public:
289  const agx::String& filePath,
290  agx::Real startAfter = 0,
291  agx::Material* startMaterial = nullptr,
292  agx::Frame * targetOffsetFrame = nullptr );
293 
294  void addNotification( EventSensor * sensor ) override;
295 
296  void triggerEvent( const agx::TimeStamp& /*t*/,
297  agxSDK::Simulation * /*simulation*/,
299  agxControl::EventSensor* /*sensor*/ ) override {}
300 
302  agxSDK::Simulation* /*simulation*/,
303  agx::Physics::ParticleGeometryContactInstance /*contact*/,
304  agx::Physics::ParticleData& /*particleData*/,
305  agx::Physics::GeometryData& /*geometryData*/,
306  agxControl::EventSensor* /*sensor*/ ) override {}
307 
308  void postContactHandling( agxSDK::Simulation * simulation, agxControl::EventSensor *sensor ) override;
309 
311 
312  protected:
314  virtual ~LoadParticleAGXFileOperation();
315 
316  void loadParticlesFromFile( EventSensor * sensor );
317 
319  // Variables
321  protected:
327  };
328 
329 }
330 #endif /*SENSOROPERATIONS_H_*/
Class that stores particle data from a continuous flow in the coupled sensor to a separate specified ...
virtual void triggerEvent(const agx::TimeStamp &, agxSDK::Simulation *, agxCollide::GeometryContact *, agxControl::EventSensor *) override
Triggers the sensor event by passing contact information.
Loads particle data from an external journal file into a simulation relative to the coupled sensor ob...
A contact between two geometries.
Definition: Contacts.h:270
#define AGXPHYSICS_EXPORT
Representation of a name string.
Definition: Name.h:32
agx::Real TimeStamp
Definition: TimeStamp.h:26
This is a sensor class that can be attached to an geometry in the simulation.
Definition: EventSensor.h:47
Base virtual class for storing particle states to an external journal file.
virtual void triggerParticleEvent(const agx::TimeStamp &, agxSDK::Simulation *, agx::Physics::ParticleGeometryContactInstance, agx::Physics::ParticleData &, agx::Physics::GeometryData &, agxControl::EventSensor *) override
Triggers the sensor event by passing particle contact information.
Loads particle data from an external agx file into a simulation relative to the coupled sensor object...
Class that stores particles in contact with the sensor to an binary .agx file.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
virtual void postContactHandling(agxSDK::Simulation *, EventSensor *) override
Post function that will be triggered for the event after all the contacts have handled in the operati...
void triggerEvent(const agx::TimeStamp &, agxSDK::Simulation *, agxCollide::GeometryContact *, agxControl::EventSensor *) override
Triggers the sensor event by passing contact information.
This namespace contains general operation and action classes which can be used to control a agxSDK::S...
Main material class which acts as a holder of a Surface Material and a Bulk material.
Definition: Material.h:375
virtual void triggerParticleEvent(const agx::TimeStamp &, agxSDK::Simulation *, agx::Physics::ParticleGeometryContactInstance, agx::Physics::ParticleData &, agx::Physics::GeometryData &, agxControl::EventSensor *) override
Triggers the sensor event by passing particle contact information.
Class that stores a single frame of the current particle configuration in the coupled sensor...
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
virtual void triggerEvent(const agx::TimeStamp &, agxSDK::Simulation *, agxCollide::GeometryContact *, agxControl::EventSensor *) override
Triggers the sensor event by passing contact information.
double Real
Definition: Real.h:42
A specific type of sensor event that triggers a change in the simulation when activated by a contact...
Definition: SensorEvent.h:117
void triggerParticleEvent(const agx::TimeStamp &, agxSDK::Simulation *, agx::Physics::ParticleGeometryContactInstance, agx::Physics::ParticleData &, agx::Physics::GeometryData &, agxControl::EventSensor *) override
Triggers the sensor event by passing particle contact information.