Loading...
Searching...
No Matches
types.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_TYPES_H
8#define PXR_USD_PCP_TYPES_H
9
10#include "pxr/pxr.h"
11#include "pxr/usd/pcp/api.h"
12#include "pxr/usd/pcp/site.h"
13#include "pxr/usd/sdf/layer.h"
14#include "pxr/base/tf/pxrTslRobinMap/robin_set.h"
15
16#include <limits>
17#include <vector>
18
20
21PXR_NAMESPACE_OPEN_SCOPE
22
28 // The root arc is a special value used for the root node of
29 // the prim index. Unlike the following arcs, it has no parent node.
30 PcpArcTypeRoot,
31
32 // The following arcs are listed in strength order.
33 PcpArcTypeInherit,
34 PcpArcTypeVariant,
35 PcpArcTypeRelocate,
36 PcpArcTypeReference,
37 PcpArcTypePayload,
38 PcpArcTypeSpecialize,
39
40 PcpNumArcTypes
41};
42
44enum PcpRangeType {
45 // Range including just the root node.
46 PcpRangeTypeRoot,
47
48 // Ranges including child arcs, from the root node, of the specified type
49 // as well as all descendants of those arcs.
50 PcpRangeTypeInherit,
51 PcpRangeTypeVariant,
52 PcpRangeTypeReference,
53 PcpRangeTypePayload,
54 PcpRangeTypeSpecialize,
55
56 // Range including all nodes.
57 PcpRangeTypeAll,
58
59 // Range including all nodes weaker than the root node.
60 PcpRangeTypeWeakerThanRoot,
61
62 // Range including all nodes stronger than the payload
63 // node.
64 PcpRangeTypeStrongerThanPayload,
65
66 PcpRangeTypeInvalid
67};
68
71inline bool
73{
74 return (arcType == PcpArcTypeInherit);
75}
76
79inline bool
81{
82 return (arcType == PcpArcTypeSpecialize);
83}
84
91inline bool
93{
94 return PcpIsInheritArc(arcType) || PcpIsSpecializeArc(arcType);
95}
96
103 PcpSite site;
104 PcpArcType arcType;
105};
106
111typedef std::vector<PcpSiteTrackerSegment> PcpSiteTracker;
112
113// Internal type for Sd sites.
114struct Pcp_SdSiteRef {
115 Pcp_SdSiteRef(const SdfLayerRefPtr& layer_, const SdfPath& path_) :
116 layer(layer_), path(path_)
117 {
118 // Do nothing
119 }
120
121 bool operator==(const Pcp_SdSiteRef& other) const
122 {
123 return layer == other.layer && path == other.path;
124 }
125
126 bool operator!=(const Pcp_SdSiteRef& other) const
127 {
128 return !(*this == other);
129 }
130
131 bool operator<(const Pcp_SdSiteRef& other) const
132 {
133 return layer < other.layer ||
134 (!(other.layer < layer) && path < other.path);
135 }
136
137 bool operator<=(const Pcp_SdSiteRef& other) const
138 {
139 return !(other < *this);
140 }
141
142 bool operator>(const Pcp_SdSiteRef& other) const
143 {
144 return other < *this;
145 }
146
147 bool operator>=(const Pcp_SdSiteRef& other) const
148 {
149 return !(*this < other);
150 }
151
152 // These are held by reference for performance,
153 // to avoid extra ref-counting operations.
154 const SdfLayerRefPtr & layer;
155 const SdfPath & path;
156};
157
158// Internal type for Sd sites.
159struct Pcp_CompressedSdSite {
160 Pcp_CompressedSdSite(size_t nodeIndex_, size_t layerIndex_) :
161 nodeIndex(static_cast<uint16_t>(nodeIndex_)),
162 layerIndex(static_cast<uint16_t>(layerIndex_))
163 {
164 TF_VERIFY(nodeIndex_ < (size_t(1) << 16));
165 TF_VERIFY(layerIndex_ < (size_t(1) << 16));
166 }
167
168 // These are small to minimize the size of vectors of these.
169 uint16_t nodeIndex; // The index of the node in its graph.
170 uint16_t layerIndex; // The index of the layer in the node's layer stack.
171};
172typedef std::vector<Pcp_CompressedSdSite> Pcp_CompressedSdSiteVector;
173
174// XXX Even with <map> included properly, doxygen refuses to acknowledge
175// the existence of std::map, so if we include the full typedef in the
176// \typedef directive, it will warn and fail to produce an entry for
177// PcpVariantFallbackMap. So we instead put the decl inline.
189typedef std::map<std::string, std::vector<std::string>> PcpVariantFallbackMap;
190
192
197#if defined(doxygen)
198constexpr size_t PCP_INVALID_INDEX = unspecified;
199#else
200constexpr size_t PCP_INVALID_INDEX = std::numeric_limits<size_t>::max();
201#endif
202
203PXR_NAMESPACE_CLOSE_SCOPE
204
205#endif // PXR_USD_PCP_TYPES_H
A site specifies a path in a layer stack of scene description.
Definition: site.h:29
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Implementation of a hash set using open-addressing and the robin hood hashing algorithm with backward...
Definition: robin_set.h:95
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Definition: diagnostic.h:266
constexpr size_t PCP_INVALID_INDEX
A value which indicates an invalid index.
Definition: types.h:198
PcpArcType
Describes the type of arc connecting two nodes in the prim index.
Definition: types.h:27
std::map< std::string, std::vector< std::string > > PcpVariantFallbackMap
typedef std::map<std::string, std::vector<std::string>> PcpVariantFallbackMap
Definition: types.h:189
bool PcpIsSpecializeArc(PcpArcType arcType)
Returns true if arcType represents a specialize arc, false otherwise.
Definition: types.h:80
bool PcpIsClassBasedArc(PcpArcType arcType)
Returns true if arcType represents a class-based composition arc, false otherwise.
Definition: types.h:92
std::vector< PcpSiteTrackerSegment > PcpSiteTracker
Represents a single path through the composition tree.
Definition: types.h:111
bool PcpIsInheritArc(PcpArcType arcType)
Returns true if arcType represents an inherit arc, false otherwise.
Definition: types.h:72
Used to keep track of which sites have been visited and through what type of arcs.
Definition: types.h:102