Loading...
Searching...
No Matches
collectionExpressionEvaluator.h
1//
2// Copyright 2024 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_IMAGING_HD_COLLECTION_EXPRESSION_EVALUATOR_H
9#define PXR_IMAGING_HD_COLLECTION_EXPRESSION_EVALUATOR_H
10
11#include "pxr/pxr.h"
12
13#include "pxr/imaging/hd/api.h"
14
16
17#include "pxr/usd/sdf/pathExpressionEval.h"
18#include "pxr/usd/sdf/predicateLibrary.h"
19
20#include <vector>
21
22PXR_NAMESPACE_OPEN_SCOPE
23
25struct HdSceneIndexPrim;
27
28using SdfPathVector = std::vector<class SdfPath>;
29
31
34
41{
42public:
45
49 HD_API
51 const HdSceneIndexBaseRefPtr &sceneIndex,
52 const SdfPathExpression &expr);
53
57 HD_API
59 const HdSceneIndexBaseRefPtr &sceneIndex,
60 const SdfPathExpression &expr,
61 const HdCollectionPredicateLibrary &predicateLib);
62
65 bool IsEmpty() const {
66 return !_sceneIndex || _eval.IsEmpty();
67 }
68
71 HdSceneIndexBaseRefPtr
72 GetSceneIndex() const {
73 return _sceneIndex;
74 }
75
79 HD_API
81 Match(const SdfPath &path) const;
82
92 HD_API
93 void
95 const SdfPath &rootPath,
96 SdfPathVector * const result) const;
97
112 MatchAll,
113 ShallowestMatches,
114 ShallowestMatchesAndAllDescendants
115 };
116
141 HD_API
142 void
144 const SdfPath &rootPath,
145 MatchKind matchKind,
146 SdfPathVector * const result) const;
147
148private:
149 HdSceneIndexBaseRefPtr _sceneIndex;
150
152 _PrimEvaluator _eval;
153};
154
155
156PXR_NAMESPACE_CLOSE_SCOPE
157
158#endif // PXR_IMAGING_HD_COLLECTION_EXPRESSION_EVALUATOR_H
Evaluates SdfPathExpressions with prims from a given HdSceneIndex.
HdSceneIndexBaseRefPtr GetSceneIndex() const
Returns the scene index provided during construction, or nullptr if it was default constructed.
HD_API HdCollectionExpressionEvaluator(const HdSceneIndexBaseRefPtr &sceneIndex, const SdfPathExpression &expr, const HdCollectionPredicateLibrary &predicateLib)
Constructs an evaluator that evaluates expr on prims from sceneIndex using the predicates in predicat...
HD_API HdCollectionExpressionEvaluator(const HdSceneIndexBaseRefPtr &sceneIndex, const SdfPathExpression &expr)
Constructs an evaluator that evaluates expr on prims from sceneIndex using the predicates in HdGetCol...
HD_API void PopulateMatches(const SdfPath &rootPath, MatchKind matchKind, SdfPathVector *const result) const
Utility that uses matchKind to configure the paths returned by result when evaluating the expression ...
HdCollectionExpressionEvaluator()=default
Default c'tor. Constructs an empty evaluator.
HD_API SdfPredicateFunctionResult Match(const SdfPath &path) const
Returns the result of evaluating the expression (provided on construction) against the scene index pr...
bool IsEmpty() const
Returns true if the evaluator has an invalid scene index or an empty underlying SdfPathExpressionEval...
MatchKind
Option to configure the paths returned by PopulateMatches.
HD_API void PopulateAllMatches(const SdfPath &rootPath, SdfPathVector *const result) const
Updates result with the paths of all prims in the subtree at rootPath (including rootPath) that match...
Abstract interface to scene data.
Definition: sceneIndex.h:54
Objects of this class represent a logical expression syntax tree consisting of SdfPathPattern s,...
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Represents the result of a predicate function: a pair of the boolean result and a Constancy token ind...
Represents a library of predicate functions for use with SdfPredicateExpression.
Standard pointer typedefs.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:72
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:35