HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XUSD_PathPattern.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __XUSD_PathPattern_h__
19 #define __XUSD_PathPattern_h__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_PathPattern.h"
23 #include "HUSD_TimeCode.h"
24 #include "XUSD_AutoCollection.h"
25 #include "XUSD_PathSet.h"
26 #include <UT/UT_Array.h>
27 #include <UT/UT_StringMap.h>
29 #include <pxr/usd/sdf/path.h>
30 
32 
33 // Match payload carrying the set of matched point instancer instance ids for
34 // a single instancer path. These are combined by the path pattern's set
35 // operators (union, intersect, difference) so that instance selections support
36 // the same algebra as primitive selections.
37 //
38 // INVARIANT: myInstanceIds is always sorted in ascending order and free of
39 // duplicates. This follows from the INSTANCE ID CONTRACT documented on the
40 // auto-collection match methods (see XUSD_AutoCollection.h) - every producer of
41 // an instance id set (auto collections, the [...] leaf/whole-instancer helpers,
42 // and combineMatchData itself) yields sorted, duplicate-free ids - and
43 // XUSD_PathPattern::combineMatchData relies on it to combine two payloads with a
44 // linear sorted merge rather than building intermediate sets.
46 {
47 public:
49  { }
51  { }
52 
54 };
55 
57 {
58 public:
60  : myInitialized(false),
61  myMayBeTimeVarying(false)
62  { }
64  { }
65 
70  // Per-path instance ids precomputed at construction by non-random-access
71  // auto collections (via matchPrimitives). Written once at construction,
72  // then read-only during matching, so no thread-specific storage is needed.
76 };
77 
78 // Match an instance-id pattern against a point instancer prim, returning the
79 // matched semantic instance ids (from the instancer's 'ids' attribute). The
80 // pattern supports numeric ranges, '*', '^' exclusions, and '{vexpr}' blocks.
81 // Returns true if any ids matched.
83  const UT_StringRef &pattern,
84  const UsdPrim &instancer_prim,
85  const HUSD_TimeCode &timecode,
86  UT_Array<int64> &matched_ids);
87 
89 {
90 public:
91  // Clone-only constructor (see the HUSD_PathPattern equivalent): no lock or
92  // time code, so the result is for boolean path matching only and must not
93  // be used to collect point-instance ids.
94  XUSD_PathPattern(bool case_sensitive,
95  bool assume_wildcards,
96  bool allow_instance_indices);
98  HUSD_AutoAnyLock &lock,
100  bool case_sensitive,
101  bool assume_wildcards,
102  bool allow_instance_indices,
103  int nodeid,
104  const HUSD_TimeCode &timecode);
105  ~XUSD_PathPattern() override;
106 
107  void getSpecialTokenPaths(SdfPathSet &collection_paths,
108  SdfPathSet &collection_expanded_paths,
109  SdfPathSet &collectionless_paths) const;
110 
111  const UT_Array<Token> &getTokens() const
112  { return myTokens; }
113 
114  const HUSD_TimeCode &timeCode() const
115  { return myTimeCode; }
116 
117 private:
118  HUSD_TimeCode myTimeCode;
119 };
120 
122 
123 #endif
124 
~XUSD_SpecialTokenData() override
UT_Array< int64 > myInstanceIds
XUSD_PathSet myCollectionExpandedPathSet
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
#define HUSD_API
Definition: HUSD_API.h:31
XUSD_PathSet myCollectionPathSet
HUSD_PrimTraversalDemands
Definition: HUSD_Utils.h:39
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
const HUSD_TimeCode & timeCode() const
UT_Array< Token > myTokens
const UT_Array< Token > & getTokens() const
XUSD_PathSet myCollectionlessPathSet
Definition: prim.h:116
GLushort pattern
Definition: glad.h:2583
std::set< class SdfPath > SdfPathSet
A set of SdfPaths.
Definition: path.h:199
UT_StringMap< UT_Array< int64 > > myMatchedInstanceIds
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
~XUSD_InstanceMatchData() override
UT_UniquePtr< XUSD_AutoCollection > myRandomAccessAutoCollection
HUSD_API bool XUSDmatchPointInstanceIds(HUSD_AutoAnyLock &lock, const UT_StringRef &pattern, const UsdPrim &instancer_prim, const HUSD_TimeCode &timecode, UT_Array< int64 > &matched_ids)