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  bool addPrimitiveType(const UT_StringRef &primtype);
97  bool addPrimitiveKind(const UT_StringRef &primkind);
98  bool addPrimitivePurpose(const UT_StringRef &primpurpose);
99  bool addVexpression(const UT_StringRef &vexpression,
100  int nodeid,
101  const HUSD_TimeCode &timecode) const;
102  bool addBoundingBox(const UT_BoundingBox &bbox,
103  const HUSD_TimeCode &t,
104  const UT_StringArray &purposes,
105  BBoxContainment containment);
106  bool addDescendants();
107  bool addAncestors();
108 
110  &getPointInstancerIds() const;
111  bool getExcludedPointInstancerIds(
112  UT_StringMap<UT_Array<int64>> &excludedids,
113  const HUSD_TimeCode &timecode) const;
114 
115  bool getIsEmpty() const;
116  bool getFindPointInstancerIds() const;
117  bool getIsTimeVarying() const;
118  bool allowInstanceProxies() const;
119 
120  /// Generally speaking, HUSD_FindPrims will never return the
121  /// HoudiniLayerInfo prim. But there are some circumstances where we
122  /// may wish to allow it.
123  void setAllowHoudiniLayerInfo(bool allow);
124  bool allowHoudiniLayerInfo() const;
125 
126  /// Returns a collection path, if only a single collection was added.
127  /// Returns an empty string, if primitive target consists of more than
128  /// a single collection.
129  UT_StringHolder getSingleCollectionPath() const;
130 
131  /// Returns the path to the most nested primitive that is the shared
132  /// root primitive of every primitive in our expanded set. If the shared
133  /// root prim is the absolute root, we return an empty string.
134  UT_StringHolder getSharedRootPrim() const;
135 
136  /// Return a string describing the last error generated by a failed
137  /// call to this object's methods.
139  { return myLastError; }
140 
141 private:
142  bool addPattern(const PXR_NS::XUSD_PathPattern &pattern,
143  int nodeid);
144 
145  class husd_FindPrimsPrivate;
146 
148  HUSD_AutoAnyLock &myAnyLock;
149  HUSD_PrimTraversalDemands myDemands;
150  UT_StringHolder myLastError;
151  bool myFindPointInstancerIds;
152  bool myAssumeWildcardsAroundPlainTokens;
153  bool myTrackMissingExplicitPrimitives;
154  bool myWarnMissingExplicitPrimitives;
155  bool myCaseSensitive;
156 };
157 
158 #endif
159 
#define HUSD_API
Definition: HUSD_API.h:32
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:317
const UT_StringHolder & getLastError() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91