AGX Dynamics
2.38.0.2
ContactMeasurement.h
Go to the documentation of this file.
1
/*
2
Copyright 2007-2023. 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
#ifndef AGXMODEL_CONTACTMEASUREMENT_H
20
#define AGXMODEL_CONTACTMEASUREMENT_H
21
22
#include <map>
23
#include <unordered_map>
24
25
#include <
agx/RigidBody.h
>
26
#include <
agxCollide/Geometry.h
>
27
#include <
agxCollide/Shape.h
>
28
#include <
agxModel/export.h
>
29
#include <
agx/Journal.h
>
30
#include <
agxData/Buffer.h
>
31
32
#include <
agxSDK/StepEventListener.h
>
33
#include <
agxSDK/ContactEventListener.h
>
34
35
#include <
agx/BitState.h
>
36
37
namespace
agxModel
38
{
51
AGX_DECLARE_POINTER_TYPES
(
ContactMeasurement
);
52
53
class
AGXMODEL_EXPORT
ContactMeasurement
:
public
agxSDK::StepEventListener
54
{
55
public
:
61
ContactMeasurement
(
bool
onlyEmittedBodies=
true
);
62
67
void
setEnableDebugRendering(
agx::Bool
enable );
68
72
agx::Bool
getEnableDebugRendering()
const
;
73
78
virtual
void
pre(
const
agx::TimeStamp
& time)
override
;
79
84
virtual
void
post(
const
agx::TimeStamp
& time)
override
;
85
90
virtual
void
addNotification()
override
;
91
96
static
ContactMeasurement
* getListener(
agxSDK::Simulation
* simulation);
97
102
agx::Real
getMaxImpactEnergy(
agx::RigidBody
* body);
103
107
void
journalAttachedCallback(
agxSDK::Simulation
* simulation,
agx::Journal
* journal);
108
109
public
:
110
DOXYGEN_START_INTERNAL_BLOCK
()
111
112
#ifndef SWIG
113
AGXSTREAM_DECLARE_SERIALIZABLE
(
agxModel::ContactMeasurement
);
114
#endif
115
116
protected
:
117
void
storeChangedImpacts();
118
119
void
restoreImpacts();
120
121
void
initImpactEnergyStorage();
122
123
void
createJournalBindings(
agx::Journal
* journal);
124
125
agxData::Buffer
* getMaxImpactBuffer();
126
128
// Variables
130
protected
:
131
agxSDK::Simulation::JournalAttachEvent::CallbackType
m_journalAttachedCallback;
132
agxData::BufferRef
m_maxImpactBuffer;
133
agx::ComponentRef
m_dataRoot;
134
agx::Uuid
m_dataRootUUID;
135
agx::JournalObserver
m_journal;
136
137
138
protected
:
139
DOXYGEN_END_INTERNAL_BLOCK
()
140
141
private
:
142
void
calculateImpactEnergy(
const
agxCollide::GeometryContactPtrVector
& contacts, std::unordered_map<
agx::Index
, std::vector<agx::Vec3f>> preImpactSpeeds);
143
144
145
enum
StateEnum :
agx::UInt32
146
{
147
DEBUG_RENDER = 1 << 0,
148
};
149
using
State = agx::BitState<StateEnum, agx::UInt32>;
150
151
private
:
152
agxSDK::ContactEventListenerRef
m_listener;
153
State m_state;
154
std::map<agx::UInt32, agx::Real> m_maxImpactEnergies;
155
bool
m_onlyEmittedBodies;
156
bool
m_clearMaxImpacts;
157
int
m_numNonEmittedBodies;
158
};
159
}
160
#endif
Shape.h
agx::Journal
Definition:
Journal.h:46
agx::Real
double Real
Definition:
Real.h:42
agxModel
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition:
FlowUnit.h:36
agxSDK::StepEventListener
Derive from this class to implement a listener for simulation step events.
Definition:
StepEventListener.h:37
BitState.h
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition:
RigidBody.h:51
export.h
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition:
macros.h:97
Geometry.h
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition:
macros.h:96
StepEventListener.h
AGXSTREAM_DECLARE_SERIALIZABLE
#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
agx::VectorPOD< GeometryContact * >
agx::observer_ptr< Journal >
agx::ref_ptr< Buffer >
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition:
Simulation.h:125
agxModel::ContactMeasurement
Definition:
ContactMeasurement.h:53
Journal.h
agx::Index
UInt32 Index
Definition:
Integer.h:44
agxData::Buffer
Abstract representation of a data buffer.
Definition:
Buffer.h:55
Buffer.h
RigidBody.h
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition:
Referenced.h:254
ContactEventListener.h
agx::Bool
bool Bool
Definition:
Integer.h:40
agx::TimeStamp
agx::Real TimeStamp
Definition:
TimeStamp.h:26
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition:
agxModel/export.h:42
agx::Uuid
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition:
Uuid.h:41
agx::Callback2
Templated callback with two arguments.
Definition:
Callback.h:139
agx::UInt32
uint32_t UInt32
Definition:
Integer.h:32
include
agxModel
ContactMeasurement.h
Generated on Sun Sep 1 2024 11:18:33 for AGX Dynamics by
1.8.17