AGX Dynamics  2.38.0.2
BodyContactEntity.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_BODYCONTACT_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_BODYCONTACT_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>
48 
49 
50 namespace agx
51 {
52  namespace Physics
53  {
54 
55  class BodyContactModel;
56  class BodyContactData;
57  class BodyContactPtr;
58  class BodyContactInstance;
59  class BodyContactSemantics;
60 
61 
63 
68  {
69  public:
71 
72  BodyContactModel(const agx::String& name = "BodyContact");
73 
75  static BodyContactModel* instance();
76 
78  static BodyContactPtr createInstance();
79 
81  static agxData::EntityStorage* defaultStorage();
82 
84  virtual void shutdownCleanup() override;
85 
86 
87 
88  /* Attributes */
92 
93  protected:
94  virtual ~BodyContactModel();
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;
99  void construct(agx::Physics::BodyContactPtr bodyContact);
100  };
101 
102 
104  #ifndef AGX_PHYSICS_BODYCONTACT_DATA_SET_OVERRIDE
105  #define AGX_PHYSICS_BODYCONTACT_DATA_SET
106  class AGXPHYSICS_EXPORT BodyContactData : public agxData::EntityData
107  {
108  public:
109  BodyContactInstance operator[] (size_t index);
110 
111  public:
115  agxData::Array< agx::Int > contactListOffset;
116 
117  public:
118  typedef agx::Int body1Type;
119  typedef agx::Int body2Type;
120  typedef agx::Int contactListOffsetType;
121 
122  public:
123  BodyContactData(agxData::EntityStorage* storage);
124  BodyContactData();
125 
126  protected:
127  virtual ~BodyContactData() {}
128  virtual void setNumElements(agx::Index numElements) override;
129 
130  private:
131  BodyContactData& operator= (const BodyContactData&) { return *this; }
132 
133  };
134  #endif
136 
137 
139  class AGXPHYSICS_EXPORT BodyContactSemantics : protected agxData::EntityPtr
140  {
141  public:
142 
143  // Automatic getters
144  agx::Int const& getBody1() const;
145  agx::Int const& getBody2() const;
146  agx::Int const& getContactListOffset() const;
147 
148  // Semantics defined by explicit kernels
149 
150  // Automatic setters
151  void setBody1(agx::Int const& value);
152  void setBody2(agx::Int const& value);
153  void setContactListOffset(agx::Int const& value);
154 
155 
156  protected:
157  friend class BodyContactPtr;
158  friend class BodyContactInstance;
159  BodyContactSemantics();
160  };
162 
163 
164 
167  class CALLABLE BodyContactPtr : public agxData::EntityPtr
168  {
169  public:
171  typedef BodyContactData DataType;
172  typedef BodyContactInstance InstanceType;
173 
174  public:
179  AGXPHYSICS_EXPORT BodyContactPtr& operator= (const agxData::EntityPtr& ptr);
180  AGXPHYSICS_EXPORT BodyContactPtr& operator= (const agxData::EntityInstance& instance);
181  AGXPHYSICS_EXPORT BodyContactInstance instance();
182  AGXPHYSICS_EXPORT const BodyContactInstance instance() const;
183 
184  AGXPHYSICS_EXPORT BodyContactSemantics* operator->();
185  AGXPHYSICS_EXPORT const BodyContactSemantics* operator->() const;
186 
187  BodyContactData* getData();
188  const BodyContactData* getData() const;
189 
190 
192  AGXPHYSICS_EXPORT agx::Int& body1();
194  AGXPHYSICS_EXPORT agx::Int const& body1() const;
195 
197  AGXPHYSICS_EXPORT agx::Int& body2();
199  AGXPHYSICS_EXPORT agx::Int const& body2() const;
200 
202  AGXPHYSICS_EXPORT agx::Int& contactListOffset();
204  AGXPHYSICS_EXPORT agx::Int const& contactListOffset() const;
205 
206  };
207 
208 
210  class AGXPHYSICS_EXPORT BodyContactInstance : public agxData::EntityInstance
211  {
212  public:
213  BodyContactInstance();
214  BodyContactInstance(BodyContactData* data, agx::Index index);
215  BodyContactInstance(agxData::EntityStorage *storage, agx::Index index);
216  BodyContactInstance(const agxData::EntityInstance& other);
217  BodyContactInstance(const agxData::EntityPtr& ptr);
218 
219  BodyContactData* getData();
220  const BodyContactData* getData() const;
221 
222  public:
224  agx::Int& body1();
226  agx::Int const& body1() const;
227 
229  agx::Int& body2();
231  agx::Int const& body2() const;
232 
234  agx::Int& contactListOffset();
236  agx::Int const& contactListOffset() const;
237 
238  };
240 
241 
242 
245 
246 
247 
249  /* Implementation */
250  //-----------------------------------------------------------------------------------------------------
251  //-----------------------------------------------------------------------------------------------------
252  inline BodyContactInstance agx::Physics::BodyContactData::operator[] (size_t index) { return BodyContactInstance(this, (agx::Index)index); }
253  //-----------------------------------------------------------------------------------------------------
256  AGX_FORCE_INLINE BodyContactPtr::BodyContactPtr(const agxData::EntityPtr& ptr) : agxData::EntityPtr(ptr)
257  {
259  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
261  }
262 
263  AGX_FORCE_INLINE BodyContactPtr::BodyContactPtr(const agxData::EntityInstance& instance) : agxData::EntityPtr(instance)
264  {
265  agxAssertN(!instance || instance.isInstanceOf(BodyContactModel::instance()),
266  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
268  }
269 
270  AGX_FORCE_INLINE BodyContactPtr& BodyContactPtr::operator= (const agxData::EntityPtr& ptr)
271  {
273  agxAssertN(!ptr || ptr.isInstanceOf(BodyContactModel::instance()),
274  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
275  EntityPtr::getModel()->fullPath().c_str(), BodyContactModel::instance()->fullPath().c_str());
276  return *this;
277  }
278 
279  AGX_FORCE_INLINE BodyContactPtr& BodyContactPtr::operator= (const agxData::EntityInstance& instance)
280  {
282  agxAssertN(!instance || instance.isInstanceOf(BodyContactModel::instance()),
283  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
284  EntityPtr::getModel()->fullPath().c_str(), BodyContactModel::instance()->fullPath().c_str());
285  return *this;
286  }
287 
288  inline BodyContactInstance BodyContactPtr::instance() { return agxData::EntityPtr::instance(); }
289  inline const BodyContactInstance BodyContactPtr::instance() const { return agxData::EntityPtr::instance(); }
290  AGX_FORCE_INLINE BodyContactSemantics* BodyContactPtr::operator->() { return (BodyContactSemantics* )this; }
291  AGX_FORCE_INLINE const BodyContactSemantics* BodyContactPtr::operator->() const { return (const BodyContactSemantics* )this; }
292  AGX_FORCE_INLINE BodyContactData* BodyContactPtr::getData() { return static_cast<BodyContactData* >(agxData::EntityPtr::getData()); }
293  AGX_FORCE_INLINE const BodyContactData* BodyContactPtr::getData() const { return static_cast<const BodyContactData* >(agxData::EntityPtr::getData()); }
294 
295  AGX_FORCE_INLINE agx::Int& BodyContactPtr::body1() { verifyIndex(); return getData()->body1[calculateIndex()]; }
296  AGX_FORCE_INLINE agx::Int const& BodyContactPtr::body1() const { verifyIndex(); return getData()->body1[calculateIndex()]; }
297 
298  AGX_FORCE_INLINE agx::Int& BodyContactPtr::body2() { verifyIndex(); return getData()->body2[calculateIndex()]; }
299  AGX_FORCE_INLINE agx::Int const& BodyContactPtr::body2() const { verifyIndex(); return getData()->body2[calculateIndex()]; }
300 
301  AGX_FORCE_INLINE agx::Int& BodyContactPtr::contactListOffset() { verifyIndex(); return getData()->contactListOffset[calculateIndex()]; }
302  AGX_FORCE_INLINE agx::Int const& BodyContactPtr::contactListOffset() const { verifyIndex(); return getData()->contactListOffset[calculateIndex()]; }
303 
304  //-----------------------------------------------------------------------------------------------------
305  AGX_FORCE_INLINE BodyContactInstance::BodyContactInstance() {}
306  AGX_FORCE_INLINE BodyContactInstance::BodyContactInstance(BodyContactData* data, agx::Index index) : agxData::EntityInstance(data, index) {}
307  AGX_FORCE_INLINE BodyContactInstance::BodyContactInstance(agxData::EntityStorage* storage, agx::Index index) : agxData::EntityInstance(storage, index) {}
308  AGX_FORCE_INLINE BodyContactInstance::BodyContactInstance(const agxData::EntityInstance& other) : agxData::EntityInstance(other)
309  {
311  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
313  }
314 
315  AGX_FORCE_INLINE BodyContactInstance::BodyContactInstance(const agxData::EntityPtr& ptr) : agxData::EntityInstance(ptr)
316  {
318  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
320  }
321 
322 
323  AGX_FORCE_INLINE BodyContactData* BodyContactInstance::getData() { return static_cast<BodyContactData* >(agxData::EntityInstance::getData()); }
324  AGX_FORCE_INLINE const BodyContactData* BodyContactInstance::getData() const { return static_cast<const BodyContactData* >(agxData::EntityInstance::getData()); }
325 
326  AGX_FORCE_INLINE agx::Int& BodyContactInstance::body1() { verifyIndex(); return getData()->body1[getIndex()]; }
327  AGX_FORCE_INLINE agx::Int const& BodyContactInstance::body1() const { verifyIndex(); return getData()->body1[getIndex()]; }
328 
329  AGX_FORCE_INLINE agx::Int& BodyContactInstance::body2() { verifyIndex(); return getData()->body2[getIndex()]; }
330  AGX_FORCE_INLINE agx::Int const& BodyContactInstance::body2() const { verifyIndex(); return getData()->body2[getIndex()]; }
331 
332  AGX_FORCE_INLINE agx::Int& BodyContactInstance::contactListOffset() { verifyIndex(); return getData()->contactListOffset[getIndex()]; }
333  AGX_FORCE_INLINE agx::Int const& BodyContactInstance::contactListOffset() const { verifyIndex(); return getData()->contactListOffset[getIndex()]; }
334 
335  //-----------------------------------------------------------------------------------------------------
336  AGX_FORCE_INLINE BodyContactSemantics::BodyContactSemantics() {}
337  //-----------------------------------------------------------------------------------------------------
339  }
340 }
341 
342 AGX_TYPE_BINDING(agx::Physics::BodyContactPtr, "Physics.BodyContactPtr")
343 AGX_TYPE_BINDING(agx::Physics::BodyContactInstance, "Physics.BodyContactInstance")
344 
345 #ifdef _MSC_VER
346 # pragma warning(pop)
347 #endif
348 
349 #undef AGX_ENTITY_WRAPPER
350 #undef AGX_ENTITY_NAMESPACE
351 #endif
352 
agxData::ScalarAttributeT< agx::Int >
agx::Physics::BodyContactModel::body2Attribute
static agxData::ScalarAttributeT< agx::Int > * body2Attribute
Definition: BodyContactEntity.h:90
agxData::EntityModel
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
Definition: EntityModel.h:63
CALLABLE
#define CALLABLE
Definition: macros.h:72
agx::Physics::BodyContactModel::contactListOffsetAttribute
static agxData::ScalarAttributeT< agx::Int > * contactListOffsetAttribute
Definition: BodyContactEntity.h:91
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
agxData::EntityPtr::getData
agxData::EntityData * getData()
Definition: EntityStorage.h:594
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
macros.h
agxData::EntityPtr::isInstanceOf
bool isInstanceOf(agxData::EntityModel *model) const
Definition: EntityStorage.h:784
agx::Model::fullPath
agx::String fullPath() const
agxData::EntityStorage
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:72
EntityModel.h
agx::VectorPOD
Vector containing 'raw' data.
Definition: Vector.h:245
agxData::EntityPtr::instance
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
agxData::EntityInstance::isInstanceOf
bool isInstanceOf(agxData::EntityModel *model) const
Definition: EntityStorage.h:829
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agxData
Contains classes for low level data storage for AGX.
Definition: Container.h:23
agxData::Array
Type-specific Array used for fast access into the data held by a Buffer.
Definition: agxData.h:30
EntityStorage.h
EntityRef.h
agx::Int
int64_t Int
Definition: Integer.h:28
EntityPtr.h
agx::Physics::BodyContactPtr::ModelType
BodyContactModel ModelType
Definition: BodyContactEntity.h:170
agx::Physics::BodyContactModel::PtrT
BodyContactPtr PtrT
Definition: BodyContactEntity.h:70
EntityInstance.h
Integer.h
agx::Physics::BodyContactModel::instance
static BodyContactModel * instance()
agxData::EntityPtr::operator=
EntityPtr & operator=(const EntityPtr &other)=default
agx::Physics::BodyContactPtr
Pointer to a entity instance of type Physics.BodyContact.
Definition: BodyContactEntity.h:167
agx::Index
UInt32 Index
Definition: Integer.h:44
agxData::EntityInstance
Entity instance provides access to a single instance in an EntityStorage.
Definition: EntityInstance.h:43
agxData::EntityInstance::getData
agxData::EntityData * getData()
Definition: EntityInstance.h:149
agx::Physics::BodyContactModel
Abstract description of the data attributes for the Physics.BodyContact entity.
Definition: BodyContactEntity.h:67
agx::Physics::BodyContactPtr::InstanceType
BodyContactInstance InstanceType
Definition: BodyContactEntity.h:172
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agx::Physics::BodyContactPtr::DataType
BodyContactData DataType
Definition: BodyContactEntity.h:171
agx::AgXString< std::string >
agxAssertN
#define agxAssertN(expr, format,...)
Definition: debug.h:145
AGX_TYPE_BINDING
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
agx::Physics::BodyContactModel::body1Attribute
static agxData::ScalarAttributeT< agx::Int > * body1Attribute
Definition: BodyContactEntity.h:89
Real.h
agxData::EntityPtr
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition: EntityPtr.h:51
agx::Physics::BodyContactPtr::BodyContactPtr
AGXPHYSICS_EXPORT BodyContactPtr()
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agx::getModel
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:363