AGX Dynamics
2.38.0.2
DimensionState.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
18
#ifndef AGX_POWERLINE_PHYSICAL_DIMENSION_STATE_H
19
#define AGX_POWERLINE_PHYSICAL_DIMENSION_STATE_H
20
21
#include <
agx/Real.h
>
22
#include <
agx/Integer.h
>
23
#include <
agx/Jacobian.h
>
24
#include <
agx/RigidBody.h
>
25
#include <
agx/Referenced.h
>
26
#include <
agx/MergedBody.h
>
27
#include <
agx/Logger.h
>
28
29
#include <
agxPowerLine/DirectionReference.h
>
30
#include <
agxPowerLine/detail/DimensionStateStorage.h
>
31
32
#include <
agxModel/export.h
>
33
34
#include <
agxStream/StorageStream.h
>
35
36
37
namespace
agxPowerLine
38
{
39
class
SlotMapper;
40
class
PhysicalDimension;
41
class
PowerLine;
42
}
43
44
45
46
namespace
agxPowerLine
47
{
48
namespace
detail
49
{
71
class
AGXMODEL_EXPORT
DimensionState
:
public
agx::Referenced
,
public
agxStream::Serializable
72
{
73
public
:
74
virtual
agx::Real
getValue()
const
= 0;
75
virtual
void
setValue(
agx::Real
value) = 0;
76
77
virtual
agx::Real
getGradient()
const
= 0;
78
virtual
void
setGradient(
agx::Real
value) = 0;
79
80
virtual
agx::Real
getSecondGradient()
const
= 0;
81
82
virtual
agx::Vec3
getLocalDirection()
const
= 0;
83
virtual
agx::Vec3
getWorldDirection()
const
= 0;
84
virtual
agx::Vec3
getDirection()
const
= 0;
85
virtual
agxPowerLine::DirectionReference
getDirectionReference()
const
= 0;
86
87
virtual
agx::Real
getMassProperty()
const
= 0;
88
virtual
bool
setMassProperty(
agx::Real
massProperty) = 0;
89
90
virtual
void
addLoad(
agx::Real
load) = 0;
91
92
virtual
void
setVelocityDamping(
float
damping) = 0;
93
virtual
float
getVelocityDamping() = 0;
94
99
virtual
bool
isExternalBody()
const
= 0;
100
104
bool
getAllowsPacking()
const
;
105
112
virtual
void
reserveBody() = 0;
113
120
virtual
agx::RigidBody
* getReservedBody() = 0;
121
virtual
const
agx::RigidBody
* getReservedBody()
const
= 0;
122
123
128
agx::RigidBody
* getCurrentBody();
129
const
agx::RigidBody
* getCurrentBody()
const
;
130
134
const
agxPowerLine::PhysicalDimension
* getDimension()
const
;
135
136
virtual
void
calculateJacobian(
agx::Jacobian6DOFElement
* G,
agx::Real
ratio,
size_t
index)
const
= 0;
137
138
virtual
void
addNotification(
agxPowerLine::PowerLine
* powerLine) = 0;
139
virtual
void
removeNotification(
agxPowerLine::PowerLine
* powerLine) = 0;
140
141
virtual
void
postUpdate(
agx::Real
timeStep) = 0;
142
143
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE
(agxPowerLine::DimensionState)
144
virtual
void
store(
agxStream::OutputArchive
&
out
)
const override
;
145
virtual
void
restore(
agxStream::InputArchive
&
in
)
override
;
146
147
virtual
bool
store(
agxStream::StorageStream
&
out
)
const
;
148
virtual
bool
restore(
agxStream::StorageStream
&
in
);
149
150
protected
:
151
DimensionState
(
agx::RigidBody
* body,
PhysicalDimension
* dimension,
bool
allowPacking);
152
153
virtual
~
DimensionState
();
154
162
void
disallowPacking();
163
164
agx::Vec3
getWorldPosition()
const
;
165
166
agx::Vec3
getWorldVelocity()
const
;
167
168
const
agx::Frame
* getBodyFrame()
const
;
169
170
void
setBody(
agx::RigidBody
* newBody);
171
172
private
:
173
agx::RigidBodyRef
m_body;
174
agxPowerLine::PhysicalDimension
* m_dimension;
175
176
bool
m_allowsPacking;
177
};
178
179
AGX_DECLARE_POINTER_TYPES
(
DimensionState
);
180
181
182
183
184
185
186
192
class
AGXMODEL_EXPORT
AbstractDimensionState1Dof
:
public
DimensionState
193
{
194
public
:
195
virtual
agx::UInt8
getSlot()
const
= 0;
196
197
protected
:
198
AbstractDimensionState1Dof
(
agx::RigidBody
* body,
agxPowerLine::PhysicalDimension
* dimension,
bool
allowPacking);
199
};
200
201
202
203
209
template
<
typename
DimensionType>
210
class
AGXMODEL_EXPORT
DimensionState1Dof
:
public
AbstractDimensionState1Dof
211
{
212
public
:
213
DimensionState1Dof
(
agx::RigidBody
* body,
agxPowerLine::PhysicalDimension
* dimension,
agx::UInt8
slot);
214
215
virtual
agx::UInt8
getSlot()
const override
;
216
217
virtual
agx::Real
getValue()
const override
;
218
219
virtual
void
setValue(
agx::Real
value)
override
;
220
221
virtual
agx::Real
getGradient()
const override
;
222
223
virtual
void
setGradient(
agx::Real
gradient)
override
;
224
225
virtual
agx::Real
getSecondGradient()
const override
;
226
227
virtual
agx::Vec3
getLocalDirection()
const override
;
228
229
virtual
agx::Vec3
getWorldDirection()
const override
;
230
231
virtual
agx::Vec3
getDirection()
const override
;
232
233
virtual
agx::Real
getMassProperty()
const override
;
234
235
virtual
bool
setMassProperty(
agx::Real
massProperty)
override
;
236
237
virtual
void
addLoad(
agx::Real
load)
override
;
238
239
virtual
void
setVelocityDamping(
float
damping)
override
;
240
241
virtual
float
getVelocityDamping()
override
;
242
243
virtual
DirectionReference
getDirectionReference()
const override
;
244
245
virtual
bool
isExternalBody()
const override
;
246
247
virtual
void
calculateJacobian(
agx::Jacobian6DOFElement
* G,
agx::Real
ratio,
size_t
index)
const override
;
248
249
virtual
void
addNotification(
agxPowerLine::PowerLine
* powerLine)
override
;
250
virtual
void
removeNotification(
agxPowerLine::PowerLine
* powerLine)
override
;
251
252
259
virtual
agx::RigidBody
* getReservedBody()
override
;
260
virtual
const
agx::RigidBody
* getReservedBody()
const override
;
261
269
virtual
void
reserveBody()
override
;
270
279
void
split();
280
293
void
move(
agx::RigidBody
* body,
agx::UInt8
slot);
294
295
SlotMapper
* getSlotMapper();
296
297
virtual
void
postUpdate(
agx::Real
timeStep)
override
;
298
299
virtual
agxStream::StorageAgent* getStorageAgent()
const override
;
300
static
const
char
* getConstructClassId();
301
friend
class
agxStream::DefStorageAgent<
DimensionState1Dof
<DimensionType>>;
302
virtual
const
char
* getClassName()
const override
;
303
static
agxStream::Serializable
* create();
304
static
agxStream::Serializable
* create(
agxStream::InputArchive
&);
305
306
virtual
void
store(
agxStream::OutputArchive
&
out
)
const override
;
307
virtual
void
restore(
agxStream::InputArchive
&
in
)
override
;
308
309
virtual
bool
store(
agxStream::StorageStream
&
out
)
const override
;
310
virtual
bool
restore(
agxStream::StorageStream
&
in
)
override
;
311
312
private
:
313
friend
class
agxPowerLine::SlotMapper
;
314
315
316
protected
:
317
DimensionState1Dof
();
// For serialization only.
318
virtual
~
DimensionState1Dof
();
319
void
reserveImpl();
320
void
splitImpl();
321
void
moveImpl(
agx::RigidBody
* newBody,
agx::UInt8
newSlot);
322
323
private
:
324
agx::UInt8
m_slot;
325
DimensionType m_storage;
326
};
327
328
329
336
class
AGXMODEL_EXPORT
AbstractDimensionState3Dof
:
public
DimensionState
337
{
338
public
:
339
virtual
void
setLocalDirection(
const
agx::Vec3
& direction) = 0;
340
virtual
void
setWorldDirection(
const
agx::Vec3
& direction) = 0;
341
342
protected
:
343
AbstractDimensionState3Dof
(
agx::RigidBody
* body,
agxPowerLine::PhysicalDimension
* dimension);
344
};
345
346
347
353
template
<
typename
DimensionType>
354
class
AGXMODEL_EXPORT
DimensionState3Dof
:
public
AbstractDimensionState3Dof
355
{
356
public
:
357
DimensionState3Dof
(
358
agx::RigidBody
* body,
359
agxPowerLine::PhysicalDimension
* dimension,
360
const
agx::Vec3
& direction,
361
DirectionReference
directionReference);
362
363
DimensionState3Dof
(
364
agx::RigidBody
* body,
365
agxPowerLine::PhysicalDimension
* dimension,
366
const
agx::Vec3
& direction,
367
DirectionReference
directionReference,
368
bool
externalBody);
369
370
virtual
agx::Real
getValue()
const override
;
371
372
virtual
void
setValue(
agx::Real
value)
override
;
373
374
virtual
agx::Real
getGradient()
const override
;
375
376
virtual
void
setGradient(
agx::Real
gradient)
override
;
377
378
virtual
agx::Real
getSecondGradient()
const override
;
379
380
virtual
agx::Vec3
getLocalDirection()
const override
;
381
382
virtual
void
setLocalDirection(
const
agx::Vec3
& direction)
override
;
383
384
virtual
agx::Vec3
getWorldDirection()
const override
;
385
386
virtual
void
setWorldDirection(
const
agx::Vec3
& direction)
override
;
387
388
virtual
agx::Vec3
getDirection()
const override
;
389
390
virtual
agx::Real
getMassProperty()
const override
;
391
392
virtual
bool
setMassProperty(
agx::Real
massProperty)
override
;
393
394
virtual
void
addLoad(
agx::Real
load)
override
;
395
396
virtual
void
setVelocityDamping(
float
damping)
override
;
397
virtual
float
getVelocityDamping()
override
;
398
399
virtual
DirectionReference
getDirectionReference()
const override
;
400
401
virtual
bool
isExternalBody()
const override
;
402
403
virtual
void
reserveBody()
override
;
404
virtual
agx::RigidBody
* getReservedBody()
override
;
405
virtual
const
agx::RigidBody
* getReservedBody()
const override
;
406
407
virtual
void
calculateJacobian(
agx::Jacobian6DOFElement
* G,
agx::Real
ratio,
size_t
index)
const override
;
408
409
virtual
void
addNotification(
agxPowerLine::PowerLine
* powerLine)
override
;
410
virtual
void
removeNotification(
agxPowerLine::PowerLine
* powerLine)
override
;
411
412
virtual
void
postUpdate(
agx::Real
/*timeStep*/
)
override
;
413
414
virtual
bool
store(
agxStream::StorageStream
&
out
)
const override
;
415
virtual
bool
restore(
agxStream::StorageStream
&
in
)
override
;
416
417
virtual
void
store(
agxStream::OutputArchive
&
out
)
const override
;
418
virtual
void
restore(
agxStream::InputArchive
&
in
)
override
;
419
420
virtual
agxStream::StorageAgent* getStorageAgent()
const override
;
421
static
const
char
* getConstructClassId();
422
friend
class
agxStream::DefStorageAgent<
DimensionState1Dof
<DimensionType>>;
423
virtual
const
char
* getClassName()
const override
;
424
static
agxStream::Serializable
* create();
425
static
agxStream::Serializable
* create(
agxStream::InputArchive
&);
426
427
428
protected
:
429
virtual
~
DimensionState3Dof
();
430
431
private
:
432
DimensionState3Dof
();
433
434
void
calculateMergedBodyJacobian(
435
agx::Jacobian6DOFElement
*
/*G*/
,
436
agx::Real
/*ratio*/
,
437
size_t
/*index*/
,
438
const
agx::MergedBody
*
/*mergedBody*/
)
const
;
439
440
void
printInvalidDirectionReference()
const
;
441
442
private
:
443
agx::Vec3
m_direction;
444
DirectionReference
m_directionReference;
445
DimensionType m_storage;
446
bool
m_externalBody;
// Will this ever be false? When?
447
};
448
449
// Some human friendly names for the four possible combinations of degrees
450
// of freedom and storage location in the rigid body.
451
using
Translational1DofState
=
DimensionState1Dof<Translational>
;
452
using
Translational3DofState
=
DimensionState3Dof<Translational>
;
453
using
Rotational1DofState
=
DimensionState1Dof<Rotational>
;
454
using
Rotational3DofState
=
DimensionState3Dof<Rotational>
;
455
}
456
}
457
458
#endif
Referenced.h
Jacobian.h
agx::Real
double Real
Definition:
Real.h:42
agx::Jacobian6DOFElementT
Definition:
Jacobian.h:104
agxStream::out
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
Definition:
OutputArchive.h:412
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition:
RigidBody.h:51
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
export.h
agxStream::StorageStream
Abstract base class for storing/restoring a line/drums with version control.
Definition:
StorageStream.h:48
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
Definition:
Serializable.h:221
DimensionStateStorage.h
agxPowerLine::PhysicalDimension
Pure virtual class.
Definition:
PhysicalDimension.h:92
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
agxPowerLine::detail::DimensionState
A DimensionState is the data carrier of a PhysicalDimension.
Definition:
DimensionState.h:71
agx::ref_ptr< RigidBody >
agx::UInt8
uint8_t UInt8
Definition:
Integer.h:30
MergedBody.h
Logger.h
Integer.h
agxPowerLine::PowerLine
PowerLine is the base class for a system of power transfer integrated into the rigid body simulation.
Definition:
PowerLine.h:65
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition:
OutputArchive.h:56
agxPowerLine::SlotMapper
The SlotMapper is reponsible for mapping one dimensional dimension states to slots in the RigidBodies...
Definition:
SlotMapper.h:50
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition:
InputArchive.h:50
RigidBody.h
agx::Referenced
Base class providing referencing counted objects.
Definition:
Referenced.h:119
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition:
Referenced.h:254
agxPowerLine
agxPowerLine contains a collection of connected components that transport power across a system.
Definition:
MotorUnit.h:23
DirectionReference.h
agxPowerLine::detail::DimensionState1Dof
Templated one dimensional dimension state.
Definition:
DimensionState.h:210
agxPowerLine::detail::AbstractDimensionState1Dof
Base class for the two one dimensional dimension state classes.
Definition:
DimensionState.h:192
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition:
agxModel/export.h:42
agxPowerLine::detail::DimensionState3Dof
Templated three dimensional dimension state.
Definition:
DimensionState.h:354
agxPowerLine::detail::AbstractDimensionState3Dof
Base class for the two three dimensional dimension state classes.
Definition:
DimensionState.h:336
agxPowerLine::DirectionReference
DirectionReference
The DirectionReference specifies what the direction attribute of a DimensionState is relative to.
Definition:
DirectionReference.h:25
agx::Vec3T< Real >
Real.h
agx::Frame
The object defining a frame of reference and providing transformations operations.
Definition:
Frame.h:67
agx::MergedBody
Structure holding several "normal" rigid bodies.
Definition:
MergedBody.h:55
StorageStream.h
include
agxPowerLine
detail
DimensionState.h
Generated on Sun Sep 1 2024 11:18:36 for AGX Dynamics by
1.8.17