24 #ifndef PXR_USD_USD_GEOM_PRIMVAR_H
25 #define PXR_USD_USD_GEOM_PRIMVAR_H
387 TfToken *interpolation,
int *elementSize)
const;
418 explicit operator bool()
const {
419 return IsDefined() ? &UsdGeomPrimvar::_attr : 0;
459 template <
typename T>
465 template <
typename T>
488 std::vector<double>* times)
const;
598 template <
typename ScalarType>
626 const VtIntArray &indices,
642 const VtIntArray &indices,
705 return !(lhs == rhs);
716 template <
typename HashState>
744 static TfToken const &_GetNamespacePrefix();
774 template<
typename ScalarType>
776 const VtIntArray &indices,
783 template <
typename ArrayType>
784 static bool _ComputeFlattenedArray(
const VtValue &attrVal,
785 const VtIntArray &indices,
798 bool _ComputeIdTargetPossibility()
const;
800 enum _IdTargetStatus {
801 IdTargetUninitialized,
802 IdTargetInitializing,
806 mutable TfToken _idTargetRelName;
807 mutable std::atomic<_IdTargetStatus> _idTargetStatus;
821 template <
typename ScalarType>
826 if (!
Get(&authored, time))
836 TF_WARN(
"No indices authored for indexed primvar <%s>.",
842 if (authored.empty())
846 bool res = _ComputeFlattenedHelper(authored, indices,
GetElementSize(), value, &errString);
847 if (!errString.empty()) {
854 template<
typename ScalarType>
857 const VtIntArray &indices,
862 TF_VERIFY(elementSize >= 1);
863 value->resize(indices.size() * elementSize);
866 std::vector<size_t> invalidIndexPositions;
867 for (
size_t i=0; i < indices.size(); i++) {
868 if (indices[i] < 0 || static_cast<size_t>((indices[i] + 1) * elementSize) > authored.size()) {
869 invalidIndexPositions.push_back(i);
874 const size_t indicesIdx = indices[i] * elementSize;
875 const size_t valuesIdx = i * elementSize;
877 size_t index = indicesIdx +
j;
878 (*value)[valuesIdx +
j] = authored[
index];
882 if (!invalidIndexPositions.empty() && errString) {
884 "Found %ld invalid indices into authored array of size %ld with"
885 " element size of %i:",
886 invalidIndexPositions.size(),
887 authored.size(), elementSize);
890 size_t numElementsToPrint =
std::min(invalidIndexPositions.size(),
892 for (
size_t i = 0; i < numElementsToPrint ; ++i) {
893 int invalidIndex = indices[invalidIndexPositions[i]];
894 int authoredStartIndex = invalidIndex * elementSize;
897 "\n\t Invalid index %i at position %ld refers to %s of the"
898 " authored array, which is out of bounds",
900 invalidIndexPositions[i],
901 elementSize == 1 ?
TfStringPrintf(
"index %i", authoredStartIndex).c_str()
902 :
TfStringPrintf(
"indices [%i,...,%i]", authoredStartIndex, authoredStartIndex + elementSize - 1).c_str());
911 #endif // USD_PRIMVAR_H
SDF_API const char * GetText() const
TF_API std::string TfStringPrintf(const char *fmt,...)
bool Get(T *value, UsdTimeCode time=UsdTimeCode::Default()) const
static USDGEOM_API TfToken StripPrimvarsName(const TfToken &name)
GLsizei GLenum const void * indices
static USDGEOM_API bool IsValidPrimvarName(const TfToken &name)
static constexpr UsdTimeCode Default()
bool Get(T *value, UsdTimeCode time=UsdTimeCode::Default()) const
USDGEOM_API UsdAttribute GetIndicesAttr() const
USD_API TfToken GetBaseName() const
friend bool operator!=(const UsdGeomPrimvar &lhs, const UsdGeomPrimvar &rhs)
GT_API const UT_StringHolder time
USDGEOM_API bool ValueMightBeTimeVarying() const
GLsizei const GLchar *const * string
GLsizei const GLchar *const * path
static USDGEOM_API bool IsPrimvar(const UsdAttribute &attr)
USDGEOM_API TfToken GetPrimvarName() const
USDGEOM_API bool GetIndices(VtIntArray *indices, UsdTimeCode time=UsdTimeCode::Default()) const
USD_API SdfValueTypeName GetTypeName() const
Return the "scene description" value type name for this attribute.
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
TfToken GetNamespace() const
USD_API bool HasAuthoredValue() const
TfToken GetBaseName() const
USDGEOM_API bool NameContainsNamespaces() const
bool ComputeFlattened(VtArray< ScalarType > *value, UsdTimeCode time=UsdTimeCode::Default()) const
USDGEOM_API int GetUnauthoredValuesIndex() const
USDGEOM_API bool SetIdTarget(const SdfPath &path) const
USD_API std::vector< std::string > SplitName() const
USDGEOM_API bool SetInterpolation(const TfToken &interpolation)
std::vector< std::string > SplitName() const
USD_API bool HasValue() const
USD_API std::string UsdDescribe(const UsdObject &)
Return a human-readable description.
bool Set(const T &value, UsdTimeCode time=UsdTimeCode::Default()) const
Set the attribute value of the Primvar at time.
USDGEOM_API UsdAttribute CreateIndicesAttr() const
TfToken const & GetName() const
bool HasAuthoredValue() const
USDGEOM_API bool IsIndexed() const
GLuint const GLchar * name
USD_API TfToken GetNamespace() const
bool Set(const T &value, UsdTimeCode time=UsdTimeCode::Default()) const
const TfToken & GetName() const
static USDGEOM_API bool IsValidInterpolation(const TfToken &interpolation)
GLfloat GLfloat GLfloat GLfloat h
SdfValueTypeName GetTypeName() const
friend size_t hash_value(const UsdGeomPrimvar &obj)
USDGEOM_API bool IsIdTarget() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
USDGEOM_API bool HasAuthoredElementSize() const
UsdAttribute const & GetAttr() const
Explicit UsdAttribute extractor.
friend void TfHashAppend(HashState &h, const UsdGeomPrimvar &obj)
#define PXR_NAMESPACE_CLOSE_SCOPE
USDGEOM_API bool GetTimeSamples(std::vector< double > *times) const
USDGEOM_API bool SetIndices(const VtIntArray &indices, UsdTimeCode time=UsdTimeCode::Default()) const
USDGEOM_API bool HasAuthoredInterpolation() const
friend bool operator==(const UsdGeomPrimvar &lhs, const UsdGeomPrimvar &rhs)
USDGEOM_API bool SetUnauthoredValuesIndex(int unauthoredValuesIndex) const
USDGEOM_API int GetElementSize() const
USDGEOM_API void GetDeclarationInfo(TfToken *name, SdfValueTypeName *typeName, TfToken *interpolation, int *elementSize) const
friend bool operator<(const UsdGeomPrimvar &lhs, const UsdGeomPrimvar &rhs)
USDGEOM_API TfToken GetInterpolation() const
USDGEOM_API bool GetTimeSamplesInInterval(const GfInterval &interval, std::vector< double > *times) const
USDGEOM_API UsdGeomPrimvar & operator=(const UsdGeomPrimvar &other)
Copy assign.
USDGEOM_API bool SetElementSize(int eltSize)
USDGEOM_API void BlockIndices() const