HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UsdGeomPrimvarsAPI Class Reference

#include <primvarsAPI.h>

+ Inheritance diagram for UsdGeomPrimvarsAPI:

Public Member Functions

 UsdGeomPrimvarsAPI (const UsdPrim &prim=UsdPrim())
 
 UsdGeomPrimvarsAPI (const UsdSchemaBase &schemaObj)
 
virtual USDGEOM_API ~UsdGeomPrimvarsAPI ()
 Destructor. More...
 
USDGEOM_API UsdGeomPrimvar CreatePrimvar (const TfToken &name, const SdfValueTypeName &typeName, const TfToken &interpolation=TfToken(), int elementSize=-1) const
 
template<typename T >
UsdGeomPrimvar CreateNonIndexedPrimvar (const TfToken &name, const SdfValueTypeName &typeName, const T &value, const TfToken &interpolation=TfToken(), int elementSize=-1, UsdTimeCode time=UsdTimeCode::Default()) const
 
template<typename T >
UsdGeomPrimvar CreateIndexedPrimvar (const TfToken &name, const SdfValueTypeName &typeName, const T &value, const VtIntArray &indices, const TfToken &interpolation=TfToken(), int elementSize=-1, UsdTimeCode time=UsdTimeCode::Default()) const
 
USDGEOM_API bool RemovePrimvar (const TfToken &name)
 
USDGEOM_API void BlockPrimvar (const TfToken &name)
 
USDGEOM_API UsdGeomPrimvar GetPrimvar (const TfToken &name) const
 
USDGEOM_API std::vector
< UsdGeomPrimvar
GetPrimvars () const
 
USDGEOM_API std::vector
< UsdGeomPrimvar
GetAuthoredPrimvars () const
 
USDGEOM_API std::vector
< UsdGeomPrimvar
GetPrimvarsWithValues () const
 
USDGEOM_API std::vector
< UsdGeomPrimvar
GetPrimvarsWithAuthoredValues () const
 
USDGEOM_API std::vector
< UsdGeomPrimvar
FindInheritablePrimvars () const
 
USDGEOM_API std::vector
< UsdGeomPrimvar
FindIncrementallyInheritablePrimvars (const std::vector< UsdGeomPrimvar > &inheritedFromAncestors) const
 
USDGEOM_API UsdGeomPrimvar FindPrimvarWithInheritance (const TfToken &name) const
 
USDGEOM_API UsdGeomPrimvar FindPrimvarWithInheritance (const TfToken &name, const std::vector< UsdGeomPrimvar > &inheritedFromAncestors) const
 
USDGEOM_API std::vector
< UsdGeomPrimvar
FindPrimvarsWithInheritance () const
 
USDGEOM_API std::vector
< UsdGeomPrimvar
FindPrimvarsWithInheritance (const std::vector< UsdGeomPrimvar > &inheritedFromAncestors) const
 
USDGEOM_API bool HasPrimvar (const TfToken &name) const
 
USDGEOM_API bool HasPossiblyInheritedPrimvar (const TfToken &name) const
 
- Public Member Functions inherited from UsdAPISchemaBase
 UsdAPISchemaBase (const UsdPrim &prim=UsdPrim())
 
 UsdAPISchemaBase (const UsdSchemaBase &schemaObj)
 
virtual USD_API ~UsdAPISchemaBase ()=0
 Destructor. More...
 
- Public Member Functions inherited from UsdSchemaBase
bool IsConcrete () const
 
bool IsTyped () const
 
bool IsAPISchema () const
 Returns whether this is an API schema or not. More...
 
bool IsAppliedAPISchema () const
 
bool IsMultipleApplyAPISchema () const
 
UsdSchemaKind GetSchemaKind () const
 Returns the kind of schema this class is. More...
 
USD_API UsdSchemaBase (const UsdPrim &prim=UsdPrim())
 Construct and store prim as the held prim. More...
 
USD_API UsdSchemaBase (const UsdSchemaBase &otherSchema)
 Construct and store for the same prim held by otherSchema. More...
 
virtual USD_API ~UsdSchemaBase ()
 Destructor. More...
 
