Loading...
Searching...
No Matches
types.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_TYPES_H
25#define PXR_USD_PCP_TYPES_H
26
27#include "pxr/pxr.h"
28#include "pxr/usd/pcp/api.h"
29#include "pxr/usd/pcp/site.h"
30#include "pxr/usd/sdf/layer.h"
31#include "pxr/base/tf/pxrTslRobinMap/robin_set.h"
32
33#include <limits>
34#include <vector>
35
37
38PXR_NAMESPACE_OPEN_SCOPE
39
45 // The root arc is a special value used for the root node of
46 // the prim index. Unlike the following arcs, it has no parent node.
47 PcpArcTypeRoot,
48
49 // The following arcs are listed in strength order.
50 PcpArcTypeInherit,
51 PcpArcTypeVariant,
52 PcpArcTypeRelocate,
53 PcpArcTypeReference,
54 PcpArcTypePayload,
55 PcpArcTypeSpecialize,
56
57 PcpNumArcTypes
58};
59
61enum PcpRangeType {
62 // Range including just the root node.
63 PcpRangeTypeRoot,
64
65 // Ranges including child arcs, from the root node, of the specified type
66 // as well as all descendants of those arcs.
67 PcpRangeTypeInherit,
68 PcpRangeTypeVariant,
69 PcpRangeTypeReference,
70 PcpRangeTypePayload,
71 PcpRangeTypeSpecialize,
72
73 // Range including all nodes.
74 PcpRangeTypeAll,
75
76 // Range including all nodes weaker than the root node.
77 PcpRangeTypeWeakerThanRoot,
78
79 // Range including all nodes stronger than the payload
80 // node.
81 PcpRangeTypeStrongerThanPayload,
82
83 PcpRangeTypeInvalid
84};
85
88inline bool
90{
91 return (arcType == PcpArcTypeInherit);
92}
93
96inline bool
98{
99 return (arcType == PcpArcTypeSpecialize);
100}
101
108inline bool
110{
111 return PcpIsInheritArc(arcType) || PcpIsSpecializeArc(arcType);
112}
113
120 PcpSite site;
121 PcpArcType arcType;
122};
123
128typedef std::vector<PcpSiteTrackerSegment> PcpSiteTracker;
129
130// Internal type for Sd sites.
131struct Pcp_SdSiteRef {
132 Pcp_SdSiteRef(const SdfLayerRefPtr& layer_, const SdfPath& path_) :
133 layer(layer_), path(path_)
134 {
135 // Do nothing
136 }
137
138 bool operator==(const Pcp_SdSiteRef& other) const
139 {
140 return layer == other.layer && path == other.path;
141 }
142
143 bool operator!=(const Pcp_SdSiteRef& other) const
144 {
145 return !(*this == other);
146 }
147
148 bool operator<(const Pcp_SdSiteRef& other) const
149 {
150 return layer < other.layer ||
151 (!(other.layer < layer) && path < other.path);
152 }
153
154 bool operator<=(const Pcp_SdSiteRef& other) const
155 {
156 return !(other < *this);
157 }
158
159 bool operator>(const Pcp_SdSiteRef& other) const
160 {
161 return other < *this;
162 }
163
164 bool operator>=(const Pcp_SdSiteRef& other) const
165 {
166 return !(*this < other);
167 }
168
169 // These are held by reference for performance,
170 // to avoid extra ref-counting operations.
171 const SdfLayerRefPtr & layer;
172 const SdfPath & path;
173};
174
175// Internal type for Sd sites.
176struct Pcp_CompressedSdSite {
177 Pcp_CompressedSdSite(size_t nodeIndex_, size_t layerIndex_) :
178 nodeIndex(static_cast<uint16_t>(nodeIndex_)),
179 layerIndex(static_cast<uint16_t>(layerIndex_))
180 {
181 TF_VERIFY(nodeIndex_ < (size_t(1) << 16));
182 TF_VERIFY(layerIndex_ < (size_t(1) << 16));
183 }
184
185 // These are small to minimize the size of vectors of these.
186 uint16_t nodeIndex; // The index of the node in its graph.
187 uint16_t layerIndex; // The index of the layer in the node's layer stack.
188};
189typedef std::vector<Pcp_CompressedSdSite> Pcp_CompressedSdSiteVector;
190
191// XXX Even with <map> included properly, doxygen refuses to acknowledge
192// the existence of std::map, so if we include the full typedef in the
193// \typedef directive, it will warn and fail to produce an entry for
194// PcpVariantFallbackMap. So we instead put the decl inline.
206typedef std::map<std::string, std::vector<std::string>> PcpVariantFallbackMap;
207
209
214#if defined(doxygen)
215constexpr size_t PCP_INVALID_INDEX = unspecified;
216#else
217constexpr size_t PCP_INVALID_INDEX = std::numeric_limits<size_t>::max();
218#endif
219
220PXR_NAMESPACE_CLOSE_SCOPE
221
222#endif // PXR_USD_PCP_TYPES_H
A site specifies a path in a layer stack of scene description.
Definition: site.h:46
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:291
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:283
constexpr size_t PCP_INVALID_INDEX
A value which indicates an invalid index.
Definition: types.h:215
PcpArcType
Describes the type of arc connecting two nodes in the prim index.
Definition: types.h:44
std::map< std::string, std::vector< std::string > > PcpVariantFallbackMap
typedef std::map<std::string, std::vector<std::string>> PcpVariantFallbackMap
Definition: types.h:206
bool PcpIsSpecializeArc(PcpArcType arcType)
Returns true if arcType represents a specialize arc, false otherwise.
Definition: types.h:97
bool PcpIsClassBasedArc(PcpArcType arcType)
Returns true if arcType represents a class-based composition arc, false otherwise.
Definition: types.h:109
std::vector< PcpSiteTrackerSegment > PcpSiteTracker
Represents a single path through the composition tree.
Definition: types.h:128
bool PcpIsInheritArc(PcpArcType arcType)
Returns true if arcType represents an inherit arc, false otherwise.
Definition: types.h:89
Used to keep track of which sites have been visited and through what type of arcs.
Definition: types.h:119