AGX Dynamics  2.38.0.2
Simulation.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 #pragma once
18 
19 #include <agx/config/AGX_USE_WEBSOCKETS.h>
20 #include <agxSDK/agxSDK.h>
21 #include <agxSDK/SimulationProxy.h>
23 #include <agxSDK/EventManager.h>
24 #include <agxSDK/MaterialManager.h>
25 #include <agxSDK/Assembly.h>
28 
29 #include <agx/DynamicsSystem.h>
30 #include <agx/TimeStamp.h>
31 #include <agx/HashTable.h>
32 #include <agx/Component.h>
33 #include <agx/GravityField.h>
34 #include <agx/Clock.h>
36 #include <agxData/Frame.h>
37 
39 
40 #include <agxCollide/Space.h>
41 
43 
44 #ifdef _MSC_VER
45 # pragma warning(push)
46 # pragma warning( disable : 4290 ) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
47 #endif
48 
49 namespace agx
50 {
51  class Interaction;
52  class ParticleSystem;
53  class RigidBody;
54  class MergedBody;
55  class ParticleEmitter;
56  class RigidBodyEmitter;
57  class Journal;
58  class RemoteSolver;
59  class Solver;
60  class ObserverFrame;
61  class StabilityReport;
62 
63  class Hinge;
64  class Prismatic;
65  class DistanceJoint;
66  class LockJoint;
67  class BallJoint;
68  class PlaneJoint;
69  class AngularLockJoint;
70  class CylindricalJoint;
71  class UniversalJoint;
72  class PrismaticUniversalJoint;
73 }
74 
75 namespace agxCollide
76 {
77  class Geometry;
78 }
79 
80 namespace agxNet
81 {
82  class RemoteDebugClient;
83 }
84 
85 namespace agxRender
86 {
87  class RenderManager;
88 }
89 
90 namespace agxWire
91 {
92  class Wire;
93 }
94 
95 namespace agxModel
96 {
97  class SurfaceVelocityConveyorBelt;
98 }
99 
100 namespace agxPlot
101 {
102  class System;
103  class DataSeries;
104 }
105 
106 namespace agxSDK
107 {
108  class SimulationFrameReader;
109  class SimulationFrameWriter;
110  class EventListener;
111  class SimulationFrameWriter;
112  class GuiEventAdapterImplementation;
113  class PickHandler;
114  class MergeSplitHandler;
115  class TerrainInstance;
117 
119 
126  {
127  public:
134 
137 
140 
143 
146 
149 
151 
152  public:
157  static agxSDK::SimulationProxyRef createDefaultProxy( agxSDK::Simulation* simulation );
158 
159  public:
164  Simulation();
165 
171  bool add( agx::Material* material );
172 
177  bool add( agx::ContactMaterial* material );
178 
183  bool remove( agx::ContactMaterial* material );
184 
188  const agx::Material* getMaterial(const agx::Name& materialName) const;
189 
193  agx::Material* getMaterial(const agx::Name& materialName);
194 
198  agx::Material* getMaterial(const agx::Uuid& uuid);
199 
203  MaterialManager* getMaterialManager();
204 
208  const MaterialManager* getMaterialManager() const;
209 
214  bool remove( agx::Material* material );
215 
221  bool add( agxCollide::Geometry* geometry );
222 
232  bool remove( agxCollide::Geometry* geometry );
233 
241  bool add( agx::RigidBody* body, bool addGeometries = true );
242 
251  bool remove( agx::RigidBody* body, bool removeGeometries = true );
252 
258  bool add( agx::MergedBody* mergedBody );
259 
265  bool remove( agx::MergedBody* mergedBody );
266 
272  bool add( agx::Constraint* constraint );
273 
279  bool remove( agx::Constraint* constraint );
280 
286  bool add( agx::Interaction* interaction );
287 
293  bool remove( agx::Interaction* interaction );
294 
301  bool add( agxSDK::Assembly* assembly, bool addAllEntries = true );
302 
309  bool remove( agxSDK::Assembly* assembly, bool removeAllEntries = true );
310 
316  bool add( agx::Component* subComponent );
317 
323  bool remove( agx::Component* subComponent );
324 
330  bool add(agx::ObserverFrame* observerFrame);
331 
337  bool remove(agx::ObserverFrame* observerFrame);
338 
345  bool contains( const agx::Component* object ) const;
346 
352  bool add( agxControl::Action* action );
353 
359  bool remove( agxControl::Action* action );
360 
366  bool add( agxControl::Operation* operation );
367 
373  bool remove( agxControl::Operation* operation );
374 
380  bool add( agx::ParticleSystem* particleSystem );
381 
387  bool remove( agx::ParticleSystem* particleSystem);
388 
396  bool add( agx::Emitter* emitter, bool addGeometries=true);
397 
405  bool remove(agx::Emitter* emitter, bool removeGeometries=true);
406 
412  bool add( agx::ParticleContactSensor* sensor );
413 
419  bool remove( agx::ParticleContactSensor* sensor );
420 
424  agx::ParticleEmitterRefVector getParticleEmitters();
425 
429  agx::EmitterRefVector getEmitters();
430 
434  agx::ParticleSystemRefVector& getParticleSystems();
435 
439  const agx::ParticleSystemRefVector& getParticleSystems() const;
440 
444  agx::ParticleSystem* getParticleSystem() const;
445 
451  bool add( agxSDK::TerrainInstance* terrain );
452 
458  bool remove( agxSDK::TerrainInstance* terrain );
459 
467  bool setUniformGravity( const agx::Vec3& g );
468 
473  agx::Vec3 getUniformGravity() const;
474 
479  void setGravityField( agx::GravityField* gravityField );
480 
482  agx::GravityField* getGravityField();
483 
485  const agx::GravityField* getGravityField() const;
486 
492  void setMainWorkThread(agx::Thread* thread);
493 
499  agx::RigidBody* getRigidBody( const agx::Name& name );
500 
506  const agx::RigidBody* getRigidBody( const agx::Name& name ) const;
507 
513  agx::RigidBody* getRigidBody( const agx::Uuid& uuid ) ;
514 
520  const agx::RigidBody* getRigidBody( const agx::Uuid& uuid ) const;
521 
527  agx::MergedBody* getMergedBody(const agx::Name& name);
528 
534  const agx::MergedBody* getMergedBody(const agx::Name& name) const;
535 
541  agx::MergedBody* getMergedBody(const agx::Uuid& uuid);
542 
548  const agx::MergedBody* getMergedBody(const agx::Uuid& uuid) const;
549 
555  const agx::Constraint* getConstraint( const agx::Uuid& uuid ) const;
556 
562  agx::Constraint* getConstraint( const agx::Uuid& uuid );
563 
569  const agx::Constraint* getConstraint(const agx::Name& name) const;
570 
576  agx::Constraint* getConstraint(const agx::Name& name);
577 
583  const agxSDK::Assembly* getAssembly(const agx::Name& name) const;
584 
590  agxSDK::Assembly* getAssembly(const agx::Name& name);
591 
597  const agxSDK::Assembly* getAssembly(const agx::Uuid& uuid) const;
598 
604  agxSDK::Assembly* getAssembly(const agx::Uuid& uuid);
605 
611  const agx::Emitter* getEmitter(const agx::Uuid& uuid) const;
612 
618  agx::Emitter* getEmitter(const agx::Uuid& uuid);
619 
625  agx::Emitter* getEmitter(const agx::Name& name) const;
626 
632  agx::Emitter* getEmitter(const agx::Name& name);
633 
642  template < typename T >
643  T* getConstraint(const agx::Uuid& uuid);
644 
653  template < typename T >
654  const T* getConstraint(const agx::Uuid& uuid) const;
655 
664  template < typename T >
665  T* getConstraint( const agx::Name& name );
666 
675  template < typename T >
676  const T* getConstraint( const agx::Name& name ) const;
677 
678 #define GETCONSTRAINT_TYPE(CLASS_NAME, TYPENAME) \
679  CLASS_NAME *get ## TYPENAME(const agx::Name& name); \
680  CLASS_NAME *get ##TYPENAME(const agx::Uuid& uuid);
681 
682  GETCONSTRAINT_TYPE(agx::AngularLockJoint, AngularLockJoint)
684  GETCONSTRAINT_TYPE(agx::CylindricalJoint, CylindricalJoint)
685  GETCONSTRAINT_TYPE(agx::DistanceJoint, DistanceJoint)
690  GETCONSTRAINT_TYPE(agx::PrismaticUniversalJoint, PrismaticUniversalJoint)
691  GETCONSTRAINT_TYPE(agx::UniversalJoint, UniversalJoint)
692 #undef GETCONSTRAINT_TYPE
693 
699  const agxCollide::Geometry* getGeometry(const agx::Name& name ) const;
700 
706  agxCollide::Geometry* getGeometry(const agx::Name& name );
707 
713  const agxCollide::Geometry* getGeometry( const agx::Uuid& uuid ) const;
714 
720  agxCollide::Geometry* getGeometry( const agx::Uuid& uuid );
721 
727  const agxSDK::EventListener* getEventListener(const agx::Name& name ) const;
728 
734  agxSDK::EventListener* getEventListener(const agx::Name& name );
735 
741  const agxSDK::EventListener* getEventListener(const agx::Uuid& uuid) const;
742 
748  agxSDK::EventListener* getEventListener(const agx::Uuid& uuid);
749 
750 
756  const agxWire::Wire* getWire(const agx::Name& name) const;
757 
763  agxWire::Wire* getWire(const agx::Name& name);
764 
770  const agxWire::Wire* getWire(const agx::Uuid& uuid) const;
771 
777  agxWire::Wire* getWire(const agx::Uuid& uuid);
778 
784  agx::ObserverFrame* getObserver(const agx::Name& name);
785 
791  const agx::ObserverFrame* getObserver(const agx::Name& name) const;
792 
798  agx::ObserverFrame* getObserver(const agx::Uuid& uuid);
799 
805  const agx::ObserverFrame* getObserver(const agx::Uuid& uuid) const;
806 
813  agx::TimeStamp stepTo( agx::TimeStamp t );
814 
816  agx::Real getTimeStep() const;
817 
823  bool setTimeStep( agx::Real timeStep );
824 
828  agx::Clock* getClock();
829 
833  const agx::Clock* getClock() const;
834 
838  agx::Journal* getJournal();
839 
843  const agx::Journal* getJournal() const;
844 
845  #if AGX_USE_WEBSOCKETS()
846 
849  agx::RemoteSolver* getRemoteSolver();
850 
854  const agx::RemoteSolver* getRemoteSolver() const;
855  #endif
856 
863  bool breakStepTo();
864 
868  agx::Real getTimeStamp() const;
869 
874  void setTimeStamp( agx::TimeStamp t );
875 
880  void stepForward();
881 
885  agxCollide::Space* getSpace();
886 
890  const agxCollide::Space* getSpace() const;
891 
895  agx::DynamicsSystem* getDynamicsSystem();
896 
900  const agx::DynamicsSystem* getDynamicsSystem() const;
901 
905  agxPlot::System* getPlotSystem() const;
906 
910  void setPlotSystem(agxPlot::System* plotSystem);
911 
915  void setSpace( agxCollide::Space* space );
916 
920  void setDynamicsSystem( agx::DynamicsSystem* system );
921 
922 
928  bool removeEventListener( agxSDK::EventListener* listener );
929 
940  bool addEventListener( agxSDK::EventListener* listener, int priority = EventManager::DEFAULT_PRIORITY );
941 
952  bool add( agxSDK::EventListener* listener, int priority = EventManager::DEFAULT_PRIORITY );
953 
959  bool remove( agxSDK::EventListener* listener );
960 
965  bool triggerEvent( const GuiEvent& e );
966 
970  agxPlot::DataSeries* getTimeDataSeries() const;
971 
972 #ifdef SWIG
973  enum CleanupSelectionMask {
974  STEP_LISTENERS = 0x1,
975  CONTACT_LISTENERS = 0x2,
976  GUI_LISTENERS = 0x4,
977  LISTENERS = STEP_LISTENERS | CONTACT_LISTENERS | GUI_LISTENERS,
978  SYSTEM = 0x200,
979  SPACE = 0x400,
980  MATERIALS = 0x800,
981  ASSEMBLIES = 0x1000,
982  PARTICLE_SYSTEMS = 0x2000,
983  CONTACT_DATA = 0x4000,
984  CLEANUP_ALL = LISTENERS | SYSTEM | SPACE | MATERIALS | ASSEMBLIES | PARTICLE_SYSTEMS | CONTACT_DATA
985  };
986 #else
987 
992  STEP_LISTENERS = EventManager::STEP_LISTENERS,
993  CONTACT_LISTENERS = EventManager::CONTACT_LISTENERS,
994  GUI_LISTENERS = EventManager::GUI_LISTENERS,
995  LISTENERS = EventManager::LISTENERS,
996  SYSTEM = 0x200,
997  SPACE = 0x400,
998  MATERIALS = 0x800,
999  ASSEMBLIES = 0x1000,
1000  PARTICLE_SYSTEMS = 0x2000,
1001  CONTACT_DATA = 0x4000,
1002  PLOTSYSTEM = 0x8000,
1003  CLEANUP_ALL = LISTENERS | SYSTEM | SPACE | MATERIALS | ASSEMBLIES | PARTICLE_SYSTEMS | CONTACT_DATA | PLOTSYSTEM
1004  };
1005 #endif
1006 
1012  READ_NONE = 0x0,
1013  READ_TIMESTEP = 0x1,
1014  READ_TIMESTAMP = 0x2,
1015  READ_GRAVITY = 0x4,
1016  READ_SOLVER = 0x8,
1017  READ_ALL = READ_TIMESTEP + READ_TIMESTAMP + READ_GRAVITY + READ_SOLVER,
1018  READ_DEFAULT = READ_TIMESTEP /* + READ_TIMESTAMP */ + READ_GRAVITY + READ_SOLVER // Not using READ_TIMESTAMP
1019  };
1020 
1028  void cleanup( agx::UInt selection = CLEANUP_ALL, bool fast=false );
1029 
1035  void setActionManagerTimeStamp(const agx::TimeStamp& time);
1036 
1040  agxControl::ActionManager* getActionManager();
1041 
1045  void clearContactData();
1046 
1050  agx::Solver* getSolver();
1051 
1055  const agx::Solver* getSolver() const;
1056 
1060  void setPreIntegratePositions( bool flag );
1061 
1065  bool getPreIntegratePositions() const;
1066 
1072  bool add( agxStream::Serializable* object );
1073 
1079  bool remove( agxStream::Serializable* object );
1080 
1081 
1086  agxSDK::PickHandler* getPickHandler();
1087 
1092  const agxSDK::PickHandler* getPickHandler() const;
1093 
1098  void setPickHandler( agxSDK::PickHandler* pickHandler );
1099 
1104  void setStatisticsPath( const agx::String& path );
1105 
1109  void setStatisticsInterval( agx::Real interval );
1110 
1116  void setEnableStatistics( bool enable );
1117 
1119  bool getEnableStatistics() const;
1120 
1122  void setEnableStatisticsRendering( bool enable );
1123 
1125  bool getEnableStatisticsRendering() const;
1126 
1130  void setProfilingFrequency(agx::Real frequency);
1131 
1135  agx::Real getProfilingFrequency() const;
1136 
1140  const AssemblyHash& getAssemblies() const;
1141 
1142 
1146  void getEventListeners( EventListenerPtrVector& eventListeners ) const;
1147 
1151  const agxCollide::GeometryRefVector& getGeometries() const;
1152 
1156  const agx::RigidBodyRefVector& getRigidBodies() const;
1157 
1161  agx::RigidBodyRefVector& getRigidBodies();
1162 
1163 
1167  const agx::ConstraintRefSetVector& getConstraints() const;
1168 
1172  agx::ConstraintRefSetVector& getConstraints();
1173 
1177  const agx::ObserverFrameRefSetVector& getObserverFrames() const;
1178 
1182  agx::ObserverFrameRefSetVector& getObserverFrames();
1183 
1187  agx::RigidBodyPtrSetVector& getEnabledRigidBodies();
1188 
1192  const agx::RigidBodyPtrSetVector& getEnabledRigidBodies() const;
1193 
1199  const agx::ObserverFrame* getObserverFrame(const agx::Uuid& uuid) const;
1200 
1206  agx::ObserverFrame* getObserverFrame(const agx::Uuid& uuid);
1207 
1212  agx::ObserverFrame* getObserverFrame(const agx::Name& name);
1213 
1218  const agx::ObserverFrame* getObserverFrame(const agx::Name& name) const;
1219 
1220 
1226  size_t write( const agx::String& filename ) const;
1227 
1234  size_t write( std::ostream& stream, bool binary ) const;
1235 
1242  size_t read( const agx::String& filename, agxSDK::Assembly* parent = nullptr, agx::UInt selection = READ_DEFAULT);
1243 
1252  size_t read( std::istream& stream, bool isBinary, agxSDK::Assembly* parent = nullptr, agx::UInt selection = READ_DEFAULT);
1253 
1259  bool restore(const agx::String& filename, agx::UInt selection = READ_DEFAULT);
1260  bool restore(std::istream& stream, bool isBinary, agx::UInt selection = READ_DEFAULT);
1261 
1262 
1270  bool addRestoreListener( agxStream::RestoreListener *listener );
1271 
1277  bool removeRestoreListener( agxStream::RestoreListener *listener );
1278 
1283  void store( agxStream::OutputArchive& archive ) const;
1284 
1292  void restore( agxStream::InputArchive& in, agxSDK::Assembly* parent = nullptr, agx::UInt selection = READ_DEFAULT, bool replaceUsingCache = false );
1293 
1301  void setEnableRemoteDebugging( bool flag, agx::Int16 port = -1, bool useCompression = false, bool waitForSynchronization = true );
1302 
1306  bool getEnableRemoteDebugging() const;
1307 
1312  void setRemoteDebuggingTimeStep( agx::Real timeStep );
1313 
1317  agx::Real getRemoteDebuggingTimeStep() const;
1318 
1327  void setContactReductionBinResolution( agx::UInt8 binResolution );
1328 
1332  agx::UInt8 getContactReductionBinResolution() const;
1333 
1339  void setContactReductionThreshold(agx::UInt threshold);
1340 
1344  agx::UInt getContactReductionThreshold() const;
1345 
1351  agxSDK::MergeSplitHandler* getMergeSplitHandler() const;
1352 
1356  agxRender::RenderManager* getRenderManager();
1357 
1361  const agxRender::RenderManager* getRenderManager() const;
1362 
1366  void updateRenderManager();
1367 
1371  void updateStatisticsRenderData();
1372 
1382  void garbageCollect();
1383 
1387  bool add(agxSDK::SimulationParameter *parameter);
1388 
1392  bool remove(agxSDK::SimulationParameter *parameter);
1393 
1397  const agxSDK::SimulationParameterRefVector& getParameters() const;
1398 
1402  agxSDK::SimulationParameter *getParameter(const agx::Name& name);
1403 
1407  agxSDK::EnergyManager* getEnergyManager() const;
1408 
1409  public:
1410  // Internal, but public methods
1411 
1413  void sendSimulation();
1414 
1419  SimulationSerializer* getSerializer();
1420 
1425  const SimulationSerializer* getSerializer() const;
1426 
1430  void setSerializer( SimulationSerializer* serializer);
1431 
1432 
1438  void updateActionManager();
1439 
1446  agxSDK::SimulationProxy* getSimulationProxy() const;
1447 
1454  void commit( agxSDK::SimulationProxy* simulationProxy );
1455 
1461  void handleStabiltyReport( const agx::StabilityReport* stabilityReport );
1462 
1463  agx::TaskGroup* getUpdateTask();
1464 
1465  void renderComponents();
1466  void createRenderTask();
1467  agx::SolveModel* getSolveModel(const agx::Name& name);
1468 
1469  const agx::SolveModelRefVector& getSolveModels() const;
1470 
1471  #if AGX_USE_WEBSOCKETS()
1472  void setRemoteSolver(agx::RemoteSolver* remoteSolver);
1473  #endif
1474 
1476  Simulation( agx::Device* device );
1477 
1478  static Simulation* load(agx::TiXmlElement* eSimulation, agx::Device* device);
1479 
1481  static agx::Model* ClassModel();
1482 
1488  void setEnableSimulationStatisticsListener( bool flag );
1489 
1490  SimulationStatisticsListener* getSimulationStatisticsListener();
1491  const SimulationStatisticsListener* getSimulationStatisticsListener() const;
1492 
1493  void addSolveModel(agx::SolveModel* model);
1494  void removeSolveModel(agx::SolveModel* model);
1495  void loadSolveModels(const agx::String& path, bool clear = false);
1496 
1497  // For LUA only
1498  agx::Constraint1DOF* getConstraint1DOF(const agx::Name& name) { return this->getConstraint<agx::Constraint1DOF>(name); }
1499  agx::Constraint2DOF* getConstraint2DOF(const agx::Name& name) { return this->getConstraint<agx::Constraint2DOF>(name); }
1500 
1504  agx::UInt getNumMergedBodies() const;
1505 
1510  agx::MergedBody* getMergedBody( agx::UInt i ) const;
1511 
1515  agx::UInt getNumTerrains() const;
1516 
1521  agxSDK::TerrainInstance* getTerrain( agx::UInt i ) const;
1522 
1524  void resetTaskTimers();
1525 
1529  void dumpTaskTimers(const agx::String& filePath = "BufferAllocations.xml");
1530 
1534  void dumpMemoryUsage(const agx::String& filePath = "TaskTimers.xml");
1535 
1536 
1538  bool allowCreateParticles() const;
1539 
1540  agx::Component *getHeader();
1541  void readStoragePermutations(agxStream::InputArchive& in, bool clearStorages = false);
1542  void writeStoragePermutations(agxStream::OutputArchive& archive) const;
1543 
1544  void writeStatisticsFiles(const agx::String& directoryPath = "Statistics", bool taskProfile = true, bool threadTimeline = true, const agx::Vector<agx::String>& timelineFormats = agx::Vector<agx::String>(), bool bufferAllocations = true);
1545 
1546  agxData::EntityStorage* getEmitterStorage();
1547 
1548  protected:
1550  friend class GuiEventAdapterImplementation;
1551  friend class agx::DynamicsSystem;
1554 
1556  virtual ~Simulation();
1557 
1558  private:
1559  void addListener(EventListener *listener);
1560  void removeListener(EventListener *listener);
1561  bool hasListener(EventListener *listener);
1562 
1563  private:
1565  void init();
1566 
1568  void initConfiguration();
1569 
1571  void updateStatisticsEnable();
1572 
1573  void setEnableComputeAllConstraintForces(bool flag);
1574  bool getEnableComputeAllConstraintForces() const;
1575 
1577  void resetGraphStatistics();
1578 
1580  agx::Vec4 getSubsystemColor(agx::RigidBody* body);
1581 
1583  void setupStatisticsLogging();
1584 
1585  void updateConstraintForceData();
1586 
1587  void createUpdateTask();
1588 
1589  void generateContactMaterials();
1590  void preCollide();
1591  void prepareContacts();
1592  void triggerParticleContactSensors();
1593  void triggerPreStepEvents();
1594  void triggerPostStepEvents();
1595  void triggerLastStepEvents();
1596  void terrainPostUpdate();
1597  void stepSystem();
1598  void resetDirtyMaterials();
1599  void updateRemoteDebugger();
1600  void recordStatistics();
1601  void recordPlaybackStatistics();
1602  void recordParticleCount();
1603  void recordWarmStartingData();
1604  void printStatistics();
1605  void updateClock();
1606 
1607 
1608  void pruneContacts();
1609  void contactPointReduction();
1610  void updateSleepState();
1611  void triggerPreCollideStepEvent();
1612  void triggerSeparationContactEventListeners();
1613  void triggerContactEventListeners();
1614  void assignContactMaterials();
1615  void dumpThreadLogs(agx::Task *);
1616 
1617  void applyPreIntegrationSettings();
1618 
1619  private:
1620  friend class agx::Solver;
1621  void registerParticleSystemPointers();
1622  void unregisterParticleSystemPointers();
1623  void removeParticleSolverObjects( agx::ParticleSystem* particleSystem );
1624 
1625  private:
1626 
1627  class StatisticsWriter;
1628 
1629  friend class agx::Journal;
1631  #if AGX_USE_WEBSOCKETS()
1632  friend class agx::RemoteSolver;
1633  #endif
1634 
1635  void setJournal(agx::Journal* journal);
1636  void setHasJournal(bool flag);
1637  void preStoreSynchronization();
1638 
1639  StatisticsEntries m_statisticsEntry;
1640  StatisticsWriter* m_statWriter;
1641 
1643 
1644  AssemblyHash m_assemblies;
1645 
1646  agxCollide::SpaceRef m_space;
1647  agx::DynamicsSystemRef m_system;
1648 
1649  agx::ref_ptr<agx::Referenced> m_plotSystem;
1650  agx::ref_ptr<agx::Referenced> m_timeDataSeries;
1651 
1652  agx::ComponentRef m_header;
1653  bool m_stepToStarted;
1654 
1655  EventManagerRef m_eventManager;
1656  MaterialManagerRef m_materialManager;
1657 
1658  agxControl::ActionManagerRef m_actionManager;
1659  agx::TaskRef m_actionManagerTask;
1660 
1661  agx::observer_ptr< Referenced > m_pickHandler;
1662 
1663  SimulationSerializerRef m_serializationListener;
1664 
1665  agx::ParticleSystemRefVector m_particleSystems;
1666  agx::TaskGroupRef m_updateEmitters;
1667  agxData::EntityStorageRef m_emitterStorage;
1668 
1669  agx::ref_ptr<agx::Referenced> m_controlledServer;
1670  agx::ref_ptr<agx::Referenced> m_debugServer;
1671  agx::UInt8 m_contactReductionBinResolution;
1672  agx::UInt m_contactReductionThreshold;
1673  agx::ComponentRefVector m_subComponents;
1674  agx::Real m_remoteDebuggerTimeStep;
1675  agx::TimeStamp m_remoteDebuggerTimeStamp;
1676  agx::TaskGroupRef m_updateTask;
1677  agx::TaskRefVector m_preIntegrateTasks;
1678  bool m_preIntegrate;
1679  bool m_fastCleanup;
1680  bool m_allowCreateParticles;
1681 
1682  agx::Timer m_stepTimer;
1683  agx::Timer m_updateRenderManagerTimer;
1684  agx::ClockRef m_clock;
1685  agx::TaskRef m_renderTask;
1686  agx::GravityFieldRef m_gravityField;
1687 
1688  agx::SolveModelTable m_solveModelTable;
1689  agx::SolveModelRefVector m_solveModels;
1690 
1691  agx::ref_ptr<agx::Referenced> m_renderManager;
1692  agx::Thread* m_mainWorkThread;
1693  agxData::FrameRef m_journalLastWrittenFrame;
1694  agx::UInt32 m_journalAgxArchiveIdCounter;
1695 
1696  void* m_journal;
1697  bool m_hasJournal;
1698  void* m_remoteSolver;
1699 
1700  agxData::EntityStorageRef m_constraintForcesStorage;
1701  bool m_enableComputeAllConstraintForces;
1702  bool m_inDestructor;
1703  SimulationProxyRef m_simulationProxy;
1704  agx::ParticleContactSensorRefVector m_particleContactSensors;
1705 
1707  ParticleContactSensorTable m_particleContactSensorTable;
1708 
1710  RestoreListenerHash m_restoreListeners;
1711  agxSDK::SimulationStatisticsListenerRef m_simulationStatisticsListener;
1712  agx::Real m_profilingFrequency;
1713 
1715  StabilityReportContainer m_stabilityReports;
1716 
1719  MergedBodiesContainer m_mergedBodies;
1720 
1722  MergeSplitHandlerPointer m_mergeSplitHandler;
1723 
1726  LinkedStructureContainer m_linkedStructures;
1727 
1730  TerrainInstanceContainer m_terrains;
1731 
1732  bool m_disableGeometryAutoAdd;
1733  agxSDK::SimulationParameterRefVector m_simulationParameters;
1734 
1735 
1736  agx::RangeJobVector m_postSolveConstraintForceJobs;
1737  agx::ParallelTaskRef m_postSolveConstraintForceTask;
1738 
1739  agx::ref_ptr<agx::Referenced> m_energyManager;
1740  };
1741 
1742  /* Implementation */
1744  {
1745  return m_clock->getTime();
1746  }
1747 
1749  {
1750  return m_space.get();
1751  }
1752 
1754  {
1755  return m_space.get();
1756  }
1757 
1759  {
1760  return m_system.get();
1761  }
1762 
1764  {
1765  return m_system.get();
1766  }
1767 
1769  {
1770  if (m_system) return m_system->getTimeGovernor()->getTimeStep();
1771  else return 0;
1772  }
1773 
1775  {
1776  return m_clock;
1777  }
1778 
1780  {
1781  return m_clock;
1782  }
1783 
1785  {
1786  return m_allowCreateParticles;
1787  }
1788 
1789  AGX_FORCE_INLINE const agx::SolveModelRefVector& Simulation::getSolveModels() const
1790  {
1791  return m_solveModels;
1792  }
1793 
1794  template< typename T >
1796  {
1797  return dynamic_cast< T* >( this->getConstraint( uuid ) );
1798  }
1799 
1800  template< typename T >
1801  const T* Simulation::getConstraint( const agx::Uuid& uuid ) const
1802  {
1803  return dynamic_cast< const T* >( this->getConstraint( uuid ) );
1804  }
1805 
1806  template< typename T >
1808  {
1809  return dynamic_cast< T* >( this->getConstraint( name ) );
1810  }
1811 
1812  template< typename T >
1813  const T* Simulation::getConstraint( const agx::Name& name ) const
1814  {
1815  return dynamic_cast< const T* >( this->getConstraint( name ) );
1816  }
1817 } // namespace agxSDK
1818 
1819 #ifdef _MSC_VER
1820 # pragma warning(pop) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow). Restored.
1821 #endif
agxSDK::Simulation::ReadSelectionMask
ReadSelectionMask
Enum for specifying some additional, part of a simulation that can be restored from a serialization.
Definition: Simulation.h:1011
agx::UInt
uint64_t UInt
Definition: Integer.h:27
agxSDK::Simulation::removeConstraintEvent
ConstraintEvent removeConstraintEvent
Definition: Simulation.h:142
agx::Int16
int16_t Int16
Definition: Integer.h:36
agx::Journal
Definition: Journal.h:46
SimulationSerializer.h
agxSDK::Simulation::ContactMaterialEvent
agx::Event2< Simulation *, agx::ContactMaterial * > ContactMaterialEvent
Definition: Simulation.h:132
agxSDK::Simulation::addRigidBodyEvent
RigidBodyEvent addRigidBodyEvent
Definition: Simulation.h:138
agx::Real
double Real
Definition: Real.h:42
SimulationProxy.h
EventManager.h
agxModel
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
agxRender
Namespace containing classes for handling debug rendering of collision geometries,...
Definition: Constraint.h:35
ParticleContactSensor.h
agxSDK::SimulationParameter
Definition: SimulationParameter.h:33
agx::Vector
Templated vector class.
Definition: Vector.h:52
agxPlot
Namespace contains functionality related to plotting.
agxSDK::Simulation::removeRigidBodyEvent
RigidBodyEvent removeRigidBodyEvent
Definition: Simulation.h:139
agx::Constraint1DOF
Specialization for constraints that have only one degree of freedom such as Hinge and Prismatic.
Definition: Constraint.h:673
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:51
agxSDK::Simulation::journalAttachedEvent
JournalAttachEvent journalAttachedEvent
Definition: Simulation.h:150
agxStream::Serializable
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
CALLABLE
#define CALLABLE
Definition: macros.h:72
agxSDK::Simulation::addMaterialEvent
MaterialEvent addMaterialEvent
Definition: Simulation.h:144
agx::Constraint2DOF
Specialization for constraints that have two degree of freedom such as Cylindrical.
Definition: Constraint.h:761
agxRender::RenderManager
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc.
Definition: RenderManager.h:106
agxSDK::Simulation::getConstraint2DOF
agx::Constraint2DOF * getConstraint2DOF(const agx::Name &name)
Definition: Simulation.h:1499
HashTable.h
agx::Prismatic
A prismatic joint keeps a fixed relative orientation between the attached bodies but allows them to s...
Definition: Prismatic.h:66
agxSDK::Simulation::getTimeStamp
agx::Real getTimeStamp() const
Definition: Simulation.h:1743
agxSDK::EventListener
An EventListener can be associated to a Simulation and triggered upon various events.
Definition: EventListener.h:40
agxNet::RemoteDebugClient
Class for receiving serialized agxSDK::Simulation:s from remote host.
Definition: RemoteDebugClient.h:35
agxSDK::Simulation::getSolveModels
const agx::SolveModelRefVector & getSolveModels() const
Definition: Simulation.h:1789
agxSDK::Simulation::getTimeStep
agx::Real getTimeStep() const
Definition: Simulation.h:1768
agx::CylindricalJoint
A cylindrical joint is similar to a prismatic joint but with an extra degree of freedom free (rotatio...
Definition: CylindricalJoint.h:64
Assembly.h
agxSDK::Simulation::GeometryEvent
agx::Event2< Simulation *, agxCollide::Geometry * > GeometryEvent
Definition: Simulation.h:128
agx::FrameRef
agx::ref_ptr< Frame > FrameRef
Definition: Frame.h:52
agx::Vec4T
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:34
agxData::EntityStorage
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:72
agxWire::Wire
Interface and placeholder of controllers/helpers for wires.
Definition: Wire.h:61
agxStream::RestoreListener
Class for listening to the restore of Serializable objects.
Definition: RestoreListener.h:29
agx::PrismaticUniversalJoint
A Prismatic Universal Joint has two translational dof's constrained.
Definition: PrismaticUniversalJoint.h:28
SimulationParameter.h
agx::AngularLockJoint
Constraint that removes 3 DOF (rotational degrees of freedom) between two bodies, or one body and the...
Definition: AngularLockJoint.h:29
agx::observer_ptr< Referenced >
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
agx::ParticleContactSensor
This class is for detecting and handling particle collisions with geometries in the simulation.
Definition: ParticleContactSensor.h:42
agxSDK::Simulation::allowCreateParticles
bool allowCreateParticles() const
Definition: Simulation.h:1784
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
Clock.h
agx::Model
A model is an abstract representation of the class of an agx::Object.
Definition: Model.h:40
agxStream::in
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:399
Space.h
agxSDK::MergeSplitHandler
Base class for a merge split algorithm handling a set of merged bodies.
Definition: MergeSplitHandler.h:34
agxSDK::Simulation::removeGeometryEvent
GeometryEvent removeGeometryEvent
Definition: Simulation.h:136
agxSDK::Assembly
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints,...
Definition: Assembly.h:67
agx::PlaneJoint
Definition: PlaneJoint.h:24
agx::Task
A representation of a generic task.
Definition: Task.h:57
StatisticsEntries.h
agxSDK::Simulation::MaterialEvent
agx::Event2< Simulation *, agx::Material * > MaterialEvent
Definition: Simulation.h:131
agx::ObserverFrame
With this class you can attach an ObserverFrame object relative to a RigidBody.
Definition: ObserverFrame.h:41
agx::ParticleSystem
A basic particle system that contains all the storages and buffers required for basic operation and a...
Definition: ParticleSystem.h:67
agx::ref_ptr< SimulationProxy >
agxSDK::PickHandler
Definition: agxSDK/PickHandler.h:36
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:125
agx::UInt8
uint8_t UInt8
Definition: Integer.h:30
agx::SetVector< ref_ptr< Constraint > >
agxWire
Implements a Wire model with adaptive resolution.
Definition: MergedBody.h:39
agxSDK::Simulation::getDynamicsSystem
agx::DynamicsSystem * getDynamicsSystem()
Definition: Simulation.h:1758
agxSDK::MaterialManager
Simulation unique manager that handles logics around and parameters in contact materials given two ag...
Definition: MaterialManager.h:49
agxSDK::Simulation::addConstraintEvent
ConstraintEvent addConstraintEvent
Definition: Simulation.h:141
agxSDK::Simulation::ConstraintEvent
agx::Event2< Simulation *, agx::Constraint * > ConstraintEvent
Definition: Simulation.h:130
agx::LinearProbingHashTable
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: LinearProbingHashTable.h:926
agx::Clock::getTime
agx::Real getTime() const
agxCollide::Geometry
The geometry representation used by the collision detection engine.
Definition: Geometry.h:91
Component.h
agxSDK::AssemblyHash
agx::HashVector< agxSDK::Assembly *, agxSDK::AssemblyRef > AssemblyHash
Definition: Simulation.h:116
agx::ContactMaterial
This class store the combine material properties between two agx::Material's.
Definition: Material.h:515
agxPlot::System
System that manages the plotting system.
Definition: System.h:38
agx::LockJoint
Constraint that removes all 6 DOF between two bodies, or one body and the world.
Definition: LockJoint.h:30
agx::TaskGroup
TaskGroup.
Definition: Task.h:585
agx::Name
Representation of a name string.
Definition: Name.h:32
agxStream::write
bool AGXPHYSICS_EXPORT write(const std::string &filename, const agxStream::Serializable *data)
Write a Serializable object to a file.
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
agxCollide::Space
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
Definition: Space.h:81
agx::Component
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:38
agx::BallJoint
Constraint that removes the three translation DOF between two bodies (or one and the world).
Definition: BallJoint.h:47
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:50
agx::UniversalJoint
A Universal Joint has one fixed relative point, the 3 translational dof's, and one constrained axis (...
Definition: UniversalJoint.h:28
agxSDK::Simulation::JournalAttachEvent
agx::Event2< Simulation *, agx::Journal * > JournalAttachEvent
Definition: Simulation.h:133
ActionManager.h
agxSDK::Simulation::removeMaterialEvent
MaterialEvent removeMaterialEvent
Definition: Simulation.h:145
agx::Interaction
The base class for interactions.
Definition: Interaction.h:31
agxPlot::DataSeries
Class that encapsulates data to be plotted, including methods for accessing the data,...
Definition: DataSeries.h:44
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agxSDK::Simulation::getSpace
agxCollide::Space * getSpace()
Definition: Simulation.h:1748
agxSDK::TerrainInstance
agxTerrain::Terrain instance in a simulation, receiving step and contact callbacks in a controllable ...
Definition: TerrainInstance.h:43
agx::Timer
The Timer class permits timing execution speed with the same refinement as the built in hardware cloc...
Definition: Timer.h:74
agxCollide
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Definition: ContactForceFilterParticipant.h:22
MaterialManager.h
agx::TimeStamp
agx::Real TimeStamp
Definition: TimeStamp.h:26
agxSDK::EnergyManager
Keeps track of the energy flow in the system.
Definition: agxSDK/EnergyManager.h:46
agx::Constraint
The base class for a constraint.
Definition: Constraint.h:88
agx::Thread
agx::Thread is a representation of an OS specific implementation of a computational thread.
Definition: Thread.h:198
agxSDK::Simulation::getConstraint1DOF
agx::Constraint1DOF * getConstraint1DOF(const agx::Name &name)
Definition: Simulation.h:1498
agxStream::read
bool AGXPHYSICS_EXPORT read(const std::string &filename, agxStream::SerializablePtrVector &readObjects)
Open and read serializable objects from a file on disk with previously stored objects.
GravityField.h
agx::Device
An agx::Device is an abstract representation of a device on which data can be stored and processed.
Definition: Device.h:57
agx::AgXString< std::string >
agx::StabilityReport
Definition: StabilityReport.h:36
agx::Hinge
The hinge constraint between two rigid bodies or one rigid body and the world.
Definition: Hinge.h:103
GETCONSTRAINT_TYPE
#define GETCONSTRAINT_TYPE(CLASS_NAME, TYPENAME)
Definition: Simulation.h:678
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
agx::Clock
Clock class keeps representation of virtual/simulated time.
Definition: Clock.h:37
agx::init
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API.
Frame.h
agxSDK::SimulationFrameWriter
Definition: SimulationTrack.FrameWriter.h:39
agx::DistanceJoint
This joint will preserve the initial distance between a body and a point in world coordinate or betwe...
Definition: DistanceJoint.h:27
SimulationStatisticsListener.h
agxSDK::Simulation::removeContactMaterialEvent
ContactMaterialEvent removeContactMaterialEvent
Definition: Simulation.h:148
agx::Material
Main material class which acts as a holder of a Surface Material and a Bulk material.
Definition: Material.h:375
agx::Vec3T< Real >
agx::Uuid
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
agxSDK::Simulation::addContactMaterialEvent
ContactMaterialEvent addContactMaterialEvent
Definition: Simulation.h:147
agx::GravityField
The class GravityField is responsible for calculating and applying a gravity force on a set of bodies...
Definition: GravityField.h:37
DynamicsSystem.h
agxTerrain::Profiler::clear
AGXTERRAIN_EXPORT void clear()
agx::DynamicsSystem
The complete physical system with bodies, interactions, data layout, time stepper,...
Definition: DynamicsSystem.h:63
agx::UInt32
uint32_t UInt32
Definition: Integer.h:32
agx::Event2< Simulation *, agxCollide::Geometry * >
agxCollide::GeometryTable
agx::HashTable< agxCollide::Geometry *, agx::ref_ptr< Geometry > > GeometryTable
Definition: agxcollide_hash_types.h:25
agx::MergedBody
Structure holding several "normal" rigid bodies.
Definition: MergedBody.h:55
agx::Emitter
Spawns new bodys inside a given volume.
Definition: Emitter.h:44
agx::HashVector< agxSDK::Assembly *, agxSDK::AssemblyRef >
agxSDK::Simulation::CleanupSelectionMask
CleanupSelectionMask
Specification of what should be cleaned up from a simulation during a call to the cleanup() method.
Definition: Simulation.h:991
agxSDK::SimulationStatisticsListener
This class will collect statistics and sizes of a simulation.
Definition: SimulationStatisticsListener.h:176
TimeStamp.h
agxSDK::Simulation::RigidBodyEvent
agx::Event2< Simulation *, agx::RigidBody * > RigidBodyEvent
Definition: Simulation.h:129
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agxSDK::SimulationFrameReader
Definition: SimulationTrack.FrameReader.h:39
agxNet
Containins classes for sending/reading data over sockets as well as compression functionality.
Definition: MacUtil.h:22
agxSDK::StatisticsEntries
Definition: StatisticsEntries.h:25
agxSDK.h
agxSDK::Simulation::getConstraint
const agx::Constraint * getConstraint(const agx::Uuid &uuid) const
Find (linear search) and return a pointer to a Constraint with the given uuid.
agxSDK::SimulationProxy
Interface class used by internal objects running in parallel.
Definition: SimulationProxy.h:49
agx::ref_ptr::get
T * get() const
Definition: ref_ptr.h:256
agxSDK::Simulation::addGeometryEvent
GeometryEvent addGeometryEvent
Definition: Simulation.h:135
agxSDK::Simulation::getClock
agx::Clock * getClock()
Definition: Simulation.h:1774
agxSDK::SimulationSerializer
class for serializing a simulation into a series for files on disk <filename>_0001....
Definition: agxSDK/SimulationSerializer.h:25