USD_API operator bool () const
 
UsdPrim GetPrim () const
 Return this schema object's held prim. More...
 
SdfPath GetPath () const
 Shorthand for GetPrim()->GetPath(). More...
 
USD_API const UsdPrimDefinitionGetSchemaClassPrimDefinition () const
 

Static Public Member Functions

static USDGEOM_API const
TfTokenVector
GetSchemaAttributeNames (bool includeInherited=true)
 
static USDGEOM_API
UsdGeomPrimvarsAPI 
Get (const UsdStagePtr &stage, const SdfPath &path)
 
static USDGEOM_API bool CanContainPropertyName (const TfToken &name)
 
- Static Public Member Functions inherited from UsdAPISchemaBase
static USD_API const
TfTokenVector
GetSchemaAttributeNames (bool includeInherited=true)
 
- Static Public Member Functions inherited from UsdSchemaBase
static const TfTokenVectorGetSchemaAttributeNames (bool includeInherited=true)
 

Static Public Attributes

static const UsdSchemaKind schemaKind = UsdSchemaKind::NonAppliedAPI
 
- Static Public Attributes inherited from UsdAPISchemaBase
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractBase
 
- Static Public Attributes inherited from UsdSchemaBase
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractBase
 

Protected Member Functions

USDGEOM_API UsdSchemaKind _GetSchemaKind () const override
 
- Protected Member Functions inherited from UsdAPISchemaBase
 UsdAPISchemaBase (const UsdPrim &prim, const TfToken &instanceName)
 
 UsdAPISchemaBase (const UsdSchemaBase &schemaObj, const TfToken &instanceName)
 
const TfToken_GetInstanceName () const
 
USD_API bool _IsCompatible () const override
 
- Protected Member Functions inherited from UsdSchemaBase
virtual UsdSchemaKind _GetSchemaType () const
 
const TfType_GetType () const
 
USD_API UsdAttribute _CreateAttr (TfToken const &attrName, SdfValueTypeName const &typeName, bool custom, SdfVariability variability, VtValue const &defaultValue, bool writeSparsely) const
 

Friends

class UsdSchemaRegistry
 

Additional Inherited Members

- Static Protected Member Functions inherited from UsdAPISchemaBase
static USD_API TfTokenVector _GetMultipleApplyInstanceNames (const UsdPrim &prim, const TfType &schemaType)
 

Detailed Description

UsdGeomPrimvarsAPI encodes geometric "primitive variables", as UsdGeomPrimvar, which interpolate across a primitive's topology, can override shader inputs, and inherit down namespace.

Which Method to Use to Retrieve Primvars

While creating primvars is unambiguous (CreatePrimvar()), there are quite a few methods available for retrieving primvars, making it potentially confusing knowing which one to use. Here are some guidelines:

Definition at line 82 of file primvarsAPI.h.

Constructor & Destructor Documentation

UsdGeomPrimvarsAPI::UsdGeomPrimvarsAPI ( const UsdPrim prim = UsdPrim())
inlineexplicit

Construct a UsdGeomPrimvarsAPI on UsdPrim prim . Equivalent to UsdGeomPrimvarsAPI::Get(prim.GetStage(), prim.GetPath()) for a valid prim, but will not immediately throw an error for an invalid prim

Definition at line 94 of file primvarsAPI.h.

UsdGeomPrimvarsAPI::UsdGeomPrimvarsAPI ( const UsdSchemaBase schemaObj)
inlineexplicit

Construct a UsdGeomPrimvarsAPI on the prim held by schemaObj . Should be preferred over UsdGeomPrimvarsAPI(schemaObj.GetPrim()), as it preserves SchemaBase state.

Definition at line 102 of file primvarsAPI.h.

virtual USDGEOM_API UsdGeomPrimvarsAPI::~UsdGeomPrimvarsAPI ( )
virtual

Destructor.

Member Function Documentation

USDGEOM_API UsdSchemaKind UsdGeomPrimvarsAPI::_GetSchemaKind ( ) const
overrideprotectedvirtual

Returns the kind of schema this class belongs to.

See Also
UsdSchemaKind

