AGX Dynamics  2.35.0.1
SurfaceMaterialEntity.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_SURFACEMATERIAL_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_SURFACEMATERIAL_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/ReferencedEntity.h>
48 #include <agx/Real.h>
49 #include <agx/Integer.h>
50 
51 
52 namespace agx
53 {
54  namespace Physics
55  {
56 
57  class SurfaceMaterialModel;
58  class SurfaceMaterialData;
59  class SurfaceMaterialPtr;
60  class SurfaceMaterialInstance;
61  class SurfaceMaterialSemantics;
62 
63 
65 
70  {
71  public:
73 
74  SurfaceMaterialModel(const agx::String& name = "SurfaceMaterial");
75 
78 
81 
84 
86  virtual void shutdownCleanup() override;
87 
88 
89 
90  /* Attributes */
97 
98  protected:
100  virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
101  virtual void configure(agx::TiXmlElement* eEntity) override;
102  virtual void initAttributeAccessors() override;
103  virtual void construct(agxData::EntityPtr instance) override;
105  };
106 
107 
109  #ifndef AGX_PHYSICS_SURFACEMATERIAL_DATA_SET_OVERRIDE
110  #define AGX_PHYSICS_SURFACEMATERIAL_DATA_SET
111  class AGXPHYSICS_EXPORT SurfaceMaterialData : public agx::ReferencedData
112  {
113  public:
114  SurfaceMaterialInstance operator[] (size_t index);
115 
116  public:
118  agxData::Array< agx::Real > roughness;
120  agxData::Array< agx::Real > adhesiveOverlap;
121  agxData::Array< agx::Real > viscosity;
122  agxData::Array< agx::Bool > frictionEnabled;
124 
125  public:
126  typedef agx::Real roughnessType;
127  typedef agx::Real adhesionType;
128  typedef agx::Real adhesiveOverlapType;
129  typedef agx::Real viscosityType;
130  typedef agx::Bool frictionEnabledType;
131  typedef agx::Bool dirtyType;
132 
133  public:
134  SurfaceMaterialData(agxData::EntityStorage* storage);
135  SurfaceMaterialData();
136 
137  protected:
138  virtual ~SurfaceMaterialData() {}
139  virtual void setNumElements(agx::Index numElements) override;
140 
141  private:
142  SurfaceMaterialData& operator= (const SurfaceMaterialData&) { return *this; }
143 
144  };
145  #endif
147 
148 
150  class AGXPHYSICS_EXPORT SurfaceMaterialSemantics : public agx::ReferencedSemantics
151  {
152  public:
153 
154  // Automatic getters
155  agx::Real const& getRoughness() const;
156  agx::Real const& getAdhesion() const;
157  agx::Real const& getAdhesiveOverlap() const;
158  agx::Real const& getViscosity() const;
159  agx::Bool const& getFrictionEnabled() const;
160  agx::Bool const& getDirty() const;
161 
162  // Semantics defined by explicit kernels
163 
164  // Automatic setters
165  void setRoughness(agx::Real const& value);
166  void setAdhesion(agx::Real const& value);
167  void setAdhesiveOverlap(agx::Real const& value);
168  void setViscosity(agx::Real const& value);
169  void setFrictionEnabled(agx::Bool const& value);
170  void setDirty(agx::Bool const& value);
171 
172 
173  protected:
174  friend class SurfaceMaterialPtr;
175  friend class SurfaceMaterialInstance;
176  SurfaceMaterialSemantics();
177  };
179 
180 
181 
185  {
186  public:
188  typedef SurfaceMaterialData DataType;
189  typedef SurfaceMaterialInstance InstanceType;
190 
191  public:
198  AGXPHYSICS_EXPORT SurfaceMaterialInstance instance();
199  AGXPHYSICS_EXPORT const SurfaceMaterialInstance instance() const;
200 
201  AGXPHYSICS_EXPORT SurfaceMaterialSemantics* operator->();
202  AGXPHYSICS_EXPORT const SurfaceMaterialSemantics* operator->() const;
203 
204  SurfaceMaterialData* getData();
205  const SurfaceMaterialData* getData() const;
206 
207 
212 
217 
222 
227 
232 
237 
239  // Only used by tolua!
240  #ifdef AGX_GENERATED_TOLUA_WRAPPER
241  inline agx::Real const& getRoughness() const { return (*this)->getRoughness(); }
242  inline agx::Real const& getAdhesion() const { return (*this)->getAdhesion(); }
243  inline agx::Real const& getAdhesiveOverlap() const { return (*this)->getAdhesiveOverlap(); }
244  inline agx::Real const& getViscosity() const { return (*this)->getViscosity(); }
245  inline agx::Bool const& getFrictionEnabled() const { return (*this)->getFrictionEnabled(); }
246  inline agx::Bool const& getDirty() const { return (*this)->getDirty(); }
247 
248 
249  inline void setRoughness(agx::Real const& value) { (*this)->setRoughness(value); }
250  inline void setAdhesion(agx::Real const& value) { (*this)->setAdhesion(value); }
251  inline void setAdhesiveOverlap(agx::Real const& value) { (*this)->setAdhesiveOverlap(value); }
252  inline void setViscosity(agx::Real const& value) { (*this)->setViscosity(value); }
253  inline void setFrictionEnabled(agx::Bool const& value) { (*this)->setFrictionEnabled(value); }
254  inline void setDirty(agx::Bool const& value) { (*this)->setDirty(value); }
255  #endif
257 
258  };
259 
260  // Entity is Referenced
262 
263 
265  class AGXPHYSICS_EXPORT SurfaceMaterialInstance : public agx::ReferencedInstance
266  {
267  public:
268  SurfaceMaterialInstance();
269  SurfaceMaterialInstance(SurfaceMaterialData* data, agx::Index index);
270  SurfaceMaterialInstance(agxData::EntityStorage *storage, agx::Index index);
271  SurfaceMaterialInstance(const agxData::EntityInstance& other);
272  SurfaceMaterialInstance(const agxData::EntityPtr& ptr);
273 
274  SurfaceMaterialData* getData();
275  const SurfaceMaterialData* getData() const;
276 
277  public:
279  agx::Real& roughness();
281  agx::Real const& roughness() const;
282 
284  agx::Real& adhesion();
286  agx::Real const& adhesion() const;
287 
289  agx::Real& adhesiveOverlap();
291  agx::Real const& adhesiveOverlap() const;
292 
294  agx::Real& viscosity();
296  agx::Real const& viscosity() const;
297 
299  agx::Bool& frictionEnabled();
301  agx::Bool const& frictionEnabled() const;
302 
304  agx::Bool& dirty();
306  agx::Bool const& dirty() const;
307 
308  };
310 
311 
312 
315 
316 
317 
319  /* Implementation */
320  //-----------------------------------------------------------------------------------------------------
321  //-----------------------------------------------------------------------------------------------------
322  inline SurfaceMaterialInstance agx::Physics::SurfaceMaterialData::operator[] (size_t index) { return SurfaceMaterialInstance(this, (agx::Index)index); }
323  //-----------------------------------------------------------------------------------------------------
326  AGX_FORCE_INLINE SurfaceMaterialPtr::SurfaceMaterialPtr(const agxData::EntityPtr& ptr) : agx::ReferencedPtr(ptr)
327  {
329  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
331  }
332 
333  AGX_FORCE_INLINE SurfaceMaterialPtr::SurfaceMaterialPtr(const agxData::EntityInstance& instance) : agx::ReferencedPtr(instance)
334  {
335  agxAssertN(!instance || instance.isInstanceOf(SurfaceMaterialModel::instance()),
336  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
338  }
339 
340  AGX_FORCE_INLINE SurfaceMaterialPtr& SurfaceMaterialPtr::operator= (const agxData::EntityPtr& ptr)
341  {
343  agxAssertN(!ptr || ptr.isInstanceOf(SurfaceMaterialModel::instance()),
344  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
345  EntityPtr::getModel()->fullPath().c_str(), SurfaceMaterialModel::instance()->fullPath().c_str());
346  return *this;
347  }
348 
349  AGX_FORCE_INLINE SurfaceMaterialPtr& SurfaceMaterialPtr::operator= (const agxData::EntityInstance& instance)
350  {
352  agxAssertN(!instance || instance.isInstanceOf(SurfaceMaterialModel::instance()),
353  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
354  EntityPtr::getModel()->fullPath().c_str(), SurfaceMaterialModel::instance()->fullPath().c_str());
355  return *this;
356  }
357 
358  inline SurfaceMaterialInstance SurfaceMaterialPtr::instance() { return agxData::EntityPtr::instance(); }
359  inline const SurfaceMaterialInstance SurfaceMaterialPtr::instance() const { return agxData::EntityPtr::instance(); }
360  AGX_FORCE_INLINE SurfaceMaterialSemantics* SurfaceMaterialPtr::operator->() { return (SurfaceMaterialSemantics* )this; }
361  AGX_FORCE_INLINE const SurfaceMaterialSemantics* SurfaceMaterialPtr::operator->() const { return (const SurfaceMaterialSemantics* )this; }
362  AGX_FORCE_INLINE SurfaceMaterialData* SurfaceMaterialPtr::getData() { return static_cast<SurfaceMaterialData* >(agxData::EntityPtr::getData()); }
363  AGX_FORCE_INLINE const SurfaceMaterialData* SurfaceMaterialPtr::getData() const { return static_cast<const SurfaceMaterialData* >(agxData::EntityPtr::getData()); }
364 
365  AGX_FORCE_INLINE agx::Real& SurfaceMaterialPtr::roughness() { verifyIndex(); return getData()->roughness[calculateIndex()]; }
366  AGX_FORCE_INLINE agx::Real const& SurfaceMaterialPtr::roughness() const { verifyIndex(); return getData()->roughness[calculateIndex()]; }
367 
368  AGX_FORCE_INLINE agx::Real& SurfaceMaterialPtr::adhesion() { verifyIndex(); return getData()->adhesion[calculateIndex()]; }
369  AGX_FORCE_INLINE agx::Real const& SurfaceMaterialPtr::adhesion() const { verifyIndex(); return getData()->adhesion[calculateIndex()]; }
370 
371  AGX_FORCE_INLINE agx::Real& SurfaceMaterialPtr::adhesiveOverlap() { verifyIndex(); return getData()->adhesiveOverlap[calculateIndex()]; }
372  AGX_FORCE_INLINE agx::Real const& SurfaceMaterialPtr::adhesiveOverlap() const { verifyIndex(); return getData()->adhesiveOverlap[calculateIndex()]; }
373 
374  AGX_FORCE_INLINE agx::Real& SurfaceMaterialPtr::viscosity() { verifyIndex(); return getData()->viscosity[calculateIndex()]; }
375  AGX_FORCE_INLINE agx::Real const& SurfaceMaterialPtr::viscosity() const { verifyIndex(); return getData()->viscosity[calculateIndex()]; }
376 
377  AGX_FORCE_INLINE agx::Bool& SurfaceMaterialPtr::frictionEnabled() { verifyIndex(); return getData()->frictionEnabled[calculateIndex()]; }
378  AGX_FORCE_INLINE agx::Bool const& SurfaceMaterialPtr::frictionEnabled() const { verifyIndex(); return getData()->frictionEnabled[calculateIndex()]; }
379 
380  AGX_FORCE_INLINE agx::Bool& SurfaceMaterialPtr::dirty() { verifyIndex(); return getData()->dirty[calculateIndex()]; }
381  AGX_FORCE_INLINE agx::Bool const& SurfaceMaterialPtr::dirty() const { verifyIndex(); return getData()->dirty[calculateIndex()]; }
382 
383  //-----------------------------------------------------------------------------------------------------
384  AGX_FORCE_INLINE SurfaceMaterialInstance::SurfaceMaterialInstance() {}
385  AGX_FORCE_INLINE SurfaceMaterialInstance::SurfaceMaterialInstance(SurfaceMaterialData* data, agx::Index index) : agx::ReferencedInstance(data, index) {}
386  AGX_FORCE_INLINE SurfaceMaterialInstance::SurfaceMaterialInstance(agxData::EntityStorage* storage, agx::Index index) : agx::ReferencedInstance(storage, index) {}
387  AGX_FORCE_INLINE SurfaceMaterialInstance::SurfaceMaterialInstance(const agxData::EntityInstance& other) : agx::ReferencedInstance(other)
388  {
390  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
392  }
393 
394  AGX_FORCE_INLINE SurfaceMaterialInstance::SurfaceMaterialInstance(const agxData::EntityPtr& ptr) : agx::ReferencedInstance(ptr)
395  {
397  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
399  }
400 
401 
402  AGX_FORCE_INLINE SurfaceMaterialData* SurfaceMaterialInstance::getData() { return static_cast<SurfaceMaterialData* >(agxData::EntityInstance::getData()); }
403  AGX_FORCE_INLINE const SurfaceMaterialData* SurfaceMaterialInstance::getData() const { return static_cast<const SurfaceMaterialData* >(agxData::EntityInstance::getData()); }
404 
405  AGX_FORCE_INLINE agx::Real& SurfaceMaterialInstance::roughness() { verifyIndex(); return getData()->roughness[getIndex()]; }
406  AGX_FORCE_INLINE agx::Real const& SurfaceMaterialInstance::roughness() const { verifyIndex(); return getData()->roughness[getIndex()]; }
407 
408  AGX_FORCE_INLINE agx::Real& SurfaceMaterialInstance::adhesion() { verifyIndex(); return getData()->adhesion[getIndex()]; }
409  AGX_FORCE_INLINE agx::Real const& SurfaceMaterialInstance::adhesion() const { verifyIndex(); return getData()->adhesion[getIndex()]; }
410 
411  AGX_FORCE_INLINE agx::Real& SurfaceMaterialInstance::adhesiveOverlap() { verifyIndex(); return getData()->adhesiveOverlap[getIndex()]; }
412  AGX_FORCE_INLINE agx::Real const& SurfaceMaterialInstance::adhesiveOverlap() const { verifyIndex(); return getData()->adhesiveOverlap[getIndex()]; }
413 
414  AGX_FORCE_INLINE agx::Real& SurfaceMaterialInstance::viscosity() { verifyIndex(); return getData()->viscosity[getIndex()]; }
415  AGX_FORCE_INLINE agx::Real const& SurfaceMaterialInstance::viscosity() const { verifyIndex(); return getData()->viscosity[getIndex()]; }
416 
417  AGX_FORCE_INLINE agx::Bool& SurfaceMaterialInstance::frictionEnabled() { verifyIndex(); return getData()->frictionEnabled[getIndex()]; }
418  AGX_FORCE_INLINE agx::Bool const& SurfaceMaterialInstance::frictionEnabled() const { verifyIndex(); return getData()->frictionEnabled[getIndex()]; }
419 
420  AGX_FORCE_INLINE agx::Bool& SurfaceMaterialInstance::dirty() { verifyIndex(); return getData()->dirty[getIndex()]; }
421  AGX_FORCE_INLINE agx::Bool const& SurfaceMaterialInstance::dirty() const { verifyIndex(); return getData()->dirty[getIndex()]; }
422 
423  //-----------------------------------------------------------------------------------------------------
424  AGX_FORCE_INLINE SurfaceMaterialSemantics::SurfaceMaterialSemantics() {}
425  //-----------------------------------------------------------------------------------------------------
427  }
428 }
429 
430 AGX_TYPE_BINDING(agx::Physics::SurfaceMaterialPtr, "Physics.SurfaceMaterialPtr")
431 AGX_TYPE_BINDING(agx::Physics::SurfaceMaterialInstance, "Physics.SurfaceMaterialInstance")
432 
433 #ifdef _MSC_VER
434 # pragma warning(pop)
435 #endif
436 
437 #undef AGX_ENTITY_WRAPPER
438 #undef AGX_ENTITY_NAMESPACE
439 #endif
440 
#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()
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.SurfaceMaterial entity.
static agxData::EntityStorage * defaultStorage()
void construct(agx::Physics::SurfaceMaterialPtr surfaceMaterial)
static agxData::ScalarAttributeT< agx::Real > * viscosityAttribute
static agxData::ScalarAttributeT< agx::Bool > * dirtyAttribute
static agxData::ScalarAttributeT< agx::Real > * adhesionAttribute
static SurfaceMaterialModel * instance()
SurfaceMaterialModel(const agx::String &name="SurfaceMaterial")
virtual void initAttributeAccessors() override
virtual void construct(agxData::EntityPtr instance) override
virtual void shutdownCleanup() override
This is part of internal cleanup and should not be called by users.
static SurfaceMaterialPtr createInstance()
Create and return a pointer to a new instance in the default storage for this entity model.
virtual agxData::EntityData * createData(agxData::EntityStorage *storage) override
virtual void configure(agx::TiXmlElement *eEntity) override
static agxData::ScalarAttributeT< agx::Bool > * frictionEnabledAttribute
static agxData::ScalarAttributeT< agx::Real > * adhesiveOverlapAttribute
static agxData::ScalarAttributeT< agx::Real > * roughnessAttribute
Pointer to a entity instance of type Physics.SurfaceMaterial.
AGXPHYSICS_EXPORT const SurfaceMaterialInstance instance() const
AGXPHYSICS_EXPORT agx::Real & roughness()
const SurfaceMaterialData * getData() const
AGXPHYSICS_EXPORT SurfaceMaterialInstance instance()
AGXPHYSICS_EXPORT SurfaceMaterialSemantics * operator->()
AGXPHYSICS_EXPORT agx::Real & adhesion()
SurfaceMaterialData * getData()
AGXPHYSICS_EXPORT agx::Bool & dirty()
AGXPHYSICS_EXPORT agx::Real & viscosity()
AGXPHYSICS_EXPORT const SurfaceMaterialSemantics * operator->() const
AGXPHYSICS_EXPORT agx::Real & adhesiveOverlap()
AGXPHYSICS_EXPORT agx::Real const & viscosity() const
AGXPHYSICS_EXPORT SurfaceMaterialPtr(const agxData::EntityInstance &instance)
AGXPHYSICS_EXPORT agx::Real const & adhesion() const
AGXPHYSICS_EXPORT agx::Bool const & dirty() const
AGXPHYSICS_EXPORT SurfaceMaterialPtr()
AGXPHYSICS_EXPORT agx::Bool & frictionEnabled()
AGXPHYSICS_EXPORT agx::Real const & adhesiveOverlap() const
AGXPHYSICS_EXPORT agx::Bool const & frictionEnabled() const
AGXPHYSICS_EXPORT SurfaceMaterialPtr(agxData::EntityStorage *storage, agx::Index id)
AGXPHYSICS_EXPORT SurfaceMaterialPtr(const agxData::EntityPtr &ptr)
AGXPHYSICS_EXPORT agx::Real const & roughness() const
Abstract description of the data attributes for the Referenced entity.
Pointer to a entity instance of type Referenced.
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
agxData::EntityRef< SurfaceMaterialPtr > SurfaceMaterialRef
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
bool Bool
Definition: Integer.h:48
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