HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GusdUSD_Utils Namespace Reference

Classes

struct  KindNode
 
struct  VariantSel
 
struct  NameMatcher
 

Typedefs

typedef UT_Array< VariantSelVariantSelArray
 
typedef std::pair< exint, exintIndexPair
 
typedef UT_Array< IndexPairIndexPairArray
 

Functions

const TfToken kModelingVariantToken ("modelingVariant")
 TODO: Would be nice to loft these TfTokens into a a shared place. More...
 
const TfToken kAllVariantsToken ("ALL_VARIANTS")
 
GUSD_API UT_StringHolder TokenToStringHolder (const TfToken &token)
 Convert a TfToken to a UT_StringHolder. More...
 
GUSD_API double GetNumericTime (UsdTimeCode time)
 
GUSD_API bool CreateSdfPath (const UT_StringRef &pathStr, SdfPath &path, UT_ErrorSeverity sev=UT_ERROR_ABORT)
 
GUSD_API const SdfPathGetDefaultPrimIdentifier ()
 Returns an SdfPath that can be used for identify the stage's defaultPrim. More...
 
GUSD_API UsdPrim GetPrimFromStage (const UsdStagePtr &stage, const SdfPath &path, UT_ErrorSeverity sev=UT_ERROR_ABORT)
 
template<typename SchemaT >
SchemaT MakeSchemaObj (const UsdPrim &prim, UT_ErrorSeverity sev=UT_ERROR_ABORT)
 
GUSD_API bool GetPrimAndVariantPathsFromPathList (const char *str, UT_Array< SdfPath > &primPaths, UT_Array< SdfPath > &variants, UT_ErrorSeverity sev=UT_ERROR_ABORT)
 
GUSD_API void ExtractPrimPathAndVariants (const SdfPath &path, SdfPath &primPath, SdfPath &variants)
 
GUSD_API void SetModelingVariant (const UsdStageRefPtr &stage, const UsdPrim &prim, const TfToken &variant)
 
GUSD_API void ClearModelingVariant (const UsdStageRefPtr &stage, const UsdPrim &prim)
 
GUSD_API bool SortPrims (UT_Array< UsdPrim > &prims)
 
GUSD_API void GetBaseSchemaTypesMatchingPattern (const char *pattern, UT_Array< TfType > &types, bool caseSensitive=true)
 
GUSD_API void GetBaseModelKindsMatchingPattern (const char *pattern, UT_Array< TfToken > &kinds, bool caseSensitive=true)
 
GUSD_API void GetPurposesMatchingPattern (const char *pattern, UT_Array< TfToken > &purposes, bool caseSensitive=true)
 
const KindNodeGetModelKindHierarchy ()
 
GUSD_API void AppendVariantSelectionString (UT_WorkBuffer &buf, const SdfPath &prim, const SdfPath &variants, const std::string &vset, const std::string &sel)
 
GUSD_API bool AppendVariantSelections (const UT_Array< UsdPrim > &prims, const VariantSelArray &selections, UT_Array< UT_StringHolder > &orderedVariants, UT_Array< exint > &indices, const UT_Array< SdfPath > *prevVariants=NULL)
 
GUSD_API bool ExpandVariantSetPaths (const UT_Array< UsdPrim > &prims, const std::string &variantSet, const NameMatcher &matcher, UT_Array< UT_StringHolder > &orderedVariants, IndexPairArray &indices, const UT_Array< SdfPath > *prevVariants=NULL)
 
GUSD_API void SetVariantsFromPath (const SdfPath &path, const SdfLayerHandle &layer)
 
GUSD_API bool GetPropertyNames (const UT_Array< UsdPrim > &prims, const NameMatcher &matcher, UT_Array< UT_StringHolder > &orderedNames, IndexPairArray &indices, const std::string &nameSpace=std::string())
 
GUSD_API bool GetUniqueVariantSetNames (const UT_Array< UsdPrim > &prims, UT_Array< UT_StringHolder > &names)
 
GUSD_API bool GetUniqueVariantNames (const UT_Array< UsdPrim > &prims, const std::string &variantSet, UT_Array< UT_StringHolder > &names)
 
