HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
composeSite.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_PCP_COMPOSE_SITE_H
8 #define PXR_USD_PCP_COMPOSE_SITE_H
9 
10 /// \file pcp/composeSite.h
11 ///
12 /// Single-site composition.
13 ///
14 /// These are helpers that compose specific fields at single sites.
15 /// They compose the field for a given path across a layer stack,
16 /// using field-specific rules to combine the values.
17 ///
18 /// These helpers are low-level utilities used by the rest of the
19 /// Pcp algorithms, to discover composition arcs in scene description.
20 /// These arcs are what guide the algorithm to pull additional
21 /// sites of scene description into the PcpPrimIndex.
22 ///
23 /// Some of these field types support list-editing. (See SdListOp.)
24 /// List-editing for these fields is applied across the fixed domain
25 /// of a single site; you cannot apply list-ops across sites.
26 /// The intention is to avoid subtle ordering issues in composition
27 /// semantics.
28 ///
29 /// Note that these helpers do not take PcpSite as a literal parameter;
30 /// instead, they require the actual computed layer stack that a site
31 /// identified. Rather than tying these helpers to PcpCache and its
32 /// process of computing layer stacks, they just employ the result.
33 /// Conceptually, though, they are operating on the scene description
34 /// identified by a PcpSite.
35 
36 #include "pxr/pxr.h"
37 #include "pxr/usd/pcp/api.h"
38 #include "pxr/usd/pcp/errors.h"
39 #include "pxr/usd/pcp/node.h"
41 #include "pxr/usd/sdf/path.h"
42 #include "pxr/usd/sdf/payload.h"
43 #include "pxr/usd/sdf/reference.h"
44 #include "pxr/usd/sdf/types.h"
45 #include "pxr/usd/sdf/site.h"
46 
47 #include <set>
48 #include <string>
49 #include <unordered_set>
50 #include <vector>
51 
53 
55 
56 class PcpLayerStackSite;
57 
58 /// \struct PcpArcInfo
59 ///
60 /// Helper information about an arc. All arcs have a
61 /// layer that the arc comes from. References and payloads
62 /// supply an authored asset path as well.
63 ///
64 struct PcpArcInfo {
65  SdfLayerHandle sourceLayer;
67  std::string authoredAssetPath;
68  int arcNum;
69 };
70 
71 /// A vector of reference or payload arc information.
72 typedef std::vector<PcpArcInfo> PcpArcInfoVector;
73 
74 /// References
75 PCP_API
76 void
78  PcpLayerStackRefPtr const &layerStack,
79  SdfPath const &path,
81  PcpArcInfoVector *info,
82  std::unordered_set<std::string> *exprVarDependencies,
83  PcpErrorVector *errors);
84 
85 inline void
87  PcpLayerStackRefPtr const &layerStack,
88  SdfPath const &path,
90  PcpArcInfoVector *info)
91 {
93  layerStack, path, result, info, nullptr , nullptr);
94 }
95 
96 inline void
98  PcpNodeRef const &node,
100  PcpArcInfoVector *info,
101  std::unordered_set<std::string> *exprVarDependencies,
102  PcpErrorVector *errors)
103 {
105  node.GetLayerStack(), node.GetPath(),
106  result, info, exprVarDependencies, errors);
107 }
108 
109 inline void
111  PcpNodeRef const &node,
113  PcpArcInfoVector *info)
114 {
116  node.GetLayerStack(), node.GetPath(), result, info, nullptr, nullptr);
117 }
118 
119 /// Payloads
120 PCP_API
121 void
123  PcpLayerStackRefPtr const &layerStack,
124  SdfPath const &path,
126  PcpArcInfoVector *info,
127  std::unordered_set<std::string> *exprVarDependencies,
128  PcpErrorVector *errors);
129 
130 inline void
132  PcpLayerStackRefPtr const &layerStack,
133  SdfPath const &path,
135  PcpArcInfoVector *info)
136 {
137  return PcpComposeSitePayloads(
138  layerStack, path, result, info, nullptr, nullptr);
139 }
140 
141 inline void
143  PcpNodeRef const &node,
145  PcpArcInfoVector *info,
146  std::unordered_set<std::string> *exprVarDependencies,
147  PcpErrorVector *errors)
148 {
149  return PcpComposeSitePayloads(
150  node.GetLayerStack(), node.GetPath(),
151  result, info, exprVarDependencies, errors);
152 }
153 
154 inline void
156  PcpNodeRef const &node,
158  PcpArcInfoVector *info)
159 {
160  return PcpComposeSitePayloads(
161  node.GetLayerStack(), node.GetPath(), result, info, nullptr, nullptr);
162 }
163 
164 /// Permission
165 PCP_API
167 PcpComposeSitePermission(PcpLayerStackRefPtr const &layerStack,
168  SdfPath const &path);
169 
170 inline SdfPermission
172 {
173  return PcpComposeSitePermission(node.GetLayerStack(), node.GetPath());
174 }
175 
176 /// Prim sites
177 PCP_API
178 void
179 PcpComposeSitePrimSites(PcpLayerStackRefPtr const &layerStack,
180  SdfPath const &path,
182 
183 inline void
185 {
187  node.GetLayerStack(), node.GetPath(), result);
188 }
189 
190 /// Relocates
191 PCP_API
192 void
193 PcpComposeSiteRelocates(PcpLayerStackRefPtr const &layerStack,
194  SdfPath const &path,
196 
197 inline void
199 {
201  node.GetLayerStack(), node.GetPath(), result);
202 }
203 
204 /// Has prim specs.
205 PCP_API
206 bool
207 PcpComposeSiteHasPrimSpecs(PcpLayerStackRefPtr const &layerStack,
208  SdfPath const &path,
209  const std::unordered_set<SdfLayerHandle, TfHash>&
210  layersToIgnore);
211 
212 PCP_API
213 bool
214 PcpComposeSiteHasPrimSpecs(PcpLayerStackRefPtr const &layerStack,
215  SdfPath const &path);
216 
217 inline bool
219 {
220  return PcpComposeSiteHasPrimSpecs(node.GetLayerStack(), node.GetPath());
221 }
222 
223 /// Symmetry
224 PCP_API
225 bool
226 PcpComposeSiteHasSymmetry(PcpLayerStackRefPtr const &layerStack,
227  SdfPath const &path);
228 inline bool
230 {
231  return PcpComposeSiteHasSymmetry(node.GetLayerStack(), node.GetPath());
232 }
233 
234 /// Inherits
235 PCP_API
236 void
237 PcpComposeSiteInherits(PcpLayerStackRefPtr const &layerStack,
238  SdfPath const &path, SdfPathVector *result,
239  PcpArcInfoVector *info);
240 
241 PCP_API
242 void
243 PcpComposeSiteInherits(PcpLayerStackRefPtr const &layerStack,
244  SdfPath const &path, SdfPathVector *result);
245 
246 inline void
248 {
249  return PcpComposeSiteInherits(node.GetLayerStack(), node.GetPath(), result);
250 }
251 
252 /// Specializes
253 PCP_API
254 void
255 PcpComposeSiteSpecializes(PcpLayerStackRefPtr const &layerStack,
256  SdfPath const &path, SdfPathVector *result,
257  PcpArcInfoVector *info);
258 
259 PCP_API
260 void
261 PcpComposeSiteSpecializes(PcpLayerStackRefPtr const &layerStack,
262  SdfPath const &path, SdfPathVector *result);
263 
264 inline void
266 {
268  node.GetLayerStack(), node.GetPath(), result);
269 }
270 
271 /// VariantSets
272 PCP_API
273 void
274 PcpComposeSiteVariantSets(PcpLayerStackRefPtr const &layerStack,
275  SdfPath const &path,
276  std::vector<std::string> *result,
277  PcpArcInfoVector *info);
278 
279 PCP_API
280 void
281 PcpComposeSiteVariantSets(PcpLayerStackRefPtr const &layerStack,
282  SdfPath const &path,
283  std::vector<std::string> *result);
284 inline void
286  std::vector<std::string> *result) {
288  node.GetLayerStack(), node.GetPath(), result);
289 }
290 
291 /// VariantSetOptions
292 PCP_API
293 void
294 PcpComposeSiteVariantSetOptions(PcpLayerStackRefPtr const &layerStack,
295  SdfPath const &path,
296  std::string const &vsetName,
297  std::set<std::string> *result);
298 inline void
300  std::string const &vsetName,
301  std::set<std::string> *result)
302 {
304  node.GetLayerStack(), node.GetPath(), vsetName, result);
305 }
306 
307 /// VariantSelection
308 PCP_API
309 bool
311  PcpLayerStackRefPtr const &layerStack,
312  SdfPath const &path,
313  std::string const &vsetName,
314  std::string *result,
315  std::unordered_set<std::string> *exprVarDependencies,
316  PcpErrorVector *errors);
317 
318 inline bool
320  PcpLayerStackRefPtr const &layerStack,
321  SdfPath const &path,
322  std::string const &vsetName,
323  std::string *result)
324 {
326  layerStack, path, vsetName, result, nullptr, nullptr);
327 }
328 
329 inline bool
331  std::string const &vsetName,
332  std::string *result)
333 {
335  node.GetLayerStack(), node.GetPath(), vsetName, result);
336 }
337 
338 /// VariantSelections
339 PCP_API
340 void
342  PcpLayerStackRefPtr const &layerStack,
343  SdfPath const &path,
345  std::unordered_set<std::string> *exprVarDependencies,
346  PcpErrorVector *errors);
347 
348 inline void
350  PcpLayerStackRefPtr const &layerStack,
351  SdfPath const &path,
353 {
355  layerStack, path, result, nullptr, nullptr);
356 }
357 
358 inline void
361 {
363  node.GetLayerStack(), node.GetPath(), result);
364 }
365 
366 PCP_API
367 bool
369  PcpLayerStackRefPtr const &layerStack,
370  SdfPath const &path);
371 
372 /// Compose child names.
373 /// If the optional \p orderField is provided, its order will be applied.
374 PCP_API
375 void
377  SdfPath const &path,
378  const TfToken & namesField,
379  TfTokenVector *nameOrder,
380  PcpTokenSet *nameSet,
381  const TfToken *orderField = nullptr);
382 
384 
385 #endif // PXR_USD_PCP_COMPOSE_SITE_H
std::vector< PcpArcInfo > PcpArcInfoVector
A vector of reference or payload arc information.
Definition: composeSite.h:72
PCP_API void PcpComposeSiteVariantSets(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, std::vector< std::string > *result, PcpArcInfoVector *info)
VariantSets.
std::vector< SdfPayload > SdfPayloadVector
Definition: payload.h:25
std::map< SdfPath, SdfPath > SdfRelocatesMap
A map of source SdfPaths to target SdfPaths for relocation.
Definition: types.h:267
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
std::vector< SdfSite > SdfSiteVector
Definition: site.h:80
std::map< std::string, std::string > SdfVariantSelectionMap
A map of reference variant set names to variants in those sets.
Definition: types.h:258
PCP_API void PcpComposeSiteChildNames(SdfLayerRefPtrVector const &layers, SdfPath const &path, const TfToken &namesField, TfTokenVector *nameOrder, PcpTokenSet *nameSet, const TfToken *orderField=nullptr)
**But if you need a result
Definition: thread.h:622
PCP_API bool PcpComposeSiteHasSymmetry(PcpLayerStackRefPtr const &layerStack, SdfPath const &path)
Symmetry.
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_AND_REF_PTRS(PcpLayerStack)
PCP_API void PcpComposeSitePayloads(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfPayloadVector *result, PcpArcInfoVector *info, std::unordered_set< std::string > *exprVarDependencies, PcpErrorVector *errors)
Payloads.
Definition: token.h:70
std::vector< TfRefPtr< SdfLayer > > SdfLayerRefPtrVector
std::vector< class SdfPath > SdfPathVector
PCP_API void PcpComposeSitePrimSites(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfSiteVector *result)
Prim sites.
PCP_API const SdfPath & GetPath() const
Returns the path for the site this node represents.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
PCP_API void PcpComposeSiteVariantSetOptions(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, std::string const &vsetName, std::set< std::string > *result)
VariantSetOptions.
Definition: path.h:273
std::vector< PcpErrorBasePtr > PcpErrorVector
Definition: errors.h:65
PCP_API const PcpLayerStackRefPtr & GetLayerStack() const
Returns the layer stack for the site this node represents.
SdfLayerHandle sourceLayer
Definition: composeSite.h:65
PCP_API bool PcpComposeSiteHasVariantSelections(PcpLayerStackRefPtr const &layerStack, SdfPath const &path)
std::vector< SdfReference > SdfReferenceVector
Definition: reference.h:27
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
SdfLayerOffset sourceLayerStackOffset
Definition: composeSite.h:66
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
PCP_API void PcpComposeSiteRelocates(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfRelocatesMap *result)
Relocates.
PCP_API void PcpComposeSiteInherits(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfPathVector *result, PcpArcInfoVector *info)
Inherits.
PCP_API bool PcpComposeSiteVariantSelection(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, std::string const &vsetName, std::string *result, std::unordered_set< std::string > *exprVarDependencies, PcpErrorVector *errors)
VariantSelection.
PCP_API bool PcpComposeSiteHasPrimSpecs(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, const std::unordered_set< SdfLayerHandle, TfHash > &layersToIgnore)
Has prim specs.
PCP_API void PcpComposeSiteVariantSelections(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfVariantSelectionMap *result, std::unordered_set< std::string > *exprVarDependencies, PcpErrorVector *errors)
VariantSelections.
std::string authoredAssetPath
Definition: composeSite.h:67
PCP_API SdfPermission PcpComposeSitePermission(PcpLayerStackRefPtr const &layerStack, SdfPath const &path)
Permission.
PCP_API void PcpComposeSiteSpecializes(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfPathVector *result, PcpArcInfoVector *info)
Specializes.
PCP_API void PcpComposeSiteReferences(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfReferenceVector *result, PcpArcInfoVector *info, std::unordered_set< std::string > *exprVarDependencies, PcpErrorVector *errors)
References.
SdfPermission
Definition: types.h:132
#define PCP_API
Definition: api.h:23