HDK
|
#include <collectionAPI.h>
Public Types | |
using | MembershipQuery = UsdCollectionMembershipQuery |
Static Public Attributes | |
static const UsdSchemaKind | schemaKind = UsdSchemaKind::MultipleApplyAPI |
![]() | |
static const UsdSchemaKind | schemaKind = UsdSchemaKind::AbstractBase |
![]() | |
static const UsdSchemaKind | schemaKind = UsdSchemaKind::AbstractBase |
Protected Member Functions | |
USD_API UsdSchemaKind | _GetSchemaKind () const override |
![]() | |
UsdAPISchemaBase (const UsdPrim &prim, const TfToken &instanceName) | |
UsdAPISchemaBase (const UsdSchemaBase &schemaObj, const TfToken &instanceName) | |
const TfToken & | _GetInstanceName () const |
USD_API bool | _IsCompatible () const override |
![]() | |
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 USD_API TfTokenVector | _GetMultipleApplyInstanceNames (const UsdPrim &prim, const TfType &schemaType) |
A general purpose API schema used to describe a collection of prims and properties within a scene. This API schema can be applied to a prim multiple times with different instance names to define several collections on a single prim.
A collection's membership is specified one of two ways. The first way uses the built-in relationships includes
and excludes
, and the attribute includeRoot
to determine membership. The second way is termed a pattern-based collection, and uses the built-in attribute membershipExpression
to determine membership. Here we will refer to collections using includes
, excludes
and includeRoot
as being in relationship-mode and those using the membershipExpression
as being in expression-mode.
A collection is determined to be in relationship-mode when either or both of its includes
and excludes
relationships have valid targets, or the includeRoot
attribute is set true
. In this case, the pattern-based membershipExpression
attribute is ignored. Otherwise, the collection is in expression-mode and the membershipExpression
attribute applies.
In relationship-mode the includes
and excludes
relationships specify the collection members as a set of paths to include and a set of paths to exclude. Whether or not the descendants of an included path belong to a collection is decided by its expansion rule (see below). If the collection excludes paths that are not descendent to included paths, the collection implicitly includes the root path </>
. If such a collection also includes paths that are not descendent to the excluded paths, it is considered invalid since the intent is ambiguous.
In expression-mode, the pattern-based membershipExpression
attribute is used with the expansionRule
attribute to determine collection membership. See the detailed descriptions of the built-in properties below for more details.
The built-in properties for this schema are in the collection:instanceName
namespace, where instanceName
is the user-provided applied API schema instance name.
uniform token collection:instanceName:expansionRule
- in relationship-mode, specifies how to expand the includes
and excludes
relationship targets to determine the collection's members. In expression-mode, specifies how matching scene objects against the membershipExpression
proceeds. Possible values include:
expandPrims
- in relationship-mode, all the prims descendent to the includes
relationship targets (and not descendent to excludes
relationship targets) belong to the collection. Any includes
-targeted property paths also belong to the collection. This is the default behavior. In expression-mode, the functions UsdComputeIncludedObjectsFromCollection() and UsdComputeIncludedPathsFromCollection() only test prims against the membershipExpression
to determine membership. expandPrimsAndProperties
- like expandPrims
, but in relationship-mode, all properties on all included prims also belong to the collection. In expression-mode, the functions UsdComputeIncludedObjectsFromCollection() and UsdComputeIncludedPathsFromCollection() test both prims and properties against the membershipExpression
to determine membership. explicitOnly
- in relationship-mode, only paths in the includes
relationship targets and not those in the excludes
relationship targets belong to the collection. Does not apply to expression-mode. If set in expression-mode, the functions UsdComputeIncludedObjectsFromCollection() and UsdComputeIncludedPathsFromCollection() return no results. bool collection:instanceName:includeRoot
- boolean attribute indicating whether the pseudo-root path </>
should be counted as one of the included target paths in relationship-mode. This separate attribute is required because relationships cannot directly target the root. When expansionRule
is explicitOnly
, this attribute is ignored. The fallback value is false. When set to true
, this collection is in relationship-mode. This attribute is ignored in expression-mode.
rel collection:instanceName:includes
- in relationship-mode, specifies a list of targets that are included in the collection. This can target prims or properties directly. A collection can insert the rules of another collection by making its includes
relationship target the collection:otherInstanceName
property from the collection to be included (see UsdCollectionAPI::GetCollectionAttr). Note that including another collection does not guarantee the contents of that collection will be in the final collection; instead, the rules are merged. This means, for example, an exclude entry may exclude a portion of the included collection. When a collection includes one or more collections, the order in which targets are added to the includes relationship may become significant, if there are conflicting opinions about the same path. Targets that are added later are considered to be stronger than earlier targets for the same path. This relationship is ignored in expression-mode.
rel collection:instanceName:excludes
- in relationship-mode, specifies a list of targets that are excluded below the included paths in this collection. This can target prims or properties directly, but cannot target another collection. This is to keep the membership determining logic simple, efficient and easier to reason about. Finally, it is invalid for a collection to exclude paths that are not included in it. The presence of such "orphaned" excluded paths will not affect the set of paths included in the collection, but may affect the performance of querying membership of a path in the collection (see UsdCollectionMembershipQuery::IsPathIncluded) or of enumerating the objects belonging to the collection (see UsdCollectionAPI::ComputeIncludedObjects). This relationship is ignored in expression-mode.
uniform opaque collection:instanceName
- opaque attribute (meaning it can never have a value) that represents the collection for the purpose of allowing another collection to include it in relationship-mode. When this property is targeted by another collection's includes
relationship, the rules of this collection will be inserted into the rules of the collection that includes it.
uniform pathExpression collection:instanceName:membershipExpression
- in expression-mode, defines the SdfPathExpression used to test objects for collection membership.
In some scenarios it is useful to express a collection that includes everything except certain paths. To support this, a relationship-mode collection that has an exclude that is not descendent to any include will include the root path </>
.
For any described attribute Fallback Value or Allowed Values below that are text/tokens, the actual token is published and defined in UsdTokens. So to set an attribute to the value "rightHanded", use UsdTokens->rightHanded as the value.
Definition at line 184 of file collectionAPI.h.
Definition at line 552 of file collectionAPI.h.
|
inlineexplicit |
Construct a UsdCollectionAPI on UsdPrim prim
with name name
. Equivalent to UsdCollectionAPI::Get( prim.GetStage(), prim.GetPath().AppendProperty( "collection:name"));
for a valid prim
, but will not immediately throw an error for an invalid prim
Definition at line 201 of file collectionAPI.h.
|
inlineexplicit |
Construct a UsdCollectionAPI on the prim held by schemaObj
with name name
. Should be preferred over UsdCollectionAPI(schemaObj.GetPrim(), name), as it preserves SchemaBase state.
Definition at line 210 of file collectionAPI.h.
|
virtual |
Destructor.
|
overrideprotectedvirtual |
Returns the kind of schema this class belongs to.
Reimplemented from UsdAPISchemaBase.
|
static |
Applies this multiple-apply API schema to the given prim
along with the given instance name, name
.
This information is stored by adding "CollectionAPI:<i>name</i>" to the token-valued, listOp metadata apiSchemas on the prim. For example, if name
is 'instance1', the token 'CollectionAPI:instance1' is added to 'apiSchemas'.
USD_API bool UsdCollectionAPI::BlockCollection | ( | ) | const |
Blocks the targets of the includes and excludes relationships of the collection, making it <* empty if "includeRoot" is false (or unset) or
|
static |
Returns true if this multiple-apply API schema can be applied, with the given instance name, name
, to the given prim
. If this schema can not be a applied the prim, this returns false and, if provided, populates whyNot
with the reason it can not be applied.
Note that if CanApply returns false, that does not necessarily imply that calling Apply will fail. Callers are expected to call CanApply before calling Apply if they want to ensure that it is valid to apply a schema.
Test whether a given name
contains the "collection:" prefix
|
static |
Returns all the usd objects that satisfy the predicate, pred
in the collection represented by the UsdCollectionMembershipQuery object, query
.
The results depends on the load state of the UsdStage, stage
.
|
static |
Returns all the paths that satisfy the predicate, pred
in the collection represented by the UsdCollectionMembershipQuery object, query
.
The result depends on the load state of the UsdStage, stage
.
USD_API UsdCollectionMembershipQuery UsdCollectionAPI::ComputeMembershipQuery | ( | ) | const |
Computes and returns a UsdCollectionMembershipQuery object which can be used to query inclusion or exclusion of paths in the collection.
USD_API void UsdCollectionAPI::ComputeMembershipQuery | ( | UsdCollectionMembershipQuery * | query | ) | const |
Populates the UsdCollectionMembershipQuery object with data from this collection, so it can be used to query inclusion or exclusion of paths.
USD_API UsdAttribute UsdCollectionAPI::CreateCollectionAttr | ( | VtValue const & | defaultValue = VtValue() , |
bool | writeSparsely = false |
||
) | const |
See GetCollectionAttr(), and also Usd_Create_Or_Get_Property for when to use Get vs Create. If specified, author defaultValue
as the attribute's default, sparsely (when it makes sense to do so) if writeSparsely
is true
- the default for writeSparsely
is false
.
USD_API UsdRelationship UsdCollectionAPI::CreateExcludesRel | ( | ) | const |
See GetExcludesRel(), and also Usd_Create_Or_Get_Property for when to use Get vs Create
USD_API UsdAttribute UsdCollectionAPI::CreateExpansionRuleAttr | ( | VtValue const & | defaultValue = VtValue() , |
bool | writeSparsely = false |
||
) | const |
See GetExpansionRuleAttr(), and also Usd_Create_Or_Get_Property for when to use Get vs Create. If specified, author defaultValue
as the attribute's default, sparsely (when it makes sense to do so) if writeSparsely
is true
- the default for writeSparsely
is false
.
USD_API UsdAttribute UsdCollectionAPI::CreateIncludeRootAttr | ( | VtValue const & | defaultValue = VtValue() , |
bool | writeSparsely = false |
||
) | const |
See GetIncludeRootAttr(), and also Usd_Create_Or_Get_Property for when to use Get vs Create. If specified, author defaultValue
as the attribute's default, sparsely (when it makes sense to do so) if writeSparsely
is true
- the default for writeSparsely
is false
.
USD_API UsdRelationship UsdCollectionAPI::CreateIncludesRel | ( | ) | const |
See GetIncludesRel(), and also Usd_Create_Or_Get_Property for when to use Get vs Create
USD_API UsdAttribute UsdCollectionAPI::CreateMembershipExpressionAttr | ( | VtValue const & | defaultValue = VtValue() , |
bool | writeSparsely = false |
||
) | const |
See GetMembershipExpressionAttr(), and also Usd_Create_Or_Get_Property for when to use Get vs Create. If specified, author defaultValue
as the attribute's default, sparsely (when it makes sense to do so) if writeSparsely
is true
- the default for writeSparsely
is false
.
Excludes or removes the given path, pathToExclude
from the collection.
If the collection is empty, the collection becomes one that includes all paths except the givne path. Otherwise, this does nothing if the path is not included in the collection.
This does not modify the expansion-rule of the collection. Hence, if the expansionRule is expandPrims or expandPrimsAndProperties, then the descendants of pathToExclude
will also be excluded from the collection, unless explicitly included.
|
static |
Return a UsdCollectionAPI 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. path
must be of the format <path>.collection:name .
This is shorthand for the following:
|
static |
Return a UsdCollectionAPI with name name
holding the prim prim
. Shorthand for UsdCollectionAPI(prim, name);
|
static |
Return a vector of all named instances of UsdCollectionAPI on the given prim
.
|
static |
Returns all the named collections on the given USD prim.
|
static |
Returns the collection represented by the given collection path, collectionPath
on the given USD stage.
|
static |
Returns the schema object representing a collection named name
on the given prim
.
USD_API UsdAttribute UsdCollectionAPI::GetCollectionAttr | ( | ) | const |
This property represents the collection for the purpose of allowing another collection to include it. When this property is targeted by another collection's includes relationship, the rules of this collection will be inserted into the rules of the collection that includes it.
Declaration | uniform opaque __INSTANCE_NAME__ |
C++ Type | SdfOpaqueValue |
Usd Type | SdfValueTypeNames->Opaque |
Variability | SdfVariabilityUniform |
Returns the canonical path that represents this collection. This points to the property named "collection:{collectionName}" on the prim defining the collection. This is the path to be used to "include" this collection in another collection.
USD_API UsdRelationship UsdCollectionAPI::GetExcludesRel | ( | ) | const |
Specifies a list of targets that are excluded below the included paths in this collection. This can target prims or properties directly, but cannot target another collection. This is to keep the membership determining logic simple, efficient and easier to reason about. Finally, it is invalid for a collection to exclude paths that are not included in it. The presence of such "orphaned" excluded paths will not affect the set of paths included in the collection, but may affect the performance of querying membership of a path in the collection (see UsdCollectionAPI::MembershipQuery::IsPathIncluded) or of enumerating the objects belonging to the collection (see UsdCollectionAPI::GetIncludedObjects).
USD_API UsdAttribute UsdCollectionAPI::GetExpansionRuleAttr | ( | ) | const |
Specifies how the paths that are included in the collection must be expanded to determine its members.
Declaration | uniform token expansionRule = "expandPrims" |
C++ Type | TfToken |
Usd Type | SdfValueTypeNames->Token |
Variability | SdfVariabilityUniform |
Allowed Values | explicitOnly, expandPrims, expandPrimsAndProperties |
USD_API UsdAttribute UsdCollectionAPI::GetIncludeRootAttr | ( | ) | const |
Boolean attribute indicating whether the pseudo-root path </>
should be counted as one of the included target paths. The fallback is false. This separate attribute is required because relationships cannot directly target the root.
Declaration | uniform bool includeRoot |
C++ Type | bool |
Usd Type | SdfValueTypeNames->Bool |
Variability | SdfVariabilityUniform |
USD_API UsdRelationship UsdCollectionAPI::GetIncludesRel | ( | ) | const |
Specifies a list of targets that are included in the collection. This can target prims or properties directly. A collection can insert the rules of another collection by making its includes relationship target the collection:{collectionName} property on the owning prim of the collection to be included
USD_API UsdAttribute UsdCollectionAPI::GetMembershipExpressionAttr | ( | ) | const |
Specifies a path expression that determines membership in this collection.
Declaration | uniform pathExpression membershipExpression |
C++ Type | SdfPathExpression |
Usd Type | SdfValueTypeNames->PathExpression |
Variability | SdfVariabilityUniform |
|
inline |
Returns the name of this multiple-apply schema instance.
Definition at line 236 of file collectionAPI.h.
|
static |
Returns the canonical path to the collection named, name
on the given prim, prim
.
|
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.
|
static |
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes for a given instance name. Does not include attributes that may be authored by custom/extended methods of the schemas involved. The names returned will have the proper namespace prefix.
USD_API bool UsdCollectionAPI::HasNoIncludedPaths | ( | ) | const |
Return true if the collection cannot possibly include anything.
For collections in relationships-mode, this is the case if the includes relationship has no target paths, and the includeRoot attribute is false.
For collections in expression-mode, this is the case if the membershipExpression attribute has either no opinion or if it is SdfPathExpression::Nothing().
Note that there may be cases where the collection includes no objects despite HasNoIncludedPaths() returning false. For example, if the included objects are unloaded, or if the included objects are also excluded, or if an authored non-empty membershipExpression happens not to match any objects on the stage.
Includes or adds the given path, pathToInclude
in the collection.
This does nothing if the path is already included in the collection.
This does not modify the expansion-rule of the collection. Hence, if the expansionRule is expandPrims or expandPrimsAndProperties, then the descendants of pathToInclude
will be also included in the collection unless explicitly excluded.
|
static |
Checks if the given path path
is of an API schema of type CollectionAPI. If so, it stores the instance name of the schema in name
and returns true. Otherwise, it returns false.
|
inline |
Return true if this collection is expression-mode. That is, if it uses the membershipExpression
attribute to determine membership and not the includes
and excludes
relationships. Equivalent to !IsInRelationshipsMode()
.
Definition at line 595 of file collectionAPI.h.
USD_API bool UsdCollectionAPI::IsInRelationshipsMode | ( | ) | const |
Return true if this collection is relationships-mode. That is, if it uses the includes
and excludes
relationships to determine membership and not the membershipExpression
attribute. This is the case when either or both of its includes
and excludes
relationships have valid targets, or the includeRoot
attribute is set true
. This is equivalent to !IsInExpressionMode()
.
Checks if the given name baseName
is the base name of a property of CollectionAPI.
USD_API bool UsdCollectionAPI::ResetCollection | ( | ) | const |
Resets the collection by clearing both the includes and excludes targets of the collection in the current UsdEditTarget.
USD_API SdfPathExpression UsdCollectionAPI::ResolveCompleteMembershipExpression | ( | ) | const |
Obtain a complete SdfPathExpression from this collection's membershipExpression. First, UsdAttribute::Get() the value of GetMembershipExpressionAttr(), then resolve any contained references. Replace any remaining "weaker" references (_) with SdfPathExpression::Nothing(). Replace other references by recursively resolving the expressions from the collections on the referenced prims. If no such prims or no such collections exist, replace those references with SdfPathExpression::Nothing() as well.
USD_API bool UsdCollectionAPI::Validate | ( | std::string * | reason | ) | const |
Validates the collection by checking the following rules:
|
friend |
Definition at line 336 of file collectionAPI.h.
|
static |
Compile time constant representing what kind of schema this class is.
Definition at line 190 of file collectionAPI.h.