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 setCaseSensitive(bool casesensitive);
81  bool caseSensitive() const;
82 
83  // Add a specific set of primitive paths or collection paths to our data.
84  bool addPaths(const HUSD_PathSet &paths,
85  bool track_missing_explicit_prims = false);
86  // Evaluate the supplied pattern and add the resulting primitives and
87  // collections to our data.
88  bool addPattern(const UT_StringRef &pattern,
89  int nodeid,
90  const HUSD_TimeCode &timecode,
91  bool track_missing_explicit_prims = false);
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  /// Split the found prims into shade and geo prims.
121  /// The parms control whether materials bound to geo prims are included
122  /// in the shade prims, and if so, whether to include material's surface
123  /// shader rather than material itself, if the material has no interface
124  /// input attributes (ie, is not particularly editable).
125  bool partitionShadePrims(
126  UT_StringArray &shadeprimpaths,
127  UT_StringArray &geoprimpaths,
128  bool include_bound_materials = true,
129  bool use_shader_for_mat_with_no_inputs = true
130  ) const;
131 
132  /// Returns the path to the most nested primitive that is the shared
133  /// root primitive of every primitive in our expanded set. If the shared
134  /// root prim is the absolute root, we return an empty string.
135  UT_StringHolder getSharedRootPrim() const;
136 
137  /// Return a string describing the last error generated by a failed
138  /// call to this object's methods.
140  { return myLastError; }
141 
142 private:
143  bool addPattern(const PXR_NS::XUSD_PathPattern &pattern,
144  int nodeid,
145  bool track_missing_explicit_prims);
146 
147  class husd_FindPrimsPrivate;
148 
150  HUSD_AutoAnyLock &myAnyLock;
151  HUSD_PrimTraversalDemands myDemands;
152  UT_StringHolder myLastError;
153  bool myFindPointInstancerIds;
154  bool myAssumeWildcardsAroundPlainTokens;
155  bool myCaseSensitive;
156 };
157 
158 #endif
159 
#define HUSD_API
Definition: HUSD_API.h:32
HUSD_PrimTraversalDemands
Definition: HUSD_Utils.h:35
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:33
GLubyte * pattern
Definition: glew.h:5741
FMT_INLINE void assume(bool condition)
Definition: format.h:336
const UT_StringHolder & getLastError() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
GLenum const void * paths
Definition: glew.h:13872