GUSD_API bool GetUniquePropertyNames (const UT_Array< UsdPrim > &prims, UT_Array< UT_StringHolder > &names, const std::string &nameSpace=std::string())
 
UsdTimeCode ClampTimeCode (UsdTimeCode t, double start, double end, int digits)
 

Typedef Documentation

typedef std::pair<exint,exint> GusdUSD_Utils::IndexPair

Definition at line 222 of file USD_Utils.h.

Definition at line 223 of file USD_Utils.h.

Definition at line 184 of file USD_Utils.h.

Function Documentation

GUSD_API bool GusdUSD_Utils::AppendVariantSelections ( const UT_Array< UsdPrim > &  prims,
const VariantSelArray &  selections,
UT_Array< UT_StringHolder > &  orderedVariants,
UT_Array< exint > &  indices,
const UT_Array< SdfPath > *  prevVariants = NULL 
)

Given an array of prims, compute new variant path strings that apply a set of variant selections. Only the variants that exist on each prim are applied. The variants array may optionally be specified to provide the previous variant path of each prim.

The resulting indices array provides an index per-prim into the orderedVariants array. The indices may be -1 to indicate that the entry has no variant selections.

GUSD_API void GusdUSD_Utils::AppendVariantSelectionString ( UT_WorkBuffer buf,
const SdfPath prim,
const SdfPath variants,
const std::string vset,
const std::string sel 
)

Helper for building up a variant-encoded prim path. Appends string {vset=sel} to buf. If the buffer is empty, the buffer is initialized to the path up to prim, including any of the variant selections specified in variants.

UsdTimeCode GusdUSD_Utils::ClampTimeCode ( UsdTimeCode  t,
double  start,
double  end,
int  digits 
)
inline

Definition at line 292 of file USD_Utils.h.

GUSD_API void GusdUSD_Utils::ClearModelingVariant ( const UsdStageRefPtr &  stage,
const UsdPrim prim 
)

Clear any variant selection on a prim.

GUSD_API bool GusdUSD_Utils::CreateSdfPath ( const UT_StringRef pathStr,
SdfPath path,
UT_ErrorSeverity  sev = UT_ERROR_ABORT 
)

Parse and construct and SdfPath from a string. Returns true if there were no parse errors. Any errors that occur while attempting to construct the path are reported on the currently scoped error manager at a severity of sev.

GUSD_API bool GusdUSD_Utils::ExpandVariantSetPaths ( const UT_Array< UsdPrim > &  prims,
const std::string variantSet,
const NameMatcher &  matcher,
UT_Array< UT_StringHolder > &  orderedVariants,
IndexPairArray &  indices,
const UT_Array< SdfPath > *  prevVariants = NULL 
)

Expand selections of variants that match a given match function. For every prim in prims that has variant set variantSet, this appends an entry in indices for each matching variant. The first component of the pair in indices is the index of the original prim from prims from which the entry was expanded. The second component is an index into the orderedVariants array.

GUSD_API void GusdUSD_Utils::ExtractPrimPathAndVariants ( const SdfPath path,
SdfPath primPath,
SdfPath variants 
)

Extract a prim path and variant selection from a path.

GUSD_API void GusdUSD_Utils::GetBaseModelKindsMatchingPattern ( const char *  pattern,
UT_Array< TfToken > &  kinds,
bool  caseSensitive = true 
)

Get the list of all model kinds matching the given pattern. Derived types of types that match the pattern are not added to the list; the minimal set of matching types is returned to simplify later type comparisons.

GUSD_API void GusdUSD_Utils::GetBaseSchemaTypesMatchingPattern ( const char *  pattern,
UT_Array< TfType > &  types,
bool  caseSensitive = true 
)

Traverse the tree of schema types to compute a list of types matching a pattern. Derived types of types that match the pattern are not added to the list; the minimal set of matching types is returned to simplify later type comparisons.

GUSD_API const SdfPath& GusdUSD_Utils::GetDefaultPrimIdentifier ( )

Returns an SdfPath that can be used for identify the stage's defaultPrim.

const KindNode& GusdUSD_Utils::GetModelKindHierarchy ( )

