 |
AGXDynamics
2.35.0.2
|
Go to the documentation of this file.
33 # pragma warning(push)
34 # pragma warning(disable: 6011) // Disable warningC6011: dereferencing nullptr pointer
42 class GlobalResultStorage;
48 class SimulationFrameWriter;
78 virtual void configure(agx::TiXmlElement *eStorage)
override;
85 void addListener(EventListener *listener);
86 void removeListener(EventListener *listener);
87 bool hasListener(EventListener *listener);
109 size_t capacity()
const;
114 size_t getNumBytes()
const;
125 void reserve(
size_t size);
133 template <
typename T>
136 template <
typename T>
151 void resize(
size_t size,
bool initializeElements =
true);
153 size_t presize(
size_t size,
size_t initialSize = 0);
156 void destroyInstance(
size_t id);
158 template <
typename VectorT>
159 void destroyInstances(
const VectorT& instances);
228 size_t idToIndex(
size_t id)
const;
233 size_t indexToId(
size_t index)
const;
239 agxData::EntityData *getData();
241 template <
typename T>
244 template <
typename T>
245 const T* getData()
const;
252 void setUseInstanceTable(
bool flag);
257 bool useInstanceTable()
const;
291 void print(std::ostream& stream)
const;
294 void verifyConsistency();
300 template <
typename T>
301 T& get(
const agx::Name& attributeName,
size_t index);
305 void preparePermutation();
320 template <
typename T>
323 template <
typename T>
331 void keyFrameResize(
size_t size,
size_t capacity);
333 void setEnableEvents(
bool flag);
339 void printInstanceTable()
const;
355 friend class EntityData;
357 void commitBatch(
size_t size);
365 void swapInstances(
size_t index1,
size_t index2);
366 void init(
size_t initialCapacity);
373 void elementBufferReallocationCallback(
Buffer* elementBuffer);
381 void destroyInstances(
const EntityPtr* instances,
size_t numInstances,
bool triggerEvent =
true);
389 template <
typename T>
398 bool m_useInstanceTable;
399 bool m_implicitResize;
401 bool m_usedResizeMethod;
407 EntityDataRef m_dataSet;
424 EventDispatch m_eventDispatch;
457 template <
typename T>
460 agxAssert(agxData::getFormat<T>()->
is(agxData::getFormat<EntityPtr>()));
464 template <
typename T>
472 buffer = this->createBuffer(attribute);
478 template <
typename T>
485 template <
typename T>
488 for (
size_t i = 0; i < m_buffers.
size(); ++i)
490 Buffer *buffer = m_buffers[i];
491 if (buffer->
getName() == attributeName)
496 return m_buffers[0]->getElement<T>(0);
502 return m_idToIndexArray[id];
522 template <
typename T>
525 template <
typename T>
540 return m_storage->idToIndex(
id);
546 return m_storage->indexToId(index);
551 return this->createInstances(1);
556 if (m_numElements + numInstances >= m_storage->size())
558 if (!m_hasBatchInstances)
560 m_storage->beginBatch();
561 m_hasBatchInstances =
true;
566 m_numElements = head;
570 m_numElements += numInstances;
572 return instanceIndex;
578 if (m_hasBatchInstances)
580 m_storage->commitBatch(m_numElements);
581 m_hasBatchInstances =
false;
602 template <
typename T>
606 return *
static_cast<T *
>(this->
getData());
609 template <
typename T>
620 template <
typename T>
624 agxAssertN(m_storage,
"Can not access attribute \'%s\' from an invalid pointer.", attribute->
fullName().c_str());
627 agxAssertN(index < m_storage->size(),
"%s: Entity (%p, %u) claims to have index %u, but storage size is %u.", m_storage->
getPath().
c_str(), (
void *)m_storage, (
unsigned)m_id, (
unsigned)index, (
unsigned)m_storage->size());
635 agxAssertN(index < m_storage->size(),
"%s: Entity (%p, %u) claims to have index %u, but storage size is %u.", m_storage->
getPath().
c_str(), (
void *)m_storage, (
unsigned)m_id, (
unsigned)index, (
unsigned)m_storage->size());
640 template <
typename T>
643 return this->getElement<T>(attribute);
646 template <
typename T>
649 return this->getElement<const T>(attribute);
652 template <
typename T>
655 return this->getElement<T>(attribute);
658 template <
typename T>
661 return this->getElement<const T>(attribute);
665 template <
typename T>
671 template <
typename T>
679 template <
typename T>
685 template <
typename T>
691 template <
typename T>
697 template <
typename T>
703 template <
typename T>
709 agxAssertN(entity.
calculateIndex() < this->size(),
"%s: Entity with id %u claims to have index %u, but storage size is %u.", this->getPath().c_str(), (
unsigned)entity.
getId(), (
unsigned)entity.
calculateIndex(), (
unsigned)this->size());
715 template <
typename T>
723 template <
typename VectorT>
737 return m_permutationBuffers[index];
742 template <
typename T>
747 return const_cast<T&
>(value->
get<T>());
750 template <
typename T>
753 return const_cast<EntityPtr *
>(
this)->
operator()(attribute);
772 m_storage->swapInstanceIds(m_id, other.m_id);
811 m_data =
const_cast<EntityData *
>(other.
getData());
832 return m ? m->
is(model) :
false;
841 agxAssertN(index < storage->size(),
"%s: Entity instance (%p, %u) is out of bounds, storage size is %u.", storage->
getPath().
c_str(), (
void *)storage, (
unsigned)index, (
unsigned)storage->
size());
868 template <
typename T>
873 template <
typename T>
878 template <
typename T>
882 return m_entityPtr.getElement<T>(m_attribute);
885 template <
typename T>
889 return m_entityPtr.getElement<T>(m_attribute);
892 template <
typename T>
895 return m_entityPtr.
isValid() && m_attribute;
899 template <
typename T>
902 return !this->isValid();
905 template <
typename T>
908 return this->isValid();
916 # pragma warning(pop)
agx::String fullName() const
void init(agxData::EntityStorage *storage, agx::Index id)
Set the target storage and id.
static const agx::Name IdToIndexName
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Abstract representation of a value.
agxData::ValueRefT< agx::UInt > sizeParameter
T align_ceil(T value, T alignment)
void destroyInstances(const VectorT &instances)
#define agxAssert1(expr, msg)
Representation of a path, a list of name components.
void verifyIndex() const
Check for broken ptr, by verifying that the id is active in the storage.
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
void destroyInstance(agxData::EntityPtr instance)
bool is(const agx::Model *other) const
agxData::EntityData * getData()
agxData::EntityData * getData()
agxData::EntityModel * getModel()
Alias for getData()->getStorage()->getModel()
void swapIndex(EntityPtr &other)
Swap index with another instance.
EntityPtr operator[](size_t index)
bool isInstanceOf(agxData::EntityModel *model) const
Data storage for a collection of entity instances of a specified EntityModel.
agx::Object * getObject(const agx::Name &name, size_t index=0)
static agxData::Array< T > raw(T *buffer, agx::Index size)
Array creation helper method that creates an array covering the given memory area.
Callback1< Value * > CallbackType
agx::Index calculateId() const
T & operator()(const agxData::ScalarAttributeT< T > *attribute)
Access the value of a specific attribute.
Vector containing 'raw' data.
agxData::EntityInstance instance()
static EntityPtr createWithIndex(EntityStorage *storage, agx::Index index)
bool isInstanceOf(agxData::EntityModel *model) const
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Contains classes for low level data storage for AGX.
A model is an abstract representation of the class of an agx::Object.
Type-specific Array used for fast access into the data held by a Buffer.
void swapId(EntityPtr &other)
Swap id with another instance.
#define AGX_DECLARE_VECTOR_TYPES(type)
agxData::Buffer * getBuffer(const agx::Name &name)
agx::UInt32 getId() const
bool useInstanceTable() const
size_t getElementArraySize() const
agx::Index getIndex() const
AGXTERRAIN_EXPORT TimingStorage & getStorage()
agxData::IndexArray & getIdToIndexTable()
agx::VectorPOD< std::pair< size_t, size_t > > InstanceSwapVector
agxData::Array< T > dereferenceMultipliedAttribute(const agxData::EntityPtr &entity, const agxData::ScalarAttributeT< T > *attribute)
agxData::ValueRefT< agx::UInt > capacityParameter
Inheritance with partial specialization due to bug with ref_ptr containers.
Abstract representation of a data buffer.
const agxData::BufferTable & getBuffers() const
Entity instance provides access to a single instance in an EntityStorage.
const char * c_str() const
agxData::Byte * getPermutationBuffer(agxData::Attribute *attribute)
Representation of a name string.
Class for writing serialized data in binary format to a stream.
agx::Object is a refcounted object with a name.
Inheritance with partial specialization due to bug with ref_ptr containers.
A component is an object containing other objects, enabling hierarchical structuring.
agxData::EntityStorage * getStorage()
Alias for getData()->getStorage()
T & getElement(size_t index)
agxData::LocalVector< std::pair< size_t, size_t > > InstanceSwapLocalVector
bool is() const
Subclass test.
#define AGX_DECLARE_POINTER_TYPES(type)
agx::HashTable< Attribute *, BufferRef > BufferTable
agx::Path getPath() const
size_t idToIndex(size_t id) const
Convert between instance id and data index.
size_t indexToId(size_t index) const
Convert between instance id and data index.
const agxData::Array< EntityPtr > getInstances() const
agxData::Buffer * getInstanceBuffer()
agxData::Buffer * getIdToIndexBuffer()
EntityPtr at(size_t index)
void verifyIndex() const
Check for broken ptr, by verifying that the index is active in the storage.
IndexRangeT< agx::UInt > IndexRange
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
T & get(const agx::Name &attributeName, size_t index)
Slow but convenient accessor.
void swapInstances(const InstanceSwapVector &swaps)
An agx::Device is an abstract representation of a device on which data can be stored and processed.
#define agxAssertN(expr, format,...)
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
void AGXPHYSICS_EXPORT init()
Initialize agx.
agxData::Buffer * getGlobalOrderBuffer()
If the storage is used as a global result, we provide a permutation buffer for parallel determinism.
const AGXCORE_EXPORT InvalidIndexStruct InvalidIndex
EntityInstance()
Constructors.
const agx::Name & getName() const
AGXTERRAIN_EXPORT void clear()
agxData::EntityModel * getEntityModel()
agxData::EntityStorage * getStorage() const
An abstract attribute description, part of an Entity.
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
agxData::EntityModel * getModel()
std::ostream & operator<<(std::ostream &output, const Attribute &attribute)
agx::Index calculateIndex() const
Calculate the index using the indirect id.
static const agx::Name IndexToIdName