7#ifndef PXR_IMAGING_HD_PRIM_GATHER_H
8#define PXR_IMAGING_HD_PRIM_GATHER_H
11#include "pxr/imaging/hd/api.h"
13#include "pxr/usd/sdf/path.h"
16#include <tbb/enumerable_thread_specific.h>
17#include <tbb/blocked_range.h>
19PXR_NAMESPACE_OPEN_SCOPE
21class HdPrimGather final {
23 typedef bool (*FilterPredicateFn)(
const SdfPath &path,
const void *param);
25 HdPrimGather() =
default;
26 ~HdPrimGather() =
default;
49 void Filter(
const SdfPathVector &paths,
50 const SdfPathVector &includePaths,
51 const SdfPathVector &excludePaths,
52 SdfPathVector *results);
83 void PredicatedFilter(
const SdfPathVector &paths,
84 const SdfPathVector &includePaths,
85 const SdfPathVector &excludePaths,
86 FilterPredicateFn predicateFn,
88 SdfPathVector *results);
100 void Subtree(
const SdfPathVector &paths,
102 SdfPathVector *results);
118 bool SubtreeAsRange(
const SdfPathVector &paths,
128 _PathFilter(
const SdfPath &path,
bool includePath)
130 , _includePath(includePath)
135 bool operator >(
const _PathFilter &other)
const {
136 return other._path < _path;
139 typedef std::vector<_PathFilter> _PathFilterArray;
149 _Range(
size_t start,
size_t end)
157 typedef std::vector<_Range> _RangeArray;
158 typedef tbb::enumerable_thread_specific<_RangeArray> _ConcurrentRangeArray;
159 typedef tbb::blocked_range<size_t> _ConcurrentRange;
163 _PathFilterArray _filterList;
164 _RangeArray _gatheredRanges;
165 _ConcurrentRangeArray _resultRanges;
169 size_t _FindLowerBound(
const SdfPathVector &paths,
173 size_t _FindUpperBound(
const SdfPathVector &paths,
178 void _FilterRange(
const SdfPathVector &paths,
183 void _SetupFilter(
const SdfPathVector &includePaths,
184 const SdfPathVector &excludePaths);
186 void _GatherPaths(
const SdfPathVector &paths);
189 void _DoPredicateTestOnRange(
const SdfPathVector &paths,
191 FilterPredicateFn predicateFn,
192 void *predicateParam);
195 void _DoPredicateTestOnPrims(
const SdfPathVector &paths,
196 _ConcurrentRange &range,
197 FilterPredicateFn predicateFn,
198 void *predicateParam);
200 template <
class Iterator>
201 static void _WriteResults(
const SdfPathVector &paths,
202 const Iterator &rangesBegin,
203 const Iterator &rangesEnd,
204 SdfPathVector *results);
206 void _FilterSubTree(
const SdfPathVector &paths,
210 HdPrimGather(
const HdPrimGather &) =
delete;
211 HdPrimGather &operator =(
const HdPrimGather &) =
delete;
216PXR_NAMESPACE_CLOSE_SCOPE
A path value used to locate objects in layers or scenegraphs.