AGX Dynamics  2.37.2.0
TriangleEntity.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_TRIANGLE_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_GEOMETRY_TRIANGLE_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/Vec3.h>
48 #include <agx/Vec4.h>
49 #include <agx/Integer.h>
50 #include <agx/Real.h>
51 
52 
53 namespace agx
54 {
55  namespace Physics
56  {
57  namespace Geometry
58  {
59 
60  class TriangleModel;
61  class TriangleData;
62  class TrianglePtr;
63  class TriangleInstance;
64  class TriangleSemantics;
65 
66 
68 
73  {
74  public:
75  typedef TrianglePtr PtrT;
76 
77  TriangleModel(const agx::String& name = "Triangle");
78 
80  static TriangleModel* instance();
81 
83  static TrianglePtr createInstance();
84 
86  static agxData::EntityStorage* defaultStorage();
87 
89  virtual void shutdownCleanup() override;
90 
91 
92 
93  /* Attributes */
95  static const size_t verticesArraySize = 3;
97  static const size_t normalsArraySize = 3;
99  static const size_t colorsArraySize = 3;
101  static const size_t indicesArraySize = 3;
103 
104  protected:
105  virtual ~TriangleModel();
106  virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
107  virtual void configure(agx::TiXmlElement* eEntity) override;
108  virtual void initAttributeAccessors() override;
109  virtual void construct(agxData::EntityPtr instance) override;
110  void construct(agx::Physics::Geometry::TrianglePtr triangle);
111  };
112 
113 
115  #ifndef AGX_PHYSICS_GEOMETRY_TRIANGLE_DATA_SET_OVERRIDE
116  #define AGX_PHYSICS_GEOMETRY_TRIANGLE_DATA_SET
117  class AGXPHYSICS_EXPORT TriangleData : public agxData::EntityData
118  {
119  public:
120  TriangleInstance operator[] (size_t index);
121 
122  public:
125  static const size_t verticesArraySize = 3;
127  static const size_t normalsArraySize = 3;
129  static const size_t colorsArraySize = 3;
131  static const size_t indicesArraySize = 3;
132  agxData::Array< agx::Real > cameraDistance;
133 
134  public:
135  typedef agx::Vec3f verticesType;
136  typedef agx::Vec3f normalsType;
137  typedef agx::Vec4f colorsType;
138  typedef agx::UInt32 indicesType;
139  typedef agx::Real cameraDistanceType;
140 
141  public:
142  TriangleData(agxData::EntityStorage* storage);
143  TriangleData();
144 
145  protected:
146  virtual ~TriangleData() {}
147  virtual void setNumElements(agx::Index numElements) override;
148 
149  private:
150  TriangleData& operator= (const TriangleData&) { return *this; }
151 
152  };
153  #endif
155 
156 
158  class AGXPHYSICS_EXPORT TriangleSemantics : protected agxData::EntityPtr
159  {
160  public:
161 
162  // Automatic getters
163  agx::Real const& getCameraDistance() const;
164 
165  // Semantics defined by explicit kernels
166 
167  // Automatic setters
168  void setCameraDistance(agx::Real const& value);
169 
170 
171  protected:
172  friend class TrianglePtr;
173  friend class TriangleInstance;
174  TriangleSemantics();
175  };
177 
178 
179 
182  class CALLABLE TrianglePtr : public agxData::EntityPtr
183  {
184  public:
186  typedef TriangleData DataType;
187  typedef TriangleInstance InstanceType;
188 
189  public:
194  AGXPHYSICS_EXPORT TrianglePtr& operator= (const agxData::EntityPtr& ptr);
195  AGXPHYSICS_EXPORT TrianglePtr& operator= (const agxData::EntityInstance& instance);
196  AGXPHYSICS_EXPORT TriangleInstance instance();
197  AGXPHYSICS_EXPORT const TriangleInstance instance() const;
198 
199  AGXPHYSICS_EXPORT TriangleSemantics* operator->();
200  AGXPHYSICS_EXPORT const TriangleSemantics* operator->() const;
201 
202  TriangleData* getData();
203  const TriangleData* getData() const;
204 
205 
207  AGXPHYSICS_EXPORT agxData::Array< agx::Vec3f > const vertices() const;
208  AGXPHYSICS_EXPORT agx::Vec3f& vertices(size_t index);
209  AGXPHYSICS_EXPORT agx::Vec3f const& vertices(size_t index) const;
210 
212  AGXPHYSICS_EXPORT agxData::Array< agx::Vec3f > const normals() const;
213  AGXPHYSICS_EXPORT agx::Vec3f& normals(size_t index);
214  AGXPHYSICS_EXPORT agx::Vec3f const& normals(size_t index) const;
215 
217  AGXPHYSICS_EXPORT agxData::Array< agx::Vec4f > const colors() const;
218  AGXPHYSICS_EXPORT agx::Vec4f& colors(size_t index);
219  AGXPHYSICS_EXPORT agx::Vec4f const& colors(size_t index) const;
220 
222  AGXPHYSICS_EXPORT agxData::Array< agx::UInt32 > const indices() const;
223  AGXPHYSICS_EXPORT agx::UInt32& indices(size_t index);
224  AGXPHYSICS_EXPORT agx::UInt32 const& indices(size_t index) const;
225 
227  AGXPHYSICS_EXPORT agx::Real& cameraDistance();
229  AGXPHYSICS_EXPORT agx::Real const& cameraDistance() const;
230 
231  };
232 
233 
235  class AGXPHYSICS_EXPORT TriangleInstance : public agxData::EntityInstance
236  {
237  public:
238  TriangleInstance();
239  TriangleInstance(TriangleData* data, agx::Index index);
240  TriangleInstance(agxData::EntityStorage *storage, agx::Index index);
241  TriangleInstance(const agxData::EntityInstance& other);
242  TriangleInstance(const agxData::EntityPtr& ptr);
243 
244  TriangleData* getData();
245  const TriangleData* getData() const;
246 
247  public:
248  agxData::Array< agx::Vec3f > vertices();
249  agxData::Array< agx::Vec3f > const vertices() const;
250  agx::Vec3f& vertices(size_t index);
251  agx::Vec3f const& vertices(size_t index) const;
252 
254  agxData::Array< agx::Vec3f > const normals() const;
255  agx::Vec3f& normals(size_t index);
256  agx::Vec3f const& normals(size_t index) const;
257 
259  agxData::Array< agx::Vec4f > const colors() const;
260  agx::Vec4f& colors(size_t index);
261  agx::Vec4f const& colors(size_t index) const;
262 
264  agxData::Array< agx::UInt32 > const indices() const;
265  agx::UInt32& indices(size_t index);
266  agx::UInt32 const& indices(size_t index) const;
267 
269  agx::Real& cameraDistance();
271  agx::Real const& cameraDistance() const;
272 
273  };
275 
276 
277 
280 
281 
282 
284  /* Implementation */
285  //-----------------------------------------------------------------------------------------------------
286  //-----------------------------------------------------------------------------------------------------
287  inline TriangleInstance agx::Physics::Geometry::TriangleData::operator[] (size_t index) { return TriangleInstance(this, (agx::Index)index); }
288  //-----------------------------------------------------------------------------------------------------
292  {
294  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
295  EntityPtr::getModel()->fullPath().c_str(), TriangleModel::instance()->fullPath().c_str());
296  }
297 
299  {
300  agxAssertN(!instance || instance.isInstanceOf(TriangleModel::instance()),
301  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
302  EntityPtr::getModel()->fullPath().c_str(), TriangleModel::instance()->fullPath().c_str());
303  }
304 
306  {
309  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
310  EntityPtr::getModel()->fullPath().c_str(), TriangleModel::instance()->fullPath().c_str());
311  return *this;
312  }
313 
315  {
317  agxAssertN(!instance || instance.isInstanceOf(TriangleModel::instance()),
318  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
319  EntityPtr::getModel()->fullPath().c_str(), TriangleModel::instance()->fullPath().c_str());
320  return *this;
321  }
322 
323  inline TriangleInstance TrianglePtr::instance() { return agxData::EntityPtr::instance(); }
324  inline const TriangleInstance TrianglePtr::instance() const { return agxData::EntityPtr::instance(); }
325  AGX_FORCE_INLINE TriangleSemantics* TrianglePtr::operator->() { return (TriangleSemantics* )this; }
326  AGX_FORCE_INLINE const TriangleSemantics* TrianglePtr::operator->() const { return (const TriangleSemantics* )this; }
327  AGX_FORCE_INLINE TriangleData* TrianglePtr::getData() { return static_cast<TriangleData* >(agxData::EntityPtr::getData()); }
328  AGX_FORCE_INLINE const TriangleData* TrianglePtr::getData() const { return static_cast<const TriangleData* >(agxData::EntityPtr::getData()); }
329 
330  AGX_FORCE_INLINE agxData::Array< agx::Vec3f > TrianglePtr::vertices() { verifyIndex(); return getData()->vertices.slice(agx::IndexRange32(calculateIndex() * (agx::Index)TriangleData::verticesArraySize, (calculateIndex()+1) * (agx::Index)TriangleData::verticesArraySize)); }
331  AGX_FORCE_INLINE const agxData::Array< agx::Vec3f > TrianglePtr::vertices() const { verifyIndex(); return getData()->vertices.slice(agx::IndexRange32(calculateIndex() * (agx::Index)TriangleData::verticesArraySize, (calculateIndex()+1) * (agx::Index)TriangleData::verticesArraySize)); }
332  AGX_FORCE_INLINE agx::Vec3f& TrianglePtr::vertices(size_t index) { return this->vertices()[index]; }
333  AGX_FORCE_INLINE agx::Vec3f const& TrianglePtr::vertices(size_t index) const { return this->vertices()[index]; }
334 
335  AGX_FORCE_INLINE agxData::Array< agx::Vec3f > TrianglePtr::normals() { verifyIndex(); return getData()->normals.slice(agx::IndexRange32(calculateIndex() * (agx::Index)TriangleData::normalsArraySize, (calculateIndex()+1) * (agx::Index)TriangleData::normalsArraySize)); }
336  AGX_FORCE_INLINE const agxData::Array< agx::Vec3f > TrianglePtr::normals() const { verifyIndex(); return getData()->normals.slice(agx::IndexRange32(calculateIndex() * (agx::Index)TriangleData::normalsArraySize, (calculateIndex()+1) * (agx::Index)TriangleData::normalsArraySize)); }
337  AGX_FORCE_INLINE agx::Vec3f& TrianglePtr::normals(size_t index) { return this->normals()[index]; }
338  AGX_FORCE_INLINE agx::Vec3f const& TrianglePtr::normals(size_t index) const { return this->normals()[index]; }
339 
340  AGX_FORCE_INLINE agxData::Array< agx::Vec4f > TrianglePtr::colors() { verifyIndex(); return getData()->colors.slice(agx::IndexRange32(calculateIndex() * (agx::Index)TriangleData::colorsArraySize, (calculateIndex()+1) * (agx::Index)TriangleData::colorsArraySize)); }
341  AGX_FORCE_INLINE const agxData::Array< agx::Vec4f > TrianglePtr::colors() const { verifyIndex(); return getData()->colors.slice(agx::IndexRange32(calculateIndex() * (agx::Index)TriangleData::colorsArraySize, (calculateIndex()+1) * (agx::Index)TriangleData::colorsArraySize)); }
342  AGX_FORCE_INLINE agx::Vec4f& TrianglePtr::colors(size_t index) { return this->colors()[index]; }
343  AGX_FORCE_INLINE agx::Vec4f const& TrianglePtr::colors(size_t index) const { return this->colors()[index]; }
344 
345  AGX_FORCE_INLINE agxData::Array< agx::UInt32 > TrianglePtr::indices() { verifyIndex(); return getData()->indices.slice(agx::IndexRange32(calculateIndex() * (agx::Index)TriangleData::indicesArraySize, (calculateIndex()+1) * (agx::Index)TriangleData::indicesArraySize)); }
346  AGX_FORCE_INLINE const agxData::Array< agx::UInt32 > TrianglePtr::indices() const { verifyIndex(); return getData()->indices.slice(agx::IndexRange32(calculateIndex() * (agx::Index)TriangleData::indicesArraySize, (calculateIndex()+1) * (agx::Index)TriangleData::indicesArraySize)); }
347  AGX_FORCE_INLINE agx::UInt32& TrianglePtr::indices(size_t index) { return this->indices()[index]; }
348  AGX_FORCE_INLINE agx::UInt32 const& TrianglePtr::indices(size_t index) const { return this->indices()[index]; }
349 
350  AGX_FORCE_INLINE agx::Real& TrianglePtr::cameraDistance() { verifyIndex(); return getData()->cameraDistance[calculateIndex()]; }
351  AGX_FORCE_INLINE agx::Real const& TrianglePtr::cameraDistance() const { verifyIndex(); return getData()->cameraDistance[calculateIndex()]; }
352 
353  //-----------------------------------------------------------------------------------------------------
354  AGX_FORCE_INLINE TriangleInstance::TriangleInstance() {}
355  AGX_FORCE_INLINE TriangleInstance::TriangleInstance(TriangleData* data, agx::Index index) : agxData::EntityInstance(data, index) {}
356  AGX_FORCE_INLINE TriangleInstance::TriangleInstance(agxData::EntityStorage* storage, agx::Index index) : agxData::EntityInstance(storage, index) {}
357  AGX_FORCE_INLINE TriangleInstance::TriangleInstance(const agxData::EntityInstance& other) : agxData::EntityInstance(other)
358  {
360  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
362  }
363 
364  AGX_FORCE_INLINE TriangleInstance::TriangleInstance(const agxData::EntityPtr& ptr) : agxData::EntityInstance(ptr)
365  {
367  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
369  }
370 
371 
372  AGX_FORCE_INLINE TriangleData* TriangleInstance::getData() { return static_cast<TriangleData* >(agxData::EntityInstance::getData()); }
373  AGX_FORCE_INLINE const TriangleData* TriangleInstance::getData() const { return static_cast<const TriangleData* >(agxData::EntityInstance::getData()); }
374 
375  AGX_FORCE_INLINE agxData::Array< agx::Vec3f > TriangleInstance::vertices() { verifyIndex(); return getData()->vertices.slice(agx::IndexRange32(getIndex() * (agx::Index)TriangleData::verticesArraySize, (getIndex()+1) * (agx::Index)TriangleData::verticesArraySize)); }
376  AGX_FORCE_INLINE const agxData::Array< agx::Vec3f > TriangleInstance::vertices() const { verifyIndex(); return getData()->vertices.slice(agx::IndexRange32(getIndex() * (agx::Index)TriangleData::verticesArraySize, (getIndex()+1) * (agx::Index)TriangleData::verticesArraySize)); }
377  AGX_FORCE_INLINE agx::Vec3f& TriangleInstance::vertices(size_t index) { return this->vertices()[index]; }
378  AGX_FORCE_INLINE agx::Vec3f const& TriangleInstance::vertices(size_t index) const { return this->vertices()[index]; }
379 
380  AGX_FORCE_INLINE agxData::Array< agx::Vec3f > TriangleInstance::normals() { verifyIndex(); return getData()->normals.slice(agx::IndexRange32(getIndex() * (agx::Index)TriangleData::normalsArraySize, (getIndex()+1) * (agx::Index)TriangleData::normalsArraySize)); }
381  AGX_FORCE_INLINE const agxData::Array< agx::Vec3f > TriangleInstance::normals() const { verifyIndex(); return getData()->normals.slice(agx::IndexRange32(getIndex() * (agx::Index)TriangleData::normalsArraySize, (getIndex()+1) * (agx::Index)TriangleData::normalsArraySize)); }
382  AGX_FORCE_INLINE agx::Vec3f& TriangleInstance::normals(size_t index) { return this->normals()[index]; }
383  AGX_FORCE_INLINE agx::Vec3f const& TriangleInstance::normals(size_t index) const { return this->normals()[index]; }
384 
385  AGX_FORCE_INLINE agxData::Array< agx::Vec4f > TriangleInstance::colors() { verifyIndex(); return getData()->colors.slice(agx::IndexRange32(getIndex() * (agx::Index)TriangleData::colorsArraySize, (getIndex()+1) * (agx::Index)TriangleData::colorsArraySize)); }
386  AGX_FORCE_INLINE const agxData::Array< agx::Vec4f > TriangleInstance::colors() const { verifyIndex(); return getData()->colors.slice(agx::IndexRange32(getIndex() * (agx::Index)TriangleData::colorsArraySize, (getIndex()+1) * (agx::Index)TriangleData::colorsArraySize)); }
387  AGX_FORCE_INLINE agx::Vec4f& TriangleInstance::colors(size_t index) { return this->colors()[index]; }
388  AGX_FORCE_INLINE agx::Vec4f const& TriangleInstance::colors(size_t index) const { return this->colors()[index]; }
389 
390  AGX_FORCE_INLINE agxData::Array< agx::UInt32 > TriangleInstance::indices() { verifyIndex(); return getData()->indices.slice(agx::IndexRange32(getIndex() * (agx::Index)TriangleData::indicesArraySize, (getIndex()+1) * (agx::Index)TriangleData::indicesArraySize)); }
391  AGX_FORCE_INLINE const agxData::Array< agx::UInt32 > TriangleInstance::indices() const { verifyIndex(); return getData()->indices.slice(agx::IndexRange32(getIndex() * (agx::Index)TriangleData::indicesArraySize, (getIndex()+1) * (agx::Index)TriangleData::indicesArraySize)); }
392  AGX_FORCE_INLINE agx::UInt32& TriangleInstance::indices(size_t index) { return this->indices()[index]; }
393  AGX_FORCE_INLINE agx::UInt32 const& TriangleInstance::indices(size_t index) const { return this->indices()[index]; }
394 
395  AGX_FORCE_INLINE agx::Real& TriangleInstance::cameraDistance() { verifyIndex(); return getData()->cameraDistance[getIndex()]; }
396  AGX_FORCE_INLINE agx::Real const& TriangleInstance::cameraDistance() const { verifyIndex(); return getData()->cameraDistance[getIndex()]; }
397 
398  //-----------------------------------------------------------------------------------------------------
399  AGX_FORCE_INLINE TriangleSemantics::TriangleSemantics() {}
400  //-----------------------------------------------------------------------------------------------------
402  }
403  }
404 }
405 
406 AGX_TYPE_BINDING(agx::Physics::Geometry::TrianglePtr, "Physics.Geometry.TrianglePtr")
407 AGX_TYPE_BINDING(agx::Physics::Geometry::TriangleInstance, "Physics.Geometry.TriangleInstance")
408 
409 #ifdef _MSC_VER
410 # pragma warning(pop)
411 #endif
412 
413 #undef AGX_ENTITY_WRAPPER
414 #undef AGX_ENTITY_NAMESPACE
415 #endif
416 
agxData::EntityData * getData()
static agxData::ScalarAttributeT< agx::Vec3f > * verticesAttribute
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:72
static agxData::ScalarAttributeT< agx::Real > * cameraDistanceAttribute
#define agxAssertN(expr, format,...)
Definition: debug.h:145
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:34
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
#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 TriangleInstance instance()
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
bool isInstanceOf(agxData::EntityModel *model) const
Abstract description of the data attributes for the Physics.Geometry.Triangle entity.
#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 TriangleModel * instance()
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.
AGXPHYSICS_EXPORT agx::Real & cameraDistance()
AGXPHYSICS_EXPORT agxData::Array< agx::Vec3f > normals()
AGXPHYSICS_EXPORT TriangleSemantics * operator->()
Contains classes for low level data storage for AGX.
Definition: Container.h:23
UInt32 Index
Definition: Integer.h:52
A range of indices.
Definition: IndexRange.h:32
Pointer to a entity instance of type Physics.Geometry.Triangle.
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
static agxData::ScalarAttributeT< agx::UInt32 > * indicesAttribute
AGXPHYSICS_EXPORT agxData::Array< agx::Vec3f > vertices()
AGXPHYSICS_EXPORT agxData::Array< agx::UInt32 > indices()
bool isInstanceOf(agxData::EntityModel *model) const
AGXPHYSICS_EXPORT TrianglePtr & operator=(const agxData::EntityPtr &ptr)
static agxData::ScalarAttributeT< agx::Vec4f > * colorsAttribute
AGXPHYSICS_EXPORT agxData::Array< agx::Vec4f > colors()
double Real
Definition: Real.h:42
static agxData::ScalarAttributeT< agx::Vec3f > * normalsAttribute
uint32_t UInt32
Definition: Integer.h:40
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97