AGX Dynamics  2.37.3.2
ShapeEntity.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_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 
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 
254  };
255 
256  // Entity is Referenced
258 
259 
261  class AGXPHYSICS_EXPORT ShapeInstance : public agx::ReferencedInstance
262  {
263  public:
264  ShapeInstance();
265  ShapeInstance(ShapeData* data, agx::Index index);
266  ShapeInstance(agxData::EntityStorage *storage, agx::Index index);
267  ShapeInstance(const agxData::EntityInstance& other);
268  ShapeInstance(const agxData::EntityPtr& ptr);
269 
270  ShapeData* getData();
271  const ShapeData* getData() const;
272 
273  public:
275  agx::UInt8& type();
277  agx::UInt8 const& type() const;
278 
280  agx::Bool& inGroup();
282  agx::Bool const& inGroup() const;
283 
285  agxCollide::BoundingAABB& boundingAABB();
287  agxCollide::BoundingAABB const& boundingAABB() const;
288 
290  agx::Physics::GeometryPtr& geometry();
292  agx::Physics::GeometryPtr const& geometry() const;
293 
297  agx::AffineMatrix4x4 const& transform() const;
298 
300  agx::UInt32& modifiedCount();
302  agx::UInt32 const& modifiedCount() const;
303 
305  agxCollide::Shape*& model();
307  agxCollide::Shape* const& model() const;
308 
309  };
311 
312 
313 
315  typedef agxData::Array<ShapePtr> ShapePtrArray;
316 
317 
318 
320  /* Implementation */
321  //-----------------------------------------------------------------------------------------------------
322  //-----------------------------------------------------------------------------------------------------
323  inline ShapeInstance agx::Physics::Geometry::ShapeData::operator[] (size_t index) { return ShapeInstance(this, (agx::Index)index); }
324  //-----------------------------------------------------------------------------------------------------
325  AGX_FORCE_INLINE ShapePtr::ShapePtr() {}
326  AGX_FORCE_INLINE ShapePtr::ShapePtr(agxData::EntityStorage* storage, agx::Index id) : agx::ReferencedPtr(storage, id) {}
327  AGX_FORCE_INLINE ShapePtr::ShapePtr(const agxData::EntityPtr& ptr) : agx::ReferencedPtr(ptr)
328  {
329  agxAssertN(!ptr || ptr.isInstanceOf(ShapeModel::instance()),
330  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
331  EntityPtr::getModel()->fullPath().c_str(), ShapeModel::instance()->fullPath().c_str());
332  }
333 
334  AGX_FORCE_INLINE ShapePtr::ShapePtr(const agxData::EntityInstance& instance) : agx::ReferencedPtr(instance)
335  {
336  agxAssertN(!instance || instance.isInstanceOf(ShapeModel::instance()),
337  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
338  EntityPtr::getModel()->fullPath().c_str(), ShapeModel::instance()->fullPath().c_str());
339  }
340 
341  AGX_FORCE_INLINE ShapePtr& ShapePtr::operator= (const agxData::EntityPtr& ptr)
342  {
344  agxAssertN(!ptr || ptr.isInstanceOf(ShapeModel::instance()),
345  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
346  EntityPtr::getModel()->fullPath().c_str(), ShapeModel::instance()->fullPath().c_str());
347  return *this;
348  }
349 
350  AGX_FORCE_INLINE ShapePtr& ShapePtr::operator= (const agxData::EntityInstance& instance)
351  {
353  agxAssertN(!instance || instance.isInstanceOf(ShapeModel::instance()),
354  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
355  EntityPtr::getModel()->fullPath().c_str(), ShapeModel::instance()->fullPath().c_str());
356  return *this;
357  }
358 
359  inline ShapeInstance ShapePtr::instance() { return agxData::EntityPtr::instance(); }
360  inline const ShapeInstance ShapePtr::instance() const { return agxData::EntityPtr::instance(); }
361  AGX_FORCE_INLINE ShapeSemantics* ShapePtr::operator->() { return (ShapeSemantics* )this; }
362  AGX_FORCE_INLINE const ShapeSemantics* ShapePtr::operator->() const { return (const ShapeSemantics* )this; }
363  AGX_FORCE_INLINE ShapeData* ShapePtr::getData() { return static_cast<ShapeData* >(agxData::EntityPtr::getData()); }
364  AGX_FORCE_INLINE const ShapeData* ShapePtr::getData() const { return static_cast<const ShapeData* >(agxData::EntityPtr::getData()); }
365 
366  AGX_FORCE_INLINE agx::UInt8& ShapePtr::type() { verifyIndex(); return getData()->type[calculateIndex()]; }
367  AGX_FORCE_INLINE agx::UInt8 const& ShapePtr::type() const { verifyIndex(); return getData()->type[calculateIndex()]; }
368 
369  AGX_FORCE_INLINE agx::Bool& ShapePtr::inGroup() { verifyIndex(); return getData()->inGroup[calculateIndex()]; }
370  AGX_FORCE_INLINE agx::Bool const& ShapePtr::inGroup() const { verifyIndex(); return getData()->inGroup[calculateIndex()]; }
371 
372  AGX_FORCE_INLINE agxCollide::BoundingAABB& ShapePtr::boundingAABB() { verifyIndex(); return getData()->boundingAABB[calculateIndex()]; }
373  AGX_FORCE_INLINE agxCollide::BoundingAABB const& ShapePtr::boundingAABB() const { verifyIndex(); return getData()->boundingAABB[calculateIndex()]; }
374 
375  AGX_FORCE_INLINE agx::Physics::GeometryPtr& ShapePtr::geometry() { verifyIndex(); return getData()->geometry[calculateIndex()]; }
376  AGX_FORCE_INLINE agx::Physics::GeometryPtr const& ShapePtr::geometry() const { verifyIndex(); return getData()->geometry[calculateIndex()]; }
377 
378  AGX_FORCE_INLINE agx::AffineMatrix4x4& ShapePtr::transform() { verifyIndex(); return getData()->transform[calculateIndex()]; }
379  AGX_FORCE_INLINE agx::AffineMatrix4x4 const& ShapePtr::transform() const { verifyIndex(); return getData()->transform[calculateIndex()]; }
380 
381  AGX_FORCE_INLINE agx::UInt32& ShapePtr::modifiedCount() { verifyIndex(); return getData()->modifiedCount[calculateIndex()]; }
382  AGX_FORCE_INLINE agx::UInt32 const& ShapePtr::modifiedCount() const { verifyIndex(); return getData()->modifiedCount[calculateIndex()]; }
383 
384  AGX_FORCE_INLINE agxCollide::Shape*& ShapePtr::model() { verifyIndex(); return getData()->model[calculateIndex()]; }
385  AGX_FORCE_INLINE agxCollide::Shape* const& ShapePtr::model() const { verifyIndex(); return getData()->model[calculateIndex()]; }
386 
387  //-----------------------------------------------------------------------------------------------------
388  AGX_FORCE_INLINE ShapeInstance::ShapeInstance() {}
389  AGX_FORCE_INLINE ShapeInstance::ShapeInstance(ShapeData* data, agx::Index index) : agx::ReferencedInstance(data, index) {}
390  AGX_FORCE_INLINE ShapeInstance::ShapeInstance(agxData::EntityStorage* storage, agx::Index index) : agx::ReferencedInstance(storage, index) {}
391  AGX_FORCE_INLINE ShapeInstance::ShapeInstance(const agxData::EntityInstance& other) : agx::ReferencedInstance(other)
392  {
393  agxAssertN(!other || other.isInstanceOf(ShapeModel::instance()),
394  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
395  EntityInstance::getModel()->fullPath().c_str(), ShapeModel::instance()->fullPath().c_str());
396  }
397 
398  AGX_FORCE_INLINE ShapeInstance::ShapeInstance(const agxData::EntityPtr& ptr) : agx::ReferencedInstance(ptr)
399  {
400  agxAssertN(!ptr || ptr.isInstanceOf(ShapeModel::instance()),
401  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
402  EntityInstance::getModel()->fullPath().c_str(), ShapeModel::instance()->fullPath().c_str());
403  }
404 
405 
406  AGX_FORCE_INLINE ShapeData* ShapeInstance::getData() { return static_cast<ShapeData* >(agxData::EntityInstance::getData()); }
407  AGX_FORCE_INLINE const ShapeData* ShapeInstance::getData() const { return static_cast<const ShapeData* >(agxData::EntityInstance::getData()); }
408 
409  AGX_FORCE_INLINE agx::UInt8& ShapeInstance::type() { verifyIndex(); return getData()->type[getIndex()]; }
410  AGX_FORCE_INLINE agx::UInt8 const& ShapeInstance::type() const { verifyIndex(); return getData()->type[getIndex()]; }
411 
412  AGX_FORCE_INLINE agx::Bool& ShapeInstance::inGroup() { verifyIndex(); return getData()->inGroup[getIndex()]; }
413  AGX_FORCE_INLINE agx::Bool const& ShapeInstance::inGroup() const { verifyIndex(); return getData()->inGroup[getIndex()]; }
414 
415  AGX_FORCE_INLINE agxCollide::BoundingAABB& ShapeInstance::boundingAABB() { verifyIndex(); return getData()->boundingAABB[getIndex()]; }
416  AGX_FORCE_INLINE agxCollide::BoundingAABB const& ShapeInstance::boundingAABB() const { verifyIndex(); return getData()->boundingAABB[getIndex()]; }
417 
418  AGX_FORCE_INLINE agx::Physics::GeometryPtr& ShapeInstance::geometry() { verifyIndex(); return getData()->geometry[getIndex()]; }
419  AGX_FORCE_INLINE agx::Physics::GeometryPtr const& ShapeInstance::geometry() const { verifyIndex(); return getData()->geometry[getIndex()]; }
420 
421  AGX_FORCE_INLINE agx::AffineMatrix4x4& ShapeInstance::transform() { verifyIndex(); return getData()->transform[getIndex()]; }
422  AGX_FORCE_INLINE agx::AffineMatrix4x4 const& ShapeInstance::transform() const { verifyIndex(); return getData()->transform[getIndex()]; }
423 
424  AGX_FORCE_INLINE agx::UInt32& ShapeInstance::modifiedCount() { verifyIndex(); return getData()->modifiedCount[getIndex()]; }
425  AGX_FORCE_INLINE agx::UInt32 const& ShapeInstance::modifiedCount() const { verifyIndex(); return getData()->modifiedCount[getIndex()]; }
426 
427  AGX_FORCE_INLINE agxCollide::Shape*& ShapeInstance::model() { verifyIndex(); return getData()->model[getIndex()]; }
428  AGX_FORCE_INLINE agxCollide::Shape* const& ShapeInstance::model() const { verifyIndex(); return getData()->model[getIndex()]; }
429 
430  //-----------------------------------------------------------------------------------------------------
431  AGX_FORCE_INLINE ShapeSemantics::ShapeSemantics() {}
432  //-----------------------------------------------------------------------------------------------------
434  }
435  }
436 }
437 
438 AGX_TYPE_BINDING(agx::Physics::Geometry::ShapePtr, "Physics.Geometry.ShapePtr")
439 AGX_TYPE_BINDING(agx::Physics::Geometry::ShapeInstance, "Physics.Geometry.ShapeInstance")
440 
441 #ifdef _MSC_VER
442 # pragma warning(pop)
443 #endif
444 
445 #undef AGX_ENTITY_WRAPPER
446 #undef AGX_ENTITY_NAMESPACE
447 #endif
448 
AGXCORE_EXPORT Type * getType(const agx::String &name)
agxData::EntityData * getData()
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:72
Base class for a shape.
Definition: Shape.h:53
This namespace consists of a set of classes for handling geometric intersection tests including boole...
#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
uint8_t UInt8
Definition: Integer.h:38
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
bool isInstanceOf(agxData::EntityModel *model) const
#define AGX_FORCE_INLINE
Definition: Object.h:59
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
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.
static agxData::PointerAttributeT< agxCollide::Shape * > * modelAttribute
Definition: ShapeEntity.h:103
Pointer to a entity instance of type Physics.Geometry.
Contains classes for low level data storage for AGX.
Definition: Container.h:23
UInt32 Index
Definition: Integer.h:52
static agxData::ScalarAttributeT< agx::Physics::GeometryPtr > * geometryAttribute
Definition: ShapeEntity.h:100
#define CALLABLE
Definition: Object.h:73
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 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:98
agx::ref_ptr< Shape > ShapeRef
Definition: Shape.h:46
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97
AGX_DECLARE_POINTER_TYPES(SpaceListener)