本文整理汇总了C++中SdfPathVector::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ SdfPathVector::empty方法的具体用法?C++ SdfPathVector::empty怎么用?C++ SdfPathVector::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SdfPathVector
的用法示例。
在下文中一共展示了SdfPathVector::empty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
UsdGeomCollectionAPI::IsEmpty() const
{
UsdRelationship targetsRel = _GetTargetsRel();
if (targetsRel) {
SdfPathVector targets;
targetsRel.GetTargets(&targets);
return targets.empty();
}
return true;
}
示例2: _VisitImpl
void _VisitImpl(SdfPathVector const &paths) {
if (!paths.empty()) {
for (SdfPath const &p: paths) {
_workQueue.push(p);
}
_consumerTask.Wake();
}
if (_recurse) {
WorkParallelForEach(
paths.begin(), paths.end(),
[this](SdfPath const &path) {
if (!path.HasPrefix(_prim.GetPath())) {
if (UsdPrim owningPrim = _prim.GetStage()->
GetPrimAtPath(path.GetPrimPath())) {
_VisitSubtree(owningPrim);
}
}
});
}
}
示例3: sourcesBldr
void
PxrUsdKatanaReadPointInstancer(
const UsdGeomPointInstancer& instancer,
const PxrUsdKatanaUsdInPrivateData& data,
PxrUsdKatanaAttrMap& instancerAttrMap,
PxrUsdKatanaAttrMap& sourcesAttrMap,
PxrUsdKatanaAttrMap& instancesAttrMap,
PxrUsdKatanaAttrMap& inputAttrMap)
{
const double currentTime = data.GetCurrentTime();
PxrUsdKatanaReadXformable(instancer, data, instancerAttrMap);
// Get primvars for setting later. Unfortunatley, the only way to get them
// out of the attr map is to build it, which will cause its contents to be
// cleared. We'll need to restore its contents before continuing.
//
FnKat::GroupAttribute instancerAttrs = instancerAttrMap.build();
FnKat::GroupAttribute primvarAttrs =
instancerAttrs.getChildByName("geometry.arbitrary");
for (int64_t i = 0; i < instancerAttrs.getNumberOfChildren(); ++i)
{
instancerAttrMap.set(instancerAttrs.getChildName(i),
instancerAttrs.getChildByIndex(i));
}
instancerAttrMap.set("type", FnKat::StringAttribute("usd point instancer"));
const std::string fileName = data.GetUsdInArgs()->GetFileName();
instancerAttrMap.set("info.usd.fileName", FnKat::StringAttribute(fileName));
FnKat::GroupAttribute inputAttrs = inputAttrMap.build();
const std::string katOutputPath = FnKat::StringAttribute(
inputAttrs.getChildByName("outputLocationPath")).getValue("", false);
if (katOutputPath.empty())
{
_LogAndSetError(instancerAttrMap, "No output location path specified");
return;
}
//
// Validate instancer data.
//
const std::string instancerPath = instancer.GetPath().GetString();
UsdStageWeakPtr stage = instancer.GetPrim().GetStage();
// Prototypes (required)
//
SdfPathVector protoPaths;
instancer.GetPrototypesRel().GetTargets(&protoPaths);
if (protoPaths.empty())
{
_LogAndSetError(instancerAttrMap, "Instancer has no prototypes");
return;
}
_PathToPrimMap primCache;
for (auto protoPath : protoPaths) {
const UsdPrim &protoPrim = stage->GetPrimAtPath(protoPath);
primCache[protoPath] = protoPrim;
}
// Indices (required)
//
VtIntArray protoIndices;
if (!instancer.GetProtoIndicesAttr().Get(&protoIndices, currentTime))
{
_LogAndSetError(instancerAttrMap, "Instancer has no prototype indices");
return;
}
const size_t numInstances = protoIndices.size();
if (numInstances == 0)
{
_LogAndSetError(instancerAttrMap, "Instancer has no prototype indices");
return;
}
for (auto protoIndex : protoIndices)
{
if (protoIndex < 0 || static_cast<size_t>(protoIndex) >= protoPaths.size())
{
_LogAndSetError(instancerAttrMap, TfStringPrintf(
"Out of range prototype index %d", protoIndex));
return;
}
}
// Mask (optional)
//
std::vector<bool> pruneMaskValues =
instancer.ComputeMaskAtTime(currentTime);
if (!pruneMaskValues.empty() and pruneMaskValues.size() != numInstances)
{
_LogAndSetError(instancerAttrMap,
"Mismatch in length of indices and mask");
return;
}
//.........这里部分代码省略.........
示例4: bboxCache
bool
UsdGeomPointInstancer::ComputeExtentAtTime(
VtVec3fArray* extent,
const UsdTimeCode time,
const UsdTimeCode baseTime) const
{
if (!extent) {
TF_WARN("%s -- null container passed to ComputeExtentAtTime()",
GetPrim().GetPath().GetText());
return false;
}
VtIntArray protoIndices;
if (!GetProtoIndicesAttr().Get(&protoIndices, time)) {
TF_WARN("%s -- no prototype indices",
GetPrim().GetPath().GetText());
return false;
}
const std::vector<bool> mask = ComputeMaskAtTime(time);
if (!mask.empty() && mask.size() != protoIndices.size()) {
TF_WARN("%s -- mask.size() [%zu] != protoIndices.size() [%zu]",
GetPrim().GetPath().GetText(),
mask.size(),
protoIndices.size());
return false;
}
const UsdRelationship prototypes = GetPrototypesRel();
SdfPathVector protoPaths;
if (!prototypes.GetTargets(&protoPaths) || protoPaths.empty()) {
TF_WARN("%s -- no prototypes",
GetPrim().GetPath().GetText());
return false;
}
// verify that all the protoIndices are in bounds.
TF_FOR_ALL(iter, protoIndices) {
const int protoIndex = *iter;
if (protoIndex < 0 ||
static_cast<size_t>(protoIndex) >= protoPaths.size()) {
TF_WARN("%s -- invalid prototype index: %d. Should be in [0, %zu)",
GetPrim().GetPath().GetText(),
protoIndex,
protoPaths.size());
return false;
}
}
// Note that we do NOT apply any masking when computing the instance
// transforms. This is so that for a particular instance we can determine
// both its transform and its prototype. Otherwise, the instanceTransforms
// array would have masked instances culled out and we would lose the
// mapping to the prototypes.
// Masked instances will be culled before being applied to the extent below.
VtMatrix4dArray instanceTransforms;
if (!ComputeInstanceTransformsAtTime(&instanceTransforms,
time,
baseTime,
IncludeProtoXform,
IgnoreMask)) {
TF_WARN("%s -- could not compute instance transforms",
GetPrim().GetPath().GetText());
return false;
}
UsdStageWeakPtr stage = GetPrim().GetStage();
const TfTokenVector purposes {
UsdGeomTokens->default_,
UsdGeomTokens->proxy,
UsdGeomTokens->render
};
UsdGeomBBoxCache bboxCache(time, purposes);
bboxCache.SetTime(time);
GfRange3d extentRange;
for (size_t instanceId = 0; instanceId < protoIndices.size(); ++instanceId) {
if (!mask.empty() && !mask[instanceId]) {
continue;
}
const int protoIndex = protoIndices[instanceId];
const SdfPath& protoPath = protoPaths[protoIndex];
const UsdPrim& protoPrim = stage->GetPrimAtPath(protoPath);
// Get the prototype bounding box.
GfBBox3d thisBounds = bboxCache.ComputeUntransformedBound(protoPrim);
// Apply the instance transform.
thisBounds.Transform(instanceTransforms[instanceId]);
extentRange.UnionWith(thisBounds.ComputeAlignedRange());
}
const GfVec3d extentMin = extentRange.GetMin();
const GfVec3d extentMax = extentRange.GetMax();
*extent = VtVec3fArray(2);
(*extent)[0] = GfVec3f(extentMin[0], extentMin[1], extentMin[2]);
(*extent)[1] = GfVec3f(extentMax[0], extentMax[1], extentMax[2]);
//.........这里部分代码省略.........
示例5: xformCache
bool
UsdGeomPointInstancer::ComputeInstanceTransformsAtTime(
VtArray<GfMatrix4d>* xforms,
const UsdTimeCode time,
const UsdTimeCode baseTime,
const ProtoXformInclusion doProtoXforms,
const MaskApplication applyMask) const
{
// XXX: Need to add handling of velocities/angularVelocities and baseTime.
(void)baseTime;
if (!xforms) {
TF_WARN("%s -- null container passed to ComputeInstanceTransformsAtTime()",
GetPrim().GetPath().GetText());
return false;
}
VtIntArray protoIndices;
if (!GetProtoIndicesAttr().Get(&protoIndices, time)) {
TF_WARN("%s -- no prototype indices",
GetPrim().GetPath().GetText());
return false;
}
if (protoIndices.empty()) {
xforms->clear();
return true;
}
VtVec3fArray positions;
if (!GetPositionsAttr().Get(&positions, time)) {
TF_WARN("%s -- no positions",
GetPrim().GetPath().GetText());
return false;
}
if (positions.size() != protoIndices.size()) {
TF_WARN("%s -- positions.size() [%zu] != protoIndices.size() [%zu]",
GetPrim().GetPath().GetText(),
positions.size(),
protoIndices.size());
return false;
}
VtVec3fArray scales;
GetScalesAttr().Get(&scales, time);
if (!scales.empty() && scales.size() != protoIndices.size()) {
TF_WARN("%s -- scales.size() [%zu] != protoIndices.size() [%zu]",
GetPrim().GetPath().GetText(),
scales.size(),
protoIndices.size());
return false;
}
VtQuathArray orientations;
GetOrientationsAttr().Get(&orientations, time);
if (!orientations.empty() && orientations.size() != protoIndices.size()) {
TF_WARN("%s -- orientations.size() [%zu] != protoIndices.size() [%zu]",
GetPrim().GetPath().GetText(),
orientations.size(),
protoIndices.size());
return false;
}
// If we're going to include the prototype transforms, verify that we have
// prototypes and that all of the protoIndices are in bounds.
SdfPathVector protoPaths;
if (doProtoXforms == IncludeProtoXform) {
const UsdRelationship prototypes = GetPrototypesRel();
if (!prototypes.GetTargets(&protoPaths) || protoPaths.empty()) {
TF_WARN("%s -- no prototypes",
GetPrim().GetPath().GetText());
return false;
}
TF_FOR_ALL(iter, protoIndices) {
const int protoIndex = *iter;
if (protoIndex < 0 || static_cast<size_t>(protoIndex) >= protoPaths.size()) {
TF_WARN("%s -- invalid prototype index: %d. Should be in [0, %zu)",
GetPrim().GetPath().GetText(),
protoIndex,
protoPaths.size());
return false;
}
}
}
// Compute the mask only if applyMask says we should, otherwise we leave
// mask empty so that its application below is a no-op.
std::vector<bool> mask;
if (applyMask == ApplyMask) {
mask = ComputeMaskAtTime(time);
if (!mask.empty() && mask.size() != protoIndices.size()) {
TF_WARN("%s -- mask.size() [%zu] != protoIndices.size() [%zu]",
GetPrim().GetPath().GetText(),
mask.size(),
protoIndices.size());
return false;
}
}
//.........这里部分代码省略.........