AGX Dynamics  2.38.0.2
ShapeGroupEntity.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_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 
81  static ShapeGroupModel* instance();
82 
84  static ShapeGroupPtr createInstance();
85 
87  static agxData::EntityStorage* defaultStorage();
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;
105  void construct(agx::Physics::Geometry::ShapeGroupPtr shapeGroup);
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:
185  AGXPHYSICS_EXPORT ShapeGroupPtr& operator= (const agxData::EntityPtr& ptr);
186  AGXPHYSICS_EXPORT ShapeGroupPtr& operator= (const agxData::EntityInstance& instance);
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 
200  AGXPHYSICS_EXPORT agx::UInt const& tag() const;
201 
206 
210  AGXPHYSICS_EXPORT agx::Vector< agx::AffineMatrix4x4 > const& childTransforms() const;
211 
212  };
213 
214  // Entity is Referenced
216 
217 
219  class AGXPHYSICS_EXPORT ShapeGroupInstance : public agx::Physics::Geometry::ShapeInstance
220  {
221  public:
222  ShapeGroupInstance();
223  ShapeGroupInstance(ShapeGroupData* data, agx::Index index);
224  ShapeGroupInstance(agxData::EntityStorage *storage, agx::Index index);
225  ShapeGroupInstance(const agxData::EntityInstance& other);
226  ShapeGroupInstance(const agxData::EntityPtr& ptr);
227 
228  ShapeGroupData* getData();
229  const ShapeGroupData* getData() const;
230 
231  public:
233  agx::UInt& tag();
235  agx::UInt const& tag() const;
236 
240  agx::Vector< agx::Physics::Geometry::ShapePtr > const& childShapes() const;
241 
243  agx::Vector< agx::AffineMatrix4x4 >& childTransforms();
245  agx::Vector< agx::AffineMatrix4x4 > const& childTransforms() const;
246 
247  };
249 
250 
251 
254 
255 
256 
258  /* Implementation */
259  //-----------------------------------------------------------------------------------------------------
260  //-----------------------------------------------------------------------------------------------------
261  inline ShapeGroupInstance agx::Physics::Geometry::ShapeGroupData::operator[] (size_t index) { return ShapeGroupInstance(this, (agx::Index)index); }
262  //-----------------------------------------------------------------------------------------------------
264  AGX_FORCE_INLINE ShapeGroupPtr::ShapeGroupPtr(agxData::EntityStorage* storage, agx::Index id) : agx::Physics::Geometry::ShapePtr(storage, id) {}
265  AGX_FORCE_INLINE ShapeGroupPtr::ShapeGroupPtr(const agxData::EntityPtr& ptr) : agx::Physics::Geometry::ShapePtr(ptr)
266  {
268  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
270  }
271 
272  AGX_FORCE_INLINE ShapeGroupPtr::ShapeGroupPtr(const agxData::EntityInstance& instance) : agx::Physics::Geometry::ShapePtr(instance)
273  {
274  agxAssertN(!instance || instance.isInstanceOf(ShapeGroupModel::instance()),
275  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
277  }
278 
279  AGX_FORCE_INLINE ShapeGroupPtr& ShapeGroupPtr::operator= (const agxData::EntityPtr& ptr)
280  {
282  agxAssertN(!ptr || ptr.isInstanceOf(ShapeGroupModel::instance()),
283  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
284  EntityPtr::getModel()->fullPath().c_str(), ShapeGroupModel::instance()->fullPath().c_str());
285  return *this;
286  }
287 
288  AGX_FORCE_INLINE ShapeGroupPtr& ShapeGroupPtr::operator= (const agxData::EntityInstance& instance)
289  {
291  agxAssertN(!instance || instance.isInstanceOf(ShapeGroupModel::instance()),
292  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
293  EntityPtr::getModel()->fullPath().c_str(), ShapeGroupModel::instance()->fullPath().c_str());
294  return *this;
295  }
296 
297  inline ShapeGroupInstance ShapeGroupPtr::instance() { return agxData::EntityPtr::instance(); }
298  inline const ShapeGroupInstance ShapeGroupPtr::instance() const { return agxData::EntityPtr::instance(); }
299  AGX_FORCE_INLINE ShapeGroupSemantics* ShapeGroupPtr::operator->() { return (ShapeGroupSemantics* )this; }
300  AGX_FORCE_INLINE const ShapeGroupSemantics* ShapeGroupPtr::operator->() const { return (const ShapeGroupSemantics* )this; }
301  AGX_FORCE_INLINE ShapeGroupData* ShapeGroupPtr::getData() { return static_cast<ShapeGroupData* >(agxData::EntityPtr::getData()); }
302  AGX_FORCE_INLINE const ShapeGroupData* ShapeGroupPtr::getData() const { return static_cast<const ShapeGroupData* >(agxData::EntityPtr::getData()); }
303 
304  AGX_FORCE_INLINE agx::UInt& ShapeGroupPtr::tag() { verifyIndex(); return getData()->tag[calculateIndex()]; }
305  AGX_FORCE_INLINE agx::UInt const& ShapeGroupPtr::tag() const { verifyIndex(); return getData()->tag[calculateIndex()]; }
306 
307  AGX_FORCE_INLINE agx::Vector< agx::Physics::Geometry::ShapePtr >& ShapeGroupPtr::childShapes() { verifyIndex(); return getData()->childShapes[calculateIndex()]; }
308  AGX_FORCE_INLINE agx::Vector< agx::Physics::Geometry::ShapePtr > const& ShapeGroupPtr::childShapes() const { verifyIndex(); return getData()->childShapes[calculateIndex()]; }
309 
310  AGX_FORCE_INLINE agx::Vector< agx::AffineMatrix4x4 >& ShapeGroupPtr::childTransforms() { verifyIndex(); return getData()->childTransforms[calculateIndex()]; }
311  AGX_FORCE_INLINE agx::Vector< agx::AffineMatrix4x4 > const& ShapeGroupPtr::childTransforms() const { verifyIndex(); return getData()->childTransforms[calculateIndex()]; }
312 
313  //-----------------------------------------------------------------------------------------------------
314  AGX_FORCE_INLINE ShapeGroupInstance::ShapeGroupInstance() {}
315  AGX_FORCE_INLINE ShapeGroupInstance::ShapeGroupInstance(ShapeGroupData* data, agx::Index index) : agx::Physics::Geometry::ShapeInstance(data, index) {}
316  AGX_FORCE_INLINE ShapeGroupInstance::ShapeGroupInstance(agxData::EntityStorage* storage, agx::Index index) : agx::Physics::Geometry::ShapeInstance(storage, index) {}
317  AGX_FORCE_INLINE ShapeGroupInstance::ShapeGroupInstance(const agxData::EntityInstance& other) : agx::Physics::Geometry::ShapeInstance(other)
318  {
320  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
322  }
323 
324  AGX_FORCE_INLINE ShapeGroupInstance::ShapeGroupInstance(const agxData::EntityPtr& ptr) : agx::Physics::Geometry::ShapeInstance(ptr)
325  {
327  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
329  }
330 
331 
332  AGX_FORCE_INLINE ShapeGroupData* ShapeGroupInstance::getData() { return static_cast<ShapeGroupData* >(agxData::EntityInstance::getData()); }
333  AGX_FORCE_INLINE const ShapeGroupData* ShapeGroupInstance::getData() const { return static_cast<const ShapeGroupData* >(agxData::EntityInstance::getData()); }
334 
335  AGX_FORCE_INLINE agx::UInt& ShapeGroupInstance::tag() { verifyIndex(); return getData()->tag[getIndex()]; }
336  AGX_FORCE_INLINE agx::UInt const& ShapeGroupInstance::tag() const { verifyIndex(); return getData()->tag[getIndex()]; }
337 
338  AGX_FORCE_INLINE agx::Vector< agx::Physics::Geometry::ShapePtr >& ShapeGroupInstance::childShapes() { verifyIndex(); return getData()->childShapes[getIndex()]; }
339  AGX_FORCE_INLINE agx::Vector< agx::Physics::Geometry::ShapePtr > const& ShapeGroupInstance::childShapes() const { verifyIndex(); return getData()->childShapes[getIndex()]; }
340 
341  AGX_FORCE_INLINE agx::Vector< agx::AffineMatrix4x4 >& ShapeGroupInstance::childTransforms() { verifyIndex(); return getData()->childTransforms[getIndex()]; }
342  AGX_FORCE_INLINE agx::Vector< agx::AffineMatrix4x4 > const& ShapeGroupInstance::childTransforms() const { verifyIndex(); return getData()->childTransforms[getIndex()]; }
343 
344  //-----------------------------------------------------------------------------------------------------
345  AGX_FORCE_INLINE ShapeGroupSemantics::ShapeGroupSemantics() {}
346  //-----------------------------------------------------------------------------------------------------
348  }
349  }
350 }
351 
352 AGX_TYPE_BINDING(agx::Physics::Geometry::ShapeGroupPtr, "Physics.Geometry.ShapeGroupPtr")
353 AGX_TYPE_BINDING(agx::Physics::Geometry::ShapeGroupInstance, "Physics.Geometry.ShapeGroupInstance")
354 
355 #ifdef _MSC_VER
356 # pragma warning(pop)
357 #endif
358 
359 #undef AGX_ENTITY_WRAPPER
360 #undef AGX_ENTITY_NAMESPACE
361 #endif
362 
agx::Physics::Geometry::ShapeGroupModel::instance
static ShapeGroupModel * instance()
agx::UInt
uint64_t UInt
Definition: Integer.h:27
agxData::ScalarAttributeT< agx::UInt >
agx::Vector
Templated vector class.
Definition: Vector.h:52
agx::Physics::Geometry::ShapeGroupModel::tagAttribute
static agxData::ScalarAttributeT< agx::UInt > * tagAttribute
Definition: ShapeGroupEntity.h:95
CALLABLE
#define CALLABLE
Definition: macros.h:72
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
agx::Physics::Geometry::ShapeGroupPtr::DataType
ShapeGroupData DataType
Definition: ShapeGroupEntity.h:177
agx::Physics::Geometry::ShapeGroupModel
Abstract description of the data attributes for the Physics.Geometry.ShapeGroup entity.
Definition: ShapeGroupEntity.h:73
agxData::EntityPtr::getData
agxData::EntityData * getData()
Definition: EntityStorage.h:594
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
macros.h
agxData::EntityPtr::isInstanceOf
bool isInstanceOf(agxData::EntityModel *model) const
Definition: EntityStorage.h:784
agx::Model::fullPath
agx::String fullPath() const
agxData::EntityStorage
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:72
EntityModel.h
agx::Physics::Geometry::ShapeGroupModel::PtrT
ShapeGroupPtr PtrT
Definition: ShapeGroupEntity.h:76
agx::VectorPOD
Vector containing 'raw' data.
Definition: Vector.h:245
agxData::EntityPtr::instance
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
agxData::EntityInstance::isInstanceOf
bool isInstanceOf(agxData::EntityModel *model) const
Definition: EntityStorage.h:829
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agxData
Contains classes for low level data storage for AGX.
Definition: Container.h:23
ShapeEntity.h
agxData::Array
Type-specific Array used for fast access into the data held by a Buffer.
Definition: agxData.h:30
AffineMatrix4x4.h
EntityStorage.h
EntityRef.h
EntityPtr.h
agx::Physics::Geometry::ShapeGroupPtr
Pointer to a entity instance of type Physics.Geometry.ShapeGroup.
Definition: ShapeGroupEntity.h:173
EntityInstance.h
Integer.h
agxData::EntityPtr::operator=
EntityPtr & operator=(const EntityPtr &other)=default
agx::Physics::Geometry::ShapeGroupPtr::InstanceType
ShapeGroupInstance InstanceType
Definition: ShapeGroupEntity.h:178
agx::Index
UInt32 Index
Definition: Integer.h:44
agx::Physics::Geometry::ShapeModel
Abstract description of the data attributes for the Physics.Geometry.Shape entity.
Definition: ShapeEntity.h:75
agx::Physics::Geometry::ShapeGroupModel::childShapesAttribute
static agxData::ScalarAttributeT< agx::Vector< agx::Physics::Geometry::ShapePtr > > * childShapesAttribute
Definition: ShapeGroupEntity.h:96
agx::Physics::Geometry::ShapeGroupRef
agxData::EntityRef< ShapeGroupPtr > ShapeGroupRef
Definition: ShapeGroupEntity.h:215
agxData::EntityInstance
Entity instance provides access to a single instance in an EntityStorage.
Definition: EntityInstance.h:43
agx::Physics::Geometry::ShapeGroupPtr::ModelType
ShapeGroupModel ModelType
Definition: ShapeGroupEntity.h:176
agxData::EntityInstance::getData
agxData::EntityData * getData()
Definition: EntityInstance.h:149
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agx::Physics::Geometry::ShapePtr
Pointer to a entity instance of type Physics.Geometry.Shape.
Definition: ShapeEntity.h:195
agx::Physics::Geometry::ShapeGroupPtr::ShapeGroupPtr
AGXPHYSICS_EXPORT ShapeGroupPtr()
agxData::EntityRef
An entity reference is a safe/referencing handle to an entity instance whose model is descendant from...
Definition: EntityRef.h:34
agx::AgXString< std::string >
agxAssertN
#define agxAssertN(expr, format,...)
Definition: debug.h:145
AGX_TYPE_BINDING
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
agx::Physics::Geometry::ShapeGroupModel::childTransformsAttribute
static agxData::ScalarAttributeT< agx::Vector< agx::AffineMatrix4x4 > > * childTransformsAttribute
Definition: ShapeGroupEntity.h:97
Real.h
agxData::EntityPtr
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition: EntityPtr.h:51
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agx::getModel
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:363