24 #ifndef _GUSD_THREADEDTRAVERSE_H_
25 #define _GUSD_THREADEDTRAVERSE_H_
46 namespace GusdUSD_ThreadedTraverse {
49 template <
class Visitor>
54 const Visitor& visitor,
57 template <
class Visitor>
62 const Visitor& visitor,
69 template <
class Visitor,
bool Recursive=false>
93 template <
class Visitor,
bool Recursive>
143 bool GatherPrimsFromThreads(
152 template <
class Visitor>
159 : _taskgroup(taskgroup), _prim(prim), _idx(idx), _time(time),
160 _purposes(purposes), _data(data),
161 _visitor(visitor), _skipPrim(skipPrim) {}
175 mutable Visitor _visitor;
180 template <
class Visitor>
189 if(
ARCH_UNLIKELY(_visitor.AcceptPrim(_prim, _time, _purposes, ctl))) {
191 auto*& threadData = _data.threadData.get();
202 auto predicate = _visitor.TraversalPredicate(_prim.IsAbstract());
203 for (
const auto& child : _prim.GetFilteredChildren(predicate)) {
205 _taskgroup, child, _idx, _time, _purposes, _data, _visitor,
211 template <
class Visitor>
217 const Visitor& visitor,
224 data, visitor, skipPrim));
233 template <
class Visitor>
240 : _roots(roots), _times(times), _purposes(purposes),
241 _visitor(visitor), _data(data), _skipRoot(skipRoot) {}
247 for(std::size_t i = r.begin(); i < r.end(); ++i)
249 if(boss->opInterrupt())
252 if(
const UsdPrim& prim = _roots(i)) {
253 bool skipPrim = _skipRoot ||
258 tg, prim, i, _times(i), _purposes(i), _data,
259 _visitor, skipPrim));
268 const Visitor& _visitor;
270 const bool _skipRoot;
276 template <
class Visitor>
282 const Visitor& visitor,
288 visitor, data, skipRoot));
void UTparallelFor(const Range &range, const Body &body, const int subscribe_ratio=2, const int min_grain_size=1, const bool force_use_task_scope=true)
static SDF_API const SdfPath & AbsoluteRootPath()
bool Get(T *value, UsdTimeCode time=UsdTimeCode::Default()) const
GT_API const UT_StringHolder time
Usd_PrimFlagsPredicate TraversalPredicate(bool allow_abstract) const
bool GetVisitChildren() const
PXR_NAMESPACE_OPEN_SCOPE T * GusdUTverify_ptr(T *ptr)
TaskThreadDataTLS threadData
void operator()(const UT_BlockedRange< std::size_t > &r) const
int opInterrupt(int percent=-1)
void runAndWait(const F &f)
USDGEOM_API UsdAttribute GetPurposeAttr() const
TraverseTaskT(UT_TaskGroup &taskgroup, const UsdPrim &prim, exint idx, UsdTimeCode time, GusdPurposeSet purposes, TaskData &data, const Visitor &visitor, bool skipPrim)
Methods for USD scene traversal.
std::pair< UsdPrim, exint > PrimIndexPair
UT_ThreadSpecificValue< TaskThreadData * > TaskThreadDataTLS
Usd_PrimFlagsPredicate UsdTraverseInstanceProxies(Usd_PrimFlagsPredicate predicate)
bool GatherPrimsFromThreads(UT_Array< UsdPrim > &prims)
UT_Array< GusdUSD_Traverse::PrimIndexPair > prims
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
LeafData & operator=(const LeafData &)=delete
UT_API UT_Interrupt * UTgetInterrupt()
Obtain global UT_Interrupt singleton.
#define PXR_NAMESPACE_CLOSE_SCOPE
GUSD_API bool GusdPurposeInSet(const TfToken &name, GusdPurposeSet set)
bool ParallelFindPrims(const UsdPrim &root, UsdTimeCode time, GusdPurposeSet purposes, UT_Array< UsdPrim > &prims, const Visitor &visitor, bool skipRoot=true)
RunTasksT(const UT_Array< UsdPrim > &roots, const GusdDefaultArray< UsdTimeCode > ×, const GusdDefaultArray< GusdPurposeSet > &purposes, const Visitor &visitor, TaskData &data, bool skipRoot)
bool AcceptPrim(const UsdPrim &prim, UsdTimeCode time, GusdPurposeSet purposes, GusdUSD_TraverseControl &ctl) const