AGX Dynamics  2.35.0.1
ShapeGroupEntity.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_SHAPEGROUP_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_GEOMETRY_SHAPEGROUP_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/Integer.h>
50 #include <agx/AffineMatrix4x4.h>
51 
52 namespace agx { namespace Physics { namespace Geometry { class ShapePtr; }}}
53 
54 namespace agx
55 {
56  namespace Physics
57  {
58  namespace Geometry
59  {
60 
61  class ShapeGroupModel;
62  class ShapeGroupData;
63  class ShapeGroupPtr;
64  class ShapeGroupInstance;
65  class ShapeGroupSemantics;
66 
67 
69 
74  {
75  public:
77 
78  ShapeGroupModel(const agx::String& name = "ShapeGroup");
79 
82 
85 
88 
90  virtual void shutdownCleanup() override;
91 
92 
93 
94  /* Attributes */
98 
99  protected:
100  virtual ~ShapeGroupModel();
101  virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
102  virtual void configure(agx::TiXmlElement* eEntity) override;
103  virtual void initAttributeAccessors() override;
104  virtual void construct(agxData::EntityPtr instance) override;
106  };
107 
108 
110  #ifndef AGX_PHYSICS_GEOMETRY_SHAPEGROUP_DATA_SET_OVERRIDE
111  #define AGX_PHYSICS_GEOMETRY_SHAPEGROUP_DATA_SET
112  class AGXPHYSICS_EXPORT ShapeGroupData : public agx::Physics::Geometry::ShapeData
113  {
114  public:
115  ShapeGroupInstance operator[] (size_t index);
116 
117  public:
122 
123  public:
124  typedef agx::UInt tagType;
125  typedef agx::Vector< agx::Physics::Geometry::ShapePtr > childShapesType;
126  typedef agx::Vector< agx::AffineMatrix4x4 > childTransformsType;
127 
128  public:
129  ShapeGroupData(agxData::EntityStorage* storage);
130  ShapeGroupData();
131 
132  protected:
133  virtual ~ShapeGroupData() {}
134  virtual void setNumElements(agx::Index numElements) override;
135 
136  private:
137  ShapeGroupData& operator= (const ShapeGroupData&) { return *this; }
138 
139  };
140  #endif
142 
143 
145  class AGXPHYSICS_EXPORT ShapeGroupSemantics : public agx::Physics::Geometry::ShapeSemantics
146  {
147  public:
148 
149  // Automatic getters
150  agx::UInt const& getTag() const;
151  agx::Vector< agx::Physics::Geometry::ShapePtr > const& getChildShapes() const;
152  agx::Vector< agx::AffineMatrix4x4 > const& getChildTransforms() const;
153 
154  // Semantics defined by explicit kernels
155 
156  // Automatic setters
157  void setTag(agx::UInt const& value);
158  void setChildShapes(agx::Vector< agx::Physics::Geometry::ShapePtr > const& value);
159  void setChildTransforms(agx::Vector< agx::AffineMatrix4x4 > const& value);
160 
161 
162  protected:
163  friend class ShapeGroupPtr;
164  friend class ShapeGroupInstance;
165  ShapeGroupSemantics();
166  };
168 
169 
170 
173  class CALLABLE ShapeGroupPtr : public agx::Physics::Geometry::ShapePtr
174  {
175  public:
177  typedef ShapeGroupData DataType;
178  typedef ShapeGroupInstance InstanceType;
179 
180  public:
187  AGXPHYSICS_EXPORT ShapeGroupInstance instance();
188  AGXPHYSICS_EXPORT const ShapeGroupInstance instance() const;
189 
190  AGXPHYSICS_EXPORT ShapeGroupSemantics* operator->();
191  AGXPHYSICS_EXPORT const ShapeGroupSemantics* operator->() const;
192 
193  ShapeGroupData* getData();
194  const ShapeGroupData* getData() const;
195 
196 
201 
206 
211 
213  // Only used by tolua!
214  #ifdef AGX_GENERATED_TOLUA_WRAPPER
215  inline agx::UInt const& getTag() const { return (*this)->getTag(); }
216  inline agx::Vector< agx::Physics::Geometry::ShapePtr > const& getChildShapes() const { return (*this)->getChildShapes(); }
217  inline agx::Vector< agx::AffineMatrix4x4 > const& getChildTransforms() const { return (*this)->getChildTransforms(); }
218 
219 
220  inline void setTag(agx::UInt const& value) { (*this)->setTag(value); }
221  inline void setChildShapes(agx::Vector< agx::Physics::Geometry::ShapePtr > const& value) { (*this)->setChildShapes(value); }
222  inline void setChildTransforms(agx::Vector< agx::AffineMatrix4x4 > const& value) { (*this)->setChildTransforms(value); }
223  #endif
225 
226  };
227 
228  // Entity is Referenced
230 
231 
233  class AGXPHYSICS_EXPORT ShapeGroupInstance : public agx::Physics::Geometry::ShapeInstance
234  {
235  public:
236  ShapeGroupInstance();
237  ShapeGroupInstance(ShapeGroupData* data, agx::Index index);
238  ShapeGroupInstance(agxData::EntityStorage *storage, agx::Index index);
239  ShapeGroupInstance(const agxData::EntityInstance& other);
240  ShapeGroupInstance(const agxData::EntityPtr& ptr);
241 
242  ShapeGroupData* getData();
243  const ShapeGroupData* getData() const;
244 
245  public:
247  agx::UInt& tag();
249  agx::UInt const& tag() const;
250 
254  agx::Vector< agx::Physics::Geometry::ShapePtr > const& childShapes() const;
255 
257  agx::Vector< agx::AffineMatrix4x4 >& childTransforms();
259  agx::Vector< agx::AffineMatrix4x4 > const& childTransforms() const;
260 
261  };
263 
264 
265 
268 
269 
270 
272  /* Implementation */
273  //-----------------------------------------------------------------------------------------------------
274  //-----------------------------------------------------------------------------------------------------
275  inline ShapeGroupInstance agx::Physics::Geometry::ShapeGroupData::operator[] (size_t index) { return ShapeGroupInstance(this, (agx::Index)index); }
276  //-----------------------------------------------------------------------------------------------------
278  AGX_FORCE_INLINE ShapeGroupPtr::ShapeGroupPtr(agxData::EntityStorage* storage, agx::Index id) : agx::Physics::Geometry::ShapePtr(storage, id) {}
279  AGX_FORCE_INLINE ShapeGroupPtr::ShapeGroupPtr(const agxData::EntityPtr& ptr) : agx::Physics::Geometry::ShapePtr(ptr)
280  {
282  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
284  }
285 
286  AGX_FORCE_INLINE ShapeGroupPtr::ShapeGroupPtr(const agxData::EntityInstance& instance) : agx::Physics::Geometry::ShapePtr(instance)
287  {
288  agxAssertN(!instance || instance.isInstanceOf(ShapeGroupModel::instance()),
289  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
291  }
292 
293  AGX_FORCE_INLINE ShapeGroupPtr& ShapeGroupPtr::operator= (const agxData::EntityPtr& ptr)
294  {
296  agxAssertN(!ptr || ptr.isInstanceOf(ShapeGroupModel::instance()),
297  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
298  EntityPtr::getModel()->fullPath().c_str(), ShapeGroupModel::instance()->fullPath().c_str());
299  return *this;
300  }
301 
302  AGX_FORCE_INLINE ShapeGroupPtr& ShapeGroupPtr::operator= (const agxData::EntityInstance& instance)
303  {
305  agxAssertN(!instance || instance.isInstanceOf(ShapeGroupModel::instance()),
306  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
307  EntityPtr::getModel()->fullPath().c_str(), ShapeGroupModel::instance()->fullPath().c_str());
308  return *this;
309  }
310 
311  inline ShapeGroupInstance ShapeGroupPtr::instance() { return agxData::EntityPtr::instance(); }
312  inline const ShapeGroupInstance ShapeGroupPtr::instance() const { return agxData::EntityPtr::instance(); }
313  AGX_FORCE_INLINE ShapeGroupSemantics* ShapeGroupPtr::operator->() { return (ShapeGroupSemantics* )this; }
314  AGX_FORCE_INLINE const ShapeGroupSemantics* ShapeGroupPtr::operator->() const { return (const ShapeGroupSemantics* )this; }
315  AGX_FORCE_INLINE ShapeGroupData* ShapeGroupPtr::getData() { return static_cast<ShapeGroupData* >(agxData::EntityPtr::getData()); }
316  AGX_FORCE_INLINE const ShapeGroupData* ShapeGroupPtr::getData() const { return static_cast<const ShapeGroupData* >(agxData::EntityPtr::getData()); }
317 
318  AGX_FORCE_INLINE agx::UInt& ShapeGroupPtr::tag() { verifyIndex(); return getData()->tag[calculateIndex()]; }
319  AGX_FORCE_INLINE agx::UInt const& ShapeGroupPtr::tag() const { verifyIndex(); return getData()->tag[calculateIndex()]; }
320 
321  AGX_FORCE_INLINE agx::Vector< agx::Physics::Geometry::ShapePtr >& ShapeGroupPtr::childShapes() { verifyIndex(); return getData()->childShapes[calculateIndex()]; }
322  AGX_FORCE_INLINE agx::Vector< agx::Physics::Geometry::ShapePtr > const& ShapeGroupPtr::childShapes() const { verifyIndex(); return getData()->childShapes[calculateIndex()]; }
323 
324  AGX_FORCE_INLINE agx::Vector< agx::AffineMatrix4x4 >& ShapeGroupPtr::childTransforms() { verifyIndex(); return getData()->childTransforms[calculateIndex()]; }
325  AGX_FORCE_INLINE agx::Vector< agx::AffineMatrix4x4 > const& ShapeGroupPtr::childTransforms() const { verifyIndex(); return getData()->childTransforms[calculateIndex()]; }
326 
327  //-----------------------------------------------------------------------------------------------------
328  AGX_FORCE_INLINE ShapeGroupInstance::ShapeGroupInstance() {}
329  AGX_FORCE_INLINE ShapeGroupInstance::ShapeGroupInstance(ShapeGroupData* data, agx::Index index) : agx::Physics::Geometry::ShapeInstance(data, index) {}
330  AGX_FORCE_INLINE ShapeGroupInstance::ShapeGroupInstance(agxData::EntityStorage* storage, agx::Index index) : agx::Physics::Geometry::ShapeInstance(storage, index) {}
331  AGX_FORCE_INLINE ShapeGroupInstance::ShapeGroupInstance(const agxData::EntityInstance& other) : agx::Physics::Geometry::ShapeInstance(other)
332  {
334  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
336  }
337 
338  AGX_FORCE_INLINE ShapeGroupInstance::ShapeGroupInstance(const agxData::EntityPtr& ptr) : agx::Physics::Geometry::ShapeInstance(ptr)
339  {
341  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
343  }
344 
345 
346  AGX_FORCE_INLINE ShapeGroupData* ShapeGroupInstance::getData() { return static_cast<ShapeGroupData* >(agxData::EntityInstance::getData()); }
347  AGX_FORCE_INLINE const ShapeGroupData* ShapeGroupInstance::getData() const { return static_cast<const ShapeGroupData* >(agxData::EntityInstance::getData()); }
348 
349  AGX_FORCE_INLINE agx::UInt& ShapeGroupInstance::tag() { verifyIndex(); return getData()->tag[getIndex()]; }
350  AGX_FORCE_INLINE agx::UInt const& ShapeGroupInstance::tag() const { verifyIndex(); return getData()->tag[getIndex()]; }
351 
352  AGX_FORCE_INLINE agx::Vector< agx::Physics::Geometry::ShapePtr >& ShapeGroupInstance::childShapes() { verifyIndex(); return getData()->childShapes[getIndex()]; }
353  AGX_FORCE_INLINE agx::Vector< agx::Physics::Geometry::ShapePtr > const& ShapeGroupInstance::childShapes() const { verifyIndex(); return getData()->childShapes[getIndex()]; }
354 
355  AGX_FORCE_INLINE agx::Vector< agx::AffineMatrix4x4 >& ShapeGroupInstance::childTransforms() { verifyIndex(); return getData()->childTransforms[getIndex()]; }
356  AGX_FORCE_INLINE agx::Vector< agx::AffineMatrix4x4 > const& ShapeGroupInstance::childTransforms() const { verifyIndex(); return getData()->childTransforms[getIndex()]; }
357 
358  //-----------------------------------------------------------------------------------------------------
359  AGX_FORCE_INLINE ShapeGroupSemantics::ShapeGroupSemantics() {}
360  //-----------------------------------------------------------------------------------------------------
362  }
363  }
364 }
365 
366 AGX_TYPE_BINDING(agx::Physics::Geometry::ShapeGroupPtr, "Physics.Geometry.ShapeGroupPtr")
367 AGX_TYPE_BINDING(agx::Physics::Geometry::ShapeGroupInstance, "Physics.Geometry.ShapeGroupInstance")
368 
369 #ifdef _MSC_VER
370 # pragma warning(pop)
371 #endif
372 
373 #undef AGX_ENTITY_WRAPPER
374 #undef AGX_ENTITY_NAMESPACE
375 #endif
376 
#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.ShapeGroup entity.
static agxData::ScalarAttributeT< agx::Vector< agx::Physics::Geometry::ShapePtr > > * childShapesAttribute
static agxData::EntityStorage * defaultStorage()
static ShapeGroupPtr 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 shutdownCleanup() override
This is part of internal cleanup and should not be called by users.
static agxData::ScalarAttributeT< agx::Vector< agx::AffineMatrix4x4 > > * childTransformsAttribute
void construct(agx::Physics::Geometry::ShapeGroupPtr shapeGroup)
ShapeGroupModel(const agx::String &name="ShapeGroup")
virtual agxData::EntityData * createData(agxData::EntityStorage *storage) override
static ShapeGroupModel * instance()
virtual void construct(agxData::EntityPtr instance) override
virtual void initAttributeAccessors() override
static agxData::ScalarAttributeT< agx::UInt > * tagAttribute
Pointer to a entity instance of type Physics.Geometry.ShapeGroup.
AGXPHYSICS_EXPORT ShapeGroupPtr(agxData::EntityStorage *storage, agx::Index id)
AGXPHYSICS_EXPORT agx::Vector< agx::Physics::Geometry::ShapePtr > & childShapes()
AGXPHYSICS_EXPORT ShapeGroupPtr(const agxData::EntityPtr &ptr)
AGXPHYSICS_EXPORT agx::Vector< agx::AffineMatrix4x4 > & childTransforms()
AGXPHYSICS_EXPORT agx::Vector< agx::Physics::Geometry::ShapePtr > const & childShapes() const
AGXPHYSICS_EXPORT agx::Vector< agx::AffineMatrix4x4 > const & childTransforms() const
AGXPHYSICS_EXPORT ShapeGroupInstance instance()
const ShapeGroupData * getData() const
AGXPHYSICS_EXPORT const ShapeGroupInstance instance() const
AGXPHYSICS_EXPORT ShapeGroupPtr(const agxData::EntityInstance &instance)
AGXPHYSICS_EXPORT agx::UInt & tag()
AGXPHYSICS_EXPORT ShapeGroupSemantics * operator->()
AGXPHYSICS_EXPORT agx::UInt const & tag() const
AGXPHYSICS_EXPORT const ShapeGroupSemantics * operator->() 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
Templated vector class.
Definition: agx/Vector.h:53
#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< ShapeGroupPtr > ShapeGroupRef
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt
Definition: Integer.h:34
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:364
UInt32 Index
Definition: Integer.h:52