AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ShapeEntity.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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_SHAPE_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_GEOMETRY_SHAPE_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/Integer.h>
51 #include <agx/AffineMatrix4x4.h>
52 namespace agxCollide { class Shape; }
53 
54 namespace agx { namespace Physics { class GeometryPtr; }}
55 
56 namespace agx
57 {
58  namespace Physics
59  {
60  namespace Geometry
61  {
62 
63  class ShapeModel;
64  class ShapeData;
65  class ShapePtr;
66  class ShapeInstance;
67  class ShapeSemantics;
68 
69 
71 
76  {
77  public:
78  typedef ShapePtr PtrT;
79 
80  ShapeModel(const agx::String& name = "Shape");
81 
83  static ShapeModel* instance();
84 
86  static ShapePtr createInstance();
87 
89  static agxData::EntityStorage* defaultStorage();
90 
92  virtual void shutdownCleanup() override;
93 
94 
95 
96  /* Attributes */
104 
105  protected:
106  virtual ~ShapeModel();
107  virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
108  virtual void configure(agx::TiXmlElement* eEntity) override;
109  virtual void initAttributeAccessors() override;
110  virtual void construct(agxData::EntityPtr instance) override;
111  void construct(agx::Physics::Geometry::ShapePtr shape);
112  };
113 
114 
116  #ifndef AGX_PHYSICS_GEOMETRY_SHAPE_DATA_SET_OVERRIDE
117  #define AGX_PHYSICS_GEOMETRY_SHAPE_DATA_SET
118  class AGXPHYSICS_EXPORT ShapeData : public agx::ReferencedData
119  {
120  public:
121  ShapeInstance operator[] (size_t index);
122 
123  public:
124  agxData::Array< ShapePtr >& instance;
130  agxData::Array< agx::UInt32 > modifiedCount;
132 
133  public:
134  typedef agx::UInt8 typeType;
135  typedef agx::Bool inGroupType;
136  typedef agxCollide::BoundingAABB boundingAABBType;
137  typedef agx::Physics::GeometryPtr geometryType;
138  typedef agx::AffineMatrix4x4 transformType;
139  typedef agx::UInt32 modifiedCountType;
140  typedef agxCollide::Shape* modelType;
141 
142  public:
143  ShapeData(agxData::EntityStorage* storage);
144  ShapeData();
145 
146  protected:
147  virtual ~ShapeData() {}
148  virtual void setNumElements(agx::Index numElements) override;
149 
150  private:
151  ShapeData& operator= (const ShapeData&) { return *this; }
152 
153  };
154  #endif
156 
157 
159  class AGXPHYSICS_EXPORT ShapeSemantics : public agx::ReferencedSemantics
160  {
161  public:
162 
163  // Automatic getters
164  agx::UInt8 const& getType() const;
165  agx::Bool const& getInGroup() const;
166  agxCollide::BoundingAABB const& getBoundingAABB() const;
167  agx::Physics::GeometryPtr const& getGeometry() const;
168  agx::AffineMatrix4x4 const& getTransform() const;
169  agx::UInt32 const& getModifiedCount() const;
170  agxCollide::Shape* const& getModel() const;
171 
172  // Semantics defined by explicit kernels
173 
174  // Automatic setters
175  void setType(agx::UInt8 const& value);
176  void setInGroup(agx::Bool const& value);
177  void setBoundingAABB(agxCollide::BoundingAABB const& value);
178  void setGeometry(agx::Physics::GeometryPtr const& value);
179  void setTransform(agx::AffineMatrix4x4 const& value);
180  void setModifiedCount(agx::UInt32 const& value);
181  void setModel(agxCollide::Shape* const& value);
182 
183 
184  protected:
185  friend class ShapePtr;
186  friend class ShapeInstance;
187  ShapeSemantics();
188  };
190 
191 
192 
195  class CALLABLE ShapePtr : public agx::ReferencedPtr
196  {
197  public:
199  typedef ShapeData DataType;
200  typedef ShapeInstance InstanceType;
201 
202  public:
207  AGXPHYSICS_EXPORT ShapePtr& operator= (const agxData::EntityPtr& ptr);
208  AGXPHYSICS_EXPORT ShapePtr& operator= (const agxData::EntityInstance& instance);
209  AGXPHYSICS_EXPORT ShapeInstance instance();
210  AGXPHYSICS_EXPORT const ShapeInstance instance() const;
211 
212  AGXPHYSICS_EXPORT ShapeSemantics* operator->();
213  AGXPHYSICS_EXPORT const ShapeSemantics* operator->() const;
214 
215  ShapeData* getData();
216  const ShapeData* getData() const;
217 
218 
222  AGXPHYSICS_EXPORT agx::UInt8 const& type() const;
223 
225  AGXPHYSICS_EXPORT agx::Bool& inGroup();
227  AGXPHYSICS_EXPORT agx::Bool const& inGroup() const;
228 
232  AGXPHYSICS_EXPORT agxCollide::BoundingAABB const& boundingAABB() const;
233 
237  AGXPHYSICS_EXPORT agx::Physics::GeometryPtr const& geometry() const;
238 
243 
245  AGXPHYSICS_EXPORT agx::UInt32& modifiedCount();
247  AGXPHYSICS_EXPORT agx::UInt32 const& modifiedCount() const;
248 
252  AGXPHYSICS_EXPORT agxCollide::Shape* const& model() const;
253 
255  // Only used by tolua!
256  #ifdef AGX_GENERATED_TOLUA_WRAPPER
257  inline agx::UInt8 const& getType() const { return (*this)->getType(); }
258  inline agx::Bool const& getInGroup() const { return (*this)->getInGroup(); }
259  inline agxCollide::BoundingAABB const& getBoundingAABB() const { return (*this)->getBoundingAABB(); }
260  inline agx::Physics::GeometryPtr const& getGeometry() const { return (*this)->getGeometry(); }
261  inline agx::AffineMatrix4x4 const& getTransform() const { return (*this)->getTransform(); }
262  inline agx::UInt32 const& getModifiedCount() const { return (*this)->getModifiedCount(); }
263  inline agxCollide::Shape* const& getModel() const { return (*this)->getModel(); }
264 
265 
266  inline void setType(agx::UInt8 const& value) { (*this)->setType(value); }
267  inline void setInGroup(agx::Bool const& value) { (*this)->setInGroup(value); }
268  inline void setBoundingAABB(agxCollide::BoundingAABB const& value) { (*this)->setBoundingAABB(value); }
269  inline void setGeometry(agx::Physics::GeometryPtr const& value) { (*this)->setGeometry(value); }
270  inline void setTransform(agx::AffineMatrix4x4 const& value) { (*this)->setTransform(value); }
271  inline void setModifiedCount(agx::UInt32 const& value) { (*this)->setModifiedCount(value); }
272  inline void setModel(agxCollide::Shape* const& value) { (*this)->setModel(value); }
273  #endif
275 
276  };
277 
278  // Entity is Referenced
280 
281 
283  class AGXPHYSICS_EXPORT ShapeInstance : public agx::ReferencedInstance
284  {
285  public:
286  ShapeInstance();
287  ShapeInstance(ShapeData* data, agx::Index index);
288  ShapeInstance(agxData::EntityStorage *storage, agx::Index index);
289  ShapeInstance(const agxData::EntityInstance& other);
290  ShapeInstance(const agxData::EntityPtr& ptr);
291 
292  ShapeData* getData();
293  const ShapeData* getData() const;
294 
295  public:
297  agx::UInt8& type();
299  agx::UInt8 const& type() const;
300 
302  agx::Bool& inGroup();
304  agx::Bool const& inGroup() const;
305 
307  agxCollide::BoundingAABB& boundingAABB();
309  agxCollide::BoundingAABB const& boundingAABB() const;
310 
312  agx::Physics::GeometryPtr& geometry();
314  agx::Physics::GeometryPtr const& geometry() const;
315 
319  agx::AffineMatrix4x4 const& transform() const;
320 
322  agx::UInt32& modifiedCount();
324  agx::UInt32 const& modifiedCount() const;
325 
327  agxCollide::Shape*& model();
329  agxCollide::Shape* const& model() const;
330 
331  };
333 
334 
335 
337  typedef agxData::Array<ShapePtr> ShapePtrArray;
338 
339 
340 
342  /* Implementation */
343  //-----------------------------------------------------------------------------------------------------
344  //-----------------------------------------------------------------------------------------------------
345  inline ShapeInstance agx::Physics::Geometry::ShapeData::operator[] (size_t index) { return ShapeInstance(this, (agx::Index)index); }
346  //-----------------------------------------------------------------------------------------------------
348  AGX_FORCE_INLINE ShapePtr::ShapePtr(agxData::EntityStorage* storage, agx::Index id) : agx::ReferencedPtr(storage, id) {}
349  AGX_FORCE_INLINE ShapePtr::ShapePtr(const agxData::EntityPtr& ptr) : agx::ReferencedPtr(ptr)
350  {
352  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
353  EntityPtr::getModel()->fullPath().c_str(), ShapeModel::instance()->fullPath().c_str());
354  }
355 
356  AGX_FORCE_INLINE ShapePtr::ShapePtr(const agxData::EntityInstance& instance) : agx::ReferencedPtr(instance)
357  {
358  agxAssertN(!instance || instance.isInstanceOf(ShapeModel::instance()),
359  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
360  EntityPtr::getModel()->fullPath().c_str(), ShapeModel::instance()->fullPath().c_str());
361  }
362 
363  AGX_FORCE_INLINE ShapePtr& ShapePtr::operator= (const agxData::EntityPtr& ptr)
364  {
366  agxAssertN(!ptr || ptr.isInstanceOf(ShapeModel::instance()),
367  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
368  EntityPtr::getModel()->fullPath().c_str(), ShapeModel::instance()->fullPath().c_str());
369  return *this;
370  }
371 
372  AGX_FORCE_INLINE ShapePtr& ShapePtr::operator= (const agxData::EntityInstance& instance)
373  {
375  agxAssertN(!instance || instance.isInstanceOf(ShapeModel::instance()),
376  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
377  EntityPtr::getModel()->fullPath().c_str(), ShapeModel::instance()->fullPath().c_str());
378  return *this;
379  }
380 
381  inline ShapeInstance ShapePtr::instance() { return agxData::EntityPtr::instance(); }
382  inline const ShapeInstance ShapePtr::instance() const { return agxData::EntityPtr::instance(); }
383  AGX_FORCE_INLINE ShapeSemantics* ShapePtr::operator->() { return (ShapeSemantics* )this; }
384  AGX_FORCE_INLINE const ShapeSemantics* ShapePtr::operator->() const { return (const ShapeSemantics* )this; }
385  AGX_FORCE_INLINE ShapeData* ShapePtr::getData() { return static_cast<ShapeData* >(agxData::EntityPtr::getData()); }
386  AGX_FORCE_INLINE const ShapeData* ShapePtr::getData() const { return static_cast<const ShapeData* >(agxData::EntityPtr::getData()); }
387 
388  AGX_FORCE_INLINE agx::UInt8& ShapePtr::type() { verifyIndex(); return getData()->type[calculateIndex()]; }
389  AGX_FORCE_INLINE agx::UInt8 const& ShapePtr::type() const { verifyIndex(); return getData()->type[calculateIndex()]; }
390 
391  AGX_FORCE_INLINE agx::Bool& ShapePtr::inGroup() { verifyIndex(); return getData()->inGroup[calculateIndex()]; }
392  AGX_FORCE_INLINE agx::Bool const& ShapePtr::inGroup() const { verifyIndex(); return getData()->inGroup[calculateIndex()]; }
393 
394  AGX_FORCE_INLINE agxCollide::BoundingAABB& ShapePtr::boundingAABB() { verifyIndex(); return getData()->boundingAABB[calculateIndex()]; }
395  AGX_FORCE_INLINE agxCollide::BoundingAABB const& ShapePtr::boundingAABB() const { verifyIndex(); return getData()->boundingAABB[calculateIndex()]; }
396 
397  AGX_FORCE_INLINE agx::Physics::GeometryPtr& ShapePtr::geometry() { verifyIndex(); return getData()->geometry[calculateIndex()]; }
398  AGX_FORCE_INLINE agx::Physics::GeometryPtr const& ShapePtr::geometry() const { verifyIndex(); return getData()->geometry[calculateIndex()]; }
399 
400  AGX_FORCE_INLINE agx::AffineMatrix4x4& ShapePtr::transform() { verifyIndex(); return getData()->transform[calculateIndex()]; }
401  AGX_FORCE_INLINE agx::AffineMatrix4x4 const& ShapePtr::transform() const { verifyIndex(); return getData()->transform[calculateIndex()]; }
402 
403  AGX_FORCE_INLINE agx::UInt32& ShapePtr::modifiedCount() { verifyIndex(); return getData()->modifiedCount[calculateIndex()]; }
404  AGX_FORCE_INLINE agx::UInt32 const& ShapePtr::modifiedCount() const { verifyIndex(); return getData()->modifiedCount[calculateIndex()]; }
405 
406  AGX_FORCE_INLINE agxCollide::Shape*& ShapePtr::model() { verifyIndex(); return getData()->model[calculateIndex()]; }
407  AGX_FORCE_INLINE agxCollide::Shape* const& ShapePtr::model() const { verifyIndex(); return getData()->model[calculateIndex()]; }
408 
409  //-----------------------------------------------------------------------------------------------------
410  AGX_FORCE_INLINE ShapeInstance::ShapeInstance() {}
411  AGX_FORCE_INLINE ShapeInstance::ShapeInstance(ShapeData* data, agx::Index index) : agx::ReferencedInstance(data, index) {}
412  AGX_FORCE_INLINE ShapeInstance::ShapeInstance(agxData::EntityStorage* storage, agx::Index index) : agx::ReferencedInstance(storage, index) {}
413  AGX_FORCE_INLINE ShapeInstance::ShapeInstance(const agxData::EntityInstance& other) : agx::ReferencedInstance(other)
414  {
415  agxAssertN(!other || other.isInstanceOf(ShapeModel::instance()),
416  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
418  }
419 
420  AGX_FORCE_INLINE ShapeInstance::ShapeInstance(const agxData::EntityPtr& ptr) : agx::ReferencedInstance(ptr)
421  {
423  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
425  }
426 
427 
428  AGX_FORCE_INLINE ShapeData* ShapeInstance::getData() { return static_cast<ShapeData* >(agxData::EntityInstance::getData()); }
429  AGX_FORCE_INLINE const ShapeData* ShapeInstance::getData() const { return static_cast<const ShapeData* >(agxData::EntityInstance::getData()); }
430 
431  AGX_FORCE_INLINE agx::UInt8& ShapeInstance::type() { verifyIndex(); return getData()->type[getIndex()]; }
432  AGX_FORCE_INLINE agx::UInt8 const& ShapeInstance::type() const { verifyIndex(); return getData()->type[getIndex()]; }
433 
434  AGX_FORCE_INLINE agx::Bool& ShapeInstance::inGroup() { verifyIndex(); return getData()->inGroup[getIndex()]; }
435  AGX_FORCE_INLINE agx::Bool const& ShapeInstance::inGroup() const { verifyIndex(); return getData()->inGroup[getIndex()]; }
436 
437  AGX_FORCE_INLINE agxCollide::BoundingAABB& ShapeInstance::boundingAABB() { verifyIndex(); return getData()->boundingAABB[getIndex()]; }
438  AGX_FORCE_INLINE agxCollide::BoundingAABB const& ShapeInstance::boundingAABB() const { verifyIndex(); return getData()->boundingAABB[getIndex()]; }
439 
440  AGX_FORCE_INLINE agx::Physics::GeometryPtr& ShapeInstance::geometry() { verifyIndex(); return getData()->geometry[getIndex()]; }
441  AGX_FORCE_INLINE agx::Physics::GeometryPtr const& ShapeInstance::geometry() const { verifyIndex(); return getData()->geometry[getIndex()]; }
442 
443  AGX_FORCE_INLINE agx::AffineMatrix4x4& ShapeInstance::transform() { verifyIndex(); return getData()->transform[getIndex()]; }
444  AGX_FORCE_INLINE agx::AffineMatrix4x4 const& ShapeInstance::transform() const { verifyIndex(); return getData()->transform[getIndex()]; }
445 
446  AGX_FORCE_INLINE agx::UInt32& ShapeInstance::modifiedCount() { verifyIndex(); return getData()->modifiedCount[getIndex()]; }
447  AGX_FORCE_INLINE agx::UInt32 const& ShapeInstance::modifiedCount() const { verifyIndex(); return getData()->modifiedCount[getIndex()]; }
448 
449  AGX_FORCE_INLINE agxCollide::Shape*& ShapeInstance::model() { verifyIndex(); return getData()->model[getIndex()]; }
450  AGX_FORCE_INLINE agxCollide::Shape* const& ShapeInstance::model() const { verifyIndex(); return getData()->model[getIndex()]; }
451 
452  //-----------------------------------------------------------------------------------------------------
453  AGX_FORCE_INLINE ShapeSemantics::ShapeSemantics() {}
454  //-----------------------------------------------------------------------------------------------------
456  }
457  }
458 }
459 
460 AGX_TYPE_BINDING(agx::Physics::Geometry::ShapePtr, "Physics.Geometry.ShapePtr")
461 AGX_TYPE_BINDING(agx::Physics::Geometry::ShapeInstance, "Physics.Geometry.ShapeInstance")
462 
463 #ifdef _MSC_VER
464 # pragma warning(pop)
465 #endif
466 
467 #undef AGX_ENTITY_WRAPPER
468 #undef AGX_ENTITY_NAMESPACE
469 #endif
470 
AGXCORE_EXPORT Type * getType(const agx::String &name)
agxData::EntityData * getData()
void setModel(agx::Model *model)
Set the object model (handled automatically).
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
Abstract description of the data attributes for the Physics.Geometry.Shape entity.
Definition: ShapeEntity.h:75
bool Bool
Definition: Integer.h:48
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:73
Base class for a shape.
Definition: Shape.h:53
#define agxAssertN(expr, format,...)
Definition: debug.h:145
agxData::EntityData * getData()
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:364
uint8_t UInt8
Definition: Integer.h:38
agx::Model * getModel()
Definition: Object.h:371
bool isInstanceOf(agxData::EntityModel *model) const
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
#define AGXPHYSICS_EXPORT
Pointer to a entity instance of type Physics.Geometry.Shape.
Definition: ShapeEntity.h:195
Entity instance provides access to a single instance in an EntityStorage.
static agxData::ScalarAttributeT< agx::Bool > * inGroupAttribute
Definition: ShapeEntity.h:98
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:248
agx::String fullPath() const
#define AGX_FORCE_INLINE
Definition: Object.h:62
Type-specific Array used for fast access into the data held by a Buffer.
Definition: agxData.h:30
static agxData::ScalarAttributeT< agxCollide::BoundingAABB > * boundingAABBAttribute
Definition: ShapeEntity.h:99
agxData::EntityRef< ShapePtr > ShapeRef
Definition: ShapeEntity.h:279
AGXPHYSICS_EXPORT ShapePtr()
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
EntityPtr & operator=(const EntityPtr &other)=default
static agxData::PointerAttributeT< agxCollide::Shape * > * modelAttribute
Definition: ShapeEntity.h:103
Pointer to a entity instance of type Physics.Geometry.
UInt32 Index
Definition: Integer.h:52
static agxData::ScalarAttributeT< agx::Physics::GeometryPtr > * geometryAttribute
Definition: ShapeEntity.h:100
#define CALLABLE
Definition: Object.h:76
Abstract description of the data attributes for the Referenced entity.
bool isInstanceOf(agxData::EntityModel *model) const
static agxData::ScalarAttributeT< agx::UInt8 > * typeAttribute
Definition: ShapeEntity.h:97
Pointer to a entity instance of type Referenced.
static ShapeModel * instance()
static agxData::ScalarAttributeT< agx::UInt32 > * modifiedCountAttribute
Definition: ShapeEntity.h:102
Axis aligned bounding box implementation.
Definition: BoundingAABB.h:37
uint32_t UInt32
Definition: Integer.h:40
static agxData::ScalarAttributeT< agx::AffineMatrix4x4 > * transformAttribute
Definition: ShapeEntity.h:101
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:101
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:100
GLenum type
Definition: gl.h:5539