本文整理汇总了C++中TfTokenVector::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ TfTokenVector::begin方法的具体用法?C++ TfTokenVector::begin怎么用?C++ TfTokenVector::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TfTokenVector
的用法示例。
在下文中一共展示了TfTokenVector::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _MakeProperties
std::vector<UsdProperty>
UsdPrim::_GetPropertiesInNamespace(const std::string &namespaces,
bool onlyAuthored) const
{
// XXX Would be nice to someday plumb the prefix search down through pcp
if (namespaces.empty())
return onlyAuthored ? GetAuthoredProperties() : GetProperties();
const char delim = UsdObject::GetNamespaceDelimiter();
TfTokenVector names = _GetPropertyNames(onlyAuthored, /*applyOrder=*/false);
// Set terminator to the expected position of the delimiter after all the
// supplied namespaces. We perform an explicit test for this char below
// so that we don't need to allocate a new string if namespaces does not
// already end with the delimiter
const size_t terminator = namespaces.size() -
(*namespaces.rbegin() == delim);
// Prune out non-matches before we sort
size_t insertionPt = 0;
for (const auto& name : names) {
const std::string &s = name.GetString();
if (s.size() > terminator &&
TfStringStartsWith(s, namespaces) &&
s[terminator] == delim) {
names[insertionPt++] = name;
}
}
names.resize(insertionPt);
sort(names.begin(), names.end(), TfDictionaryLessThan());
_ApplyOrdering(GetPropertyOrder(), &names);
return _MakeProperties(names);
}
示例2: GetAppliedSchemas
void
UsdMayaAdaptor::UnapplySchemaByName(
const TfToken& schemaName,
MDGModifier& modifier)
{
if (!*this) {
TF_CODING_ERROR("Adaptor is not valid");
return;
}
// Remove from schema list.
TfTokenVector currentSchemas = GetAppliedSchemas();
currentSchemas.erase(
std::remove(
currentSchemas.begin(), currentSchemas.end(), schemaName),
currentSchemas.end());
if (currentSchemas.empty()) {
ClearMetadata(UsdTokens->apiSchemas, modifier);
}
else {
SetMetadata(
UsdTokens->apiSchemas,
_GetListOpForTokenVector(currentSchemas),
modifier);
}
}
示例3: SchemaAdaptor
UsdMayaAdaptor::SchemaAdaptor
UsdMayaAdaptor::ApplySchemaByName(
const TfToken& schemaName,
MDGModifier& modifier)
{
if (!*this) {
TF_CODING_ERROR("Adaptor is not valid");
return SchemaAdaptor();
}
// Get the schema's TfType; its name should be registered as an alias.
const TfType schemaType =
TfType::Find<UsdSchemaBase>().FindDerivedByName(schemaName);
// Make sure that this is an API schema. Only API schemas can be applied.
if (!schemaType.IsA<UsdAPISchemaBase>()) {
TF_CODING_ERROR("'%s' is not a registered API schema",
schemaName.GetText());
return SchemaAdaptor();
}
// Make sure that this is an "apply" schema.
if (!UsdSchemaRegistry::GetInstance().IsAppliedAPISchema(schemaType)) {
TF_CODING_ERROR("'%s' is not an applied API schema",
schemaName.GetText());
return SchemaAdaptor();
}
// Get the schema definition. If it's registered, there should be a def.
SdfPrimSpecHandle primDef =
UsdSchemaRegistry::GetInstance().GetPrimDefinition(schemaName);
if (!primDef) {
TF_CODING_ERROR("Can't find schema definition for name '%s'",
schemaName.GetText());
return SchemaAdaptor();
}
// Add to schema list (if not yet present).
TfTokenVector currentSchemas = GetAppliedSchemas();
if (std::find(currentSchemas.begin(), currentSchemas.end(), schemaName) ==
currentSchemas.end()) {
currentSchemas.push_back(schemaName);
SetMetadata(
UsdTokens->apiSchemas,
_GetListOpForTokenVector(currentSchemas),
modifier);
}
return SchemaAdaptor(_handle.object(), primDef);
}
示例4: UsdUISceneGraphPrimAPI
/* static */
UsdUISceneGraphPrimAPI
UsdUISceneGraphPrimAPI::Apply(const UsdStagePtr &stage, const SdfPath &path)
{
// Ensure we have a valid stage, path and prim
if (!stage) {
TF_CODING_ERROR("Invalid stage");
return UsdUISceneGraphPrimAPI();
}
if (path == SdfPath::AbsoluteRootPath()) {
TF_CODING_ERROR("Cannot apply an api schema on the pseudoroot");
return UsdUISceneGraphPrimAPI();
}
auto prim = stage->GetPrimAtPath(path);
if (!prim) {
TF_CODING_ERROR("Prim at <%s> does not exist.", path.GetText());
return UsdUISceneGraphPrimAPI();
}
TfToken apiName("SceneGraphPrimAPI");
// Get the current listop at the edit target
UsdEditTarget editTarget = stage->GetEditTarget();
SdfPrimSpecHandle primSpec = editTarget.GetPrimSpecForScenePath(path);
SdfTokenListOp listOp = primSpec->GetInfo(UsdTokens->apiSchemas)
.UncheckedGet<SdfTokenListOp>();
// Append our name to the prepend list, if it doesnt exist locally
TfTokenVector prepends = listOp.GetPrependedItems();
if (std::find(prepends.begin(), prepends.end(), apiName) != prepends.end()) {
return UsdUISceneGraphPrimAPI();
}
SdfTokenListOp prependListOp;
prepends.push_back(apiName);
prependListOp.SetPrependedItems(prepends);
auto result = listOp.ApplyOperations(prependListOp);
if (!result) {
TF_CODING_ERROR("Failed to prepend api name to current listop.");
return UsdUISceneGraphPrimAPI();
}
// Set the listop at the current edit target and return the API prim
primSpec->SetInfo(UsdTokens->apiSchemas, VtValue(*result));
return UsdUISceneGraphPrimAPI(prim);
}
示例5: TfToken
TfTokenVector
UsdPrim::_GetPropertyNames(bool onlyAuthored, bool applyOrder) const
{
TfTokenVector names;
// If we're including unauthored properties, take names from definition, if
// present.
if (!onlyAuthored) {
UsdSchemaRegistry::HasField(GetTypeName(), TfToken(),
SdfChildrenKeys->PropertyChildren, &names);
}
// Add authored names, then sort and apply ordering.
GetPrimIndex().ComputePrimPropertyNames(&names);
if (applyOrder) {
sort(names.begin(), names.end(), TfDictionaryLessThan());
_ApplyOrdering(GetPropertyOrder(), &names);
}
return names;
}