AGX Dynamics  2.37.3.2
CachedGranularContactEntity.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_GRANULARBODY_CACHEDGRANULARCONTACT_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_GRANULARBODY_CACHEDGRANULARCONTACT_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/Integer.h>
49 #include <agx/Vec3.h>
50 
51 
52 namespace agx
53 {
54  namespace Physics
55  {
56  namespace GranularBody
57  {
58 
59  class CachedGranularContactModel;
60  class CachedGranularContactData;
61  class CachedGranularContactPtr;
62  class CachedGranularContactInstance;
63  class CachedGranularContactSemantics;
64 
65 
67 
72  {
73  public:
75 
76  CachedGranularContactModel(const agx::String& name = "CachedGranularContact");
77 
79  static CachedGranularContactModel* instance();
80 
82  static CachedGranularContactPtr createInstance();
83 
85  static agxData::EntityStorage* defaultStorage();
86 
88  virtual void shutdownCleanup() override;
89 
90 
91 
92  /* Attributes */
98 
99  protected:
100  virtual ~CachedGranularContactModel();
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::GranularBody::CachedGranularContactPtr cachedGranularContact);
106  };
107 
108 
110  #ifndef AGX_PHYSICS_GRANULARBODY_CACHEDGRANULARCONTACT_DATA_SET_OVERRIDE
111  #define AGX_PHYSICS_GRANULARBODY_CACHEDGRANULARCONTACT_DATA_SET
112  class AGXPHYSICS_EXPORT CachedGranularContactData : public agxData::EntityData
113  {
114  public:
115  CachedGranularContactInstance operator[] (size_t index);
116 
117  public:
120  agxData::Array< agx::Bool > duplicate;
122  agxData::Array< agx::Vec3f > contactNormal;
123  agxData::Array< agx::Bool > shouldWarmStart;
124 
125  public:
126  typedef agx::Bool keepType;
127  typedef agx::Bool duplicateType;
128  typedef agx::Physics::GranularBody::ContactLambda contactLambdasType;
129  typedef agx::Vec3f contactNormalType;
130  typedef agx::Bool shouldWarmStartType;
131 
132  public:
133  CachedGranularContactData(agxData::EntityStorage* storage);
134  CachedGranularContactData();
135 
136  protected:
137  virtual ~CachedGranularContactData() {}
138  virtual void setNumElements(agx::Index numElements) override;
139 
140  private:
141  CachedGranularContactData& operator= (const CachedGranularContactData&) { return *this; }
142 
143  };
144  #endif
146 
147 
149  class AGXPHYSICS_EXPORT CachedGranularContactSemantics : protected agxData::EntityPtr
150  {
151  public:
152 
153  // Automatic getters
154  agx::Bool const& getKeep() const;
155  agx::Bool const& getDuplicate() const;
156  agx::Physics::GranularBody::ContactLambda const& getContactLambdas() const;
157  agx::Vec3f const& getContactNormal() const;
158  agx::Bool const& getShouldWarmStart() const;
159 
160  // Semantics defined by explicit kernels
161 
162  // Automatic setters
163  void setKeep(agx::Bool const& value);
164  void setDuplicate(agx::Bool const& value);
165  void setContactLambdas(agx::Physics::GranularBody::ContactLambda const& value);
166  void setContactNormal(agx::Vec3f const& value);
167  void setShouldWarmStart(agx::Bool const& value);
168 
169 
170  protected:
171  friend class CachedGranularContactPtr;
172  friend class CachedGranularContactInstance;
173  CachedGranularContactSemantics();
174  };
176 
177 
178 
181  class CALLABLE CachedGranularContactPtr : public agxData::EntityPtr
182  {
183  public:
185  typedef CachedGranularContactData DataType;
186  typedef CachedGranularContactInstance InstanceType;
187 
188  public:
195  AGXPHYSICS_EXPORT CachedGranularContactInstance instance();
196  AGXPHYSICS_EXPORT const CachedGranularContactInstance instance() const;
197 
198  AGXPHYSICS_EXPORT CachedGranularContactSemantics* operator->();
199  AGXPHYSICS_EXPORT const CachedGranularContactSemantics* operator->() const;
200 
201  CachedGranularContactData* getData();
202  const CachedGranularContactData* getData() const;
203 
204 
208  AGXPHYSICS_EXPORT agx::Bool const& keep() const;
209 
211  AGXPHYSICS_EXPORT agx::Bool& duplicate();
213  AGXPHYSICS_EXPORT agx::Bool const& duplicate() const;
214 
218  AGXPHYSICS_EXPORT agx::Physics::GranularBody::ContactLambda const& contactLambdas() const;
219 
221  AGXPHYSICS_EXPORT agx::Vec3f& contactNormal();
223  AGXPHYSICS_EXPORT agx::Vec3f const& contactNormal() const;
224 
226  AGXPHYSICS_EXPORT agx::Bool& shouldWarmStart();
228  AGXPHYSICS_EXPORT agx::Bool const& shouldWarmStart() const;
229 
230  };
231 
232 
234  class AGXPHYSICS_EXPORT CachedGranularContactInstance : public agxData::EntityInstance
235  {
236  public:
237  CachedGranularContactInstance();
238  CachedGranularContactInstance(CachedGranularContactData* data, agx::Index index);
239  CachedGranularContactInstance(agxData::EntityStorage *storage, agx::Index index);
240  CachedGranularContactInstance(const agxData::EntityInstance& other);
241  CachedGranularContactInstance(const agxData::EntityPtr& ptr);
242 
243  CachedGranularContactData* getData();
244  const CachedGranularContactData* getData() const;
245 
246  public:
248  agx::Bool& keep();
250  agx::Bool const& keep() const;
251 
253  agx::Bool& duplicate();
255  agx::Bool const& duplicate() const;
256 
260  agx::Physics::GranularBody::ContactLambda const& contactLambdas() const;
261 
263  agx::Vec3f& contactNormal();
265  agx::Vec3f const& contactNormal() const;
266 
268  agx::Bool& shouldWarmStart();
270  agx::Bool const& shouldWarmStart() const;
271 
272  };
274 
275 
276 
279 
280 
281 
283  /* Implementation */
284  //-----------------------------------------------------------------------------------------------------
285  //-----------------------------------------------------------------------------------------------------
286  inline CachedGranularContactInstance agx::Physics::GranularBody::CachedGranularContactData::operator[] (size_t index) { return CachedGranularContactInstance(this, (agx::Index)index); }
287  //-----------------------------------------------------------------------------------------------------
291  {
293  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
295  }
296 
298  {
300  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
302  }
303 
305  {
308  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
310  return *this;
311  }
312 
314  {
317  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
319  return *this;
320  }
321 
322  inline CachedGranularContactInstance CachedGranularContactPtr::instance() { return agxData::EntityPtr::instance(); }
323  inline const CachedGranularContactInstance CachedGranularContactPtr::instance() const { return agxData::EntityPtr::instance(); }
324  AGX_FORCE_INLINE CachedGranularContactSemantics* CachedGranularContactPtr::operator->() { return (CachedGranularContactSemantics* )this; }
325  AGX_FORCE_INLINE const CachedGranularContactSemantics* CachedGranularContactPtr::operator->() const { return (const CachedGranularContactSemantics* )this; }
326  AGX_FORCE_INLINE CachedGranularContactData* CachedGranularContactPtr::getData() { return static_cast<CachedGranularContactData* >(agxData::EntityPtr::getData()); }
327  AGX_FORCE_INLINE const CachedGranularContactData* CachedGranularContactPtr::getData() const { return static_cast<const CachedGranularContactData* >(agxData::EntityPtr::getData()); }
328 
329  AGX_FORCE_INLINE agx::Bool& CachedGranularContactPtr::keep() { verifyIndex(); return getData()->keep[calculateIndex()]; }
330  AGX_FORCE_INLINE agx::Bool const& CachedGranularContactPtr::keep() const { verifyIndex(); return getData()->keep[calculateIndex()]; }
331 
332  AGX_FORCE_INLINE agx::Bool& CachedGranularContactPtr::duplicate() { verifyIndex(); return getData()->duplicate[calculateIndex()]; }
333  AGX_FORCE_INLINE agx::Bool const& CachedGranularContactPtr::duplicate() const { verifyIndex(); return getData()->duplicate[calculateIndex()]; }
334 
335  AGX_FORCE_INLINE agx::Physics::GranularBody::ContactLambda& CachedGranularContactPtr::contactLambdas() { verifyIndex(); return getData()->contactLambdas[calculateIndex()]; }
336  AGX_FORCE_INLINE agx::Physics::GranularBody::ContactLambda const& CachedGranularContactPtr::contactLambdas() const { verifyIndex(); return getData()->contactLambdas[calculateIndex()]; }
337 
338  AGX_FORCE_INLINE agx::Vec3f& CachedGranularContactPtr::contactNormal() { verifyIndex(); return getData()->contactNormal[calculateIndex()]; }
339  AGX_FORCE_INLINE agx::Vec3f const& CachedGranularContactPtr::contactNormal() const { verifyIndex(); return getData()->contactNormal[calculateIndex()]; }
340 
341  AGX_FORCE_INLINE agx::Bool& CachedGranularContactPtr::shouldWarmStart() { verifyIndex(); return getData()->shouldWarmStart[calculateIndex()]; }
342  AGX_FORCE_INLINE agx::Bool const& CachedGranularContactPtr::shouldWarmStart() const { verifyIndex(); return getData()->shouldWarmStart[calculateIndex()]; }
343 
344  //-----------------------------------------------------------------------------------------------------
345  AGX_FORCE_INLINE CachedGranularContactInstance::CachedGranularContactInstance() {}
346  AGX_FORCE_INLINE CachedGranularContactInstance::CachedGranularContactInstance(CachedGranularContactData* data, agx::Index index) : agxData::EntityInstance(data, index) {}
347  AGX_FORCE_INLINE CachedGranularContactInstance::CachedGranularContactInstance(agxData::EntityStorage* storage, agx::Index index) : agxData::EntityInstance(storage, index) {}
348  AGX_FORCE_INLINE CachedGranularContactInstance::CachedGranularContactInstance(const agxData::EntityInstance& other) : agxData::EntityInstance(other)
349  {
351  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
353  }
354 
355  AGX_FORCE_INLINE CachedGranularContactInstance::CachedGranularContactInstance(const agxData::EntityPtr& ptr) : agxData::EntityInstance(ptr)
356  {
358  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
360  }
361 
362 
363  AGX_FORCE_INLINE CachedGranularContactData* CachedGranularContactInstance::getData() { return static_cast<CachedGranularContactData* >(agxData::EntityInstance::getData()); }
364  AGX_FORCE_INLINE const CachedGranularContactData* CachedGranularContactInstance::getData() const { return static_cast<const CachedGranularContactData* >(agxData::EntityInstance::getData()); }
365 
366  AGX_FORCE_INLINE agx::Bool& CachedGranularContactInstance::keep() { verifyIndex(); return getData()->keep[getIndex()]; }
367  AGX_FORCE_INLINE agx::Bool const& CachedGranularContactInstance::keep() const { verifyIndex(); return getData()->keep[getIndex()]; }
368 
369  AGX_FORCE_INLINE agx::Bool& CachedGranularContactInstance::duplicate() { verifyIndex(); return getData()->duplicate[getIndex()]; }
370  AGX_FORCE_INLINE agx::Bool const& CachedGranularContactInstance::duplicate() const { verifyIndex(); return getData()->duplicate[getIndex()]; }
371 
372  AGX_FORCE_INLINE agx::Physics::GranularBody::ContactLambda& CachedGranularContactInstance::contactLambdas() { verifyIndex(); return getData()->contactLambdas[getIndex()]; }
373  AGX_FORCE_INLINE agx::Physics::GranularBody::ContactLambda const& CachedGranularContactInstance::contactLambdas() const { verifyIndex(); return getData()->contactLambdas[getIndex()]; }
374 
375  AGX_FORCE_INLINE agx::Vec3f& CachedGranularContactInstance::contactNormal() { verifyIndex(); return getData()->contactNormal[getIndex()]; }
376  AGX_FORCE_INLINE agx::Vec3f const& CachedGranularContactInstance::contactNormal() const { verifyIndex(); return getData()->contactNormal[getIndex()]; }
377 
378  AGX_FORCE_INLINE agx::Bool& CachedGranularContactInstance::shouldWarmStart() { verifyIndex(); return getData()->shouldWarmStart[getIndex()]; }
379  AGX_FORCE_INLINE agx::Bool const& CachedGranularContactInstance::shouldWarmStart() const { verifyIndex(); return getData()->shouldWarmStart[getIndex()]; }
380 
381  //-----------------------------------------------------------------------------------------------------
382  AGX_FORCE_INLINE CachedGranularContactSemantics::CachedGranularContactSemantics() {}
383  //-----------------------------------------------------------------------------------------------------
385  }
386  }
387 }
388 
389 AGX_TYPE_BINDING(agx::Physics::GranularBody::CachedGranularContactPtr, "Physics.GranularBody.CachedGranularContactPtr")
390 AGX_TYPE_BINDING(agx::Physics::GranularBody::CachedGranularContactInstance, "Physics.GranularBody.CachedGranularContactInstance")
391 
392 #ifdef _MSC_VER
393 # pragma warning(pop)
394 #endif
395 
396 #undef AGX_ENTITY_WRAPPER
397 #undef AGX_ENTITY_NAMESPACE
398 #endif
399 
static agxData::ScalarAttributeT< agx::Bool > * keepAttribute
agxData::EntityData * getData()
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
AGXPHYSICS_EXPORT agx::Bool & shouldWarmStart()
bool Bool
Definition: Integer.h:48
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:72
#define agxAssertN(expr, format,...)
Definition: debug.h:145
agxData::EntityData * getData()
agx::String fullPath() const
#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::Bool > * duplicateAttribute
#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
AGXPHYSICS_EXPORT CachedGranularContactPtr & operator=(const agxData::EntityPtr &ptr)
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
bool isInstanceOf(agxData::EntityModel *model) const
#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 CachedGranularContactSemantics * operator->()
static agxData::ScalarAttributeT< agx::Physics::GranularBody::ContactLambda > * contactLambdasAttribute
AGXPHYSICS_EXPORT agx::Vec3f & contactNormal()
Abstract description of the data attributes for the Physics.GranularBody.CachedGranularContact entity...
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.
static agxData::ScalarAttributeT< agx::Bool > * shouldWarmStartAttribute
AGXPHYSICS_EXPORT CachedGranularContactInstance instance()
Contains classes for low level data storage for AGX.
Definition: Container.h:23
UInt32 Index
Definition: Integer.h:52
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
Definition: EntityModel.h:63
static agxData::ScalarAttributeT< agx::Vec3f > * contactNormalAttribute
#define CALLABLE
Definition: Object.h:73
bool isInstanceOf(agxData::EntityModel *model) const
Pointer to a entity instance of type Physics.GranularBody.CachedGranularContact.
AGXPHYSICS_EXPORT agx::Physics::GranularBody::ContactLambda & contactLambdas()
static CachedGranularContactModel * instance()
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97