AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
HeightFieldEntity.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or
9having been advised so by Algoryx Simulation AB for a time limited evaluation,
10or having purchased a valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
18// AUTOMATICALLY GENERATED ENTITY, DO NOT EDIT! //
20
21#ifndef GENERATED_AGX_PHYSICS_GEOMETRY_HEIGHTFIELD_H_PLUGIN
22#define GENERATED_AGX_PHYSICS_GEOMETRY_HEIGHTFIELD_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>
41#include <agxData/EntityRef.h>
42#include <agxData/EntityPtr.h>
44#include <agx/Integer.h>
45#include <agx/Real.h>
46#include <agx/macros.h>
48#include <agx/Real.h>
49#include <agx/Integer.h>
50
51
52namespace agx
53{
54 namespace Physics
55 {
56 namespace Geometry
57 {
58
59 class HeightFieldModel;
60 class HeightFieldData;
61 class HeightFieldPtr;
62 class HeightFieldInstance;
63 class HeightFieldSemantics;
64
65
67
72 {
73 public:
75
76 HeightFieldModel(const agx::String& name = "HeightField");
77
80
83
86
88 virtual void shutdownCleanup() override;
89
90
91
92 /* Attributes */
97
98 protected:
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;
105 };
106
107
109 #ifndef AGX_PHYSICS_GEOMETRY_HEIGHTFIELD_DATA_SET_OVERRIDE
110 #define AGX_PHYSICS_GEOMETRY_HEIGHTFIELD_DATA_SET
111 class AGXPHYSICS_EXPORT HeightFieldData : public agx::Physics::Geometry::MeshData
112 {
113 public:
114 HeightFieldInstance operator[] (size_t index);
115
116 public:
122
123 public:
124 typedef agx::Real sizeXType;
125 typedef agx::Real sizeYType;
126 typedef agx::UInt64 resolutionXType;
127 typedef agx::UInt64 resolutionYType;
128
129 public:
130 HeightFieldData(agxData::EntityStorage* storage);
131 HeightFieldData();
132
133 protected:
134 virtual ~HeightFieldData() {}
135 virtual void setNumElements(agx::Index numElements) override;
136
137 private:
138 HeightFieldData& operator= (const HeightFieldData&) { return *this; }
139
140 };
141 #endif
143
144
146 class AGXPHYSICS_EXPORT HeightFieldSemantics : public agx::Physics::Geometry::MeshSemantics
147 {
148 public:
149
150 // Automatic getters
151 agx::Real const& getSizeX() const;
152 agx::Real const& getSizeY() const;
153 agx::UInt64 const& getResolutionX() const;
154 agx::UInt64 const& getResolutionY() const;
155
156 // Semantics defined by explicit kernels
157
158 // Automatic setters
159 void setSizeX(agx::Real const& value);
160 void setSizeY(agx::Real const& value);
161 void setResolutionX(agx::UInt64 const& value);
162 void setResolutionY(agx::UInt64 const& value);
163
164
165 protected:
166 friend class HeightFieldPtr;
167 friend class HeightFieldInstance;
168 HeightFieldSemantics();
169 };
171
172
173
176 class CALLABLE HeightFieldPtr : public agx::Physics::Geometry::MeshPtr
177 {
178 public:
180 typedef HeightFieldData DataType;
181 typedef HeightFieldInstance InstanceType;
182
183 public:
190 AGXPHYSICS_EXPORT HeightFieldInstance instance();
191 AGXPHYSICS_EXPORT const HeightFieldInstance instance() const;
192
193 AGXPHYSICS_EXPORT HeightFieldSemantics* operator->();
194 AGXPHYSICS_EXPORT const HeightFieldSemantics* operator->() const;
195
196 HeightFieldData* getData();
197 const HeightFieldData* getData() const;
198
199
204
209
214
219
220 };
221
222 // Entity is Referenced
224
225
227 class AGXPHYSICS_EXPORT HeightFieldInstance : public agx::Physics::Geometry::MeshInstance
228 {
229 public:
230 HeightFieldInstance();
231 HeightFieldInstance(HeightFieldData* data, agx::Index index);
232 HeightFieldInstance(agxData::EntityStorage *storage, agx::Index index);
233 HeightFieldInstance(const agxData::EntityInstance& other);
234 HeightFieldInstance(const agxData::EntityPtr& ptr);
235
236 HeightFieldData* getData();
237 const HeightFieldData* getData() const;
238
239 public:
241 agx::Real& sizeX();
243 agx::Real const& sizeX() const;
244
246 agx::Real& sizeY();
248 agx::Real const& sizeY() const;
249
251 agx::UInt64& resolutionX();
253 agx::UInt64 const& resolutionX() const;
254
256 agx::UInt64& resolutionY();
258 agx::UInt64 const& resolutionY() const;
259
260 };
262
263
264
267
268
269
271 /* Implementation */
272 //-----------------------------------------------------------------------------------------------------
273 //-----------------------------------------------------------------------------------------------------
274 inline HeightFieldInstance agx::Physics::Geometry::HeightFieldData::operator[] (size_t index) { return HeightFieldInstance(this, (agx::Index)index); }
275 //-----------------------------------------------------------------------------------------------------
277 AGX_FORCE_INLINE HeightFieldPtr::HeightFieldPtr(agxData::EntityStorage* storage, agx::Index id) : agx::Physics::Geometry::MeshPtr(storage, id) {}
278 AGX_FORCE_INLINE HeightFieldPtr::HeightFieldPtr(const agxData::EntityPtr& ptr) : agx::Physics::Geometry::MeshPtr(ptr)
279 {
281 "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
282 EntityPtr::getModel()->fullPath().c_str(), HeightFieldModel::instance()->fullPath().c_str());
283 }
284
285 AGX_FORCE_INLINE HeightFieldPtr::HeightFieldPtr(const agxData::EntityInstance& instance) : agx::Physics::Geometry::MeshPtr(instance)
286 {
287 agxAssertN(!instance || instance.isInstanceOf(HeightFieldModel::instance()),
288 "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
289 EntityPtr::getModel()->fullPath().c_str(), HeightFieldModel::instance()->fullPath().c_str());
290 }
291
292 AGX_FORCE_INLINE HeightFieldPtr& HeightFieldPtr::operator= (const agxData::EntityPtr& ptr)
293 {
295 agxAssertN(!ptr || ptr.isInstanceOf(HeightFieldModel::instance()),
296 "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
297 EntityPtr::getModel()->fullPath().c_str(), HeightFieldModel::instance()->fullPath().c_str());
298 return *this;
299 }
300
301 AGX_FORCE_INLINE HeightFieldPtr& HeightFieldPtr::operator= (const agxData::EntityInstance& instance)
302 {
304 agxAssertN(!instance || instance.isInstanceOf(HeightFieldModel::instance()),
305 "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
306 EntityPtr::getModel()->fullPath().c_str(), HeightFieldModel::instance()->fullPath().c_str());
307 return *this;
308 }
309
310 inline HeightFieldInstance HeightFieldPtr::instance() { return agxData::EntityPtr::instance(); }
311 inline const HeightFieldInstance HeightFieldPtr::instance() const { return agxData::EntityPtr::instance(); }
312 AGX_FORCE_INLINE HeightFieldSemantics* HeightFieldPtr::operator->() { return (HeightFieldSemantics* )this; }
313 AGX_FORCE_INLINE const HeightFieldSemantics* HeightFieldPtr::operator->() const { return (const HeightFieldSemantics* )this; }
314 AGX_FORCE_INLINE HeightFieldData* HeightFieldPtr::getData() { return static_cast<HeightFieldData* >(agxData::EntityPtr::getData()); }
315 AGX_FORCE_INLINE const HeightFieldData* HeightFieldPtr::getData() const { return static_cast<const HeightFieldData* >(agxData::EntityPtr::getData()); }
316
317 AGX_FORCE_INLINE agx::Real& HeightFieldPtr::sizeX() { verifyIndex(); return getData()->sizeX[calculateIndex()]; }
318 AGX_FORCE_INLINE agx::Real const& HeightFieldPtr::sizeX() const { verifyIndex(); return getData()->sizeX[calculateIndex()]; }
319
320 AGX_FORCE_INLINE agx::Real& HeightFieldPtr::sizeY() { verifyIndex(); return getData()->sizeY[calculateIndex()]; }
321 AGX_FORCE_INLINE agx::Real const& HeightFieldPtr::sizeY() const { verifyIndex(); return getData()->sizeY[calculateIndex()]; }
322
323 AGX_FORCE_INLINE agx::UInt64& HeightFieldPtr::resolutionX() { verifyIndex(); return getData()->resolutionX[calculateIndex()]; }
324 AGX_FORCE_INLINE agx::UInt64 const& HeightFieldPtr::resolutionX() const { verifyIndex(); return getData()->resolutionX[calculateIndex()]; }
325
326 AGX_FORCE_INLINE agx::UInt64& HeightFieldPtr::resolutionY() { verifyIndex(); return getData()->resolutionY[calculateIndex()]; }
327 AGX_FORCE_INLINE agx::UInt64 const& HeightFieldPtr::resolutionY() const { verifyIndex(); return getData()->resolutionY[calculateIndex()]; }
328
329 //-----------------------------------------------------------------------------------------------------
330 AGX_FORCE_INLINE HeightFieldInstance::HeightFieldInstance() {}
331 AGX_FORCE_INLINE HeightFieldInstance::HeightFieldInstance(HeightFieldData* data, agx::Index index) : agx::Physics::Geometry::MeshInstance(data, index) {}
332 AGX_FORCE_INLINE HeightFieldInstance::HeightFieldInstance(agxData::EntityStorage* storage, agx::Index index) : agx::Physics::Geometry::MeshInstance(storage, index) {}
333 AGX_FORCE_INLINE HeightFieldInstance::HeightFieldInstance(const agxData::EntityInstance& other) : agx::Physics::Geometry::MeshInstance(other)
334 {
336 "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
337 EntityInstance::getModel()->fullPath().c_str(), HeightFieldModel::instance()->fullPath().c_str());
338 }
339
340 AGX_FORCE_INLINE HeightFieldInstance::HeightFieldInstance(const agxData::EntityPtr& ptr) : agx::Physics::Geometry::MeshInstance(ptr)
341 {
343 "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
344 EntityInstance::getModel()->fullPath().c_str(), HeightFieldModel::instance()->fullPath().c_str());
345 }
346
347
348 AGX_FORCE_INLINE HeightFieldData* HeightFieldInstance::getData() { return static_cast<HeightFieldData* >(agxData::EntityInstance::getData()); }
349 AGX_FORCE_INLINE const HeightFieldData* HeightFieldInstance::getData() const { return static_cast<const HeightFieldData* >(agxData::EntityInstance::getData()); }
350
351 AGX_FORCE_INLINE agx::Real& HeightFieldInstance::sizeX() { verifyIndex(); return getData()->sizeX[getIndex()]; }
352 AGX_FORCE_INLINE agx::Real const& HeightFieldInstance::sizeX() const { verifyIndex(); return getData()->sizeX[getIndex()]; }
353
354 AGX_FORCE_INLINE agx::Real& HeightFieldInstance::sizeY() { verifyIndex(); return getData()->sizeY[getIndex()]; }
355 AGX_FORCE_INLINE agx::Real const& HeightFieldInstance::sizeY() const { verifyIndex(); return getData()->sizeY[getIndex()]; }
356
357 AGX_FORCE_INLINE agx::UInt64& HeightFieldInstance::resolutionX() { verifyIndex(); return getData()->resolutionX[getIndex()]; }
358 AGX_FORCE_INLINE agx::UInt64 const& HeightFieldInstance::resolutionX() const { verifyIndex(); return getData()->resolutionX[getIndex()]; }
359
360 AGX_FORCE_INLINE agx::UInt64& HeightFieldInstance::resolutionY() { verifyIndex(); return getData()->resolutionY[getIndex()]; }
361 AGX_FORCE_INLINE agx::UInt64 const& HeightFieldInstance::resolutionY() const { verifyIndex(); return getData()->resolutionY[getIndex()]; }
362
363 //-----------------------------------------------------------------------------------------------------
364 AGX_FORCE_INLINE HeightFieldSemantics::HeightFieldSemantics() {}
365 //-----------------------------------------------------------------------------------------------------
367 }
368 }
369}
370
371AGX_TYPE_BINDING(agx::Physics::Geometry::HeightFieldPtr, "Physics.Geometry.HeightFieldPtr")
372AGX_TYPE_BINDING(agx::Physics::Geometry::HeightFieldInstance, "Physics.Geometry.HeightFieldInstance")
373
374#ifdef _MSC_VER
375# pragma warning(pop)
376#endif
377
378#undef AGX_ENTITY_WRAPPER
379#undef AGX_ENTITY_NAMESPACE
380#endif
381
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#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
EntityPtr & operator=(const EntityPtr &other)=default
bool isInstanceOf(agxData::EntityModel *model) const
agxData::EntityData * getData()
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
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.HeightField entity.
static HeightFieldModel * instance()
virtual void shutdownCleanup() override
This is part of internal cleanup and should not be called by users.
static agxData::EntityStorage * defaultStorage()
void construct(agx::Physics::Geometry::HeightFieldPtr heightField)
static agxData::ScalarAttributeT< agx::UInt64 > * resolutionXAttribute
static HeightFieldPtr createInstance()
Create and return a pointer to a new instance in the default storage for this entity model.
virtual void initAttributeAccessors() override
static agxData::ScalarAttributeT< agx::Real > * sizeYAttribute
HeightFieldModel(const agx::String &name="HeightField")
static agxData::ScalarAttributeT< agx::Real > * sizeXAttribute
virtual void configure(agx::TiXmlElement *eEntity) override
static agxData::ScalarAttributeT< agx::UInt64 > * resolutionYAttribute
virtual agxData::EntityData * createData(agxData::EntityStorage *storage) override
virtual void construct(agxData::EntityPtr instance) override
Pointer to a entity instance of type Physics.Geometry.HeightField.
AGXPHYSICS_EXPORT agx::UInt64 & resolutionY()
AGXPHYSICS_EXPORT agx::UInt64 const & resolutionY() const
AGXPHYSICS_EXPORT agx::UInt64 & resolutionX()
AGXPHYSICS_EXPORT agx::UInt64 const & resolutionX() const
const HeightFieldData * getData() const
AGXPHYSICS_EXPORT agx::Real & sizeX()
AGXPHYSICS_EXPORT HeightFieldInstance instance()
AGXPHYSICS_EXPORT const HeightFieldInstance instance() const
AGXPHYSICS_EXPORT HeightFieldPtr(agxData::EntityStorage *storage, agx::Index id)
AGXPHYSICS_EXPORT const HeightFieldSemantics * operator->() const
AGXPHYSICS_EXPORT agx::Real & sizeY()
AGXPHYSICS_EXPORT HeightFieldPtr(const agxData::EntityInstance &instance)
AGXPHYSICS_EXPORT HeightFieldSemantics * operator->()
AGXPHYSICS_EXPORT agx::Real const & sizeX() const
AGXPHYSICS_EXPORT HeightFieldPtr(const agxData::EntityPtr &ptr)
AGXPHYSICS_EXPORT agx::Real const & sizeY() const
Abstract description of the data attributes for the Physics.Geometry.Mesh entity.
Definition: MeshEntity.h:70
Pointer to a entity instance of type Physics.Geometry.Mesh.
Definition: MeshEntity.h:155
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:89
#define CALLABLE
Definition: macros.h:72
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
#define AGX_FORCE_INLINE
Definition: macros.h:58
Contains classes for low level data storage for AGX.
Definition: Container.h:23
agxData::EntityRef< HeightFieldPtr > HeightFieldRef
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint64_t UInt64
Definition: Integer.h:33
double Real
Definition: Real.h:41
UInt32 Index
Definition: Integer.h:44