AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SolveParticleEntity.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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 
249  // Only used by tolua!
250  #ifdef AGX_GENERATED_TOLUA_WRAPPER
251  inline agx::Vec3 const& getPosition() const { return (*this)->getPosition(); }
252  inline agx::Vec3 const& getVelocity() const { return (*this)->getVelocity(); }
253  inline agx::Vec3 const& getForce() const { return (*this)->getForce(); }
254  inline agx::Real const& getDensity() const { return (*this)->getDensity(); }
255  inline agx::UInt32 const& getSourceIndex() const { return (*this)->getSourceIndex(); }
256  inline agx::UInt32 const& getSolveIndex() const { return (*this)->getSolveIndex(); }
257  inline agxData::Array< agx::UInt32 > const& getContactList() const { return (*this)->getContactList(); }
258 
259 
260  inline void setPosition(agx::Vec3 const& value) { (*this)->setPosition(value); }
261  inline void setVelocity(agx::Vec3 const& value) { (*this)->setVelocity(value); }
262  inline void setForce(agx::Vec3 const& value) { (*this)->setForce(value); }
263  inline void setDensity(agx::Real const& value) { (*this)->setDensity(value); }
264  inline void setSourceIndex(agx::UInt32 const& value) { (*this)->setSourceIndex(value); }
265  inline void setSolveIndex(agx::UInt32 const& value) { (*this)->setSolveIndex(value); }
266  inline void setContactList(agxData::Array< agx::UInt32 > const& value) { (*this)->setContactList(value); }
267  #endif
269 
270  };
271 
272 
274  class AGXPHYSICS_EXPORT SolveParticleInstance : public agxData::EntityInstance
275  {
276  public:
277  SolveParticleInstance();
278  SolveParticleInstance(SolveParticleData* data, agx::Index index);
279  SolveParticleInstance(agxData::EntityStorage *storage, agx::Index index);
280  SolveParticleInstance(const agxData::EntityInstance& other);
281  SolveParticleInstance(const agxData::EntityPtr& ptr);
282 
283  SolveParticleData* getData();
284  const SolveParticleData* getData() const;
285 
286  public:
288  agx::Vec3& position();
290  agx::Vec3 const& position() const;
291 
293  agx::Vec3& velocity();
295  agx::Vec3 const& velocity() const;
296 
298  agx::Vec3& force();
300  agx::Vec3 const& force() const;
301 
303  agx::Real& density();
305  agx::Real const& density() const;
306 
308  agx::UInt32& sourceIndex();
310  agx::UInt32 const& sourceIndex() const;
311 
313  agx::UInt32& solveIndex();
315  agx::UInt32 const& solveIndex() const;
316 
318  agxData::Array< agx::UInt32 >& contactList();
320  agxData::Array< agx::UInt32 > const& contactList() const;
321 
322  };
324 
325 
326 
328  typedef agxData::Array<SolveParticlePtr> SolveParticlePtrArray;
329 
330 
331 
333  /* Implementation */
334  //-----------------------------------------------------------------------------------------------------
335  //-----------------------------------------------------------------------------------------------------
336  inline SolveParticleInstance agx::Physics::SolveParticleData::operator[] (size_t index) { return SolveParticleInstance(this, (agx::Index)index); }
337  //-----------------------------------------------------------------------------------------------------
339  AGX_FORCE_INLINE SolveParticlePtr::SolveParticlePtr(agxData::EntityStorage* storage, agx::Index id) : agxData::EntityPtr(storage, id) {}
340  AGX_FORCE_INLINE SolveParticlePtr::SolveParticlePtr(const agxData::EntityPtr& ptr) : agxData::EntityPtr(ptr)
341  {
343  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
345  }
346 
347  AGX_FORCE_INLINE SolveParticlePtr::SolveParticlePtr(const agxData::EntityInstance& instance) : agxData::EntityPtr(instance)
348  {
349  agxAssertN(!instance || instance.isInstanceOf(SolveParticleModel::instance()),
350  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
352  }
353 
354  AGX_FORCE_INLINE SolveParticlePtr& SolveParticlePtr::operator= (const agxData::EntityPtr& ptr)
355  {
357  agxAssertN(!ptr || ptr.isInstanceOf(SolveParticleModel::instance()),
358  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
359  EntityPtr::getModel()->fullPath().c_str(), SolveParticleModel::instance()->fullPath().c_str());
360  return *this;
361  }
362 
363  AGX_FORCE_INLINE SolveParticlePtr& SolveParticlePtr::operator= (const agxData::EntityInstance& instance)
364  {
366  agxAssertN(!instance || instance.isInstanceOf(SolveParticleModel::instance()),
367  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
368  EntityPtr::getModel()->fullPath().c_str(), SolveParticleModel::instance()->fullPath().c_str());
369  return *this;
370  }
371 
372  inline SolveParticleInstance SolveParticlePtr::instance() { return agxData::EntityPtr::instance(); }
373  inline const SolveParticleInstance SolveParticlePtr::instance() const { return agxData::EntityPtr::instance(); }
374  AGX_FORCE_INLINE SolveParticleSemantics* SolveParticlePtr::operator->() { return (SolveParticleSemantics* )this; }
375  AGX_FORCE_INLINE const SolveParticleSemantics* SolveParticlePtr::operator->() const { return (const SolveParticleSemantics* )this; }
376  AGX_FORCE_INLINE SolveParticleData* SolveParticlePtr::getData() { return static_cast<SolveParticleData* >(agxData::EntityPtr::getData()); }
377  AGX_FORCE_INLINE const SolveParticleData* SolveParticlePtr::getData() const { return static_cast<const SolveParticleData* >(agxData::EntityPtr::getData()); }
378 
379  AGX_FORCE_INLINE agx::Vec3& SolveParticlePtr::position() { verifyIndex(); return getData()->position[calculateIndex()]; }
380  AGX_FORCE_INLINE agx::Vec3 const& SolveParticlePtr::position() const { verifyIndex(); return getData()->position[calculateIndex()]; }
381 
382  AGX_FORCE_INLINE agx::Vec3& SolveParticlePtr::velocity() { verifyIndex(); return getData()->velocity[calculateIndex()]; }
383  AGX_FORCE_INLINE agx::Vec3 const& SolveParticlePtr::velocity() const { verifyIndex(); return getData()->velocity[calculateIndex()]; }
384 
385  AGX_FORCE_INLINE agx::Vec3& SolveParticlePtr::force() { verifyIndex(); return getData()->force[calculateIndex()]; }
386  AGX_FORCE_INLINE agx::Vec3 const& SolveParticlePtr::force() const { verifyIndex(); return getData()->force[calculateIndex()]; }
387 
388  AGX_FORCE_INLINE agx::Real& SolveParticlePtr::density() { verifyIndex(); return getData()->density[calculateIndex()]; }
389  AGX_FORCE_INLINE agx::Real const& SolveParticlePtr::density() const { verifyIndex(); return getData()->density[calculateIndex()]; }
390 
391  AGX_FORCE_INLINE agx::UInt32& SolveParticlePtr::sourceIndex() { verifyIndex(); return getData()->sourceIndex[calculateIndex()]; }
392  AGX_FORCE_INLINE agx::UInt32 const& SolveParticlePtr::sourceIndex() const { verifyIndex(); return getData()->sourceIndex[calculateIndex()]; }
393 
394  AGX_FORCE_INLINE agx::UInt32& SolveParticlePtr::solveIndex() { verifyIndex(); return getData()->solveIndex[calculateIndex()]; }
395  AGX_FORCE_INLINE agx::UInt32 const& SolveParticlePtr::solveIndex() const { verifyIndex(); return getData()->solveIndex[calculateIndex()]; }
396 
397  AGX_FORCE_INLINE agxData::Array< agx::UInt32 >& SolveParticlePtr::contactList() { verifyIndex(); return getData()->contactList[calculateIndex()]; }
398  AGX_FORCE_INLINE agxData::Array< agx::UInt32 > const& SolveParticlePtr::contactList() const { verifyIndex(); return getData()->contactList[calculateIndex()]; }
399 
400  //-----------------------------------------------------------------------------------------------------
401  AGX_FORCE_INLINE SolveParticleInstance::SolveParticleInstance() {}
402  AGX_FORCE_INLINE SolveParticleInstance::SolveParticleInstance(SolveParticleData* data, agx::Index index) : agxData::EntityInstance(data, index) {}
403  AGX_FORCE_INLINE SolveParticleInstance::SolveParticleInstance(agxData::EntityStorage* storage, agx::Index index) : agxData::EntityInstance(storage, index) {}
404  AGX_FORCE_INLINE SolveParticleInstance::SolveParticleInstance(const agxData::EntityInstance& other) : agxData::EntityInstance(other)
405  {
407  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
409  }
410 
411  AGX_FORCE_INLINE SolveParticleInstance::SolveParticleInstance(const agxData::EntityPtr& ptr) : agxData::EntityInstance(ptr)
412  {
414  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
416  }
417 
418 
419  AGX_FORCE_INLINE SolveParticleData* SolveParticleInstance::getData() { return static_cast<SolveParticleData* >(agxData::EntityInstance::getData()); }
420  AGX_FORCE_INLINE const SolveParticleData* SolveParticleInstance::getData() const { return static_cast<const SolveParticleData* >(agxData::EntityInstance::getData()); }
421 
422  AGX_FORCE_INLINE agx::Vec3& SolveParticleInstance::position() { verifyIndex(); return getData()->position[getIndex()]; }
423  AGX_FORCE_INLINE agx::Vec3 const& SolveParticleInstance::position() const { verifyIndex(); return getData()->position[getIndex()]; }
424 
425  AGX_FORCE_INLINE agx::Vec3& SolveParticleInstance::velocity() { verifyIndex(); return getData()->velocity[getIndex()]; }
426  AGX_FORCE_INLINE agx::Vec3 const& SolveParticleInstance::velocity() const { verifyIndex(); return getData()->velocity[getIndex()]; }
427 
428  AGX_FORCE_INLINE agx::Vec3& SolveParticleInstance::force() { verifyIndex(); return getData()->force[getIndex()]; }
429  AGX_FORCE_INLINE agx::Vec3 const& SolveParticleInstance::force() const { verifyIndex(); return getData()->force[getIndex()]; }
430 
431  AGX_FORCE_INLINE agx::Real& SolveParticleInstance::density() { verifyIndex(); return getData()->density[getIndex()]; }
432  AGX_FORCE_INLINE agx::Real const& SolveParticleInstance::density() const { verifyIndex(); return getData()->density[getIndex()]; }
433 
434  AGX_FORCE_INLINE agx::UInt32& SolveParticleInstance::sourceIndex() { verifyIndex(); return getData()->sourceIndex[getIndex()]; }
435  AGX_FORCE_INLINE agx::UInt32 const& SolveParticleInstance::sourceIndex() const { verifyIndex(); return getData()->sourceIndex[getIndex()]; }
436 
437  AGX_FORCE_INLINE agx::UInt32& SolveParticleInstance::solveIndex() { verifyIndex(); return getData()->solveIndex[getIndex()]; }
438  AGX_FORCE_INLINE agx::UInt32 const& SolveParticleInstance::solveIndex() const { verifyIndex(); return getData()->solveIndex[getIndex()]; }
439 
440  AGX_FORCE_INLINE agxData::Array< agx::UInt32 >& SolveParticleInstance::contactList() { verifyIndex(); return getData()->contactList[getIndex()]; }
441  AGX_FORCE_INLINE agxData::Array< agx::UInt32 > const& SolveParticleInstance::contactList() const { verifyIndex(); return getData()->contactList[getIndex()]; }
442 
443  //-----------------------------------------------------------------------------------------------------
444  AGX_FORCE_INLINE SolveParticleSemantics::SolveParticleSemantics() {}
445  //-----------------------------------------------------------------------------------------------------
447  }
448 }
449 
450 AGX_TYPE_BINDING(agx::Physics::SolveParticlePtr, "Physics.SolveParticlePtr")
451 AGX_TYPE_BINDING(agx::Physics::SolveParticleInstance, "Physics.SolveParticleInstance")
452 
453 #ifdef _MSC_VER
454 # pragma warning(pop)
455 #endif
456 
457 #undef AGX_ENTITY_WRAPPER
458 #undef AGX_ENTITY_NAMESPACE
459 #endif
460 
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
static agxData::ScalarAttributeT< agx::Vec3 > * forceAttribute
#define agxAssertN(expr, format,...)
Definition: debug.h:145
agxData::EntityData * getData()
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:364
bool isInstanceOf(agxData::EntityModel *model) const
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:248
agx::String fullPath() const
#define AGX_FORCE_INLINE
Definition: Object.h:62
Type-specific Array used for fast access into the data held by a Buffer.
Definition: agxData.h:30
static agxData::ArrayAttributeT< agx::UInt32 > * contactListAttribute
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
EntityPtr & operator=(const EntityPtr &other)=default
Pointer to a entity instance of type Physics.SolveParticle.
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:76
bool isInstanceOf(agxData::EntityModel *model) const
static agxData::ScalarAttributeT< agx::Vec3 > * velocityAttribute
AGXPHYSICS_EXPORT SolveParticlePtr()
static SolveParticleModel * instance()
static agxData::ScalarAttributeT< agx::Vec3 > * positionAttribute
double Real
Definition: Real.h:42
uint32_t UInt32
Definition: Integer.h:40
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:101
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:100
static agxData::ScalarAttributeT< agx::UInt32 > * sourceIndexAttribute