AGX Dynamics  2.35.0.1
SolveMaterialEntity.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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_SOLVEMATERIAL_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_SOLVEMATERIAL_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/Real.h>
48 #include <agx/Vec2.h>
49 
50 
51 namespace agx
52 {
53  namespace Physics
54  {
55 
56  class SolveMaterialModel;
57  class SolveMaterialData;
58  class SolveMaterialPtr;
59  class SolveMaterialInstance;
60  class SolveMaterialSemantics;
61 
62 
64 
69  {
70  public:
72 
73  SolveMaterialModel(const agx::String& name = "SolveMaterial");
74 
77 
80 
83 
85  virtual void shutdownCleanup() override;
86 
87 
88 
89  /* Attributes */
92 
93  protected:
95  virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
96  virtual void configure(agx::TiXmlElement* eEntity) override;
97  virtual void initAttributeAccessors() override;
98  virtual void construct(agxData::EntityPtr instance) override;
100  };
101 
102 
104  #ifndef AGX_PHYSICS_SOLVEMATERIAL_DATA_SET_OVERRIDE
105  #define AGX_PHYSICS_SOLVEMATERIAL_DATA_SET
106  class AGXPHYSICS_EXPORT SolveMaterialData : public agxData::EntityData
107  {
108  public:
109  SolveMaterialInstance operator[] (size_t index);
110 
111  public:
113  agxData::Array< agx::Real > adhesiveImpulse;
115 
116  public:
117  typedef agx::Real adhesiveImpulseType;
118  typedef agx::Vec2 frictionType;
119 
120  public:
121  SolveMaterialData(agxData::EntityStorage* storage);
122  SolveMaterialData();
123 
124  protected:
125  virtual ~SolveMaterialData() {}
126  virtual void setNumElements(agx::Index numElements) override;
127 
128  private:
129  SolveMaterialData& operator= (const SolveMaterialData&) { return *this; }
130 
131  };
132  #endif
134 
135 
137  class AGXPHYSICS_EXPORT SolveMaterialSemantics : protected agxData::EntityPtr
138  {
139  public:
140 
141  // Automatic getters
142  agx::Real const& getAdhesiveImpulse() const;
143  agx::Vec2 const& getFriction() const;
144 
145  // Semantics defined by explicit kernels
146 
147  // Automatic setters
148  void setAdhesiveImpulse(agx::Real const& value);
149  void setFriction(agx::Vec2 const& value);
150 
151 
152  protected:
153  friend class SolveMaterialPtr;
154  friend class SolveMaterialInstance;
155  SolveMaterialSemantics();
156  };
158 
159 
160 
163  class CALLABLE SolveMaterialPtr : public agxData::EntityPtr
164  {
165  public:
167  typedef SolveMaterialData DataType;
168  typedef SolveMaterialInstance InstanceType;
169 
170  public:
177  AGXPHYSICS_EXPORT SolveMaterialInstance instance();
178  AGXPHYSICS_EXPORT const SolveMaterialInstance instance() const;
179 
180  AGXPHYSICS_EXPORT SolveMaterialSemantics* operator->();
181  AGXPHYSICS_EXPORT const SolveMaterialSemantics* operator->() const;
182 
183  SolveMaterialData* getData();
184  const SolveMaterialData* getData() const;
185 
186 
191 
196 
198  // Only used by tolua!
199  #ifdef AGX_GENERATED_TOLUA_WRAPPER
200  inline agx::Real const& getAdhesiveImpulse() const { return (*this)->getAdhesiveImpulse(); }
201  inline agx::Vec2 const& getFriction() const { return (*this)->getFriction(); }
202 
203 
204  inline void setAdhesiveImpulse(agx::Real const& value) { (*this)->setAdhesiveImpulse(value); }
205  inline void setFriction(agx::Vec2 const& value) { (*this)->setFriction(value); }
206  #endif
208 
209  };
210 
211 
213  class AGXPHYSICS_EXPORT SolveMaterialInstance : public agxData::EntityInstance
214  {
215  public:
216  SolveMaterialInstance();
217  SolveMaterialInstance(SolveMaterialData* data, agx::Index index);
218  SolveMaterialInstance(agxData::EntityStorage *storage, agx::Index index);
219  SolveMaterialInstance(const agxData::EntityInstance& other);
220  SolveMaterialInstance(const agxData::EntityPtr& ptr);
221 
222  SolveMaterialData* getData();
223  const SolveMaterialData* getData() const;
224 
225  public:
227  agx::Real& adhesiveImpulse();
229  agx::Real const& adhesiveImpulse() const;
230 
232  agx::Vec2& friction();
234  agx::Vec2 const& friction() const;
235 
236  };
238 
239 
240 
243 
244 
245 
247  /* Implementation */
248  //-----------------------------------------------------------------------------------------------------
249  //-----------------------------------------------------------------------------------------------------
250  inline SolveMaterialInstance agx::Physics::SolveMaterialData::operator[] (size_t index) { return SolveMaterialInstance(this, (agx::Index)index); }
251  //-----------------------------------------------------------------------------------------------------
254  AGX_FORCE_INLINE SolveMaterialPtr::SolveMaterialPtr(const agxData::EntityPtr& ptr) : agxData::EntityPtr(ptr)
255  {
257  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
259  }
260 
261  AGX_FORCE_INLINE SolveMaterialPtr::SolveMaterialPtr(const agxData::EntityInstance& instance) : agxData::EntityPtr(instance)
262  {
263  agxAssertN(!instance || instance.isInstanceOf(SolveMaterialModel::instance()),
264  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
266  }
267 
268  AGX_FORCE_INLINE SolveMaterialPtr& SolveMaterialPtr::operator= (const agxData::EntityPtr& ptr)
269  {
271  agxAssertN(!ptr || ptr.isInstanceOf(SolveMaterialModel::instance()),
272  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
273  EntityPtr::getModel()->fullPath().c_str(), SolveMaterialModel::instance()->fullPath().c_str());
274  return *this;
275  }
276 
277  AGX_FORCE_INLINE SolveMaterialPtr& SolveMaterialPtr::operator= (const agxData::EntityInstance& instance)
278  {
280  agxAssertN(!instance || instance.isInstanceOf(SolveMaterialModel::instance()),
281  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
282  EntityPtr::getModel()->fullPath().c_str(), SolveMaterialModel::instance()->fullPath().c_str());
283  return *this;
284  }
285 
286  inline SolveMaterialInstance SolveMaterialPtr::instance() { return agxData::EntityPtr::instance(); }
287  inline const SolveMaterialInstance SolveMaterialPtr::instance() const { return agxData::EntityPtr::instance(); }
288  AGX_FORCE_INLINE SolveMaterialSemantics* SolveMaterialPtr::operator->() { return (SolveMaterialSemantics* )this; }
289  AGX_FORCE_INLINE const SolveMaterialSemantics* SolveMaterialPtr::operator->() const { return (const SolveMaterialSemantics* )this; }
290  AGX_FORCE_INLINE SolveMaterialData* SolveMaterialPtr::getData() { return static_cast<SolveMaterialData* >(agxData::EntityPtr::getData()); }
291  AGX_FORCE_INLINE const SolveMaterialData* SolveMaterialPtr::getData() const { return static_cast<const SolveMaterialData* >(agxData::EntityPtr::getData()); }
292 
293  AGX_FORCE_INLINE agx::Real& SolveMaterialPtr::adhesiveImpulse() { verifyIndex(); return getData()->adhesiveImpulse[calculateIndex()]; }
294  AGX_FORCE_INLINE agx::Real const& SolveMaterialPtr::adhesiveImpulse() const { verifyIndex(); return getData()->adhesiveImpulse[calculateIndex()]; }
295 
296  AGX_FORCE_INLINE agx::Vec2& SolveMaterialPtr::friction() { verifyIndex(); return getData()->friction[calculateIndex()]; }
297  AGX_FORCE_INLINE agx::Vec2 const& SolveMaterialPtr::friction() const { verifyIndex(); return getData()->friction[calculateIndex()]; }
298 
299  //-----------------------------------------------------------------------------------------------------
300  AGX_FORCE_INLINE SolveMaterialInstance::SolveMaterialInstance() {}
301  AGX_FORCE_INLINE SolveMaterialInstance::SolveMaterialInstance(SolveMaterialData* data, agx::Index index) : agxData::EntityInstance(data, index) {}
302  AGX_FORCE_INLINE SolveMaterialInstance::SolveMaterialInstance(agxData::EntityStorage* storage, agx::Index index) : agxData::EntityInstance(storage, index) {}
303  AGX_FORCE_INLINE SolveMaterialInstance::SolveMaterialInstance(const agxData::EntityInstance& other) : agxData::EntityInstance(other)
304  {
306  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
308  }
309 
310  AGX_FORCE_INLINE SolveMaterialInstance::SolveMaterialInstance(const agxData::EntityPtr& ptr) : agxData::EntityInstance(ptr)
311  {
313  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
315  }
316 
317 
318  AGX_FORCE_INLINE SolveMaterialData* SolveMaterialInstance::getData() { return static_cast<SolveMaterialData* >(agxData::EntityInstance::getData()); }
319  AGX_FORCE_INLINE const SolveMaterialData* SolveMaterialInstance::getData() const { return static_cast<const SolveMaterialData* >(agxData::EntityInstance::getData()); }
320 
321  AGX_FORCE_INLINE agx::Real& SolveMaterialInstance::adhesiveImpulse() { verifyIndex(); return getData()->adhesiveImpulse[getIndex()]; }
322  AGX_FORCE_INLINE agx::Real const& SolveMaterialInstance::adhesiveImpulse() const { verifyIndex(); return getData()->adhesiveImpulse[getIndex()]; }
323 
324  AGX_FORCE_INLINE agx::Vec2& SolveMaterialInstance::friction() { verifyIndex(); return getData()->friction[getIndex()]; }
325  AGX_FORCE_INLINE agx::Vec2 const& SolveMaterialInstance::friction() const { verifyIndex(); return getData()->friction[getIndex()]; }
326 
327  //-----------------------------------------------------------------------------------------------------
328  AGX_FORCE_INLINE SolveMaterialSemantics::SolveMaterialSemantics() {}
329  //-----------------------------------------------------------------------------------------------------
331  }
332 }
333 
334 AGX_TYPE_BINDING(agx::Physics::SolveMaterialPtr, "Physics.SolveMaterialPtr")
335 AGX_TYPE_BINDING(agx::Physics::SolveMaterialInstance, "Physics.SolveMaterialInstance")
336 
337 #ifdef _MSC_VER
338 # pragma warning(pop)
339 #endif
340 
341 #undef AGX_ENTITY_WRAPPER
342 #undef AGX_ENTITY_NAMESPACE
343 #endif
344 
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#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()
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
Definition: EntityModel.h:64
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition: EntityPtr.h:52
bool isInstanceOf(agxData::EntityModel *model) const
agxData::EntityData * getData()
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
EntityPtr & operator=(const EntityPtr &other)=default
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.SolveMaterial entity.
virtual void construct(agxData::EntityPtr instance) override
virtual void initAttributeAccessors() override
static agxData::EntityStorage * defaultStorage()
static SolveMaterialPtr createInstance()
Create and return a pointer to a new instance in the default storage for this entity model.
void construct(agx::Physics::SolveMaterialPtr solveMaterial)
static agxData::ScalarAttributeT< agx::Vec2 > * frictionAttribute
static SolveMaterialModel * instance()
virtual void configure(agx::TiXmlElement *eEntity) override
virtual void shutdownCleanup() override
This is part of internal cleanup and should not be called by users.
SolveMaterialModel(const agx::String &name="SolveMaterial")
virtual agxData::EntityData * createData(agxData::EntityStorage *storage) override
static agxData::ScalarAttributeT< agx::Real > * adhesiveImpulseAttribute
Pointer to a entity instance of type Physics.SolveMaterial.
AGXPHYSICS_EXPORT SolveMaterialPtr(const agxData::EntityInstance &instance)
AGXPHYSICS_EXPORT const SolveMaterialInstance instance() const
AGXPHYSICS_EXPORT agx::Real & adhesiveImpulse()
AGXPHYSICS_EXPORT SolveMaterialSemantics * operator->()
AGXPHYSICS_EXPORT SolveMaterialInstance instance()
SolveMaterialInstance InstanceType
AGXPHYSICS_EXPORT const SolveMaterialSemantics * operator->() const
AGXPHYSICS_EXPORT SolveMaterialPtr()
SolveMaterialData * getData()
AGXPHYSICS_EXPORT agx::Vec2 & friction()
AGXPHYSICS_EXPORT agx::Real const & adhesiveImpulse() const
AGXPHYSICS_EXPORT SolveMaterialPtr(agxData::EntityStorage *storage, agx::Index id)
const SolveMaterialData * getData() const
AGXPHYSICS_EXPORT SolveMaterialPtr(const agxData::EntityPtr &ptr)
AGXPHYSICS_EXPORT agx::Vec2 const & friction() const
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:97
#define CALLABLE
Definition: macros.h:72
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
#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:42
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:364
UInt32 Index
Definition: Integer.h:52