 |
AGX Dynamics
2.38.0.2
|
Go to the documentation of this file.
31 # pragma warning(push)
32 # pragma warning(disable: 6011) // Disable warningC6011: dereferencing nullptr pointer
39 class GlobalResultBuffer;
61 virtual void configure(agx::TiXmlElement *eBuffer)
override;
62 virtual void snapshot(agx::TiXmlNode *eParent,
const agx::String& directory)
const override;
73 void addListener(EventListener *listener);
74 void removeListener(EventListener *listener);
75 bool hasListener(EventListener *listener);
105 template <
typename T>
108 template <
typename T>
123 size_t capacity()
const;
133 void resize(
size_t size,
bool initializeElements =
true);
134 void presize(
size_t size,
size_t initialSize);
144 void reserve(
size_t size);
155 const void* ptr()
const;
157 template <
typename T>
160 template <
typename T>
161 const T *ptr()
const;
171 template <
typename T>
172 T& getElement(
size_t index);
174 template <
typename T>
175 const T& getElement(
size_t index)
const;
187 void *getElement(
size_t index);
188 const void *getElement(
size_t index)
const;
190 void *kernelOverflowReallocation(
size_t size);
191 void deleteOverflowBuffer(
void *buffer,
size_t numElements);
193 void *allocateBackBuffer();
194 void swapBackBuffer(
void *backBuffer);
199 size_t getElementArraySize()
const;
218 static void copy(
Buffer *target,
size_t targetOffset,
const Buffer *source,
size_t sourceOffset,
size_t numElements);
229 void print(std::ostream& stream)
const;
254 Buffer *getGlobalOrderBuffer();
255 const Buffer *getGlobalOrderBuffer()
const;
257 Buffer *getOrCreateGlobalOrderBuffer();
263 Buffer *getElementBuffer();
264 const Buffer *getElementBuffer()
const;
269 void setElementBuffer(
Buffer *buffer);
289 Buffer *getOriginalBuffer();
290 const Buffer *getOriginalBuffer()
const;
295 virtual void buildNavigationTree(agxJson::Value& eNode)
const override;
306 virtual void reallocate(
size_t size);
313 void signalReallocation();
318 void keyFrameReserve(
size_t capacity);
333 void setOriginalBuffer(
Buffer *buffer);
364 template <
typename T>
375 void setBuffer(
Buffer *buffer);
383 void *allocateBytes(
size_t numBytes);
384 void deallocateBytes(
void *buffer,
size_t numBytes);
395 template <
typename T>
399 template <
typename T2>
418 template <
typename T2>
419 bool contains(
const T2& value)
const;
421 template <
typename T2>
422 size_t find(
const T2& value)
const;
428 const T&
at(
size_t index)
const;
431 const T&
front()
const;
434 const T&
back()
const;
482 template <
typename T>
485 agxAssertN(
m_format->is(agxData::getFormat<T>()) &&
m_format->getSize() == agxData::getFormat<T>()->getSize(),
"Type mismatch! Buffer has type %s, requested array of type %s",
m_format->fullName().c_str(), agxData::getFormat<T>()->fullName().c_str());
489 template <
typename T>
492 return const_cast<Buffer *
>(
this)->getArray<T>();
502 template <
typename T>
506 return static_cast<T *
>(
m_ptr);
509 template <
typename T>
512 return const_cast<Buffer *
>(
this)->ptr<T>();
516 template <
typename T>
528 template <
typename T>
531 return const_cast<Buffer *
>(
this)->getElement<T>(index);
563 template <
typename T>
568 return m_buffer->getGlobalResult();
571 template <
typename T>
574 return this->getGlobalResult()->allocateResult(numElements);
577 template <
typename T>
580 if (numElements == 0)
583 return this->getGlobalResult()->commit(*
this, numElements, localResult, sortIndex);
586 template <
typename T>
589 if (numElements == 0)
592 return this->getGlobalResult()->commit(*
this, numElements, localResult);
595 template <
typename T>
template <
typename T2>
601 return this->getGlobalResult()->commit(*
this, vector, sortIndex);
605 template <
typename T>
template <
typename T2>
611 return this->getGlobalResult()->commit(*
this, vector);
619 template <
typename T>
622 template <
typename T>
732 template <
typename T>
737 result.m_ptr = buffer;
743 template <
typename T>
748 result.m_ptr = (T *)buffer;
754 template <
typename T>
759 template <
typename T>
762 #ifndef AGX_ENTITY_WRAPPER
768 template <
typename T>
771 #ifndef AGX_ENTITY_WRAPPER
776 template <
typename T>
781 template <
typename T>
784 this->m_ptr = vec.
ptr();
788 template <
typename T>
792 this->m_ptr = vec.
ptr();
793 this->m_range = range;
796 template <
typename T>
799 this->m_ptr = vec.
ptr();
803 template <
typename T>
807 this->m_ptr = vec.
ptr();
808 this->m_range = range;
811 template <
typename T>
815 agxAssert1(!m_range.empty(),
"Can not take back element of an empty array!");
816 return ((T*)m_ptr)[m_range.size()-1];
819 template <
typename T>
823 agxAssert1(!m_range.empty(),
"Can not take back element of an empty array!");
824 return ((T*)m_ptr)[m_range.size()-1];
827 template <
typename T>
831 agxAssert1(!m_range.empty(),
"Can not take front element of an empty array!");
832 return ((T*)m_ptr)[0];
835 template <
typename T>
839 agxAssert1(!m_range.empty(),
"Can not take front element of an empty array!");
840 return ((T*)m_ptr)[0];
844 template <
typename T>
847 agxAssert1(m_ptr,
"Array does not have an active buffer!");
848 agxAssertN(index < m_range.size(),
"Array index %llu is out of bounds, size is %llu", (
long long unsigned)index, (
long long unsigned)m_range.size());
849 return ((T*)m_ptr)[index];
853 template <
typename T>
856 return const_cast<Array<T>*
>(
this)->
operator[](index);
859 template <
typename T>
863 agxVerifyN(index < m_range.size(),
"Array index %llu is out of bounds, size is %llu", (
long long unsigned)index, (
long long unsigned)m_range.size());
864 return ((T*)m_ptr)[index];
867 template <
typename T>
870 return const_cast<Array<T>*
>(
this)->at(index);
874 template <
typename T>
881 template <
typename T>
884 return this->slice(subRange);
887 template <
typename T>
890 template <
typename T>
893 template <
typename T>
896 template <
typename T>
899 template <
typename T>
903 template <
typename T>
907 template <
typename T>
template <
typename T2>
910 for (
size_t i = 0, numElements = size(); i < numElements; ++i)
912 if ((*
this)[i] == element)
919 template <
typename T>
template <
typename T2>
926 template <
typename T>
929 for (
size_t i = 0; i < array.size(); i++)
933 if (i < array.size()-1)
944 template <
typename T>
template <
typename T2>
947 const Buffer *buffer =
dynamic_cast<const Buffer *
>(object);
948 return buffer ? buffer->
getFormat() == agxData::getFormat<T>() :
false;
951 template <
typename T>
956 template <
typename T>
961 template <
typename T>
967 template <
typename T>
971 return reinterpret_cast<Array<T>&
>(m_array);
974 template <
typename T>
977 return const_cast<BufferT<T> *
>(
this)->array();
982 template <
typename T>
989 array().range().end()++;
990 ::new((
void *)&array().back()) T(value);
993 template <
typename T>
999 array().range().end()--;
1003 template <
typename T>
1006 for (
size_t i = 0; i <
m_size; ++i)
1010 array().range().end() = 0;
1013 template <
typename T>
template <
typename T2>
1016 return array().contains(value);
1019 template <
typename T>
template <
typename T2>
1022 return array().find(value);
1025 template <
typename T>
1028 return array()[index];
1031 template <
typename T>
1034 return const_cast<BufferT<T> *
>(
this)->
operator[](index);
1037 template <
typename T>
1040 return array().at(index);
1043 template <
typename T>
1046 return const_cast<BufferT<T> *
>(
this)->at(index);
1049 template <
typename T>
1052 return array().front();
1055 template <
typename T>
1058 return const_cast<BufferT<T> *
>(
this)->front();
1061 template <
typename T>
1064 return array().back();
1067 template <
typename T>
1070 return const_cast<BufferT<T> *
>(
this)->back();
1075 template <
typename T>
1078 return array().begin();
1081 template <
typename T>
1084 return array().begin();
1087 template <
typename T>
1090 return array().end();
1093 template <
typename T>
1096 return array().end();
1099 template <
typename T>
1105 template <
typename T>
1111 template <
typename T>
1117 template <
typename T>
1123 template <
typename T>
1135 # pragma warning(pop)
agx::IndexRange32 m_range
T * ptr()
Get access to the internal data buffer.
bool contains(const T2 &value) const
static agx::UInt MIN_BUFFER_CAPACITY
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Abstract representation of a value.
agxData::Attribute * getAttribute()
Arrays are fast accessors into the data, or a portion of it, held by a Buffer.
const AbstractArray & asArray() const
AbstractArray()
Create a new invalid array.
agxData::ValueRef m_defaultElementValue
#define agxAssert1(expr, msg)
AGXCORE_EXPORT Format * getFormat(const agx::String &typeFormatName)
agxData::BufferRef m_elementBuffer
size_t find(const T2 &value) const
agxData::ValueRefT< agx::UInt > capacityParameter
bool is(const agx::Model *other) const
RangeCallback m_initializer
T * ptr()
Get access to the internal data buffer.
AGXCORE_EXPORT Type * getType(const agx::String &name)
void sync()
Updates the internal data access pointer. Called when the back end buffer is reallocated.
EventDispatch m_eventDispatch
static agx::UInt ALIGNMENT
Array()
Create a new invalid array.
Data storage for a collection of entity instances of a specified EntityModel.
VectorPOD< Index > IndexVector
agxData::Buffer * m_buffer
T & operator[](size_t index)
static agxData::Array< T > raw(T *buffer, agx::Index size)
Array creation helper method that creates an array covering the given memory area.
static bool ValidateCast(const agx::Referenced *object)
Callback1< Value * > CallbackType
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.
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Type-specific Array used for fast access into the data held by a Buffer.
size_t commitResult(size_t numElements, const void *localResult, agx::Index sortIndex)
void init()
Set to empty array.
#define AGX_DECLARE_VECTOR_TYPES(type)
size_t getElementArraySize() const
#define agxVerifyN(expr, format,...)
Buffer * getElementBuffer()
If the buffer contains arrays/vectors, the actual elements are stored in another buffer.
AGXTERRAIN_EXPORT TimingStorage & getStorage()
const agxData::Buffer * buffer() const
agxData::Format * getFormat()
void setRange(size_t startIndex, size_t endIndex)
Set the range of the buffer that the array will cover.
agx::ByteAllocator m_allocator
Abstract representation of a data buffer.
agx::GlobalResult::Transaction allocateResult(size_t numElements)
agxData::Value::Event::CallbackType m_resizeCallback
agx::String fullName() const
Event reallocationEvent
Triggered when buffer is reallocated.
Representation of a name string.
agxData::ValueRefT< agx::UInt > sizeParameter
agx::IndexRange32 & range()
A component is an object containing other objects, enabling hierarchical structuring.
T & getElement(size_t index)
agxData::Array< T > & getArray()
Convenience method to get an direct data array.
static agx::Real CAPACITY_MULTIPLIER
agxData::BufferRef m_globalOrderBuffer
agx::GlobalResultBuffer * getGlobalResult()
agxData::ShareHandleRef m_shareHandle
agx::GlobalResultBuffer * m_globalResult
bool is() const
Subclass test.
bool AGXCORE_EXPORT isShutdown()
Transactions are used to reserve exclusive memory areas in which the threads can write their data.
Base class providing referencing counted objects.
#define AGX_DECLARE_POINTER_TYPES(type)
agxData::Buffer * m_originalBuffer
agx::UInt64 getRevision() const
agxData::Format * getFormat()
agx::Event1< Buffer * > Event
agxData::Value::Event::CallbackType m_reserveCallback
The Container is the base class for several of the container classes proided by AGX,...
An agx::Device is an abstract representation of a device on which data can be stored and processed.
agx::GlobalResult * getGlobalResult()
void push_back(const T &value)
#define agxAssertN(expr, format,...)
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API.
const typedef T * const_iterator
agxData::Value * getDefaultValue()
EntityStorage * m_storage
const AGXCORE_EXPORT InvalidIndexStruct InvalidIndex
std::ostream & operator<<(std::ostream &o, const agx::Vec6 &v)
AGXTERRAIN_EXPORT void clear()
agxData::EntityStorage * getStorage()
An abstract attribute description, part of an Entity.
Vec3T< T > max(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
Buffer * getGlobalOrderBuffer()
If the buffer is used as a global result, we provide a permutation buffer for parallel determinism.
IndexRangeT< agx::UInt32 > IndexRange32
agx::Container * m_sharedContainer
agxData::Type * getType()
RangeCallback m_destructor
void _setBuffer(agxData::Buffer *buffer)
Set the buffer while maintaining the current range, should normally not be used.
agx::Callback2< Buffer *, const agx::IndexRange & > RangeCallback
Specify a custom element initializer callback.
void * ptr()
Get access to the raw data buffer.
GlobalResult is used by kernels to generate result data from different threads.