AGX Dynamics  2.35.0.1
CapsuleEntity.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_GEOMETRY_CAPSULE_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_GEOMETRY_CAPSULE_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/Real.h>
49 
50 
51 namespace agx
52 {
53  namespace Physics
54  {
55  namespace Geometry
56  {
57 
58  class CapsuleModel;
59  class CapsuleData;
60  class CapsulePtr;
61  class CapsuleInstance;
62  class CapsuleSemantics;
63 
64 
66 
71  {
72  public:
73  typedef CapsulePtr PtrT;
74 
75  CapsuleModel(const agx::String& name = "Capsule");
76 
79 
82 
85 
87  virtual void shutdownCleanup() override;
88 
89 
90 
91  /* Attributes */
94 
95  protected:
96  virtual ~CapsuleModel();
97  virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
98  virtual void configure(agx::TiXmlElement* eEntity) override;
99  virtual void initAttributeAccessors() override;
100  virtual void construct(agxData::EntityPtr instance) override;
102  };
103 
104 
106  #ifndef AGX_PHYSICS_GEOMETRY_CAPSULE_DATA_SET_OVERRIDE
107  #define AGX_PHYSICS_GEOMETRY_CAPSULE_DATA_SET
108  class AGXPHYSICS_EXPORT CapsuleData : public agx::Physics::Geometry::ShapeData
109  {
110  public:
111  CapsuleInstance operator[] (size_t index);
112 
113  public:
117 
118  public:
119  typedef agx::Real heightType;
120  typedef agx::Real radiusType;
121 
122  public:
123  CapsuleData(agxData::EntityStorage* storage);
124  CapsuleData();
125 
126  protected:
127  virtual ~CapsuleData() {}
128  virtual void setNumElements(agx::Index numElements) override;
129 
130  private:
131  CapsuleData& operator= (const CapsuleData&) { return *this; }
132 
133  };
134  #endif
136 
137 
139  class AGXPHYSICS_EXPORT CapsuleSemantics : public agx::Physics::Geometry::ShapeSemantics
140  {
141  public:
142 
143  // Automatic getters
144  agx::Real const& getHeight() const;
145  agx::Real const& getRadius() const;
146 
147  // Semantics defined by explicit kernels
148 
149  // Automatic setters
150  void setHeight(agx::Real const& value);
151  void setRadius(agx::Real const& value);
152 
153 
154  protected:
155  friend class CapsulePtr;
156  friend class CapsuleInstance;
157  CapsuleSemantics();
158  };
160 
161 
162 
165  class CALLABLE CapsulePtr : public agx::Physics::Geometry::ShapePtr
166  {
167  public:
169  typedef CapsuleData DataType;
170  typedef CapsuleInstance InstanceType;
171 
172  public:
179  AGXPHYSICS_EXPORT CapsuleInstance instance();
180  AGXPHYSICS_EXPORT const CapsuleInstance instance() const;
181 
182  AGXPHYSICS_EXPORT CapsuleSemantics* operator->();
183  AGXPHYSICS_EXPORT const CapsuleSemantics* operator->() const;
184 
185  CapsuleData* getData();
186  const CapsuleData* getData() const;
187 
188 
193 
198 
200  // Only used by tolua!
201  #ifdef AGX_GENERATED_TOLUA_WRAPPER
202  inline agx::Real const& getHeight() const { return (*this)->getHeight(); }
203  inline agx::Real const& getRadius() const { return (*this)->getRadius(); }
204 
205 
206  inline void setHeight(agx::Real const& value) { (*this)->setHeight(value); }
207  inline void setRadius(agx::Real const& value) { (*this)->setRadius(value); }
208  #endif
210 
211  };
212 
213  // Entity is Referenced
215 
216 
218  class AGXPHYSICS_EXPORT CapsuleInstance : public agx::Physics::Geometry::ShapeInstance
219  {
220  public:
221  CapsuleInstance();
222  CapsuleInstance(CapsuleData* data, agx::Index index);
223  CapsuleInstance(agxData::EntityStorage *storage, agx::Index index);
224  CapsuleInstance(const agxData::EntityInstance& other);
225  CapsuleInstance(const agxData::EntityPtr& ptr);
226 
227  CapsuleData* getData();
228  const CapsuleData* getData() const;
229 
230  public:
232  agx::Real& height();
234  agx::Real const& height() const;
235 
237  agx::Real& radius();
239  agx::Real const& radius() const;
240 
241  };
243 
244 
245 
248 
249 
250 
252  /* Implementation */
253  //-----------------------------------------------------------------------------------------------------
254  //-----------------------------------------------------------------------------------------------------
255  inline CapsuleInstance agx::Physics::Geometry::CapsuleData::operator[] (size_t index) { return CapsuleInstance(this, (agx::Index)index); }
256  //-----------------------------------------------------------------------------------------------------
258  AGX_FORCE_INLINE CapsulePtr::CapsulePtr(agxData::EntityStorage* storage, agx::Index id) : agx::Physics::Geometry::ShapePtr(storage, id) {}
259  AGX_FORCE_INLINE CapsulePtr::CapsulePtr(const agxData::EntityPtr& ptr) : agx::Physics::Geometry::ShapePtr(ptr)
260  {
262  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
263  EntityPtr::getModel()->fullPath().c_str(), CapsuleModel::instance()->fullPath().c_str());
264  }
265 
266  AGX_FORCE_INLINE CapsulePtr::CapsulePtr(const agxData::EntityInstance& instance) : agx::Physics::Geometry::ShapePtr(instance)
267  {
268  agxAssertN(!instance || instance.isInstanceOf(CapsuleModel::instance()),
269  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
270  EntityPtr::getModel()->fullPath().c_str(), CapsuleModel::instance()->fullPath().c_str());
271  }
272 
273  AGX_FORCE_INLINE CapsulePtr& CapsulePtr::operator= (const agxData::EntityPtr& ptr)
274  {
276  agxAssertN(!ptr || ptr.isInstanceOf(CapsuleModel::instance()),
277  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
278  EntityPtr::getModel()->fullPath().c_str(), CapsuleModel::instance()->fullPath().c_str());
279  return *this;
280  }
281 
282  AGX_FORCE_INLINE CapsulePtr& CapsulePtr::operator= (const agxData::EntityInstance& instance)
283  {
285  agxAssertN(!instance || instance.isInstanceOf(CapsuleModel::instance()),
286  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
287  EntityPtr::getModel()->fullPath().c_str(), CapsuleModel::instance()->fullPath().c_str());
288  return *this;
289  }
290 
291  inline CapsuleInstance CapsulePtr::instance() { return agxData::EntityPtr::instance(); }
292  inline const CapsuleInstance CapsulePtr::instance() const { return agxData::EntityPtr::instance(); }
293  AGX_FORCE_INLINE CapsuleSemantics* CapsulePtr::operator->() { return (CapsuleSemantics* )this; }
294  AGX_FORCE_INLINE const CapsuleSemantics* CapsulePtr::operator->() const { return (const CapsuleSemantics* )this; }
295  AGX_FORCE_INLINE CapsuleData* CapsulePtr::getData() { return static_cast<CapsuleData* >(agxData::EntityPtr::getData()); }
296  AGX_FORCE_INLINE const CapsuleData* CapsulePtr::getData() const { return static_cast<const CapsuleData* >(agxData::EntityPtr::getData()); }
297 
298  AGX_FORCE_INLINE agx::Real& CapsulePtr::height() { verifyIndex(); return getData()->height[calculateIndex()]; }
299  AGX_FORCE_INLINE agx::Real const& CapsulePtr::height() const { verifyIndex(); return getData()->height[calculateIndex()]; }
300 
301  AGX_FORCE_INLINE agx::Real& CapsulePtr::radius() { verifyIndex(); return getData()->radius[calculateIndex()]; }
302  AGX_FORCE_INLINE agx::Real const& CapsulePtr::radius() const { verifyIndex(); return getData()->radius[calculateIndex()]; }
303 
304  //-----------------------------------------------------------------------------------------------------
305  AGX_FORCE_INLINE CapsuleInstance::CapsuleInstance() {}
306  AGX_FORCE_INLINE CapsuleInstance::CapsuleInstance(CapsuleData* data, agx::Index index) : agx::Physics::Geometry::ShapeInstance(data, index) {}
307  AGX_FORCE_INLINE CapsuleInstance::CapsuleInstance(agxData::EntityStorage* storage, agx::Index index) : agx::Physics::Geometry::ShapeInstance(storage, index) {}
308  AGX_FORCE_INLINE CapsuleInstance::CapsuleInstance(const agxData::EntityInstance& other) : agx::Physics::Geometry::ShapeInstance(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 CapsuleInstance::CapsuleInstance(const agxData::EntityPtr& ptr) : agx::Physics::Geometry::ShapeInstance(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 CapsuleData* CapsuleInstance::getData() { return static_cast<CapsuleData* >(agxData::EntityInstance::getData()); }
324  AGX_FORCE_INLINE const CapsuleData* CapsuleInstance::getData() const { return static_cast<const CapsuleData* >(agxData::EntityInstance::getData()); }
325 
326  AGX_FORCE_INLINE agx::Real& CapsuleInstance::height() { verifyIndex(); return getData()->height[getIndex()]; }
327  AGX_FORCE_INLINE agx::Real const& CapsuleInstance::height() const { verifyIndex(); return getData()->height[getIndex()]; }
328 
329  AGX_FORCE_INLINE agx::Real& CapsuleInstance::radius() { verifyIndex(); return getData()->radius[getIndex()]; }
330  AGX_FORCE_INLINE agx::Real const& CapsuleInstance::radius() const { verifyIndex(); return getData()->radius[getIndex()]; }
331 
332  //-----------------------------------------------------------------------------------------------------
333  AGX_FORCE_INLINE CapsuleSemantics::CapsuleSemantics() {}
334  //-----------------------------------------------------------------------------------------------------
336  }
337  }
338 }
339 
340 AGX_TYPE_BINDING(agx::Physics::Geometry::CapsulePtr, "Physics.Geometry.CapsulePtr")
341 AGX_TYPE_BINDING(agx::Physics::Geometry::CapsuleInstance, "Physics.Geometry.CapsuleInstance")
342 
343 #ifdef _MSC_VER
344 # pragma warning(pop)
345 #endif
346 
347 #undef AGX_ENTITY_WRAPPER
348 #undef AGX_ENTITY_NAMESPACE
349 #endif
350 
#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
An entity reference is a safe/referencing handle to an entity instance whose model is descendant from...
Definition: EntityRef.h:35
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.Geometry.Capsule entity.
Definition: CapsuleEntity.h:71
virtual void construct(agxData::EntityPtr instance) override
static CapsuleModel * instance()
void construct(agx::Physics::Geometry::CapsulePtr capsule)
static agxData::ScalarAttributeT< agx::Real > * heightAttribute
Definition: CapsuleEntity.h:92
virtual void shutdownCleanup() override
This is part of internal cleanup and should not be called by users.
virtual void configure(agx::TiXmlElement *eEntity) override
static agxData::EntityStorage * defaultStorage()
CapsuleModel(const agx::String &name="Capsule")
static CapsulePtr createInstance()
Create and return a pointer to a new instance in the default storage for this entity model.
static agxData::ScalarAttributeT< agx::Real > * radiusAttribute
Definition: CapsuleEntity.h:93
virtual agxData::EntityData * createData(agxData::EntityStorage *storage) override
virtual void initAttributeAccessors() override
Pointer to a entity instance of type Physics.Geometry.Capsule.
AGXPHYSICS_EXPORT agx::Real & height()
AGXPHYSICS_EXPORT CapsulePtr(const agxData::EntityInstance &instance)
AGXPHYSICS_EXPORT agx::Real & radius()
AGXPHYSICS_EXPORT CapsulePtr(agxData::EntityStorage *storage, agx::Index id)
AGXPHYSICS_EXPORT const CapsuleInstance instance() const
AGXPHYSICS_EXPORT CapsulePtr(const agxData::EntityPtr &ptr)
AGXPHYSICS_EXPORT agx::Real const & height() const
const CapsuleData * getData() const
AGXPHYSICS_EXPORT agx::Real const & radius() const
AGXPHYSICS_EXPORT const CapsuleSemantics * operator->() const
AGXPHYSICS_EXPORT CapsuleSemantics * operator->()
AGXPHYSICS_EXPORT CapsuleInstance instance()
Abstract description of the data attributes for the Physics.Geometry.Shape entity.
Definition: ShapeEntity.h:76
Pointer to a entity instance of type Physics.Geometry.Shape.
Definition: ShapeEntity.h:196
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< CapsulePtr > CapsuleRef
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