Loading...
Searching...
No Matches
collectionExpressionEvaluator.h
1//
2// Copyright 2024 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24
25#ifndef PXR_IMAGING_HD_COLLECTION_EXPRESSION_EVALUATOR_H
26#define PXR_IMAGING_HD_COLLECTION_EXPRESSION_EVALUATOR_H
27
28#include "pxr/pxr.h"
29
30#include "pxr/imaging/hd/api.h"
31
33
34#include "pxr/usd/sdf/pathExpressionEval.h"
35#include "pxr/usd/sdf/predicateLibrary.h"
36
37#include <vector>
38
39PXR_NAMESPACE_OPEN_SCOPE
40
42struct HdSceneIndexPrim;
44
45using SdfPathVector = std::vector<class SdfPath>;
46
48
51
58{
59public:
62
66 HD_API
68 const HdSceneIndexBaseRefPtr &sceneIndex,
69 const SdfPathExpression &expr);
70
74 HD_API
76 const HdSceneIndexBaseRefPtr &sceneIndex,
77 const SdfPathExpression &expr,
78 const HdCollectionPredicateLibrary &predicateLib);
79
82 bool IsEmpty() const {
83 return !_sceneIndex || _eval.IsEmpty();
84 }
85
88 HdSceneIndexBaseRefPtr
89 GetSceneIndex() const {
90 return _sceneIndex;
91 }
92
96 HD_API
98 Match(const SdfPath &path) const;
99
109 HD_API
110 void
112 const SdfPath &rootPath,
113 SdfPathVector * const result) const;
114
129 MatchAll,
130 ShallowestMatches,
131 ShallowestMatchesAndAllDescendants
132 };
133
158 HD_API
159 void
161 const SdfPath &rootPath,
162 MatchKind matchKind,
163 SdfPathVector * const result) const;
164
165private:
166 HdSceneIndexBaseRefPtr _sceneIndex;
167
169 _PrimEvaluator _eval;
170};
171
172
173PXR_NAMESPACE_CLOSE_SCOPE
174
175#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:65
Objects of this class represent a logical expression syntax tree consisting of SdfPath matching patte...
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
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:89
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:52