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 <pxr/pxr.h>
31 #include <vector>
32 
34 class XUSD_PathPattern;
36 
37 class HUSD_PathSet;
38 class HUSD_TimeCode;
39 
41 {
42 public:
46  bool find_point_instancer_ids = false);
47  // Simple constructors when you just want to operate
48  // on one or an array of primitives and you know the
49  // paths.
51  const UT_StringRef &primpath,
55  const UT_StringArray &primpaths,
59  const HUSD_PathSet &primpaths,
62  ~HUSD_FindPrims();
63 
68  BBOX_PARTIALLY_OUTSIDE
69  };
70 
71  const HUSD_PathSet &getExpandedPathSet() const;
72  const HUSD_PathSet &getCollectionAwarePathSet() const;
73  const HUSD_PathSet &getExcludedPathSet(bool skipdescendants) const;
74  const HUSD_PathSet &getMissingExplicitPathSet() const;
75 
76  void setTraversalDemands(HUSD_PrimTraversalDemands demands);
77  HUSD_PrimTraversalDemands traversalDemands() const;
78  void setAssumeWildcardsAroundPlainTokens(bool assume);
79  bool assumeWildcardsAroundPlainTokens() const;
80  void setTrackMissingExplicitPrimitives(bool track_missing);
81  bool trackMissingExplicitPrimitives() const;
82  void setCaseSensitive(bool casesensitive);
83  bool caseSensitive() const;
84 
85  // Add a specific set of primitive paths or collection paths to our data.
86  bool addPaths(const HUSD_PathSet &paths);
87  // Evaluate the supplied pattern and add the resulting primitives and
88  // collections to our data.
89  bool addPattern(const UT_StringRef &pattern,
90  int nodeid,
91  const HUSD_TimeCode &timecode);
92  bool addPrimitiveType(const UT_StringRef &primtype);
93  bool addPrimitiveKind(const UT_StringRef &primkind);
94  bool addPrimitivePurpose(const UT_StringRef &primpurpose);
95  bool addVexpression(const UT_StringRef &vexpression,
96  int nodeid,
97  const HUSD_TimeCode &timecode) const;
98  bool addBoundingBox(const UT_BoundingBox &bbox,
99  const HUSD_TimeCode &t,
100  const UT_StringArray &purposes,
101  BBoxContainment containment);
102  bool addDescendants();
103  bool addAncestors();
104 
105  const UT_StringMap<UT_Int64Array> &getPointInstancerIds() const;
106  bool getExcludedPointInstancerIds(
107  UT_StringMap<UT_Int64Array> &excludedids,
108  const HUSD_TimeCode &timecode) const;
109 
110  bool getIsEmpty() const;
111  bool getFindPointInstancerIds() const;
112  bool getIsTimeVarying() const;
113  bool allowInstanceProxies() const;
114 
115  /// Returns a collection path, if only a single collection was added.
116  /// Returns an empty string, if primitive target consists of more than
117  /// a single collection.
118  UT_StringHolder getSingleCollectionPath() const;
119 
120  /// Returns the path to the most nested primitive that is the shared
121  /// root primitive of every primitive in our expanded set. If the shared
122  /// root prim is the absolute root, we return an empty string.
123  UT_StringHolder getSharedRootPrim() const;
124 
125  /// Return a string describing the last error generated by a failed
126  /// call to this object's methods.
128  { return myLastError; }
129 
130 private:
131  bool addPattern(const PXR_NS::XUSD_PathPattern &pattern,
132  int nodeid);
133 
134  class husd_FindPrimsPrivate;
135 
137  HUSD_AutoAnyLock &myAnyLock;
138  HUSD_PrimTraversalDemands myDemands;
139  UT_StringHolder myLastError;
140  bool myFindPointInstancerIds;
141  bool myAssumeWildcardsAroundPlainTokens;
142  bool myTrackMissingExplicitPrimitives;
143  bool myCaseSensitive;
144 };
145 
146 #endif
147 
#define HUSD_API
Definition: HUSD_API.h:32
HUSD_PrimTraversalDemands
Definition: HUSD_Utils.h:37
GLdouble GLdouble t
Definition: glew.h:1403
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
GLubyte * pattern
Definition: glew.h:5741
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:1394
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
GLenum const void * paths
Definition: glew.h:13872