AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
GranularBodyEntity.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or
9having been advised so by Algoryx Simulation AB for a time limited evaluation,
10or having purchased a valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
18// AUTOMATICALLY GENERATED ENTITY, DO NOT EDIT! //
20
21#ifndef GENERATED_AGX_PHYSICS_GRANULARBODY_H_PLUGIN
22#define GENERATED_AGX_PHYSICS_GRANULARBODY_H_PLUGIN
23
24#define AGX_ENTITY_WRAPPER 1
25
26
27#ifdef _MSC_VER
28# pragma warning(push)
29// warning C4505: 'agxData::VectorAttributeT<T>::print' : unreferenced local function has been removed
30# pragma warning( disable : 4505 )
31// warning C4251: 'X' : class 'Y' needs to have dll-interface to be used by clients of class 'Z'
32# pragma warning( disable : 4251 )
33// warning C4355: 'this' : used in base member initializer list
34# pragma warning( disable : 4355 )
35// marked as __forceinline not inlined
36# pragma warning( disable: 4714 )
37#endif
38
39#include <agxData/EntityModel.h>
41#include <agxData/EntityRef.h>
42#include <agxData/EntityPtr.h>
44#include <agx/Integer.h>
45#include <agx/Real.h>
46#include <agx/macros.h>
48#include <agx/Vec3.h>
49#include <agx/Quat.h>
50#include <agx/Real.h>
51
52
53namespace agx
54{
55 namespace Physics
56 {
57
58 class GranularBodyModel;
59 class GranularBodyData;
60 class GranularBodyPtr;
61 class GranularBodyInstance;
62 class GranularBodySemantics;
63
64
66
71 {
72 public:
74
75 GranularBodyModel(const agx::String& name = "GranularBody");
76
79
82
85
87 virtual void shutdownCleanup() override;
88
89
90
91 /* Attributes */
98
99 protected:
101 virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
102 virtual void configure(agx::TiXmlElement* eEntity) override;
103 virtual void initAttributeAccessors() override;
104 virtual void construct(agxData::EntityPtr instance) override;
106 };
107
108
110 #ifndef AGX_PHYSICS_GRANULARBODY_DATA_SET_OVERRIDE
111 #define AGX_PHYSICS_GRANULARBODY_DATA_SET
112 class AGXPHYSICS_EXPORT GranularBodyData : public agx::Physics::ParticleData
113 {
114 public:
115 GranularBodyInstance operator[] (size_t index);
116
117 public:
119 agxData::Array< agx::Vec3 > angularVelocity;
120 agxData::Array< agx::Vec3 > oldAngularVelocity;
125
126 public:
127 typedef agx::Vec3 angularVelocityType;
128 typedef agx::Vec3 oldAngularVelocityType;
129 typedef agx::Quat rotationType;
130 typedef agx::Vec3 torqueType;
131 typedef agx::Real inertiaType;
132 typedef agx::Real invInertiaType;
133
134 public:
135 GranularBodyData(agxData::EntityStorage* storage);
136 GranularBodyData();
137
138 protected:
139 virtual ~GranularBodyData() {}
140 virtual void setNumElements(agx::Index numElements) override;
141
142 private:
143 GranularBodyData& operator= (const GranularBodyData&) { return *this; }
144
145 };
146 #endif
148
149
151 class AGXPHYSICS_EXPORT GranularBodySemantics : public agx::Physics::ParticleSemantics
152 {
153 public:
154
155 // Automatic getters
156 agx::Vec3 const& getAngularVelocity() const;
157 agx::Vec3 const& getOldAngularVelocity() const;
158 agx::Quat const& getRotation() const;
159 agx::Vec3 const& getTorque() const;
160 agx::Real const& getInertia() const;
161 agx::Real const& getInvInertia() const;
162
163 // Semantics defined by explicit kernels
164 void integratePosition(const agx::Real& clock_timeStep);
165 void integrateVelocity(const agx::Real& clock_timeStep);
166 void setAngularVelocity(const agx::Vec3& angularVelocity);
167 void setMass(const agx::Real& mass);
168 void setMaterial(const agx::Physics::MaterialPtr& material);
169 void setRadius(const agx::Real& radius);
170
171 // Automatic setters
172 void setOldAngularVelocity(agx::Vec3 const& value);
173 void setRotation(agx::Quat const& value);
174 void setTorque(agx::Vec3 const& value);
175 void setInertia(agx::Real const& value);
176 void setInvInertia(agx::Real const& value);
177
178
179 protected:
180 friend class GranularBodyPtr;
181 friend class GranularBodyInstance;
182 GranularBodySemantics();
183 };
185
186
187
190 class CALLABLE GranularBodyPtr : public agx::Physics::ParticlePtr
191 {
192 public:
194 typedef GranularBodyData DataType;
195 typedef GranularBodyInstance InstanceType;
196
197 public:
204 AGXPHYSICS_EXPORT GranularBodyInstance instance();
205 AGXPHYSICS_EXPORT const GranularBodyInstance instance() const;
206
207 AGXPHYSICS_EXPORT GranularBodySemantics* operator->();
208 AGXPHYSICS_EXPORT const GranularBodySemantics* operator->() const;
209
210 GranularBodyData* getData();
211 const GranularBodyData* getData() const;
212
213
218
223
228
233
238
243
244 };
245
246
248 class AGXPHYSICS_EXPORT GranularBodyInstance : public agx::Physics::ParticleInstance
249 {
250 public:
251 GranularBodyInstance();
252 GranularBodyInstance(GranularBodyData* data, agx::Index index);
253 GranularBodyInstance(agxData::EntityStorage *storage, agx::Index index);
254 GranularBodyInstance(const agxData::EntityInstance& other);
255 GranularBodyInstance(const agxData::EntityPtr& ptr);
256
257 GranularBodyData* getData();
258 const GranularBodyData* getData() const;
259
260 public:
262 agx::Vec3& angularVelocity();
264 agx::Vec3 const& angularVelocity() const;
265
267 agx::Vec3& oldAngularVelocity();
269 agx::Vec3 const& oldAngularVelocity() const;
270
272 agx::Quat& rotation();
274 agx::Quat const& rotation() const;
275
277 agx::Vec3& torque();
279 agx::Vec3 const& torque() const;
280
282 agx::Real& inertia();
284 agx::Real const& inertia() const;
285
287 agx::Real& invInertia();
289 agx::Real const& invInertia() const;
290
291 };
293
294
295
298
299
300
302 /* Implementation */
303 //-----------------------------------------------------------------------------------------------------
304 //-----------------------------------------------------------------------------------------------------
305 inline GranularBodyInstance agx::Physics::GranularBodyData::operator[] (size_t index) { return GranularBodyInstance(this, (agx::Index)index); }
306 //-----------------------------------------------------------------------------------------------------
308 AGX_FORCE_INLINE GranularBodyPtr::GranularBodyPtr(agxData::EntityStorage* storage, agx::Index id) : agx::Physics::ParticlePtr(storage, id) {}
309 AGX_FORCE_INLINE GranularBodyPtr::GranularBodyPtr(const agxData::EntityPtr& ptr) : agx::Physics::ParticlePtr(ptr)
310 {
312 "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
313 EntityPtr::getModel()->fullPath().c_str(), GranularBodyModel::instance()->fullPath().c_str());
314 }
315
316 AGX_FORCE_INLINE GranularBodyPtr::GranularBodyPtr(const agxData::EntityInstance& instance) : agx::Physics::ParticlePtr(instance)
317 {
318 agxAssertN(!instance || instance.isInstanceOf(GranularBodyModel::instance()),
319 "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
320 EntityPtr::getModel()->fullPath().c_str(), GranularBodyModel::instance()->fullPath().c_str());
321 }
322
323 AGX_FORCE_INLINE GranularBodyPtr& GranularBodyPtr::operator= (const agxData::EntityPtr& ptr)
324 {
326 agxAssertN(!ptr || ptr.isInstanceOf(GranularBodyModel::instance()),
327 "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
328 EntityPtr::getModel()->fullPath().c_str(), GranularBodyModel::instance()->fullPath().c_str());
329 return *this;
330 }
331
332 AGX_FORCE_INLINE GranularBodyPtr& GranularBodyPtr::operator= (const agxData::EntityInstance& instance)
333 {
335 agxAssertN(!instance || instance.isInstanceOf(GranularBodyModel::instance()),
336 "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
337 EntityPtr::getModel()->fullPath().c_str(), GranularBodyModel::instance()->fullPath().c_str());
338 return *this;
339 }
340
341 inline GranularBodyInstance GranularBodyPtr::instance() { return agxData::EntityPtr::instance(); }
342 inline const GranularBodyInstance GranularBodyPtr::instance() const { return agxData::EntityPtr::instance(); }
343 AGX_FORCE_INLINE GranularBodySemantics* GranularBodyPtr::operator->() { return (GranularBodySemantics* )this; }
344 AGX_FORCE_INLINE const GranularBodySemantics* GranularBodyPtr::operator->() const { return (const GranularBodySemantics* )this; }
345 AGX_FORCE_INLINE GranularBodyData* GranularBodyPtr::getData() { return static_cast<GranularBodyData* >(agxData::EntityPtr::getData()); }
346 AGX_FORCE_INLINE const GranularBodyData* GranularBodyPtr::getData() const { return static_cast<const GranularBodyData* >(agxData::EntityPtr::getData()); }
347
348 AGX_FORCE_INLINE agx::Vec3& GranularBodyPtr::angularVelocity() { verifyIndex(); return getData()->angularVelocity[calculateIndex()]; }
349 AGX_FORCE_INLINE agx::Vec3 const& GranularBodyPtr::angularVelocity() const { verifyIndex(); return getData()->angularVelocity[calculateIndex()]; }
350
351 AGX_FORCE_INLINE agx::Vec3& GranularBodyPtr::oldAngularVelocity() { verifyIndex(); return getData()->oldAngularVelocity[calculateIndex()]; }
352 AGX_FORCE_INLINE agx::Vec3 const& GranularBodyPtr::oldAngularVelocity() const { verifyIndex(); return getData()->oldAngularVelocity[calculateIndex()]; }
353
354 AGX_FORCE_INLINE agx::Quat& GranularBodyPtr::rotation() { verifyIndex(); return getData()->rotation[calculateIndex()]; }
355 AGX_FORCE_INLINE agx::Quat const& GranularBodyPtr::rotation() const { verifyIndex(); return getData()->rotation[calculateIndex()]; }
356
357 AGX_FORCE_INLINE agx::Vec3& GranularBodyPtr::torque() { verifyIndex(); return getData()->torque[calculateIndex()]; }
358 AGX_FORCE_INLINE agx::Vec3 const& GranularBodyPtr::torque() const { verifyIndex(); return getData()->torque[calculateIndex()]; }
359
360 AGX_FORCE_INLINE agx::Real& GranularBodyPtr::inertia() { verifyIndex(); return getData()->inertia[calculateIndex()]; }
361 AGX_FORCE_INLINE agx::Real const& GranularBodyPtr::inertia() const { verifyIndex(); return getData()->inertia[calculateIndex()]; }
362
363 AGX_FORCE_INLINE agx::Real& GranularBodyPtr::invInertia() { verifyIndex(); return getData()->invInertia[calculateIndex()]; }
364 AGX_FORCE_INLINE agx::Real const& GranularBodyPtr::invInertia() const { verifyIndex(); return getData()->invInertia[calculateIndex()]; }
365
366 //-----------------------------------------------------------------------------------------------------
367 AGX_FORCE_INLINE GranularBodyInstance::GranularBodyInstance() {}
368 AGX_FORCE_INLINE GranularBodyInstance::GranularBodyInstance(GranularBodyData* data, agx::Index index) : agx::Physics::ParticleInstance(data, index) {}
369 AGX_FORCE_INLINE GranularBodyInstance::GranularBodyInstance(agxData::EntityStorage* storage, agx::Index index) : agx::Physics::ParticleInstance(storage, index) {}
370 AGX_FORCE_INLINE GranularBodyInstance::GranularBodyInstance(const agxData::EntityInstance& other) : agx::Physics::ParticleInstance(other)
371 {
373 "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
374 EntityInstance::getModel()->fullPath().c_str(), GranularBodyModel::instance()->fullPath().c_str());
375 }
376
377 AGX_FORCE_INLINE GranularBodyInstance::GranularBodyInstance(const agxData::EntityPtr& ptr) : agx::Physics::ParticleInstance(ptr)
378 {
380 "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
381 EntityInstance::getModel()->fullPath().c_str(), GranularBodyModel::instance()->fullPath().c_str());
382 }
383
384
385 AGX_FORCE_INLINE GranularBodyData* GranularBodyInstance::getData() { return static_cast<GranularBodyData* >(agxData::EntityInstance::getData()); }
386 AGX_FORCE_INLINE const GranularBodyData* GranularBodyInstance::getData() const { return static_cast<const GranularBodyData* >(agxData::EntityInstance::getData()); }
387
388 AGX_FORCE_INLINE agx::Vec3& GranularBodyInstance::angularVelocity() { verifyIndex(); return getData()->angularVelocity[getIndex()]; }
389 AGX_FORCE_INLINE agx::Vec3 const& GranularBodyInstance::angularVelocity() const { verifyIndex(); return getData()->angularVelocity[getIndex()]; }
390
391 AGX_FORCE_INLINE agx::Vec3& GranularBodyInstance::oldAngularVelocity() { verifyIndex(); return getData()->oldAngularVelocity[getIndex()]; }
392 AGX_FORCE_INLINE agx::Vec3 const& GranularBodyInstance::oldAngularVelocity() const { verifyIndex(); return getData()->oldAngularVelocity[getIndex()]; }
393
394 AGX_FORCE_INLINE agx::Quat& GranularBodyInstance::rotation() { verifyIndex(); return getData()->rotation[getIndex()]; }
395 AGX_FORCE_INLINE agx::Quat const& GranularBodyInstance::rotation() const { verifyIndex(); return getData()->rotation[getIndex()]; }
396
397 AGX_FORCE_INLINE agx::Vec3& GranularBodyInstance::torque() { verifyIndex(); return getData()->torque[getIndex()]; }
398 AGX_FORCE_INLINE agx::Vec3 const& GranularBodyInstance::torque() const { verifyIndex(); return getData()->torque[getIndex()]; }
399
400 AGX_FORCE_INLINE agx::Real& GranularBodyInstance::inertia() { verifyIndex(); return getData()->inertia[getIndex()]; }
401 AGX_FORCE_INLINE agx::Real const& GranularBodyInstance::inertia() const { verifyIndex(); return getData()->inertia[getIndex()]; }
402
403 AGX_FORCE_INLINE agx::Real& GranularBodyInstance::invInertia() { verifyIndex(); return getData()->invInertia[getIndex()]; }
404 AGX_FORCE_INLINE agx::Real const& GranularBodyInstance::invInertia() const { verifyIndex(); return getData()->invInertia[getIndex()]; }
405
406 //-----------------------------------------------------------------------------------------------------
407 AGX_FORCE_INLINE GranularBodySemantics::GranularBodySemantics() {}
408 //-----------------------------------------------------------------------------------------------------
410 }
411}
412
413AGX_TYPE_BINDING(agx::Physics::GranularBodyPtr, "Physics.GranularBodyPtr")
414AGX_TYPE_BINDING(agx::Physics::GranularBodyInstance, "Physics.GranularBodyInstance")
415
416#ifdef _MSC_VER
417# pragma warning(pop)
418#endif
419
420#undef AGX_ENTITY_WRAPPER
421#undef AGX_ENTITY_NAMESPACE
422#endif
423
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
#define AGXPHYSICS_EXPORT
Type-specific Array used for fast access into the data held by a Buffer.
Definition: Array.h:107
Entity instance provides access to a single instance in an EntityStorage.
bool isInstanceOf(agxData::EntityModel *model) const
agxData::EntityData * getData()
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition: EntityPtr.h:52
EntityPtr & operator=(const EntityPtr &other)=default
bool isInstanceOf(agxData::EntityModel *model) const
agxData::EntityData * getData()
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:73
agx::String fullPath() const
Abstract description of the data attributes for the Physics.GranularBody entity.
static GranularBodyPtr createInstance()
Create and return a pointer to a new instance in the default storage for this entity model.
void construct(agx::Physics::GranularBodyPtr granularBody)
static agxData::ScalarAttributeT< agx::Real > * inertiaAttribute
static agxData::ScalarAttributeT< agx::Real > * invInertiaAttribute
static GranularBodyModel * instance()
virtual void initAttributeAccessors() override
virtual void construct(agxData::EntityPtr instance) override
static agxData::ScalarAttributeT< agx::Quat > * rotationAttribute
GranularBodyModel(const agx::String &name="GranularBody")
virtual agxData::EntityData * createData(agxData::EntityStorage *storage) override
static agxData::EntityStorage * defaultStorage()
static agxData::ScalarAttributeT< agx::Vec3 > * oldAngularVelocityAttribute
virtual void shutdownCleanup() override
This is part of internal cleanup and should not be called by users.
static agxData::ScalarAttributeT< agx::Vec3 > * torqueAttribute
static agxData::ScalarAttributeT< agx::Vec3 > * angularVelocityAttribute
virtual void configure(agx::TiXmlElement *eEntity) override
Pointer to a entity instance of type Physics.GranularBody.
AGXPHYSICS_EXPORT agx::Real & invInertia()
AGXPHYSICS_EXPORT GranularBodyPtr()
AGXPHYSICS_EXPORT agx::Real & inertia()
AGXPHYSICS_EXPORT agx::Vec3 const & angularVelocity() const
GranularBodyInstance InstanceType
AGXPHYSICS_EXPORT GranularBodyPtr(agxData::EntityStorage *storage, agx::Index id)
AGXPHYSICS_EXPORT agx::Vec3 & oldAngularVelocity()
AGXPHYSICS_EXPORT agx::Vec3 const & oldAngularVelocity() const
AGXPHYSICS_EXPORT const GranularBodyInstance instance() const
AGXPHYSICS_EXPORT GranularBodyPtr(const agxData::EntityInstance &instance)
const GranularBodyData * getData() const
AGXPHYSICS_EXPORT agx::Vec3 & angularVelocity()
AGXPHYSICS_EXPORT agx::Real const & inertia() const
AGXPHYSICS_EXPORT GranularBodySemantics * operator->()
GranularBodyData * getData()
AGXPHYSICS_EXPORT agx::Quat & rotation()
AGXPHYSICS_EXPORT agx::Vec3 & torque()
AGXPHYSICS_EXPORT agx::Quat const & rotation() const
AGXPHYSICS_EXPORT GranularBodyInstance instance()
AGXPHYSICS_EXPORT agx::Real const & invInertia() const
AGXPHYSICS_EXPORT const GranularBodySemantics * operator->() const
AGXPHYSICS_EXPORT GranularBodyPtr(const agxData::EntityPtr &ptr)
AGXPHYSICS_EXPORT agx::Vec3 const & torque() const
Pointer to a entity instance of type Physics.Material.
Abstract description of the data attributes for the Physics.Particle entity.
Pointer to a entity instance of type Physics.Particle.
Vector containing 'raw' data.
Definition: agx/Vector.h:246
#define agxAssertN(expr, format,...)
Definition: debug.h:145
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define CALLABLE
Definition: macros.h:72
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
#define AGX_FORCE_INLINE
Definition: macros.h:58
Contains classes for low level data storage for AGX.
Definition: Container.h:23
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:41
UInt32 Index
Definition: Integer.h:44