AGX Dynamics  2.35.0.1
SphereEntity.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_SPHERE_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_GEOMETRY_SPHERE_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/Real.h>
49 
50 
51 namespace agx
52 {
53  namespace Physics
54  {
55  namespace Geometry
56  {
57 
58  class SphereModel;
59  class SphereData;
60  class SpherePtr;
61  class SphereInstance;
62  class SphereSemantics;
63 
64 
66 
71  {
72  public:
73  typedef SpherePtr PtrT;
74 
75  SphereModel(const agx::String& name = "Sphere");
76 
78  static SphereModel* instance();
79 
82 
85 
87  virtual void shutdownCleanup() override;
88 
89 
90 
91  /* Attributes */
93 
94  protected:
95  virtual ~SphereModel();
96  virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
97  virtual void configure(agx::TiXmlElement* eEntity) override;
98  virtual void initAttributeAccessors() override;
99  virtual void construct(agxData::EntityPtr instance) override;
101  };
102 
103 
105  #ifndef AGX_PHYSICS_GEOMETRY_SPHERE_DATA_SET_OVERRIDE
106  #define AGX_PHYSICS_GEOMETRY_SPHERE_DATA_SET
107  class AGXPHYSICS_EXPORT SphereData : public agx::Physics::Geometry::ShapeData
108  {
109  public:
110  SphereInstance operator[] (size_t index);
111 
112  public:
113  agxData::Array< SpherePtr >& instance;
115 
116  public:
117  typedef agx::Real radiusType;
118 
119  public:
120  SphereData(agxData::EntityStorage* storage);
121  SphereData();
122 
123  protected:
124  virtual ~SphereData() {}
125  virtual void setNumElements(agx::Index numElements) override;
126 
127  private:
128  SphereData& operator= (const SphereData&) { return *this; }
129 
130  };
131  #endif
133 
134 
136  class AGXPHYSICS_EXPORT SphereSemantics : public agx::Physics::Geometry::ShapeSemantics
137  {
138  public:
139 
140  // Automatic getters
141  agx::Real const& getRadius() const;
142 
143  // Semantics defined by explicit kernels
144 
145  // Automatic setters
146  void setRadius(agx::Real const& value);
147 
148 
149  protected:
150  friend class SpherePtr;
151  friend class SphereInstance;
152  SphereSemantics();
153  };
155 
156 
157 
160  class CALLABLE SpherePtr : public agx::Physics::Geometry::ShapePtr
161  {
162  public:
164  typedef SphereData DataType;
165  typedef SphereInstance InstanceType;
166 
167  public:
174  AGXPHYSICS_EXPORT SphereInstance instance();
175  AGXPHYSICS_EXPORT const SphereInstance instance() const;
176 
177  AGXPHYSICS_EXPORT SphereSemantics* operator->();
178  AGXPHYSICS_EXPORT const SphereSemantics* operator->() const;
179 
180  SphereData* getData();
181  const SphereData* getData() const;
182 
183 
188 
190  // Only used by tolua!
191  #ifdef AGX_GENERATED_TOLUA_WRAPPER
192  inline agx::Real const& getRadius() const { return (*this)->getRadius(); }
193 
194 
195  inline void setRadius(agx::Real const& value) { (*this)->setRadius(value); }
196  #endif
198 
199  };
200 
201  // Entity is Referenced
203 
204 
206  class AGXPHYSICS_EXPORT SphereInstance : public agx::Physics::Geometry::ShapeInstance
207  {
208  public:
209  SphereInstance();
210  SphereInstance(SphereData* data, agx::Index index);
211  SphereInstance(agxData::EntityStorage *storage, agx::Index index);
212  SphereInstance(const agxData::EntityInstance& other);
213  SphereInstance(const agxData::EntityPtr& ptr);
214 
215  SphereData* getData();
216  const SphereData* getData() const;
217 
218  public:
220  agx::Real& radius();
222  agx::Real const& radius() const;
223 
224  };
226 
227 
228 
231 
232 
233 
235  /* Implementation */
236  //-----------------------------------------------------------------------------------------------------
237  //-----------------------------------------------------------------------------------------------------
238  inline SphereInstance agx::Physics::Geometry::SphereData::operator[] (size_t index) { return SphereInstance(this, (agx::Index)index); }
239  //-----------------------------------------------------------------------------------------------------
241  AGX_FORCE_INLINE SpherePtr::SpherePtr(agxData::EntityStorage* storage, agx::Index id) : agx::Physics::Geometry::ShapePtr(storage, id) {}
242  AGX_FORCE_INLINE SpherePtr::SpherePtr(const agxData::EntityPtr& ptr) : agx::Physics::Geometry::ShapePtr(ptr)
243  {
245  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
246  EntityPtr::getModel()->fullPath().c_str(), SphereModel::instance()->fullPath().c_str());
247  }
248 
249  AGX_FORCE_INLINE SpherePtr::SpherePtr(const agxData::EntityInstance& instance) : agx::Physics::Geometry::ShapePtr(instance)
250  {
251  agxAssertN(!instance || instance.isInstanceOf(SphereModel::instance()),
252  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
253  EntityPtr::getModel()->fullPath().c_str(), SphereModel::instance()->fullPath().c_str());
254  }
255 
256  AGX_FORCE_INLINE SpherePtr& SpherePtr::operator= (const agxData::EntityPtr& ptr)
257  {
259  agxAssertN(!ptr || ptr.isInstanceOf(SphereModel::instance()),
260  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
261  EntityPtr::getModel()->fullPath().c_str(), SphereModel::instance()->fullPath().c_str());
262  return *this;
263  }
264 
265  AGX_FORCE_INLINE SpherePtr& SpherePtr::operator= (const agxData::EntityInstance& instance)
266  {
268  agxAssertN(!instance || instance.isInstanceOf(SphereModel::instance()),
269  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
270  EntityPtr::getModel()->fullPath().c_str(), SphereModel::instance()->fullPath().c_str());
271  return *this;
272  }
273 
274  inline SphereInstance SpherePtr::instance() { return agxData::EntityPtr::instance(); }
275  inline const SphereInstance SpherePtr::instance() const { return agxData::EntityPtr::instance(); }
276  AGX_FORCE_INLINE SphereSemantics* SpherePtr::operator->() { return (SphereSemantics* )this; }
277  AGX_FORCE_INLINE const SphereSemantics* SpherePtr::operator->() const { return (const SphereSemantics* )this; }
278  AGX_FORCE_INLINE SphereData* SpherePtr::getData() { return static_cast<SphereData* >(agxData::EntityPtr::getData()); }
279  AGX_FORCE_INLINE const SphereData* SpherePtr::getData() const { return static_cast<const SphereData* >(agxData::EntityPtr::getData()); }
280 
281  AGX_FORCE_INLINE agx::Real& SpherePtr::radius() { verifyIndex(); return getData()->radius[calculateIndex()]; }
282  AGX_FORCE_INLINE agx::Real const& SpherePtr::radius() const { verifyIndex(); return getData()->radius[calculateIndex()]; }
283 
284  //-----------------------------------------------------------------------------------------------------
285  AGX_FORCE_INLINE SphereInstance::SphereInstance() {}
286  AGX_FORCE_INLINE SphereInstance::SphereInstance(SphereData* data, agx::Index index) : agx::Physics::Geometry::ShapeInstance(data, index) {}
287  AGX_FORCE_INLINE SphereInstance::SphereInstance(agxData::EntityStorage* storage, agx::Index index) : agx::Physics::Geometry::ShapeInstance(storage, index) {}
288  AGX_FORCE_INLINE SphereInstance::SphereInstance(const agxData::EntityInstance& other) : agx::Physics::Geometry::ShapeInstance(other)
289  {
290  agxAssertN(!other || other.isInstanceOf(SphereModel::instance()),
291  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
293  }
294 
295  AGX_FORCE_INLINE SphereInstance::SphereInstance(const agxData::EntityPtr& ptr) : agx::Physics::Geometry::ShapeInstance(ptr)
296  {
298  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
300  }
301 
302 
303  AGX_FORCE_INLINE SphereData* SphereInstance::getData() { return static_cast<SphereData* >(agxData::EntityInstance::getData()); }
304  AGX_FORCE_INLINE const SphereData* SphereInstance::getData() const { return static_cast<const SphereData* >(agxData::EntityInstance::getData()); }
305 
306  AGX_FORCE_INLINE agx::Real& SphereInstance::radius() { verifyIndex(); return getData()->radius[getIndex()]; }
307  AGX_FORCE_INLINE agx::Real const& SphereInstance::radius() const { verifyIndex(); return getData()->radius[getIndex()]; }
308 
309  //-----------------------------------------------------------------------------------------------------
310  AGX_FORCE_INLINE SphereSemantics::SphereSemantics() {}
311  //-----------------------------------------------------------------------------------------------------
313  }
314  }
315 }
316 
317 AGX_TYPE_BINDING(agx::Physics::Geometry::SpherePtr, "Physics.Geometry.SpherePtr")
318 AGX_TYPE_BINDING(agx::Physics::Geometry::SphereInstance, "Physics.Geometry.SphereInstance")
319 
320 #ifdef _MSC_VER
321 # pragma warning(pop)
322 #endif
323 
324 #undef AGX_ENTITY_WRAPPER
325 #undef AGX_ENTITY_NAMESPACE
326 #endif
327 
#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.Shape entity.
Definition: ShapeEntity.h:76
Pointer to a entity instance of type Physics.Geometry.Shape.
Definition: ShapeEntity.h:196
Abstract description of the data attributes for the Physics.Geometry.Sphere entity.
Definition: SphereEntity.h:71
virtual agxData::EntityData * createData(agxData::EntityStorage *storage) override
virtual void construct(agxData::EntityPtr instance) override
static SphereModel * instance()
SphereModel(const agx::String &name="Sphere")
virtual void initAttributeAccessors() override
virtual void shutdownCleanup() override
This is part of internal cleanup and should not be called by users.
static SpherePtr createInstance()
Create and return a pointer to a new instance in the default storage for this entity model.
void construct(agx::Physics::Geometry::SpherePtr sphere)
static agxData::ScalarAttributeT< agx::Real > * radiusAttribute
Definition: SphereEntity.h:92
virtual void configure(agx::TiXmlElement *eEntity) override
static agxData::EntityStorage * defaultStorage()
Pointer to a entity instance of type Physics.Geometry.Sphere.
Definition: SphereEntity.h:161
AGXPHYSICS_EXPORT const SphereInstance instance() const
AGXPHYSICS_EXPORT agx::Real & radius()
const SphereData * getData() const
AGXPHYSICS_EXPORT SphereSemantics * operator->()
AGXPHYSICS_EXPORT SpherePtr(const agxData::EntityInstance &instance)
AGXPHYSICS_EXPORT SphereInstance instance()
AGXPHYSICS_EXPORT const SphereSemantics * operator->() const
AGXPHYSICS_EXPORT SpherePtr(agxData::EntityStorage *storage, agx::Index id)
AGXPHYSICS_EXPORT agx::Real const & radius() const
AGXPHYSICS_EXPORT SpherePtr(const agxData::EntityPtr &ptr)
Vector containing 'raw' data.
Definition: agx/Vector.h:246
#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< SpherePtr > SphereRef
Definition: SphereEntity.h:202
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:42
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:364
UInt32 Index
Definition: Integer.h:52