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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_PCP_COMPOSE_SITE_H
25 #define PXR_USD_PCP_COMPOSE_SITE_H
26 
27 /// \file pcp/composeSite.h
28 ///
29 /// Single-site composition.
30 ///
31 /// These are helpers that compose specific fields at single sites.
32 /// They compose the field for a given path across a layer stack,
33 /// using field-specific rules to combine the values.
34 ///
35 /// These helpers are low-level utilities used by the rest of the
36 /// Pcp algorithms, to discover composition arcs in scene description.
37 /// These arcs are what guide the algorithm to pull additional
38 /// sites of scene description into the PcpPrimIndex.
39 ///
40 /// Some of these field types support list-editing. (See SdListOp.)
41 /// List-editing for these fields is applied across the fixed domain
42 /// of a single site; you cannot apply list-ops across sites.
43 /// The intention is to avoid subtle ordering issues in composition
44 /// semantics.
45 ///
46 /// Note that these helpers do not take PcpSite as a literal parameter;
47 /// instead, they require the actual computed layer stack that a site
48 /// identified. Rather than tying these helpers to PcpCache and its
49 /// process of computing layer stacks, they just employ the result.
50 /// Conceptually, though, they are operating on the scene description
51 /// identified by a PcpSite.
52 
53 #include "pxr/pxr.h"
54 #include "pxr/usd/pcp/api.h"
55 #include "pxr/usd/pcp/errors.h"
56 #include "pxr/usd/pcp/node.h"
58 #include "pxr/usd/sdf/path.h"
59 #include "pxr/usd/sdf/payload.h"
60 #include "pxr/usd/sdf/reference.h"
61 #include "pxr/usd/sdf/types.h"
62 #include "pxr/usd/sdf/site.h"
63 
64 #include <set>
65 #include <string>
66 #include <unordered_set>
67 #include <vector>
68 
70 
72 
73 class PcpLayerStackSite;
74 
75 /// \struct PcpSourceArcInfo
76 ///
77 /// Information about the source of the target of an arc.
78 /// All arcs have a layer that the arc comes from. References and payloads
79 /// supply an authored asset path as well.
80 ///
82  SdfLayerHandle layer;
85 };
86 
87 /// A vector of reference or payload arc information.
88 typedef std::vector<PcpSourceArcInfo> PcpSourceArcInfoVector;
89 
90 /// References
91 PCP_API
92 void
94  PcpLayerStackRefPtr const &layerStack,
95  SdfPath const &path,
98  std::unordered_set<std::string> *exprVarDependencies,
99  PcpErrorVector *errors);
100 
101 inline void
103  PcpLayerStackRefPtr const &layerStack,
104  SdfPath const &path,
107 {
109  layerStack, path, result, info, nullptr , nullptr);
110 }
111 
112 inline void
114  PcpNodeRef const &node,
117  std::unordered_set<std::string> *exprVarDependencies,
118  PcpErrorVector *errors)
119 {
121  node.GetLayerStack(), node.GetPath(),
122  result, info, exprVarDependencies, errors);
123 }
124 
125 inline void
127  PcpNodeRef const &node,
130 {
132  node.GetLayerStack(), node.GetPath(), result, info, nullptr, nullptr);
133 }
134 
135 /// Payloads
136 PCP_API
137 void
139  PcpLayerStackRefPtr const &layerStack,
140  SdfPath const &path,
143  std::unordered_set<std::string> *exprVarDependencies,
144  PcpErrorVector *errors);
145 
146 inline void
148  PcpLayerStackRefPtr const &layerStack,
149  SdfPath const &path,
152 {
153  return PcpComposeSitePayloads(
154  layerStack, path, result, info, nullptr, nullptr);
155 }
156 
157 inline void
159  PcpNodeRef const &node,
162  std::unordered_set<std::string> *exprVarDependencies,
163  PcpErrorVector *errors)
164 {
165  return PcpComposeSitePayloads(
166  node.GetLayerStack(), node.GetPath(),
167  result, info, exprVarDependencies, errors);
168 }
169 
170 inline void
172  PcpNodeRef const &node,
175 {
176  return PcpComposeSitePayloads(
177  node.GetLayerStack(), node.GetPath(), result, info, nullptr, nullptr);
178 }
179 
180 /// Permission
181 PCP_API
183 PcpComposeSitePermission(PcpLayerStackRefPtr const &layerStack,
184  SdfPath const &path);
185 
186 inline SdfPermission
188 {
189  return PcpComposeSitePermission(node.GetLayerStack(), node.GetPath());
190 }
191 
192 /// Prim sites
193 PCP_API
194 void
195 PcpComposeSitePrimSites(PcpLayerStackRefPtr const &layerStack,
196  SdfPath const &path,
198 
199 inline void
201 {
203  node.GetLayerStack(), node.GetPath(), result);
204 }
205 
206 /// Relocates
207 PCP_API
208 void
209 PcpComposeSiteRelocates(PcpLayerStackRefPtr const &layerStack,
210  SdfPath const &path,
212 
213 inline void
215 {
217  node.GetLayerStack(), node.GetPath(), result);
218 }
219 
220 /// Has prim specs.
221 PCP_API
222 bool
223 PcpComposeSiteHasPrimSpecs(PcpLayerStackRefPtr const &layerStack,
224  SdfPath const &path);
225 inline bool
227 {
228  return PcpComposeSiteHasPrimSpecs(node.GetLayerStack(), node.GetPath());
229 }
230 
231 /// Symmetry
232 PCP_API
233 bool
234 PcpComposeSiteHasSymmetry(PcpLayerStackRefPtr const &layerStack,
235  SdfPath const &path);
236 inline bool
238 {
239  return PcpComposeSiteHasSymmetry(node.GetLayerStack(), node.GetPath());
240 }
241 
242 /// Inherits
243 PCP_API
244 void
245 PcpComposeSiteInherits(PcpLayerStackRefPtr const &layerStack,
246  SdfPath const &path, SdfPathVector *result,
247  PcpSourceArcInfoVector *info);
248 
249 PCP_API
250 void
251 PcpComposeSiteInherits(PcpLayerStackRefPtr const &layerStack,
252  SdfPath const &path, SdfPathVector *result);
253 
254 inline void
256 {
257  return PcpComposeSiteInherits(node.GetLayerStack(), node.GetPath(), result);
258 }
259 
260 /// Specializes
261 PCP_API
262 void
263 PcpComposeSiteSpecializes(PcpLayerStackRefPtr const &layerStack,
264  SdfPath const &path, SdfPathVector *result,
265  PcpSourceArcInfoVector *info);
266 
267 PCP_API
268 void
269 PcpComposeSiteSpecializes(PcpLayerStackRefPtr const &layerStack,
270  SdfPath const &path, SdfPathVector *result);
271 
272 inline void
274 {
276  node.GetLayerStack(), node.GetPath(), result);
277 }
278 
279 /// VariantSets
280 PCP_API
281 void
282 PcpComposeSiteVariantSets(PcpLayerStackRefPtr const &layerStack,
283  SdfPath const &path,
284  std::vector<std::string> *result,
285  PcpSourceArcInfoVector *info);
286 
287 PCP_API
288 void
289 PcpComposeSiteVariantSets(PcpLayerStackRefPtr const &layerStack,
290  SdfPath const &path,
291  std::vector<std::string> *result);
292 inline void
294  std::vector<std::string> *result) {
296  node.GetLayerStack(), node.GetPath(), result);
297 }
298 
299 /// VariantSetOptions
300 PCP_API
301 void
302 PcpComposeSiteVariantSetOptions(PcpLayerStackRefPtr const &layerStack,
303  SdfPath const &path,
304  std::string const &vsetName,
305  std::set<std::string> *result);
306 inline void
308  std::string const &vsetName,
309  std::set<std::string> *result)
310 {
312  node.GetLayerStack(), node.GetPath(), vsetName, result);
313 }
314 
315 /// VariantSelection
316 PCP_API
317 bool
319  PcpLayerStackRefPtr const &layerStack,
320  SdfPath const &path,
321  std::string const &vsetName,
323  std::unordered_set<std::string> *exprVarDependencies,
324  PcpErrorVector *errors);
325 
326 inline bool
328  PcpLayerStackRefPtr const &layerStack,
329  SdfPath const &path,
330  std::string const &vsetName,
332 {
334  layerStack, path, vsetName, result, nullptr, nullptr);
335 }
336 
337 inline bool
339  std::string const &vsetName,
341 {
343  node.GetLayerStack(), node.GetPath(), vsetName, result);
344 }
345 
346 /// VariantSelections
347 PCP_API
348 void
350  PcpLayerStackRefPtr const &layerStack,
351  SdfPath const &path,
353  std::unordered_set<std::string> *exprVarDependencies,
354  PcpErrorVector *errors);
355 
356 inline void
358  PcpLayerStackRefPtr const &layerStack,
359  SdfPath const &path,
361 {
363  layerStack, path, result, nullptr, nullptr);
364 }
365 
366 inline void
369 {
371  node.GetLayerStack(), node.GetPath(), result);
372 }
373 
374 /// Compose child names.
375 /// If the optional \p orderField is provided, its order will be applied.
376 PCP_API
377 void
379  SdfPath const &path,
380  const TfToken & namesField,
381  TfTokenVector *nameOrder,
382  PcpTokenSet *nameSet,
383  const TfToken *orderField = nullptr);
384 
386 
387 #endif // PXR_USD_PCP_COMPOSE_SITE_H
PCP_API void PcpComposeSiteReferences(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfReferenceVector *result, PcpSourceArcInfoVector *info, std::unordered_set< std::string > *exprVarDependencies, PcpErrorVector *errors)
References.
std::vector< SdfPayload > SdfPayloadVector
Definition: payload.h:44
std::map< SdfPath, SdfPath > SdfRelocatesMap
A map of source SdfPaths to target SdfPaths for relocation.
Definition: types.h:292
std::string authoredAssetPath
Definition: composeSite.h:84
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
std::vector< SdfSite > SdfSiteVector
Definition: site.h:79
std::map< std::string, std::string > SdfVariantSelectionMap
A map of reference variant set names to variants in those sets.
Definition: types.h:283
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:613
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 PcpComposeSiteInherits(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfPathVector *result, PcpSourceArcInfoVector *info)
Inherits.
PCP_API void PcpComposeSiteSpecializes(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfPathVector *result, PcpSourceArcInfoVector *info)
Specializes.
Definition: token.h:87
std::vector< TfRefPtr< SdfLayer > > SdfLayerRefPtrVector
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:442
SdfLayerHandle layer
Definition: composeSite.h:82
std::vector< PcpSourceArcInfo > PcpSourceArcInfoVector
A vector of reference or payload arc information.
Definition: composeSite.h:88
PCP_API void PcpComposeSiteVariantSetOptions(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, std::string const &vsetName, std::set< std::string > *result)
VariantSetOptions.
Definition: path.h:291
std::vector< class SdfPath > SdfPathVector
A vector of SdfPaths.
Definition: path.h:212
std::vector< PcpErrorBasePtr > PcpErrorVector
Definition: errors.h:78
PCP_API const PcpLayerStackRefPtr & GetLayerStack() const
Returns the layer stack for the site this node represents.
std::vector< SdfReference > SdfReferenceVector
Definition: reference.h:44
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
PCP_API void PcpComposeSitePayloads(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfPayloadVector *result, PcpSourceArcInfoVector *info, std::unordered_set< std::string > *exprVarDependencies, PcpErrorVector *errors)
Payloads.
PCP_API void PcpComposeSiteVariantSets(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, std::vector< std::string > *result, PcpSourceArcInfoVector *info)
VariantSets.
PCP_API bool PcpComposeSiteHasPrimSpecs(PcpLayerStackRefPtr const &layerStack, SdfPath const &path)
Has prim specs.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
PCP_API void PcpComposeSiteRelocates(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfRelocatesMap *result)
Relocates.
SdfLayerOffset layerStackOffset
Definition: composeSite.h:83
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 void PcpComposeSiteVariantSelections(PcpLayerStackRefPtr const &layerStack, SdfPath const &path, SdfVariantSelectionMap *result, std::unordered_set< std::string > *exprVarDependencies, PcpErrorVector *errors)
VariantSelections.
PCP_API SdfPermission PcpComposeSitePermission(PcpLayerStackRefPtr const &layerStack, SdfPath const &path)
Permission.
SdfPermission
Definition: types.h:154
#define PCP_API
Definition: api.h:40