AGX Dynamics  2.37.3.2
ContactEntity.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_CONTACT_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_CONTACT_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>
48 #include <agx/Integer.h>
50 
51 namespace agx { namespace Physics { class ContactMaterialPtr; }}
52 
53 namespace agx
54 {
55  namespace Physics
56  {
57 
58  class ContactModel;
59  class ContactData;
60  class ContactPtr;
61  class ContactInstance;
62  class ContactSemantics;
63 
64 
66 
71  {
72  public:
73  typedef ContactPtr PtrT;
74 
75  ContactModel(const agx::String& name = "Contact");
76 
78  static ContactModel* instance();
79 
81  static ContactPtr createInstance();
82 
84  static agxData::EntityStorage* defaultStorage();
85 
87  virtual void shutdownCleanup() override;
88 
89 
90 
91  /* Attributes */
96 
97  protected:
98  virtual ~ContactModel();
99  virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
100  virtual void configure(agx::TiXmlElement* eEntity) override;
101  virtual void initAttributeAccessors() override;
102  virtual void construct(agxData::EntityPtr instance) override;
103  void construct(agx::Physics::ContactPtr contact);
104  };
105 
106 
108  #ifndef AGX_PHYSICS_CONTACT_DATA_SET_OVERRIDE
109  #define AGX_PHYSICS_CONTACT_DATA_SET
110  class AGXPHYSICS_EXPORT ContactData : public agx::Physics::InteractionData
111  {
112  public:
113  ContactInstance operator[] (size_t index);
114 
115  public:
117  agxData::Array< agx::UInt32 > constraintIndex;
119  agxData::Array< agx::UInt32 > contactZoneIndex;
120  agxData::Array< agx::UInt16 > contactZoneSlot;
121 
122  public:
123  typedef agx::UInt32 constraintIndexType;
124  typedef agx::Physics::ContactMaterialPtr materialType;
125  typedef agx::UInt32 contactZoneIndexType;
126  typedef agx::UInt16 contactZoneSlotType;
127 
128  public:
129  ContactData(agxData::EntityStorage* storage);
130  ContactData();
131 
132  protected:
133  virtual ~ContactData() {}
134  virtual void setNumElements(agx::Index numElements) override;
135 
136  private:
137  ContactData& operator= (const ContactData&) { return *this; }
138 
139  };
140  #endif
142 
143 
145  class AGXPHYSICS_EXPORT ContactSemantics : public agx::Physics::InteractionSemantics
146  {
147  public:
148 
149  // Automatic getters
150  agx::UInt32 const& getConstraintIndex() const;
151  agx::Physics::ContactMaterialPtr const& getMaterial() const;
152  agx::UInt32 const& getContactZoneIndex() const;
153  agx::UInt16 const& getContactZoneSlot() const;
154 
155  // Semantics defined by explicit kernels
156 
157  // Automatic setters
158  void setConstraintIndex(agx::UInt32 const& value);
159  void setMaterial(agx::Physics::ContactMaterialPtr const& value);
160  void setContactZoneIndex(agx::UInt32 const& value);
161  void setContactZoneSlot(agx::UInt16 const& value);
162 
163 
164  protected:
165  friend class ContactPtr;
166  friend class ContactInstance;
167  ContactSemantics();
168  };
170 
171 
172 
175  class CALLABLE ContactPtr : public agx::Physics::InteractionPtr
176  {
177  public:
179  typedef ContactData DataType;
180  typedef ContactInstance InstanceType;
181 
182  public:
187  AGXPHYSICS_EXPORT ContactPtr& operator= (const agxData::EntityPtr& ptr);
188  AGXPHYSICS_EXPORT ContactPtr& operator= (const agxData::EntityInstance& instance);
189  AGXPHYSICS_EXPORT ContactInstance instance();
190  AGXPHYSICS_EXPORT const ContactInstance instance() const;
191 
192  AGXPHYSICS_EXPORT ContactSemantics* operator->();
193  AGXPHYSICS_EXPORT const ContactSemantics* operator->() const;
194 
195  ContactData* getData();
196  const ContactData* getData() const;
197 
198 
200  AGXPHYSICS_EXPORT agx::UInt32& constraintIndex();
202  AGXPHYSICS_EXPORT agx::UInt32 const& constraintIndex() const;
203 
207  AGXPHYSICS_EXPORT agx::Physics::ContactMaterialPtr const& material() const;
208 
210  AGXPHYSICS_EXPORT agx::UInt32& contactZoneIndex();
212  AGXPHYSICS_EXPORT agx::UInt32 const& contactZoneIndex() const;
213 
215  AGXPHYSICS_EXPORT agx::UInt16& contactZoneSlot();
217  AGXPHYSICS_EXPORT agx::UInt16 const& contactZoneSlot() const;
218 
219  };
220 
221 
223  class AGXPHYSICS_EXPORT ContactInstance : public agx::Physics::InteractionInstance
224  {
225  public:
226  ContactInstance();
227  ContactInstance(ContactData* data, agx::Index index);
228  ContactInstance(agxData::EntityStorage *storage, agx::Index index);
229  ContactInstance(const agxData::EntityInstance& other);
230  ContactInstance(const agxData::EntityPtr& ptr);
231 
232  ContactData* getData();
233  const ContactData* getData() const;
234 
235  public:
237  agx::UInt32& constraintIndex();
239  agx::UInt32 const& constraintIndex() const;
240 
244  agx::Physics::ContactMaterialPtr const& material() const;
245 
247  agx::UInt32& contactZoneIndex();
249  agx::UInt32 const& contactZoneIndex() const;
250 
252  agx::UInt16& contactZoneSlot();
254  agx::UInt16 const& contactZoneSlot() const;
255 
256  };
258 
259 
260 
263 
264 
265 
267  /* Implementation */
268  //-----------------------------------------------------------------------------------------------------
269  //-----------------------------------------------------------------------------------------------------
270  inline ContactInstance agx::Physics::ContactData::operator[] (size_t index) { return ContactInstance(this, (agx::Index)index); }
271  //-----------------------------------------------------------------------------------------------------
275  {
277  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
278  EntityPtr::getModel()->fullPath().c_str(), ContactModel::instance()->fullPath().c_str());
279  }
280 
282  {
283  agxAssertN(!instance || instance.isInstanceOf(ContactModel::instance()),
284  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
285  EntityPtr::getModel()->fullPath().c_str(), ContactModel::instance()->fullPath().c_str());
286  }
287 
289  {
292  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
293  EntityPtr::getModel()->fullPath().c_str(), ContactModel::instance()->fullPath().c_str());
294  return *this;
295  }
296 
298  {
300  agxAssertN(!instance || instance.isInstanceOf(ContactModel::instance()),
301  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
302  EntityPtr::getModel()->fullPath().c_str(), ContactModel::instance()->fullPath().c_str());
303  return *this;
304  }
305 
306  inline ContactInstance ContactPtr::instance() { return agxData::EntityPtr::instance(); }
307  inline const ContactInstance ContactPtr::instance() const { return agxData::EntityPtr::instance(); }
308  AGX_FORCE_INLINE ContactSemantics* ContactPtr::operator->() { return (ContactSemantics* )this; }
309  AGX_FORCE_INLINE const ContactSemantics* ContactPtr::operator->() const { return (const ContactSemantics* )this; }
310  AGX_FORCE_INLINE ContactData* ContactPtr::getData() { return static_cast<ContactData* >(agxData::EntityPtr::getData()); }
311  AGX_FORCE_INLINE const ContactData* ContactPtr::getData() const { return static_cast<const ContactData* >(agxData::EntityPtr::getData()); }
312 
313  AGX_FORCE_INLINE agx::UInt32& ContactPtr::constraintIndex() { verifyIndex(); return getData()->constraintIndex[calculateIndex()]; }
314  AGX_FORCE_INLINE agx::UInt32 const& ContactPtr::constraintIndex() const { verifyIndex(); return getData()->constraintIndex[calculateIndex()]; }
315 
316  AGX_FORCE_INLINE agx::Physics::ContactMaterialPtr& ContactPtr::material() { verifyIndex(); return getData()->material[calculateIndex()]; }
317  AGX_FORCE_INLINE agx::Physics::ContactMaterialPtr const& ContactPtr::material() const { verifyIndex(); return getData()->material[calculateIndex()]; }
318 
319  AGX_FORCE_INLINE agx::UInt32& ContactPtr::contactZoneIndex() { verifyIndex(); return getData()->contactZoneIndex[calculateIndex()]; }
320  AGX_FORCE_INLINE agx::UInt32 const& ContactPtr::contactZoneIndex() const { verifyIndex(); return getData()->contactZoneIndex[calculateIndex()]; }
321 
322  AGX_FORCE_INLINE agx::UInt16& ContactPtr::contactZoneSlot() { verifyIndex(); return getData()->contactZoneSlot[calculateIndex()]; }
323  AGX_FORCE_INLINE agx::UInt16 const& ContactPtr::contactZoneSlot() const { verifyIndex(); return getData()->contactZoneSlot[calculateIndex()]; }
324 
325  //-----------------------------------------------------------------------------------------------------
326  AGX_FORCE_INLINE ContactInstance::ContactInstance() {}
327  AGX_FORCE_INLINE ContactInstance::ContactInstance(ContactData* data, agx::Index index) : agx::Physics::InteractionInstance(data, index) {}
328  AGX_FORCE_INLINE ContactInstance::ContactInstance(agxData::EntityStorage* storage, agx::Index index) : agx::Physics::InteractionInstance(storage, index) {}
329  AGX_FORCE_INLINE ContactInstance::ContactInstance(const agxData::EntityInstance& other) : agx::Physics::InteractionInstance(other)
330  {
332  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
334  }
335 
336  AGX_FORCE_INLINE ContactInstance::ContactInstance(const agxData::EntityPtr& ptr) : agx::Physics::InteractionInstance(ptr)
337  {
339  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
341  }
342 
343 
344  AGX_FORCE_INLINE ContactData* ContactInstance::getData() { return static_cast<ContactData* >(agxData::EntityInstance::getData()); }
345  AGX_FORCE_INLINE const ContactData* ContactInstance::getData() const { return static_cast<const ContactData* >(agxData::EntityInstance::getData()); }
346 
347  AGX_FORCE_INLINE agx::UInt32& ContactInstance::constraintIndex() { verifyIndex(); return getData()->constraintIndex[getIndex()]; }
348  AGX_FORCE_INLINE agx::UInt32 const& ContactInstance::constraintIndex() const { verifyIndex(); return getData()->constraintIndex[getIndex()]; }
349 
350  AGX_FORCE_INLINE agx::Physics::ContactMaterialPtr& ContactInstance::material() { verifyIndex(); return getData()->material[getIndex()]; }
351  AGX_FORCE_INLINE agx::Physics::ContactMaterialPtr const& ContactInstance::material() const { verifyIndex(); return getData()->material[getIndex()]; }
352 
353  AGX_FORCE_INLINE agx::UInt32& ContactInstance::contactZoneIndex() { verifyIndex(); return getData()->contactZoneIndex[getIndex()]; }
354  AGX_FORCE_INLINE agx::UInt32 const& ContactInstance::contactZoneIndex() const { verifyIndex(); return getData()->contactZoneIndex[getIndex()]; }
355 
356  AGX_FORCE_INLINE agx::UInt16& ContactInstance::contactZoneSlot() { verifyIndex(); return getData()->contactZoneSlot[getIndex()]; }
357  AGX_FORCE_INLINE agx::UInt16 const& ContactInstance::contactZoneSlot() const { verifyIndex(); return getData()->contactZoneSlot[getIndex()]; }
358 
359  //-----------------------------------------------------------------------------------------------------
360  AGX_FORCE_INLINE ContactSemantics::ContactSemantics() {}
361  //-----------------------------------------------------------------------------------------------------
363  }
364 }
365 
366 AGX_TYPE_BINDING(agx::Physics::ContactPtr, "Physics.ContactPtr")
367 AGX_TYPE_BINDING(agx::Physics::ContactInstance, "Physics.ContactInstance")
368 
369 #ifdef _MSC_VER
370 # pragma warning(pop)
371 #endif
372 
373 #undef AGX_ENTITY_WRAPPER
374 #undef AGX_ENTITY_NAMESPACE
375 #endif
376 
AGXPHYSICS_EXPORT ContactSemantics * operator->()
agxData::EntityData * getData()
static ContactModel * instance()
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
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
Pointer to a entity instance of type Physics.Interaction.
#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
#define AGX_FORCE_INLINE
Definition: Object.h:59
AGXPHYSICS_EXPORT agx::Physics::ContactMaterialPtr & material()
Type-specific Array used for fast access into the data held by a Buffer.
Definition: agxData.h:30
Abstract description of the data attributes for the Physics.Interaction entity.
Pointer to a entity instance of type Physics.Contact.
static agxData::ScalarAttributeT< agx::UInt32 > * contactZoneIndexAttribute
Definition: ContactEntity.h:94
static agxData::ScalarAttributeT< agx::UInt32 > * constraintIndexAttribute
Definition: ContactEntity.h:92
ContactData * getData()
AGXPHYSICS_EXPORT agx::UInt16 & contactZoneSlot()
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.
AGXPHYSICS_EXPORT ContactPtr & operator=(const agxData::EntityPtr &ptr)
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.Contact entity.
Definition: ContactEntity.h:70
AGXPHYSICS_EXPORT agx::UInt32 & contactZoneIndex()
AGXPHYSICS_EXPORT agx::UInt32 & constraintIndex()
#define CALLABLE
Definition: Object.h:73
bool isInstanceOf(agxData::EntityModel *model) const
static agxData::ScalarAttributeT< agx::Physics::ContactMaterialPtr > * materialAttribute
Definition: ContactEntity.h:93
uint16_t UInt16
Definition: Integer.h:39
AGXPHYSICS_EXPORT ContactPtr()
AGXPHYSICS_EXPORT ContactInstance instance()
ContactInstance InstanceType
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
Pointer to a entity instance of type Physics.ContactMaterial.
static agxData::ScalarAttributeT< agx::UInt16 > * contactZoneSlotAttribute
Definition: ContactEntity.h:95