Get a walkable hierarchy of the registered model kinds. The root of the hierarchy is always a root node with an empty kind.

double GusdUSD_Utils::GetNumericTime ( UsdTimeCode  time)
inline

Extract the numeric time from a time code. If time is not numeric, returns the numeric value from UsdTimeCode::EarliestTime().

Definition at line 284 of file USD_Utils.h.

GUSD_API bool GusdUSD_Utils::GetPrimAndVariantPathsFromPathList ( const char *  str,
UT_Array< SdfPath > &  primPaths,
UT_Array< SdfPath > &  variants,
UT_ErrorSeverity  sev = UT_ERROR_ABORT 
)

Given a string representing a list of whitespace-delimited paths, which may or may not include variant specifications, return an array of prim and variant paths.

The resulting primPaths and variantPaths arrays will be the same size. If no variants are associated with a path, then the corresponding entry in variants will be an empty path. If any errors occur while parsing the path, errors are reporeted on the currently scoped error manager at a severity of sev.

GUSD_API UsdPrim GusdUSD_Utils::GetPrimFromStage ( const UsdStagePtr &  stage,
const SdfPath path,
UT_ErrorSeverity  sev = UT_ERROR_ABORT 
)

Get a prim from a stage. If no prim can be found at path, an error is reported on the currently scoped error manager at a severity of sev.

GUSD_API bool GusdUSD_Utils::GetPropertyNames ( const UT_Array< UsdPrim > &  prims,
const NameMatcher &  matcher,
UT_Array< UT_StringHolder > &  orderedNames,
IndexPairArray &  indices,
const std::string nameSpace = std::string() 
)

Compute a set of properties matching the namespace of a range of prims. For every prim in prims, this appends an entry in indices for each matching attribute. The first component of the pairt in indices is the index of the original prim from prims that the attribute was matched from. The second component is an index into the orderedNames array.

GUSD_API void GusdUSD_Utils::GetPurposesMatchingPattern ( const char *  pattern,
UT_Array< TfToken > &  purposes,
bool  caseSensitive = true 
)
GUSD_API bool GusdUSD_Utils::GetUniquePropertyNames ( const UT_Array< UsdPrim > &  prims,
UT_Array< UT_StringHolder > &  names,
const std::string nameSpace = std::string() 
)

Query all unique property names for a range of prims.

GUSD_API bool GusdUSD_Utils::GetUniqueVariantNames ( const UT_Array< UsdPrim > &  prims,
const std::string variantSet,
UT_Array< UT_StringHolder > &  names 
)

Query all unique variant names for a specific variant set on all of the given prims.

GUSD_API bool GusdUSD_Utils::GetUniqueVariantSetNames ( const UT_Array< UsdPrim > &  prims,
UT_Array< UT_StringHolder > &  names 
)

Query all unique variant set names for a range of prims.

const TfToken GusdUSD_Utils::kAllVariantsToken ( "ALL_VARIANTS"  )
const TfToken GusdUSD_Utils::kModelingVariantToken ( "modelingVariant"  )

TODO: Would be nice to loft these TfTokens into a a shared place.

template<typename SchemaT >
SchemaT GusdUSD_Utils::MakeSchemaObj ( const UsdPrim prim,
UT_ErrorSeverity  sev = UT_ERROR_ABORT 
)

Helper for creating and validating schema objects. If the prim doesn't match the expected schema type, an error is reported on the currently scoped error manager at a severity of sev.

Definition at line 303 of file USD_Utils.h.

GUSD_API void GusdUSD_Utils::SetModelingVariant ( const UsdStageRefPtr &  stage,
const UsdPrim prim,
const TfToken variant 
)

Set a modeling variant on a stage given the prim and variant to set.

GUSD_API void GusdUSD_Utils::SetVariantsFromPath ( const SdfPath path,
const SdfLayerHandle &  layer 
)

Author variant selections on a layer using variants stored in a path.

GUSD_API bool GusdUSD_Utils::SortPrims ( UT_Array< UsdPrim > &  prims)

Sort an array of prims (by path)

GUSD_API UT_StringHolder GusdUSD_Utils::TokenToStringHolder ( const TfToken token)

Convert a TfToken to a UT_StringHolder.