AGX Dynamics  2.35.0.1
CylinderEntity.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_CYLINDER_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_GEOMETRY_CYLINDER_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 CylinderModel;
59  class CylinderData;
60  class CylinderPtr;
61  class CylinderInstance;
62  class CylinderSemantics;
63 
64 
66 
71  {
72  public:
73  typedef CylinderPtr PtrT;
74 
75  CylinderModel(const agx::String& name = "Cylinder");
76 
79 
82 
85 
87  virtual void shutdownCleanup() override;
88 
89 
90 
91  /* Attributes */
94 
95  protected:
96  virtual ~CylinderModel();
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_CYLINDER_DATA_SET_OVERRIDE
107  #define AGX_PHYSICS_GEOMETRY_CYLINDER_DATA_SET
108  class AGXPHYSICS_EXPORT CylinderData : public agx::Physics::Geometry::ShapeData
109  {
110  public:
111  CylinderInstance operator[] (size_t index);
112 
113  public:
117 
118  public:
119  typedef agx::Real heightType;
120  typedef agx::Real radiusType;
121 
122  public:
123  CylinderData(agxData::EntityStorage* storage);
124  CylinderData();
125 
126  protected:
127  virtual ~CylinderData() {}
128  virtual void setNumElements(agx::Index numElements) override;
129 
130  private:
131  CylinderData& operator= (const CylinderData&) { return *this; }
132 
133  };
134  #endif
136 
137 
139  class AGXPHYSICS_EXPORT CylinderSemantics : 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 CylinderPtr;
156  friend class CylinderInstance;
157  CylinderSemantics();
158  };
160 
161 
162 
165  class CALLABLE CylinderPtr : public agx::Physics::Geometry::ShapePtr
166  {
167  public:
169  typedef CylinderData DataType;
170  typedef CylinderInstance InstanceType;
171 
172  public:
179  AGXPHYSICS_EXPORT CylinderInstance instance();
180  AGXPHYSICS_EXPORT const CylinderInstance instance() const;
181 
182  AGXPHYSICS_EXPORT CylinderSemantics* operator->();
183  AGXPHYSICS_EXPORT const CylinderSemantics* operator->() const;
184 
185  CylinderData* getData();
186  const CylinderData* 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 CylinderInstance : public agx::Physics::Geometry::ShapeInstance
219  {
220  public:
221  CylinderInstance();
222  CylinderInstance(CylinderData* data, agx::Index index);
223  CylinderInstance(agxData::EntityStorage *storage, agx::Index index);
224  CylinderInstance(const agxData::EntityInstance& other);
225  CylinderInstance(const agxData::EntityPtr& ptr);
226 
227  CylinderData* getData();
228  const CylinderData* 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 CylinderInstance agx::Physics::Geometry::CylinderData::operator[] (size_t index) { return CylinderInstance(this, (agx::Index)index); }
256  //-----------------------------------------------------------------------------------------------------
258  AGX_FORCE_INLINE CylinderPtr::CylinderPtr(agxData::EntityStorage* storage, agx::Index id) : agx::Physics::Geometry::ShapePtr(storage, id) {}
259  AGX_FORCE_INLINE CylinderPtr::CylinderPtr(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(), CylinderModel::instance()->fullPath().c_str());
264  }
265 
266  AGX_FORCE_INLINE CylinderPtr::CylinderPtr(const agxData::EntityInstance& instance) : agx::Physics::Geometry::ShapePtr(instance)
267  {
268  agxAssertN(!instance || instance.isInstanceOf(CylinderModel::instance()),
269  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
270  EntityPtr::getModel()->fullPath().c_str(), CylinderModel::instance()->fullPath().c_str());
271  }
272 
273  AGX_FORCE_INLINE CylinderPtr& CylinderPtr::operator= (const agxData::EntityPtr& ptr)
274  {
276  agxAssertN(!ptr || ptr.isInstanceOf(CylinderModel::instance()),
277  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
278  EntityPtr::getModel()->fullPath().c_str(), CylinderModel::instance()->fullPath().c_str());
279  return *this;
280  }
281 
282  AGX_FORCE_INLINE CylinderPtr& CylinderPtr::operator= (const agxData::EntityInstance& instance)
283  {
285  agxAssertN(!instance || instance.isInstanceOf(CylinderModel::instance()),
286  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
287  EntityPtr::getModel()->fullPath().c_str(), CylinderModel::instance()->fullPath().c_str());
288  return *this;
289  }
290 
291  inline CylinderInstance CylinderPtr::instance() { return agxData::EntityPtr::instance(); }
292  inline const CylinderInstance CylinderPtr::instance() const { return agxData::EntityPtr::instance(); }
293  AGX_FORCE_INLINE CylinderSemantics* CylinderPtr::operator->() { return (CylinderSemantics* )this; }
294  AGX_FORCE_INLINE const CylinderSemantics* CylinderPtr::operator->() const { return (const CylinderSemantics* )this; }
295  AGX_FORCE_INLINE CylinderData* CylinderPtr::getData() { return static_cast<CylinderData* >(agxData::EntityPtr::getData()); }
296  AGX_FORCE_INLINE const CylinderData* CylinderPtr::getData() const { return static_cast<const CylinderData* >(agxData::EntityPtr::getData()); }
297 
298  AGX_FORCE_INLINE agx::Real& CylinderPtr::height() { verifyIndex(); return getData()->height[calculateIndex()]; }
299  AGX_FORCE_INLINE agx::Real const& CylinderPtr::height() const { verifyIndex(); return getData()->height[calculateIndex()]; }
300 
301  AGX_FORCE_INLINE agx::Real& CylinderPtr::radius() { verifyIndex(); return getData()->radius[calculateIndex()]; }
302  AGX_FORCE_INLINE agx::Real const& CylinderPtr::radius() const { verifyIndex(); return getData()->radius[calculateIndex()]; }
303 
304  //-----------------------------------------------------------------------------------------------------
305  AGX_FORCE_INLINE CylinderInstance::CylinderInstance() {}
306  AGX_FORCE_INLINE CylinderInstance::CylinderInstance(CylinderData* data, agx::Index index) : agx::Physics::Geometry::ShapeInstance(data, index) {}
307  AGX_FORCE_INLINE CylinderInstance::CylinderInstance(agxData::EntityStorage* storage, agx::Index index) : agx::Physics::Geometry::ShapeInstance(storage, index) {}
308  AGX_FORCE_INLINE CylinderInstance::CylinderInstance(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 CylinderInstance::CylinderInstance(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 CylinderData* CylinderInstance::getData() { return static_cast<CylinderData* >(agxData::EntityInstance::getData()); }
324  AGX_FORCE_INLINE const CylinderData* CylinderInstance::getData() const { return static_cast<const CylinderData* >(agxData::EntityInstance::getData()); }
325 
326  AGX_FORCE_INLINE agx::Real& CylinderInstance::height() { verifyIndex(); return getData()->height[getIndex()]; }
327  AGX_FORCE_INLINE agx::Real const& CylinderInstance::height() const { verifyIndex(); return getData()->height[getIndex()]; }
328 
329  AGX_FORCE_INLINE agx::Real& CylinderInstance::radius() { verifyIndex(); return getData()->radius[getIndex()]; }
330  AGX_FORCE_INLINE agx::Real const& CylinderInstance::radius() const { verifyIndex(); return getData()->radius[getIndex()]; }
331 
332  //-----------------------------------------------------------------------------------------------------
333  AGX_FORCE_INLINE CylinderSemantics::CylinderSemantics() {}
334  //-----------------------------------------------------------------------------------------------------
336  }
337  }
338 }
339 
340 AGX_TYPE_BINDING(agx::Physics::Geometry::CylinderPtr, "Physics.Geometry.CylinderPtr")
341 AGX_TYPE_BINDING(agx::Physics::Geometry::CylinderInstance, "Physics.Geometry.CylinderInstance")
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.Cylinder entity.
static CylinderPtr createInstance()
Create and return a pointer to a new instance in the default storage for this entity model.
virtual void configure(agx::TiXmlElement *eEntity) override
virtual void initAttributeAccessors() override
void construct(agx::Physics::Geometry::CylinderPtr cylinder)
virtual void construct(agxData::EntityPtr instance) override
static agxData::ScalarAttributeT< agx::Real > * radiusAttribute
virtual agxData::EntityData * createData(agxData::EntityStorage *storage) override
static CylinderModel * instance()
static agxData::ScalarAttributeT< agx::Real > * heightAttribute
CylinderModel(const agx::String &name="Cylinder")
virtual void shutdownCleanup() override
This is part of internal cleanup and should not be called by users.
static agxData::EntityStorage * defaultStorage()
Pointer to a entity instance of type Physics.Geometry.Cylinder.
AGXPHYSICS_EXPORT agx::Real const & radius() const
AGXPHYSICS_EXPORT CylinderPtr(agxData::EntityStorage *storage, agx::Index id)
AGXPHYSICS_EXPORT agx::Real & height()
AGXPHYSICS_EXPORT CylinderPtr(const agxData::EntityInstance &instance)
AGXPHYSICS_EXPORT const CylinderInstance instance() const
AGXPHYSICS_EXPORT agx::Real const & height() const
AGXPHYSICS_EXPORT CylinderInstance instance()
AGXPHYSICS_EXPORT agx::Real & radius()
AGXPHYSICS_EXPORT CylinderSemantics * operator->()
AGXPHYSICS_EXPORT const CylinderSemantics * operator->() const
AGXPHYSICS_EXPORT CylinderPtr(const agxData::EntityPtr &ptr)
const CylinderData * getData() const
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< CylinderPtr > CylinderRef
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