HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_FindPrims.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 __HUSD_FindPrims_h__
19 #define __HUSD_FindPrims_h__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_DataHandle.h"
23 #include "HUSD_Utils.h"
24 #include <OP/OP_ItemId.h>
25 #include <UT/UT_BoundingBox.h>
26 #include <UT/UT_StringMap.h>
27 #include <UT/UT_StringArray.h>
28 #include <UT/UT_UniquePtr.h>
29 #include <UT/UT_VectorTypes.h>
30 #include <SYS/SYS_Types.h>
31 #include <pxr/pxr.h>
32 
34 class XUSD_PathPattern;
36 
37 class HUSD_PathSet;
38 class HUSD_TimeCode;
39 template <typename T> class UT_Array;
40 
42 {
43 public:
47  bool find_point_instancer_ids = false);
48  // Simple constructors when you just want to operate
49  // on one or an array of primitives and you know the
50  // paths.
52  const UT_StringRef &primpath,
56  const UT_StringArray &primpaths,
60  const HUSD_PathSet &primpaths,
63  ~HUSD_FindPrims();
64 
69  BBOX_PARTIALLY_OUTSIDE
70  };
71 
72  const HUSD_PathSet &getExpandedPathSet() const;
73  const HUSD_PathSet &getCollectionAwarePathSet() const;
74  const HUSD_PathSet &getExcludedPathSet(bool skipdescendants) const;
75  const HUSD_PathSet &getMissingExplicitPathSet() const;
76  const HUSD_PathSet &getExpandedOrMissingExplicitPathSet() const;
77 
78  void setTraversalDemands(HUSD_PrimTraversalDemands demands);
79  HUSD_PrimTraversalDemands traversalDemands() const;
80  void setAssumeWildcardsAroundPlainTokens(bool assume);
81  bool assumeWildcardsAroundPlainTokens() const;
82  void setTrackMissingExplicitPrimitives(bool track_missing);
83  bool trackMissingExplicitPrimitives() const;
84  void setWarnMissingExplicitPrimitives(bool warn_missing);
85  bool warnMissingExplicitPrimitives() const;
86  void setCaseSensitive(bool casesensitive);
87  bool caseSensitive() const;
88 
89  // Add a specific set of primitive paths or collection paths to our data.
90  bool addPaths(const HUSD_PathSet &paths);
91  // Evaluate the supplied pattern and add the resulting primitives and
92  // collections to our data.
93  bool addPattern(const UT_StringRef &pattern,
94  int nodeid,
95  const HUSD_TimeCode &timecode);
96  // Evaluate the supplied USD path expression and add the resulting
97  // primitives to our data.
98  bool addPathExpression(const UT_StringRef &path_expr);
99 
100  // These functions exist for use by the Prune node and Collection::1.0
101  // LOPs which used a multiparm for determining prim membership instead
102  // of the single path pattern used everywhere else.
103  bool addPrimitiveType(const UT_StringRef &primtype);
104  bool addPrimitiveKind(const UT_StringRef &primkind);
105  bool addPrimitivePurpose(const UT_StringRef &primpurpose);
106  bool addVexpression(const UT_StringRef &vexpression,
107  int nodeid,
108  const HUSD_TimeCode &timecode) const;
109  bool addBoundingBox(const UT_BoundingBox &bbox,
110  const HUSD_TimeCode &t,
111  const UT_StringArray &purposes,
112  BBoxContainment containment);
113  bool addDescendants();
114  bool addAncestors();
115 
117  &getPointInstancerIds() const;
118  bool getExcludedPointInstancerIds(
119  UT_StringMap<UT_Array<int64>> &excludedids,
120  const HUSD_TimeCode &timecode) const;
121 
122  bool getIsEmpty() const;
123  bool getFindPointInstancerIds() const;
124  bool getIsTimeVarying() const;
125  bool allowInstanceProxies() const;
126 
127  /// Generally speaking, HUSD_FindPrims will never return the
128  /// HoudiniLayerInfo prim. But there are some circumstances where we
129  /// may wish to allow it.
130  void setAllowHoudiniLayerInfo(bool allow);
131  bool allowHoudiniLayerInfo() const;
132 
133  /// Returns a collection path, if only a single collection was added.
134  /// Returns an empty string, if primitive target consists of more than
135  /// a single collection.
136  UT_StringHolder getSingleCollectionPath() const;
137 
138  /// Returns the path to the most nested primitive that is the shared
139  /// root primitive of every primitive in our expanded set. If the shared
140  /// root prim is the absolute root, we return an empty string.
141  UT_StringHolder getSharedRootPrim() const;
142 
143  /// Return a string describing the last error generated by a failed
144  /// call to this object's methods.
146  { return myLastError; }
147 
148  // Creates a prim pattern that executes the supplied path expression.
149  // It is safe to use the same string for th input and output parameters.
150  static bool primPatternFromPathExpression(
151  const UT_StringRef &path_expr,
153  // Creates a path expression if the prim pattern contains only an
154  // invocatino of a path expression auto collection.
155  // It is safe to use the same string for th input and output parameters.
156  static bool pathExpressionFromPrimPattern(
157  const UT_StringRef &pattern,
158  UT_StringHolder &path_expr);
159 
160 private:
161  bool addPattern(const PXR_NS::XUSD_PathPattern &pattern,
162  int nodeid);
163 
164  class husd_FindPrimsPrivate;
165 
167  HUSD_AutoAnyLock &myAnyLock;
168  HUSD_PrimTraversalDemands myDemands;
169  UT_StringHolder myLastError;
170  bool myFindPointInstancerIds;
171  bool myAssumeWildcardsAroundPlainTokens;
172  bool myTrackMissingExplicitPrimitives;
173  bool myWarnMissingExplicitPrimitives;
174  bool myCaseSensitive;
175 };
176 
177 #endif
178 
#define HUSD_API
Definition: HUSD_API.h:31
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
GLushort pattern
Definition: glad.h:2583
GLdouble t
Definition: glad.h:2397
FMT_INLINE void assume(bool condition)
Definition: format.h:535
const UT_StringHolder & getLastError() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74