Loading...
Searching...
No Matches
UsdGeomPrimvarsAPI Class Reference

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

#include <primvarsAPI.h>

+ Inheritance diagram for UsdGeomPrimvarsAPI:

Public Member Functions

 UsdGeomPrimvarsAPI (const UsdPrim &prim=UsdPrim())
 Construct a UsdGeomPrimvarsAPI on UsdPrim prim .
 
 UsdGeomPrimvarsAPI (const UsdSchemaBase &schemaObj)
 Construct a UsdGeomPrimvarsAPI on the prim held by schemaObj .
 
virtual USDGEOM_API ~UsdGeomPrimvarsAPI ()
 Destructor.
 
USDGEOM_API UsdGeomPrimvar 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.
 
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
 Author scene description to create an attribute and authoring a value on this prim that will be recognized as a Primvar (i.e.
 
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
 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.
 
USDGEOM_API bool RemovePrimvar (const TfToken &name)
 Author scene description to delete an attribute on this prim that was recognized as Primvar (i.e.
 
USDGEOM_API void BlockPrimvar (const TfToken &name)
 Remove all time samples on the primvar and its associated indices attr, and author a block default value.
 
USDGEOM_API UsdGeomPrimvar GetPrimvar (const TfToken &name) const
 Return the Primvar object named by name, which will be valid if a Primvar attribute definition already exists.
 
USDGEOM_API std::vector< UsdGeomPrimvarGetPrimvars () const
 Return valid UsdGeomPrimvar objects for all defined Primvars on this prim, similarly to UsdPrim::GetAttributes().
 
USDGEOM_API std::vector< UsdGeomPrimvarGetAuthoredPrimvars () const
 Like GetPrimvars(), but include only primvars that have some authored scene description (though not necessarily a value).
 
USDGEOM_API std::vector< UsdGeomPrimvarGetPrimvarsWithValues () const
 Like GetPrimvars(), but include only primvars that have some value, whether it comes from authored scene description or a schema fallback.
 
USDGEOM_API std::vector< UsdGeomPrimvarGetPrimvarsWithAuthoredValues () const
 Like GetPrimvars(), but include only primvars that have an authored value.
 
USDGEOM_API std::vector< UsdGeomPrimvarFindInheritablePrimvars () 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.
 
USDGEOM_API std::vector< UsdGeomPrimvarFindIncrementallyInheritablePrimvars (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.
 
USDGEOM_API UsdGeomPrimvar 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.
 
USDGEOM_API UsdGeomPrimvar 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.
 
USDGEOM_API std::vector< UsdGeomPrimvarFindPrimvarsWithInheritance () const
 Find all of the value-producing primvars either defined on this prim, or inherited from ancestor prims.
 
USDGEOM_API std::vector< UsdGeomPrimvarFindPrimvarsWithInheritance (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.
 
USDGEOM_API bool HasPrimvar (const TfToken &name) const
 Is there a defined Primvar name on this prim?
 
USDGEOM_API bool HasPossiblyInheritedPrimvar (const TfToken &name) const
 Is there a Primvar named name with an authored value on this prim or any of its ancestors?
 
- Public Member Functions inherited from UsdAPISchemaBase
 UsdAPISchemaBase (const UsdPrim &prim=UsdPrim())
 Construct a UsdAPISchemaBase on UsdPrim prim .
 
 UsdAPISchemaBase (const UsdSchemaBase &schemaObj)
 Construct a UsdAPISchemaBase on the prim held by schemaObj .
 
virtual USD_API ~UsdAPISchemaBase ()=0
 Destructor.
 
- Public Member Functions inherited from UsdSchemaBase
bool IsConcrete () const
 Returns whether or not this class corresponds to a concrete instantiable prim type in scene description.
 
bool IsTyped () const
 Returns whether or not this class inherits from UsdTyped.
 
bool IsAPISchema () const
 Returns whether this is an API schema or not.
 
bool IsAppliedAPISchema () const
 Returns whether this is an applied API schema or not.
 
bool IsMultipleApplyAPISchema () const
 Returns whether this is an applied API schema or not.
 
UsdSchemaKind GetSchemaKind () const
 Returns the kind of schema this class is.
 
USD_API UsdSchemaBase (const UsdPrim &prim=UsdPrim())
 Construct and store prim as the held prim.
 
USD_API UsdSchemaBase (const UsdSchemaBase &otherSchema)
 Construct and store for the same prim held by otherSchema.
 
virtual USD_API ~UsdSchemaBase ()
 Destructor.
 
UsdPrim GetPrim () const
 Return this schema object's held prim.
 
SdfPath GetPath () const
 Shorthand for GetPrim()->GetPath().
 
USD_API const UsdPrimDefinitionGetSchemaClassPrimDefinition () const
 Return the prim definition associated with this schema instance if one exists, otherwise return null.
 
USD_API operator bool () const
 Return true if this schema object is compatible with its held prim, false otherwise.
 

Static Public Member Functions

static USDGEOM_API const TfTokenVectorGetSchemaAttributeNames (bool includeInherited=true)
 Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes.
 
static USDGEOM_API UsdGeomPrimvarsAPI Get (const UsdStagePtr &stage, const SdfPath &path)
 Return a UsdGeomPrimvarsAPI holding the prim adhering to this schema at path on stage.
 
static USDGEOM_API bool CanContainPropertyName (const TfToken &name)
 Test whether a given name contains the "primvars:" prefix.
 
- Static Public Member Functions inherited from UsdAPISchemaBase
static USD_API const TfTokenVectorGetSchemaAttributeNames (bool includeInherited=true)
 Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes.
 
- Static Public Member Functions inherited from UsdSchemaBase
static const TfTokenVectorGetSchemaAttributeNames (bool includeInherited=true)
 

Static Public Attributes

static const UsdSchemaKind schemaKind = UsdSchemaKind::NonAppliedAPI
 Compile time constant representing what kind of schema this class is.
 
- Static Public Attributes inherited from UsdAPISchemaBase
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractBase
 Compile time constant representing what kind of schema this class is.
 
- Static Public Attributes inherited from UsdSchemaBase
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractBase
 Compile time constant representing what kind of schema this class is.
 

Protected Member Functions

USDGEOM_API UsdSchemaKind _GetSchemaKind () const override
 Returns the kind of schema this class belongs to.
 
- Protected Member Functions inherited from UsdAPISchemaBase
USD_API UsdSchemaKind _GetSchemaKind () const override
 Returns the kind of schema this class belongs to.
 
 UsdAPISchemaBase (const UsdPrim &prim, const TfToken &instanceName)
 Construct a multiple-apply UsdAPISchemaBase on UsdPrim prim with the specified instanceName.
 
 UsdAPISchemaBase (const UsdSchemaBase &schemaObj, const TfToken &instanceName)
 Construct a multiple-apply UsdAPISchemaBase on the prim held by schemaObj with the given instanceName.
 
const TfToken_GetInstanceName () const
 Returns the instance name of the API schema object belonging to a multiple-apply API schema.
 
USD_API bool _IsCompatible () const override
 Check whether this APISchema object is valid for the currently held
prim.
 
- 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)
 Returns a vector of names of API schema objects belonging to a multiple-apply API schema applied to a given prim.
 

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() [1/2]

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() [2/2]

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.

◆ ~UsdGeomPrimvarsAPI()

virtual USDGEOM_API ~UsdGeomPrimvarsAPI ( )
virtual

Destructor.

Member Function Documentation

◆ _GetSchemaKind()

USDGEOM_API UsdSchemaKind _GetSchemaKind ( ) const
overrideprotectedvirtual

Returns the kind of schema this class belongs to.

See also
UsdSchemaKind

Reimplemented from UsdAPISchemaBase.

◆ BlockPrimvar()

USDGEOM_API void 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

◆ CanContainPropertyName()

static USDGEOM_API bool CanContainPropertyName ( const TfToken name)
static

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

◆ CreateIndexedPrimvar()

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
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.

◆ CreateNonIndexedPrimvar()

UsdGeomPrimvar 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.

◆ CreatePrimvar()

USDGEOM_API UsdGeomPrimvar 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()

◆ FindIncrementallyInheritablePrimvars()

USDGEOM_API std::vector< UsdGeomPrimvar > 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

◆ FindInheritablePrimvars()

USDGEOM_API std::vector< UsdGeomPrimvar > 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

◆ FindPrimvarsWithInheritance() [1/2]

USDGEOM_API std::vector< UsdGeomPrimvar > 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

◆ FindPrimvarsWithInheritance() [2/2]

USDGEOM_API std::vector< UsdGeomPrimvar > 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

◆ FindPrimvarWithInheritance() [1/2]

USDGEOM_API UsdGeomPrimvar 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

◆ FindPrimvarWithInheritance() [2/2]

USDGEOM_API UsdGeomPrimvar 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

◆ Get()

static USDGEOM_API 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));
UsdGeomPrimvarsAPI encodes geometric "primitive variables", as UsdGeomPrimvar, which interpolate acro...
Definition: primvarsAPI.h:83

◆ GetAuthoredPrimvars()

USDGEOM_API std::vector< UsdGeomPrimvar > 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

◆ GetPrimvar()

USDGEOM_API UsdGeomPrimvar 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

UsdGeomPrimvar(prim->GetAttribute(name))
Schema wrapper for UsdAttribute for authoring and introspecting attributes that are primvars.
Definition: primvar.h:262

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

◆ GetPrimvars()

USDGEOM_API std::vector< UsdGeomPrimvar > 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

◆ GetPrimvarsWithAuthoredValues()

USDGEOM_API std::vector< UsdGeomPrimvar > 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

◆ GetPrimvarsWithValues()

USDGEOM_API std::vector< UsdGeomPrimvar > 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

◆ GetSchemaAttributeNames()

static USDGEOM_API const TfTokenVector & 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.

◆ HasPossiblyInheritedPrimvar()

USDGEOM_API bool 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()

◆ HasPrimvar()

USDGEOM_API bool 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.

◆ RemovePrimvar()

USDGEOM_API bool 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

◆ UsdSchemaRegistry

friend class UsdSchemaRegistry
friend

Definition at line 141 of file primvarsAPI.h.

Member Data Documentation

◆ schemaKind

const UsdSchemaKind 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: