usdrt::VtArray
Defined in usdrt/scenegraph/base/vt/array.h
Functions
usdrt::VtArray::DetachFromSource: Make an instance-local copy of the fabric array data, at which point modifications happen on the instance-local array.
usdrt::VtArray::GetGpuData: Get GPU data. Debugging use only.
usdrt::VtArray::HasFabricCpuData: Check if this instance has fabric cpu data. Debug use only.
usdrt::VtArray::HasFabricGpuData: Check if this instance has fabric Gpu data. Debug use only.
usdrt::VtArray::IsFabricData: Check if this instance is reading/writing Fabric data directly.
usdrt::VtArray::IsOwnData: Check if this instance contains its own localized data (not external or fabric data)
usdrt::VtArray::IsPythonData: Check if this instance was created from an external python object (buffer or cuda array interface)
usdrt::VtArray::VtArray: Create a new array that points to fabric data.
usdrt::VtArray::VtArray: Copy
other
. The new array shares underlying data withother
.usdrt::VtArray::VtArray: Create a new array from
span
.usdrt::VtArray::VtArray: Create a new array from
vec
.usdrt::VtArray::VtArray: Create an empty array.
usdrt::VtArray::VtArray: Create a new array from given data.
usdrt::VtArray::VtArray: Create an array with
n
value-initialized elements.usdrt::VtArray::VtArray: Move from !p other. The new array takes ownership of !p other's underlying data.
usdrt::VtArray::VtArray: Create a new array from
initList
.usdrt::VtArray::begin: Localizes the data, and returns an iterator to the first element in this array.
usdrt::VtArray::capacity: Return the capacity of this array.
usdrt::VtArray::cbegin: Returns a const iterator to the first element in this array.
usdrt::VtArray::cdata: Return a const pointer to the beginning of the data sequence.
usdrt::VtArray::cend: Returns a const iterator to the element following the last element in this array.
usdrt::VtArray::crbegin: Localize the data, and return a const iterator to the element following the last element in this array.
usdrt::VtArray::crend: Returns a const iterator to the first element in this array.
usdrt::VtArray::data: Localize the data, and return a pointer to the beginning of the data sequence.
usdrt::VtArray::data: Return a const pointer to the beginning of the data sequence.
usdrt::VtArray::empty: Check if this array is empty.
usdrt::VtArray::end: Returns an iterator to the element following the last element in this array.
usdrt::VtArray::operator=: Copy assign from
other
. This array shares underlying data withother
.usdrt::VtArray::operator=: Replace current array contents with a copy of those in
other
.usdrt::VtArray::operator=: Replace current array contents with a copy of those in
initList
.usdrt::VtArray::operator[]: Allows usage of [i].
usdrt::VtArray::operator[]: Allows usage of [i]. TODO more detail of gpu & fabric stuff.
usdrt::VtArray::push_back: Append
element
to the back of the array.usdrt::VtArray::rbegin: Localize the data, and return an iterator to the element following the last element in this array.
usdrt::VtArray::rbegin: Localize the data, and return a const iterator to the element following the last element in this array.
usdrt::VtArray::rend: Returns a const iterator to the first element in this array.
usdrt::VtArray::rend: Returns an iterator to the first element in this array.
usdrt::VtArray::reserve: Reserve memory to increase the length of this array.
usdrt::VtArray::reset: Reset this array to empty.
usdrt::VtArray::resize: Resize this array.
usdrt::VtArray::size: Return the total number of elements in this array.
usdrt::VtArray::span: Get the span for this data array.
usdrt::VtArray::~VtArray: Destructor.
Typedefs
usdrt::VtArray::const_iterator: Const iterator.
usdrt::VtArray::const_reverse_iterator: Const reverse iterator.
usdrt::VtArray::iterator: Iterator.
usdrt::VtArray::reverse_iterator: Reverse iterator.
-
template<typename ElementType>
class VtArray Represents an arbitrary dimensional rectangular container class.
VtArray can
own its own CPU memory via a std::vector<ElementType> which follows Copy On Write and Copy On Non-Const Access, semantics the same way Pixar’s VtArray does
refer to a Fabric CPU/GPU attribute via a stage ID, a path and an attribute
refer to an external CPU python array (numpy) or GPU python array (pytorch/warp)
Special RT functionality When a VtArray is initialized from Fabric data, generally with UsdAttribute.Get(), its underlying span will point at data directly in Fabric. In this default attached state, the VtArray can be used to modify Fabric arrays directly. The developer may choose to make an instance-local copy of the array data using DetachFromSource, at which point modifications happen on the instance-local array. IsFabricData() will let you know if a VtArray instance is reading/writing Fabric data directly. See
DetachFromSource()
IsFabricData()
IsPythonData()
IsOwnData()
HasFabricCpuData()
HasFabricGpuData()
GetGpuData()
- Template Parameters
ElementType – The type of element contained in this VtArray
Public Types
-
using element_type = ElementType
-
using value_type = std::remove_cv_t<ElementType>
-
using pointer = element_type*
-
using const_pointer = const element_type*
-
using reference = element_type&
-
using const_reference = const element_type&
-
typedef gsl::details::span_iterator<ElementType> iterator
Iterator.
-
typedef gsl::details::span_iterator<const ElementType> const_iterator
Const iterator.
-
typedef std::reverse_iterator<const_iterator> const_reverse_iterator
Const reverse iterator.
Public Functions
-
inline VtArray()
Create an empty array.
-
inline VtArray(const VtArray<ElementType> &other)
Copy
other
. The new array shares underlying data withother
.
-
inline VtArray(VtArray<ElementType> &&other)
Move from !p other. The new array takes ownership of !p other’s underlying data.
-
inline VtArray(size_t n)
Create an array with
n
value-initialized elements.
-
inline VtArray(gsl::span<ElementType> span)
Create a new array from
span
.Make a copy of data from
span
that is unique to this instance.
-
inline VtArray(const std::vector<ElementType> &vec)
Create a new array from
vec
.Make a copy of data from
vec
that is unique to this instance.
-
inline VtArray(size_t n, ElementType *data, void *gpuData, const py::object &externalArray = py::none())
Create a new array from given data.
- Parameters
n – size of array
data – Pointer to n elements.
gpuData – Pointer to GPU data
externalArray – Reference to an external python object. Default py::none().
-
inline VtArray(std::initializer_list<ElementType> initList)
Create a new array from
initList
.Make a copy of data from
initList
that is unique to this instance.- Parameters
initList –
-
inline VtArray(omni::fabric::StageReaderWriterId stageId, omni::fabric::PathC path, omni::fabric::TokenC attr)
Create a new array that points to fabric data.
- Parameters
stageId – stage on which this data exists.
path – path to the attribute whose value is this array data.
attr – attribute name whose value is this array data.
-
inline ~VtArray()
Destructor.
-
inline VtArray &operator=(const VtArray<ElementType> &other)
Copy assign from
other
. This array shares underlying data withother
.
-
inline VtArray &operator=(gsl::span<ElementType> other)
Replace current array contents with a copy of those in
other
.
-
inline VtArray &operator=(std::initializer_list<ElementType> initList)
Replace current array contents with a copy of those in
initList
.
-
inline ElementType &operator[](size_t index)
Allows usage of [i]. TODO more detail of gpu & fabric stuff.
-
inline ElementType const &operator[](size_t index) const
Allows usage of [i].
-
inline size_t size() const
Return the total number of elements in this array.
-
inline size_t capacity() const
Return the capacity of this array.
-
inline bool empty() const
Check if this array is empty.
- Returns
Return true if empty, false otherwise.
-
inline void reset()
Reset this array to empty.
Reset the capactiy to 0, delete the contents, an nullify any external data pointers.
-
inline void resize(size_t newSize)
Resize this array.
Localize the data, and resize. Increase the capacity if needed.
- Parameters
newSize – New length of this array.
-
inline void reserve(size_t num)
Reserve memory to increase the length of this array.
Localize the data. If
num
is less than the max capacity of this array, reserve new localized memory for an array of sizenum
. If this instance already contains local data, copy that to the new span.Used by push_back.
- Parameters
num – new size of this array.
-
inline void push_back(const ElementType &element)
Append
element
to the back of the array.- Parameters
element – New element to add.
-
inline pointer data()
Localize the data, and return a pointer to the beginning of the data sequence.
-
inline const_pointer data() const
Return a const pointer to the beginning of the data sequence.
-
inline const_pointer cdata() const
Return a const pointer to the beginning of the data sequence.
-
inline gsl::span<ElementType> span() const
Get the span for this data array.
This can be:
the localized CPU memory
the Fabric data
the external CPU python array (numpy)
or the GPU python array (pytorch/warp)
- Returns
Return the span for this data array.
-
inline void DetachFromSource()
Make an instance-local copy of the fabric array data, at which point modifications happen on the instance-local array.
-
inline bool IsFabricData() const
Check if this instance is reading/writing Fabric data directly.
- Returns
true if this instance is reading/writing fabric data directly, and false if the data has been localized. See DetatchFromSource.
-
inline bool IsPythonData() const
Check if this instance was created from an external python object (buffer or cuda array interface)
- Returns
Returns true if this instance was created from an external python object.
-
inline bool IsOwnData() const
Check if this instance contains its own localized data (not external or fabric data)
- Returns
Return true if this data is localized.
-
inline bool HasFabricCpuData() const
Check if this instance has fabric cpu data. Debug use only.
Warning
For debug use only.
- Returns
Return true if this instance has fabric CPU data, and false otherwise.
-
inline bool HasFabricGpuData() const
Check if this instance has fabric Gpu data. Debug use only.
Warning
For debug use only.
- Returns
Return true if this instance has fabric GPU data, and false otherwise.
-
inline void *GetGpuData() const
Get GPU data. Debugging use only.
Warning
For debug use only.
- Returns
Return void* pointer to GPU data.
-
inline iterator begin()
Localizes the data, and returns an iterator to the first element in this array.
-
inline const_iterator cbegin()
Returns a const iterator to the first element in this array.
-
inline const_iterator cend()
Returns a const iterator to the element following the last element in this array.
-
inline reverse_iterator rbegin()
Localize the data, and return an iterator to the element following the last element in this array.
-
inline reverse_iterator rend()
Returns an iterator to the first element in this array.
-
inline const_reverse_iterator rbegin() const
Localize the data, and return a const iterator to the element following the last element in this array.
-
inline const_reverse_iterator rend() const
Returns a const iterator to the first element in this array.
-
inline const_reverse_iterator crbegin() const
Localize the data, and return a const iterator to the element following the last element in this array.
-
inline const_reverse_iterator crend() const
Returns a const iterator to the first element in this array.