AGX Dynamics  2.37.2.0
SolveParticleEntity.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
9 having been advised so by Algoryx Simulation AB for a time limited evaluation,
10 or having purchased a 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 
18 // AUTOMATICALLY GENERATED ENTITY, DO NOT EDIT! //
20 
21 #ifndef GENERATED_AGX_PHYSICS_SOLVEPARTICLE_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_SOLVEPARTICLE_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>
40 #include <agxData/EntityStorage.h>
41 #include <agxData/EntityRef.h>
42 #include <agxData/EntityPtr.h>
43 #include <agxData/EntityInstance.h>
44 #include <agx/Integer.h>
45 #include <agx/Real.h>
46 #include <agx/macros.h>
47 #include <agx/Vec3.h>
48 #include <agx/Real.h>
49 #include <agx/Integer.h>
50 
51 
52 namespace agx
53 {
54  namespace Physics
55  {
56 
57  class SolveParticleModel;
58  class SolveParticleData;
59  class SolveParticlePtr;
60  class SolveParticleInstance;
61  class SolveParticleSemantics;
62 
63 
65 
70  {
71  public:
73 
74  SolveParticleModel(const agx::String& name = "SolveParticle");
75 
77  static SolveParticleModel* instance();
78 
80  static SolveParticlePtr createInstance();
81 
83  static agxData::EntityStorage* defaultStorage();
84 
86  virtual void shutdownCleanup() override;
87 
88 
89 
90  /* Attributes */
98 
99  protected:
100  virtual ~SolveParticleModel();
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;
105  void construct(agx::Physics::SolveParticlePtr solveParticle);
106  };
107 
108 
110  #ifndef AGX_PHYSICS_SOLVEPARTICLE_DATA_SET_OVERRIDE
111  #define AGX_PHYSICS_SOLVEPARTICLE_DATA_SET
112  class AGXPHYSICS_EXPORT SolveParticleData : public agxData::EntityData
113  {
114  public:
115  SolveParticleInstance operator[] (size_t index);
116 
117  public:
123  agxData::Array< agx::UInt32 > sourceIndex;
126 
127  public:
128  typedef agx::Vec3 positionType;
129  typedef agx::Vec3 velocityType;
130  typedef agx::Vec3 forceType;
131  typedef agx::Real densityType;
132  typedef agx::UInt32 sourceIndexType;
133  typedef agx::UInt32 solveIndexType;
134  typedef agxData::Array< agx::UInt32 > contactListType;
135 
136  public:
137  SolveParticleData(agxData::EntityStorage* storage);
138  SolveParticleData();
139 
140  protected:
141  virtual ~SolveParticleData() {}
142  virtual void setNumElements(agx::Index numElements) override;
143 
144  private:
145  SolveParticleData& operator= (const SolveParticleData&) { return *this; }
146 
147  };
148  #endif
150 
151 
153  class AGXPHYSICS_EXPORT SolveParticleSemantics : protected agxData::EntityPtr
154  {
155  public:
156 
157  // Automatic getters
158  agx::Vec3 const& getPosition() const;
159  agx::Vec3 const& getVelocity() const;
160  agx::Vec3 const& getForce() const;
161  agx::Real const& getDensity() const;
162  agx::UInt32 const& getSourceIndex() const;
163  agx::UInt32 const& getSolveIndex() const;
164  agxData::Array< agx::UInt32 > const& getContactList() const;
165 
166  // Semantics defined by explicit kernels
167 
168  // Automatic setters
169  void setPosition(agx::Vec3 const& value);
170  void setVelocity(agx::Vec3 const& value);
171  void setForce(agx::Vec3 const& value);
172  void setDensity(agx::Real const& value);
173  void setSourceIndex(agx::UInt32 const& value);
174  void setSolveIndex(agx::UInt32 const& value);
175  void setContactList(agxData::Array< agx::UInt32 > const& value);
176 
177 
178  protected:
179  friend class SolveParticlePtr;
180  friend class SolveParticleInstance;
181  SolveParticleSemantics();
182  };
184 
185 
186 
189  class CALLABLE SolveParticlePtr : public agxData::EntityPtr
190  {
191  public:
193  typedef SolveParticleData DataType;
194  typedef SolveParticleInstance InstanceType;
195 
196  public:
201  AGXPHYSICS_EXPORT SolveParticlePtr& operator= (const agxData::EntityPtr& ptr);
202  AGXPHYSICS_EXPORT SolveParticlePtr& operator= (const agxData::EntityInstance& instance);
203  AGXPHYSICS_EXPORT SolveParticleInstance instance();
204  AGXPHYSICS_EXPORT const SolveParticleInstance instance() const;
205 
206  AGXPHYSICS_EXPORT SolveParticleSemantics* operator->();
207  AGXPHYSICS_EXPORT const SolveParticleSemantics* operator->() const;
208 
209  SolveParticleData* getData();
210  const SolveParticleData* getData() const;
211 
212 
214  AGXPHYSICS_EXPORT agx::Vec3& position();
216  AGXPHYSICS_EXPORT agx::Vec3 const& position() const;
217 
219  AGXPHYSICS_EXPORT agx::Vec3& velocity();
221  AGXPHYSICS_EXPORT agx::Vec3 const& velocity() const;
222 
224  AGXPHYSICS_EXPORT agx::Vec3& force();
226  AGXPHYSICS_EXPORT agx::Vec3 const& force() const;
227 
229  AGXPHYSICS_EXPORT agx::Real& density();
231  AGXPHYSICS_EXPORT agx::Real const& density() const;
232 
234  AGXPHYSICS_EXPORT agx::UInt32& sourceIndex();
236  AGXPHYSICS_EXPORT agx::UInt32 const& sourceIndex() const;
237 
239  AGXPHYSICS_EXPORT agx::UInt32& solveIndex();
241  AGXPHYSICS_EXPORT agx::UInt32 const& solveIndex() const;
242 
246  AGXPHYSICS_EXPORT agxData::Array< agx::UInt32 > const& contactList() const;
247 
248  };
249 
250 
252  class AGXPHYSICS_EXPORT SolveParticleInstance : public agxData::EntityInstance
253  {
254  public:
255  SolveParticleInstance();
256  SolveParticleInstance(SolveParticleData* data, agx::Index index);
257  SolveParticleInstance(agxData::EntityStorage *storage, agx::Index index);
258  SolveParticleInstance(const agxData::EntityInstance& other);
259  SolveParticleInstance(const agxData::EntityPtr& ptr);
260 
261  SolveParticleData* getData();
262  const SolveParticleData* getData() const;
263 
264  public:
266  agx::Vec3& position();
268  agx::Vec3 const& position() const;
269 
271  agx::Vec3& velocity();
273  agx::Vec3 const& velocity() const;
274 
276  agx::Vec3& force();
278  agx::Vec3 const& force() const;
279 
281  agx::Real& density();
283  agx::Real const& density() const;
284 
286  agx::UInt32& sourceIndex();
288  agx::UInt32 const& sourceIndex() const;
289 
291  agx::UInt32& solveIndex();
293  agx::UInt32 const& solveIndex() const;
294 
296  agxData::Array< agx::UInt32 >& contactList();
298  agxData::Array< agx::UInt32 > const& contactList() const;
299 
300  };
302 
303 
304 
307 
308 
309 
311  /* Implementation */
312  //-----------------------------------------------------------------------------------------------------
313  //-----------------------------------------------------------------------------------------------------
314  inline SolveParticleInstance agx::Physics::SolveParticleData::operator[] (size_t index) { return SolveParticleInstance(this, (agx::Index)index); }
315  //-----------------------------------------------------------------------------------------------------
319  {
321  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
323  }
324 
326  {
327  agxAssertN(!instance || instance.isInstanceOf(SolveParticleModel::instance()),
328  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
330  }
331 
333  {
336  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
338  return *this;
339  }
340 
342  {
344  agxAssertN(!instance || instance.isInstanceOf(SolveParticleModel::instance()),
345  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
347  return *this;
348  }
349 
350  inline SolveParticleInstance SolveParticlePtr::instance() { return agxData::EntityPtr::instance(); }
351  inline const SolveParticleInstance SolveParticlePtr::instance() const { return agxData::EntityPtr::instance(); }
352  AGX_FORCE_INLINE SolveParticleSemantics* SolveParticlePtr::operator->() { return (SolveParticleSemantics* )this; }
353  AGX_FORCE_INLINE const SolveParticleSemantics* SolveParticlePtr::operator->() const { return (const SolveParticleSemantics* )this; }
354  AGX_FORCE_INLINE SolveParticleData* SolveParticlePtr::getData() { return static_cast<SolveParticleData* >(agxData::EntityPtr::getData()); }
355  AGX_FORCE_INLINE const SolveParticleData* SolveParticlePtr::getData() const { return static_cast<const SolveParticleData* >(agxData::EntityPtr::getData()); }
356 
357  AGX_FORCE_INLINE agx::Vec3& SolveParticlePtr::position() { verifyIndex(); return getData()->position[calculateIndex()]; }
358  AGX_FORCE_INLINE agx::Vec3 const& SolveParticlePtr::position() const { verifyIndex(); return getData()->position[calculateIndex()]; }
359 
360  AGX_FORCE_INLINE agx::Vec3& SolveParticlePtr::velocity() { verifyIndex(); return getData()->velocity[calculateIndex()]; }
361  AGX_FORCE_INLINE agx::Vec3 const& SolveParticlePtr::velocity() const { verifyIndex(); return getData()->velocity[calculateIndex()]; }
362 
363  AGX_FORCE_INLINE agx::Vec3& SolveParticlePtr::force() { verifyIndex(); return getData()->force[calculateIndex()]; }
364  AGX_FORCE_INLINE agx::Vec3 const& SolveParticlePtr::force() const { verifyIndex(); return getData()->force[calculateIndex()]; }
365 
366  AGX_FORCE_INLINE agx::Real& SolveParticlePtr::density() { verifyIndex(); return getData()->density[calculateIndex()]; }
367  AGX_FORCE_INLINE agx::Real const& SolveParticlePtr::density() const { verifyIndex(); return getData()->density[calculateIndex()]; }
368 
369  AGX_FORCE_INLINE agx::UInt32& SolveParticlePtr::sourceIndex() { verifyIndex(); return getData()->sourceIndex[calculateIndex()]; }
370  AGX_FORCE_INLINE agx::UInt32 const& SolveParticlePtr::sourceIndex() const { verifyIndex(); return getData()->sourceIndex[calculateIndex()]; }
371 
372  AGX_FORCE_INLINE agx::UInt32& SolveParticlePtr::solveIndex() { verifyIndex(); return getData()->solveIndex[calculateIndex()]; }
373  AGX_FORCE_INLINE agx::UInt32 const& SolveParticlePtr::solveIndex() const { verifyIndex(); return getData()->solveIndex[calculateIndex()]; }
374 
375  AGX_FORCE_INLINE agxData::Array< agx::UInt32 >& SolveParticlePtr::contactList() { verifyIndex(); return getData()->contactList[calculateIndex()]; }
376  AGX_FORCE_INLINE agxData::Array< agx::UInt32 > const& SolveParticlePtr::contactList() const { verifyIndex(); return getData()->contactList[calculateIndex()]; }
377 
378  //-----------------------------------------------------------------------------------------------------
379  AGX_FORCE_INLINE SolveParticleInstance::SolveParticleInstance() {}
380  AGX_FORCE_INLINE SolveParticleInstance::SolveParticleInstance(SolveParticleData* data, agx::Index index) : agxData::EntityInstance(data, index) {}
381  AGX_FORCE_INLINE SolveParticleInstance::SolveParticleInstance(agxData::EntityStorage* storage, agx::Index index) : agxData::EntityInstance(storage, index) {}
382  AGX_FORCE_INLINE SolveParticleInstance::SolveParticleInstance(const agxData::EntityInstance& other) : agxData::EntityInstance(other)
383  {
385  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
387  }
388 
389  AGX_FORCE_INLINE SolveParticleInstance::SolveParticleInstance(const agxData::EntityPtr& ptr) : agxData::EntityInstance(ptr)
390  {
392  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
394  }
395 
396 
397  AGX_FORCE_INLINE SolveParticleData* SolveParticleInstance::getData() { return static_cast<SolveParticleData* >(agxData::EntityInstance::getData()); }
398  AGX_FORCE_INLINE const SolveParticleData* SolveParticleInstance::getData() const { return static_cast<const SolveParticleData* >(agxData::EntityInstance::getData()); }
399 
400  AGX_FORCE_INLINE agx::Vec3& SolveParticleInstance::position() { verifyIndex(); return getData()->position[getIndex()]; }
401  AGX_FORCE_INLINE agx::Vec3 const& SolveParticleInstance::position() const { verifyIndex(); return getData()->position[getIndex()]; }
402 
403  AGX_FORCE_INLINE agx::Vec3& SolveParticleInstance::velocity() { verifyIndex(); return getData()->velocity[getIndex()]; }
404  AGX_FORCE_INLINE agx::Vec3 const& SolveParticleInstance::velocity() const { verifyIndex(); return getData()->velocity[getIndex()]; }
405 
406  AGX_FORCE_INLINE agx::Vec3& SolveParticleInstance::force() { verifyIndex(); return getData()->force[getIndex()]; }
407  AGX_FORCE_INLINE agx::Vec3 const& SolveParticleInstance::force() const { verifyIndex(); return getData()->force[getIndex()]; }
408 
409  AGX_FORCE_INLINE agx::Real& SolveParticleInstance::density() { verifyIndex(); return getData()->density[getIndex()]; }
410  AGX_FORCE_INLINE agx::Real const& SolveParticleInstance::density() const { verifyIndex(); return getData()->density[getIndex()]; }
411 
412  AGX_FORCE_INLINE agx::UInt32& SolveParticleInstance::sourceIndex() { verifyIndex(); return getData()->sourceIndex[getIndex()]; }
413  AGX_FORCE_INLINE agx::UInt32 const& SolveParticleInstance::sourceIndex() const { verifyIndex(); return getData()->sourceIndex[getIndex()]; }
414 
415  AGX_FORCE_INLINE agx::UInt32& SolveParticleInstance::solveIndex() { verifyIndex(); return getData()->solveIndex[getIndex()]; }
416  AGX_FORCE_INLINE agx::UInt32 const& SolveParticleInstance::solveIndex() const { verifyIndex(); return getData()->solveIndex[getIndex()]; }
417 
418  AGX_FORCE_INLINE agxData::Array< agx::UInt32 >& SolveParticleInstance::contactList() { verifyIndex(); return getData()->contactList[getIndex()]; }
419  AGX_FORCE_INLINE agxData::Array< agx::UInt32 > const& SolveParticleInstance::contactList() const { verifyIndex(); return getData()->contactList[getIndex()]; }
420 
421  //-----------------------------------------------------------------------------------------------------
422  AGX_FORCE_INLINE SolveParticleSemantics::SolveParticleSemantics() {}
423  //-----------------------------------------------------------------------------------------------------
425  }
426 }
427 
428 AGX_TYPE_BINDING(agx::Physics::SolveParticlePtr, "Physics.SolveParticlePtr")
429 AGX_TYPE_BINDING(agx::Physics::SolveParticleInstance, "Physics.SolveParticleInstance")
430 
431 #ifdef _MSC_VER
432 # pragma warning(pop)
433 #endif
434 
435 #undef AGX_ENTITY_WRAPPER
436 #undef AGX_ENTITY_NAMESPACE
437 #endif
438 
agxData::EntityData * getData()
AGXPHYSICS_EXPORT agx::Vec3 & force()
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
AGXPHYSICS_EXPORT agx::Vec3 & position()
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:72
static agxData::ScalarAttributeT< agx::Vec3 > * forceAttribute
#define agxAssertN(expr, format,...)
Definition: debug.h:145
agxData::EntityData * getData()
agx::String fullPath() const
AGXPHYSICS_EXPORT agxData::Array< agx::UInt32 > & contactList()
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:363
static agxData::ScalarAttributeT< agx::UInt32 > * solveIndexAttribute
SolveParticleInstance InstanceType
#define AGXPHYSICS_EXPORT
Entity instance provides access to a single instance in an EntityStorage.
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition: EntityPtr.h:51
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
bool isInstanceOf(agxData::EntityModel *model) const
AGXPHYSICS_EXPORT agx::Real & density()
#define AGX_FORCE_INLINE
Definition: Object.h:59
Type-specific Array used for fast access into the data held by a Buffer.
Definition: agxData.h:30
AGXPHYSICS_EXPORT SolveParticleSemantics * operator->()
static agxData::ArrayAttributeT< agx::UInt32 > * contactListAttribute
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
EntityPtr & operator=(const EntityPtr &other)=default
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Pointer to a entity instance of type Physics.SolveParticle.
Contains classes for low level data storage for AGX.
Definition: Container.h:23
UInt32 Index
Definition: Integer.h:52
Abstract description of the data attributes for the Physics.SolveParticle entity. ...
static agxData::ScalarAttributeT< agx::Real > * densityAttribute
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
Definition: EntityModel.h:63
#define CALLABLE
Definition: Object.h:73
AGXPHYSICS_EXPORT SolveParticleInstance instance()
SolveParticleData * getData()
static agxData::ScalarAttributeT< agx::Vec3 > * velocityAttribute
bool isInstanceOf(agxData::EntityModel *model) const
AGXPHYSICS_EXPORT SolveParticlePtr & operator=(const agxData::EntityPtr &ptr)
AGXPHYSICS_EXPORT agx::UInt32 & sourceIndex()
AGXPHYSICS_EXPORT agx::UInt32 & solveIndex()
AGXPHYSICS_EXPORT SolveParticlePtr()
static SolveParticleModel * instance()
static agxData::ScalarAttributeT< agx::Vec3 > * positionAttribute
double Real
Definition: Real.h:42
AGXPHYSICS_EXPORT agx::Vec3 & velocity()
uint32_t UInt32
Definition: Integer.h:40
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97
static agxData::ScalarAttributeT< agx::UInt32 > * sourceIndexAttribute