Reimplemented from UsdAPISchemaBase.

USDGEOM_API void UsdGeomPrimvarsAPI::BlockPrimvar ( const TfToken name)

Remove all time samples on the primvar and its associated indices attr, and author a block default value. This will cause authored opinions in weaker layers to be ignored.

See Also
UsdAttribute::Block(), UsdGeomPrimvar::BlockIndices
static USDGEOM_API bool UsdGeomPrimvarsAPI::CanContainPropertyName ( const TfToken name)
static

Test whether a given name contains the "primvars:" prefix

template<typename T >
UsdGeomPrimvar UsdGeomPrimvarsAPI::CreateIndexedPrimvar ( const TfToken name,
const SdfValueTypeName typeName,
const T value,
const VtIntArray &  indices,
const TfToken interpolation = TfToken(),
int  elementSize = -1,
UsdTimeCode  time = UsdTimeCode::Default() 
) const
inline

Author scene description to create an attribute and authoring a value on this prim that will be recognized as an indexed Primvar with indices appropriately set (i.e. will present as a valid UsdGeomPrimvar).

Returns
an invalid UsdGeomPrimvar on error, a valid UsdGeomPrimvar otherwise. It is fine to call this method multiple times, and in different UsdEditTargets, even if there is an existing primvar of the same name, indexed or not.
See Also
CreatePrimvar(), CreateNonIndexedPrimvar(), UsdPrim::CreateAttribute(), UsdGeomPrimvar::IsPrimvar()

Definition at line 238 of file primvarsAPI.h.

template<typename T >
UsdGeomPrimvar UsdGeomPrimvarsAPI::CreateNonIndexedPrimvar ( const TfToken name,
const SdfValueTypeName typeName,
const T value,
const TfToken interpolation = TfToken(),
int  elementSize = -1,
UsdTimeCode  time = UsdTimeCode::Default() 
) const
inline

Author scene description to create an attribute and authoring a value on this prim that will be recognized as a Primvar (i.e. will present as a valid UsdGeomPrimvar). Note that unlike CreatePrimvar using this API explicitly authors a block for the indices attr associated with the primvar, thereby blocking any indices set in any weaker layers.

Returns
an invalid UsdGeomPrimvar on error, a valid UsdGeomPrimvar otherwise. It is fine to call this method multiple times, and in different UsdEditTargets, even if there is an existing primvar of the same name, indexed or not.
See Also
CreatePrimvar(), CreateIndexedPrimvar(), UsdPrim::CreateAttribute(), UsdGeomPrimvar::IsPrimvar()

Definition at line 210 of file primvarsAPI.h.

USDGEOM_API UsdGeomPrimvar UsdGeomPrimvarsAPI::CreatePrimvar ( const TfToken name,
const SdfValueTypeName typeName,
const TfToken interpolation = TfToken(),
int  elementSize = -1 
) const

Author scene description to create an attribute on this prim that will be recognized as Primvar (i.e. will present as a valid UsdGeomPrimvar).

The name of the created attribute may or may not be the specified name, due to the possible need to apply property namespacing for primvars. See Creating and Accessing Primvars for more information. Creation may fail and return an invalid Primvar if name contains a reserved keyword, such as the "indices" suffix we use for indexed primvars.

The behavior with respect to the provided typeName is the same as for UsdAttributes::Create(), and interpolation and elementSize are as described in UsdGeomPrimvar::GetInterpolation() and UsdGeomPrimvar::GetElementSize().

If interpolation and/or elementSize are left unspecified, we will author no opinions for them, which means any (strongest) opinion already authored in any contributing layer for these fields will become the Primvar's values, or the fallbacks if no opinions have been authored.

Returns
an invalid UsdGeomPrimvar if we failed to create a valid attribute, a valid UsdGeomPrimvar otherwise. It is not an error to create over an existing, compatible attribute.
See Also
UsdPrim::CreateAttribute(), UsdGeomPrimvar::IsPrimvar()
USDGEOM_API std::vector<UsdGeomPrimvar> UsdGeomPrimvarsAPI::FindIncrementallyInheritablePrimvars ( const std::vector< UsdGeomPrimvar > &  inheritedFromAncestors) const

