24 #ifndef PXR_USD_USD_GEOM_PRIMVAR_H
25 #define PXR_USD_USD_GEOM_PRIMVAR_H
383 TfToken *interpolation,
int *elementSize)
const;
414 explicit operator bool()
const {
415 return IsDefined() ? &UsdGeomPrimvar::_attr : 0;
455 template <
typename T>
461 template <
typename T>
484 std::vector<double>* times)
const;
594 template <
typename ScalarType>
621 const VtIntArray &indices,
683 return !(lhs == rhs);
717 static TfToken const &_GetNamespacePrefix();
746 void _SetIdTargetRelName();
752 template<
typename ScalarType>
754 const VtIntArray &indices,
760 template <
typename ArrayType>
761 static bool _ComputeFlattenedArray(
const VtValue &attrVal,
762 const VtIntArray &indices,
782 template <
typename ScalarType>
787 if (!
Get(&authored, time))
797 TF_WARN(
"No indices authored for indexed primvar <%s>.",
803 if (authored.empty())
807 bool res = _ComputeFlattenedHelper(authored, indices, value, &errString);
808 if (!errString.empty()) {
815 template<
typename ScalarType>
818 const VtIntArray &indices,
822 value->resize(indices.size());
825 std::vector<size_t> invalidIndexPositions;
826 for (
size_t i=0; i < indices.size(); i++) {
827 int index = indices[i];
828 if (index >= 0 && (
size_t)index < authored.size()) {
829 (*value)[i] = authored[
index];
831 invalidIndexPositions.push_back(i);
836 if (!invalidIndexPositions.empty()) {
837 std::vector<std::string> invalidPositionsStrVec;
839 size_t numElementsToPrint =
std::min(invalidIndexPositions.size(),
841 invalidPositionsStrVec.reserve(numElementsToPrint);
842 for (
size_t i = 0; i < numElementsToPrint ; ++i) {
843 invalidPositionsStrVec.push_back(
849 "Found %ld invalid indices at positions [%s%s] that are out of "
850 "range [0,%ld).", invalidIndexPositions.size(),
852 invalidIndexPositions.size() > 5 ?
", ..." :
"",
863 #endif // USD_PRIMVAR_H
SDF_API const char * GetText() const
Returns the string representation of this path as a c string.
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)
static USDGEOM_API bool IsValidPrimvarName(const TfToken &name)
GLuint const GLchar * 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
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.
TfToken GetNamespace() const
USD_API bool HasAuthoredValue() const
USD_API std::string UsdDescribe(const UsdObject &)
Return a human-readable description.
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
static USDGEOM_API bool IsPrimvarRelatedPropertyName(const TfToken &name)
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
GLuint GLuint GLsizei GLenum const void * indices
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
USDGEOM_API friend size_t hash_value(const UsdGeomPrimvar &obj)
bool HasAuthoredValue() const
USDGEOM_API bool IsIndexed() const
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)
std::string TfStringJoin(ForwardIterator begin, ForwardIterator end, const char *separator=" ")
GLsizei const GLchar *const * path
GLsizei const GLchar *const * string
SdfValueTypeName GetTypeName() const
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.
#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
std::enable_if<!std::is_enum< T >::value, std::string >::type TfStringify(const T &v)
vint4 min(const vint4 &a, const vint4 &b)
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
GLsizei const GLfloat * value
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 bool SetElementSize(int eltSize)
USDGEOM_API void BlockIndices() const