24 #ifndef PXR_IMAGING_HD_PRIM_GATHER_H
25 #define PXR_IMAGING_HD_PRIM_GATHER_H
28 #include "pxr/imaging/hd/api.h"
30 #include "pxr/usd/sdf/path.h"
33 #include <tbb/enumerable_thread_specific.h>
34 #include <tbb/blocked_range.h>
36 PXR_NAMESPACE_OPEN_SCOPE
38 class HdPrimGather final {
40 typedef bool (*FilterPredicateFn)(
const SdfPath &path,
const void *param);
42 HdPrimGather() =
default;
43 ~HdPrimGather() =
default;
66 void Filter(
const SdfPathVector &paths,
67 const SdfPathVector &includePaths,
68 const SdfPathVector &excludePaths,
69 SdfPathVector *results);
100 void PredicatedFilter(
const SdfPathVector &paths,
101 const SdfPathVector &includePaths,
102 const SdfPathVector &excludePaths,
103 FilterPredicateFn predicateFn,
104 void *predicateParam,
105 SdfPathVector *results);
117 void Subtree(
const SdfPathVector &paths,
119 SdfPathVector *results);
135 bool SubtreeAsRange(
const SdfPathVector &paths,
145 _PathFilter(
const SdfPath &path,
bool includePath)
147 , _includePath(includePath)
152 bool operator >(
const _PathFilter &other)
const {
153 return other._path < _path;
156 typedef std::vector<_PathFilter> _PathFilterArray;
166 _Range(
size_t start,
size_t end)
174 typedef std::vector<_Range> _RangeArray;
175 typedef tbb::enumerable_thread_specific<_RangeArray> _ConcurrentRangeArray;
176 typedef tbb::blocked_range<size_t> _ConcurrentRange;
180 _PathFilterArray _filterList;
181 _RangeArray _gatheredRanges;
182 _ConcurrentRangeArray _resultRanges;
186 size_t _FindLowerBound(
const SdfPathVector &paths,
190 size_t _FindUpperBound(
const SdfPathVector &paths,
195 void _FilterRange(
const SdfPathVector &paths,
200 void _SetupFilter(
const SdfPathVector &includePaths,
201 const SdfPathVector &excludePaths);
203 void _GatherPaths(
const SdfPathVector &paths);
206 void _DoPredicateTestOnRange(
const SdfPathVector &paths,
208 FilterPredicateFn predicateFn,
209 void *predicateParam);
212 void _DoPredicateTestOnPrims(
const SdfPathVector &paths,
213 _ConcurrentRange &range,
214 FilterPredicateFn predicateFn,
215 void *predicateParam);
217 template <
class Iterator>
218 static void _WriteResults(
const SdfPathVector &paths,
219 const Iterator &rangesBegin,
220 const Iterator &rangesEnd,
221 SdfPathVector *results);
223 void _FilterSubTree(
const SdfPathVector &paths,
227 HdPrimGather(
const HdPrimGather &) =
delete;
228 HdPrimGather &operator =(
const HdPrimGather &) =
delete;
233 PXR_NAMESPACE_CLOSE_SCOPE
235 #endif // PXR_IMAGING_HD_PRIM_GATHER_H
A path value used to locate objects in layers or scenegraphs.