Compute the primvars that can be inherited from this prim by its child prims, starting from the set of primvars inherited from this prim's ancestors. If this method returns an empty vector, then this prim's children should inherit the same set of primvars available to this prim, i.e. the input inheritedFromAncestors .

As opposed to FindInheritablePrimvars(), which always recurses up through all of the prim's ancestors, this method allows more efficient computation of inheritable primvars by starting with the list of primvars inherited from this prim's ancestors, and returning a newly allocated vector only when this prim makes a change to the set of inherited primvars. This enables O(n) inherited primvar computation for all prims on a Stage, with potential to share computed results that are identical (i.e. when this method returns an empty vector, its parent's result can (and must!) be reused for all of the prim's children.

See Also
Which Method to Use to Retrieve Primvars
USDGEOM_API std::vector<UsdGeomPrimvar> UsdGeomPrimvarsAPI::FindInheritablePrimvars ( ) const

Compute the primvars that can be inherited from this prim by its child prims, including the primvars that this prim inherits from ancestor prims. Inherited primvars will be bound to attributes on the corresponding ancestor prims.

Only primvars with authored, non-blocked, constant interpolation values are inheritable; fallback values are not inherited. The order of the returned primvars is undefined.

It is not generally useful to call this method on UsdGeomGprim leaf prims, and furthermore likely to be expensive since most primvars are defined on Gprims.

See Also
Which Method to Use to Retrieve Primvars
USDGEOM_API std::vector<UsdGeomPrimvar> UsdGeomPrimvarsAPI::FindPrimvarsWithInheritance ( ) const

Find all of the value-producing primvars either defined on this prim, or inherited from ancestor prims.

See Also
Which Method to Use to Retrieve Primvars
USDGEOM_API std::vector<UsdGeomPrimvar> UsdGeomPrimvarsAPI::FindPrimvarsWithInheritance ( const std::vector< UsdGeomPrimvar > &  inheritedFromAncestors) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This version of FindPrimvarsWithInheritance() takes the pre-computed set of primvars inherited from this prim's ancestors, as computed by FindInheritablePrimvars() or FindIncrementallyInheritablePrimvars() on the prim's parent.

See Also
Which Method to Use to Retrieve Primvars
USDGEOM_API UsdGeomPrimvar UsdGeomPrimvarsAPI::FindPrimvarWithInheritance ( const TfToken name) const

Like GetPrimvar(), but if the named primvar does not exist or has no authored value on this prim, search for the named, value-producing primvar on ancestor prims.

The returned primvar will be bound to the attribute on the corresponding ancestor prim on which it was found (if any). If neither this prim nor any ancestor contains a value-producing primvar, then the returned primvar will be the same as that returned by GetPrimvar().

This is probably the method you want to call when needing to consume a primvar of a particular name.

See Also
Which Method to Use to Retrieve Primvars
USDGEOM_API UsdGeomPrimvar UsdGeomPrimvarsAPI::FindPrimvarWithInheritance ( const TfToken name,
const std::vector< UsdGeomPrimvar > &  inheritedFromAncestors 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This version of FindPrimvarWithInheritance() takes the pre-computed set of primvars inherited from this prim's ancestors, as computed by FindInheritablePrimvars() or FindIncrementallyInheritablePrimvars() on the prim's parent.

See Also
Which Method to Use to Retrieve Primvars
static USDGEOM_API UsdGeomPrimvarsAPI UsdGeomPrimvarsAPI::Get ( const UsdStagePtr &  stage,
const SdfPath path 
)
static

Return a UsdGeomPrimvarsAPI holding the prim adhering to this schema at path on stage. If no prim exists at path on stage, or if the prim at that path does not adhere to this schema, return an invalid schema object. This is shorthand for the following:

UsdGeomPrimvarsAPI(stage->GetPrimAtPath(path));
USDGEOM_API std::vector<UsdGeomPrimvar> UsdGeomPrimvarsAPI::GetAuthoredPrimvars ( ) const

Like GetPrimvars(), but include only primvars that have some authored scene description (though not necessarily a value).

See Also
Which Method to Use to Retrieve Primvars
USDGEOM_API UsdGeomPrimvar UsdGeomPrimvarsAPI::GetPrimvar ( const TfToken name) const

Return the Primvar object named by name, which will be valid if a Primvar attribute definition already exists.

Name lookup will account for Primvar namespacing, which means that this method will succeed in some cases where

will not, unless name is properly namespace prefixed.

Note
Just because a Primvar is valid and defined, and even if its underlying UsdAttribute (GetAttr()) answers HasValue() affirmatively, one must still check the return value of Get(), due to the potential of time-varying value blocks (see Attribute Value Blocking).
See Also
HasPrimvar(), Which Method to Use to Retrieve Primvars
USDGEOM_API std::vector<UsdGeomPrimvar> UsdGeomPrimvarsAPI::GetPrimvars ( ) const

Return valid UsdGeomPrimvar objects for all defined Primvars on this prim, similarly to UsdPrim::GetAttributes().

The returned primvars may not possess any values, and therefore not be useful to some clients. For the primvars useful for inheritance computations, see GetPrimvarsWithAuthoredValues(), and for primvars useful for direct consumption, see GetPrimvarsWithValues().

See Also
Which Method to Use to Retrieve Primvars
USDGEOM_API std::vector<UsdGeomPrimvar> UsdGeomPrimvarsAPI::GetPrimvarsWithAuthoredValues ( ) const

Like GetPrimvars(), but include only primvars that have an authored value.

This is the query used when computing inheritable primvars, and is generally more useful than GetAuthoredPrimvars().

See Also
Which Method to Use to Retrieve Primvars
USDGEOM_API std::vector<UsdGeomPrimvar> UsdGeomPrimvarsAPI::GetPrimvarsWithValues ( ) const

Like GetPrimvars(), but include only primvars that have some value, whether it comes from authored scene description or a schema fallback.

For most purposes, this method is more useful than GetPrimvars().

See Also
Which Method to Use to Retrieve Primvars
static USDGEOM_API const TfTokenVector& UsdGeomPrimvarsAPI::GetSchemaAttributeNames ( bool  includeInherited = true)
static

Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes. Does not include attributes that may be authored by custom/extended methods of the schemas involved.

USDGEOM_API bool UsdGeomPrimvarsAPI::HasPossiblyInheritedPrimvar ( const TfToken name) const

Is there a Primvar named name with an authored value on this prim or any of its ancestors?

This is probably the method you want to call when wanting to know whether or not the prim "has" a primvar of a particular name.

See Also
FindPrimvarWithInheritance()
USDGEOM_API bool UsdGeomPrimvarsAPI::HasPrimvar ( const TfToken name) const

Is there a defined Primvar name on this prim?

Name lookup will account for Primvar namespacing.

Like GetPrimvar(), a return value of true for HasPrimvar() does not guarantee the primvar will produce a value.

USDGEOM_API bool UsdGeomPrimvarsAPI::RemovePrimvar ( const TfToken name)

Author scene description to delete an attribute on this prim that was recognized as Primvar (i.e. will present as a valid UsdGeomPrimvar), in the current UsdEditTarget.

Because this method can only remove opinions about the primvar from the current EditTarget, you may generally find it more useful to use BlockPrimvar() which will ensure that all values from the EditTarget and weaker layers for the primvar and its indices will be ignored.

Removal may fail and return false if name contains a reserved keyword, such as the "indices" suffix we use for indexed primvars.

Note this will also remove the indices attribute associated with an indiced primvar.

Returns
true if UsdGeomPrimvar and indices attribute was successfully removed, false otherwise.
See Also
UsdPrim::RemoveProperty())

Friends And Related Function Documentation

friend class UsdSchemaRegistry
friend

Definition at line 141 of file primvarsAPI.h.

Member Data Documentation

const UsdSchemaKind UsdGeomPrimvarsAPI::schemaKind = UsdSchemaKind::NonAppliedAPI
static

Compile time constant representing what kind of schema this class is.

See Also
UsdSchemaKind

Definition at line 88 of file primvarsAPI.h.


The documentation for this class was generated from the following file: