AGX Dynamics  2.37.3.2
GridTierEntity.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_HIERARCHICALGRID_GRIDTIER_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_HIERARCHICALGRID_GRIDTIER_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/Real.h>
49 
50 
51 namespace agx
52 {
53  namespace Physics
54  {
55  namespace HierarchicalGrid
56  {
57 
58  class GridTierModel;
59  class GridTierData;
60  class GridTierPtr;
61  class GridTierInstance;
62  class GridTierSemantics;
63 
64 
66 
71  {
72  public:
73  typedef GridTierPtr PtrT;
74 
75  GridTierModel(const agx::String& name = "GridTier");
76 
78  static GridTierModel* instance();
79 
81  static GridTierPtr createInstance();
82 
84  static agxData::EntityStorage* defaultStorage();
85 
87  virtual void shutdownCleanup() override;
88 
89 
90 
91  /* Attributes */
97 
98  protected:
99  virtual ~GridTierModel();
100  virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
101  virtual void configure(agx::TiXmlElement* eEntity) override;
102  virtual void initAttributeAccessors() override;
103  virtual void construct(agxData::EntityPtr instance) override;
104  void construct(agx::Physics::HierarchicalGrid::GridTierPtr gridTier);
105  };
106 
107 
109  #ifndef AGX_PHYSICS_HIERARCHICALGRID_GRIDTIER_DATA_SET_OVERRIDE
110  #define AGX_PHYSICS_HIERARCHICALGRID_GRIDTIER_DATA_SET
111  class AGXPHYSICS_EXPORT GridTierData : public agxData::EntityData
112  {
113  public:
114  GridTierInstance operator[] (size_t index);
115 
116  public:
120  agxData::Array< agx::Real32 > boundingRadius;
123 
124  public:
125  typedef agx::Real sizeType;
126  typedef agx::Real invSizeType;
127  typedef agx::Real32 boundingRadiusType;
128  typedef agx::GridCellTable* cellTableType;
129  typedef agx::ContactZoneTable* zoneTableType;
130 
131  public:
132  GridTierData(agxData::EntityStorage* storage);
133  GridTierData();
134 
135  protected:
136  virtual ~GridTierData() {}
137  virtual void setNumElements(agx::Index numElements) override;
138 
139  private:
140  GridTierData& operator= (const GridTierData&) { return *this; }
141 
142  };
143  #endif
145 
146 
148  class AGXPHYSICS_EXPORT GridTierSemantics : protected agxData::EntityPtr
149  {
150  public:
151 
152  // Automatic getters
153  agx::Real const& getSize() const;
154  agx::Real const& getInvSize() const;
155  agx::Real32 const& getBoundingRadius() const;
156  agx::GridCellTable* const& getCellTable() const;
157  agx::ContactZoneTable* const& getZoneTable() const;
158 
159  // Semantics defined by explicit kernels
160 
161  // Automatic setters
162  void setSize(agx::Real const& value);
163  void setInvSize(agx::Real const& value);
164  void setBoundingRadius(agx::Real32 const& value);
165  void setCellTable(agx::GridCellTable* const& value);
166  void setZoneTable(agx::ContactZoneTable* const& value);
167 
168 
169  protected:
170  friend class GridTierPtr;
171  friend class GridTierInstance;
172  GridTierSemantics();
173  };
175 
176 
177 
180  class CALLABLE GridTierPtr : public agxData::EntityPtr
181  {
182  public:
184  typedef GridTierData DataType;
185  typedef GridTierInstance InstanceType;
186 
187  public:
192  AGXPHYSICS_EXPORT GridTierPtr& operator= (const agxData::EntityPtr& ptr);
193  AGXPHYSICS_EXPORT GridTierPtr& operator= (const agxData::EntityInstance& instance);
194  AGXPHYSICS_EXPORT GridTierInstance instance();
195  AGXPHYSICS_EXPORT const GridTierInstance instance() const;
196 
197  AGXPHYSICS_EXPORT GridTierSemantics* operator->();
198  AGXPHYSICS_EXPORT const GridTierSemantics* operator->() const;
199 
200  GridTierData* getData();
201  const GridTierData* getData() const;
202 
203 
207  AGXPHYSICS_EXPORT agx::Real const& size() const;
208 
210  AGXPHYSICS_EXPORT agx::Real& invSize();
212  AGXPHYSICS_EXPORT agx::Real const& invSize() const;
213 
215  AGXPHYSICS_EXPORT agx::Real32& boundingRadius();
217  AGXPHYSICS_EXPORT agx::Real32 const& boundingRadius() const;
218 
222  AGXPHYSICS_EXPORT agx::GridCellTable* const& cellTable() const;
223 
227  AGXPHYSICS_EXPORT agx::ContactZoneTable* const& zoneTable() const;
228 
229  };
230 
231 
233  class AGXPHYSICS_EXPORT GridTierInstance : public agxData::EntityInstance
234  {
235  public:
236  GridTierInstance();
237  GridTierInstance(GridTierData* data, agx::Index index);
238  GridTierInstance(agxData::EntityStorage *storage, agx::Index index);
239  GridTierInstance(const agxData::EntityInstance& other);
240  GridTierInstance(const agxData::EntityPtr& ptr);
241 
242  GridTierData* getData();
243  const GridTierData* getData() const;
244 
245  public:
247  agx::Real& size();
249  agx::Real const& size() const;
250 
252  agx::Real& invSize();
254  agx::Real const& invSize() const;
255 
257  agx::Real32& boundingRadius();
259  agx::Real32 const& boundingRadius() const;
260 
262  agx::GridCellTable*& cellTable();
264  agx::GridCellTable* const& cellTable() const;
265 
267  agx::ContactZoneTable*& zoneTable();
269  agx::ContactZoneTable* const& zoneTable() const;
270 
271  };
273 
274 
275 
278 
279 
280 
282  /* Implementation */
283  //-----------------------------------------------------------------------------------------------------
284  //-----------------------------------------------------------------------------------------------------
285  inline GridTierInstance agx::Physics::HierarchicalGrid::GridTierData::operator[] (size_t index) { return GridTierInstance(this, (agx::Index)index); }
286  //-----------------------------------------------------------------------------------------------------
290  {
292  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
293  EntityPtr::getModel()->fullPath().c_str(), GridTierModel::instance()->fullPath().c_str());
294  }
295 
297  {
298  agxAssertN(!instance || instance.isInstanceOf(GridTierModel::instance()),
299  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
300  EntityPtr::getModel()->fullPath().c_str(), GridTierModel::instance()->fullPath().c_str());
301  }
302 
304  {
307  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
308  EntityPtr::getModel()->fullPath().c_str(), GridTierModel::instance()->fullPath().c_str());
309  return *this;
310  }
311 
313  {
315  agxAssertN(!instance || instance.isInstanceOf(GridTierModel::instance()),
316  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
317  EntityPtr::getModel()->fullPath().c_str(), GridTierModel::instance()->fullPath().c_str());
318  return *this;
319  }
320 
321  inline GridTierInstance GridTierPtr::instance() { return agxData::EntityPtr::instance(); }
322  inline const GridTierInstance GridTierPtr::instance() const { return agxData::EntityPtr::instance(); }
323  AGX_FORCE_INLINE GridTierSemantics* GridTierPtr::operator->() { return (GridTierSemantics* )this; }
324  AGX_FORCE_INLINE const GridTierSemantics* GridTierPtr::operator->() const { return (const GridTierSemantics* )this; }
325  AGX_FORCE_INLINE GridTierData* GridTierPtr::getData() { return static_cast<GridTierData* >(agxData::EntityPtr::getData()); }
326  AGX_FORCE_INLINE const GridTierData* GridTierPtr::getData() const { return static_cast<const GridTierData* >(agxData::EntityPtr::getData()); }
327 
328  AGX_FORCE_INLINE agx::Real& GridTierPtr::size() { verifyIndex(); return getData()->size[calculateIndex()]; }
329  AGX_FORCE_INLINE agx::Real const& GridTierPtr::size() const { verifyIndex(); return getData()->size[calculateIndex()]; }
330 
331  AGX_FORCE_INLINE agx::Real& GridTierPtr::invSize() { verifyIndex(); return getData()->invSize[calculateIndex()]; }
332  AGX_FORCE_INLINE agx::Real const& GridTierPtr::invSize() const { verifyIndex(); return getData()->invSize[calculateIndex()]; }
333 
334  AGX_FORCE_INLINE agx::Real32& GridTierPtr::boundingRadius() { verifyIndex(); return getData()->boundingRadius[calculateIndex()]; }
335  AGX_FORCE_INLINE agx::Real32 const& GridTierPtr::boundingRadius() const { verifyIndex(); return getData()->boundingRadius[calculateIndex()]; }
336 
337  AGX_FORCE_INLINE agx::GridCellTable*& GridTierPtr::cellTable() { verifyIndex(); return getData()->cellTable[calculateIndex()]; }
338  AGX_FORCE_INLINE agx::GridCellTable* const& GridTierPtr::cellTable() const { verifyIndex(); return getData()->cellTable[calculateIndex()]; }
339 
340  AGX_FORCE_INLINE agx::ContactZoneTable*& GridTierPtr::zoneTable() { verifyIndex(); return getData()->zoneTable[calculateIndex()]; }
341  AGX_FORCE_INLINE agx::ContactZoneTable* const& GridTierPtr::zoneTable() const { verifyIndex(); return getData()->zoneTable[calculateIndex()]; }
342 
343  //-----------------------------------------------------------------------------------------------------
344  AGX_FORCE_INLINE GridTierInstance::GridTierInstance() {}
345  AGX_FORCE_INLINE GridTierInstance::GridTierInstance(GridTierData* data, agx::Index index) : agxData::EntityInstance(data, index) {}
346  AGX_FORCE_INLINE GridTierInstance::GridTierInstance(agxData::EntityStorage* storage, agx::Index index) : agxData::EntityInstance(storage, index) {}
347  AGX_FORCE_INLINE GridTierInstance::GridTierInstance(const agxData::EntityInstance& other) : agxData::EntityInstance(other)
348  {
350  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
352  }
353 
354  AGX_FORCE_INLINE GridTierInstance::GridTierInstance(const agxData::EntityPtr& ptr) : agxData::EntityInstance(ptr)
355  {
357  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
359  }
360 
361 
362  AGX_FORCE_INLINE GridTierData* GridTierInstance::getData() { return static_cast<GridTierData* >(agxData::EntityInstance::getData()); }
363  AGX_FORCE_INLINE const GridTierData* GridTierInstance::getData() const { return static_cast<const GridTierData* >(agxData::EntityInstance::getData()); }
364 
365  AGX_FORCE_INLINE agx::Real& GridTierInstance::size() { verifyIndex(); return getData()->size[getIndex()]; }
366  AGX_FORCE_INLINE agx::Real const& GridTierInstance::size() const { verifyIndex(); return getData()->size[getIndex()]; }
367 
368  AGX_FORCE_INLINE agx::Real& GridTierInstance::invSize() { verifyIndex(); return getData()->invSize[getIndex()]; }
369  AGX_FORCE_INLINE agx::Real const& GridTierInstance::invSize() const { verifyIndex(); return getData()->invSize[getIndex()]; }
370 
371  AGX_FORCE_INLINE agx::Real32& GridTierInstance::boundingRadius() { verifyIndex(); return getData()->boundingRadius[getIndex()]; }
372  AGX_FORCE_INLINE agx::Real32 const& GridTierInstance::boundingRadius() const { verifyIndex(); return getData()->boundingRadius[getIndex()]; }
373 
374  AGX_FORCE_INLINE agx::GridCellTable*& GridTierInstance::cellTable() { verifyIndex(); return getData()->cellTable[getIndex()]; }
375  AGX_FORCE_INLINE agx::GridCellTable* const& GridTierInstance::cellTable() const { verifyIndex(); return getData()->cellTable[getIndex()]; }
376 
377  AGX_FORCE_INLINE agx::ContactZoneTable*& GridTierInstance::zoneTable() { verifyIndex(); return getData()->zoneTable[getIndex()]; }
378  AGX_FORCE_INLINE agx::ContactZoneTable* const& GridTierInstance::zoneTable() const { verifyIndex(); return getData()->zoneTable[getIndex()]; }
379 
380  //-----------------------------------------------------------------------------------------------------
381  AGX_FORCE_INLINE GridTierSemantics::GridTierSemantics() {}
382  //-----------------------------------------------------------------------------------------------------
384  }
385  }
386 }
387 
388 AGX_TYPE_BINDING(agx::Physics::HierarchicalGrid::GridTierPtr, "Physics.HierarchicalGrid.GridTierPtr")
389 AGX_TYPE_BINDING(agx::Physics::HierarchicalGrid::GridTierInstance, "Physics.HierarchicalGrid.GridTierInstance")
390 
391 #ifdef _MSC_VER
392 # pragma warning(pop)
393 #endif
394 
395 #undef AGX_ENTITY_WRAPPER
396 #undef AGX_ENTITY_NAMESPACE
397 #endif
398 
AGXPHYSICS_EXPORT agx::Real & invSize()
static agxData::ScalarAttributeT< agx::Real > * sizeAttribute
float Real32
Definition: Real.h:44
agxData::EntityData * getData()
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:72
#define agxAssertN(expr, format,...)
Definition: debug.h:145
agxData::EntityData * getData()
agx::String fullPath() const
AGXPHYSICS_EXPORT GridTierSemantics * operator->()
#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
AGXPHYSICS_EXPORT GridTierInstance instance()
#define AGXPHYSICS_EXPORT
Entity instance provides access to a single instance in an EntityStorage.
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition: EntityPtr.h:51
AGXPHYSICS_EXPORT agx::Real32 & boundingRadius()
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
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
AGXPHYSICS_EXPORT agx::GridCellTable *& cellTable()
static agxData::PointerAttributeT< agx::GridCellTable * > * cellTableAttribute
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< agx::ContactZoneTable * > * zoneTableAttribute
static agxData::ScalarAttributeT< agx::Real > * invSizeAttribute
Contains classes for low level data storage for AGX.
Definition: Container.h:23
UInt32 Index
Definition: Integer.h:52
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
Definition: EntityModel.h:63
#define CALLABLE
Definition: Object.h:73
Abstract description of the data attributes for the Physics.HierarchicalGrid.GridTier entity...
bool isInstanceOf(agxData::EntityModel *model) const
AGXPHYSICS_EXPORT agx::ContactZoneTable *& zoneTable()
double Real
Definition: Real.h:42
static agxData::ScalarAttributeT< agx::Real32 > * boundingRadiusAttribute
Pointer to a entity instance of type Physics.HierarchicalGrid.GridTier.
Inheritance with partial specialization due to bug with ref_ptr containers.
AGXPHYSICS_EXPORT GridTierPtr & operator=(const agxData::EntityPtr &ptr)
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97
AGXPHYSICS_EXPORT agx::Real & size()