All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 PCP_TYPES_H
25 #define 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/denseHashSet.h"
32 
33 #include <limits>
34 #include <vector>
35 
36 #include <boost/operators.hpp>
37 
39 
40 PXR_NAMESPACE_OPEN_SCOPE
41 
46 enum PcpArcType {
47  // The root arc is a special value used for the root node of
48  // the prim index. Unlike the following arcs, it has no parent node.
49  PcpArcTypeRoot,
50 
51  // The following arcs are listed in strength order.
52  PcpArcTypeInherit,
53  PcpArcTypeVariant,
54  PcpArcTypeRelocate,
55  PcpArcTypeReference,
56  PcpArcTypePayload,
57  PcpArcTypeSpecialize,
58 
59  PcpNumArcTypes
60 };
61 
63 enum PcpRangeType {
64  // Range including just the root node.
65  PcpRangeTypeRoot,
66 
67  // Ranges including child arcs, from the root node, of the specified type
68  // as well as all descendants of those arcs.
69  PcpRangeTypeInherit,
70  PcpRangeTypeVariant,
71  PcpRangeTypeReference,
72  PcpRangeTypePayload,
73  PcpRangeTypeSpecialize,
74 
75  // Range including all nodes.
76  PcpRangeTypeAll,
77 
78  // Range including all nodes weaker than the root node.
79  PcpRangeTypeWeakerThanRoot,
80 
81  // Range including all nodes stronger than the payload
82  // node.
83  PcpRangeTypeStrongerThanPayload,
84 
85  PcpRangeTypeInvalid
86 };
87 
90 inline bool
92 {
93  return (arcType == PcpArcTypeInherit);
94 }
95 
98 inline bool
100 {
101  return (arcType == PcpArcTypeSpecialize);
102 }
103 
110 inline bool
112 {
113  return PcpIsInheritArc(arcType) || PcpIsSpecializeArc(arcType);
114 }
115 
122  PcpSiteStr site;
123  PcpArcType arcType;
124 };
125 
130 typedef std::vector<PcpSiteTrackerSegment> PcpSiteTracker;
131 
132 // Internal type for Sd sites.
133 struct Pcp_SdSiteRef : boost::totally_ordered<Pcp_SdSiteRef> {
134  Pcp_SdSiteRef(const SdfLayerRefPtr& layer_, const SdfPath& path_) :
135  layer(layer_), path(path_)
136  {
137  // Do nothing
138  }
139 
140  bool operator==(const Pcp_SdSiteRef& other) const
141  {
142  return layer == other.layer && path == other.path;
143  }
144 
145  bool operator<(const Pcp_SdSiteRef& other) const
146  {
147  return layer < other.layer ||
148  (!(other.layer < layer) && path < other.path);
149  }
150 
151  // These are held by reference for performance,
152  // to avoid extra ref-counting operations.
153  const SdfLayerRefPtr & layer;
154  const SdfPath & path;
155 };
156 
157 // Internal type for Sd sites.
158 struct Pcp_CompressedSdSite {
159  Pcp_CompressedSdSite(size_t nodeIndex_, size_t layerIndex_) :
160  nodeIndex(static_cast<uint16_t>(nodeIndex_)),
161  layerIndex(static_cast<uint16_t>(layerIndex_))
162  {
163  TF_VERIFY(nodeIndex_ < (size_t(1) << 16));
164  TF_VERIFY(layerIndex_ < (size_t(1) << 16));
165  }
166 
167  // These are small to minimize the size of vectors of these.
168  uint16_t nodeIndex; // The index of the node in its graph.
169  uint16_t layerIndex; // The index of the layer in the node's layer stack.
170 };
171 typedef std::vector<Pcp_CompressedSdSite> Pcp_CompressedSdSiteVector;
172 
173 // XXX Even with <map> included properly, doxygen refuses to acknowledge
174 // the existence of std::map, so if we include the full typedef in the
175 // \typedef directive, it will warn and fail to produce an entry for
176 // PcpVariantFallbackMap. So we instead put the decl inline.
188 typedef std::map<std::string, std::vector<std::string>> PcpVariantFallbackMap;
189 
191 
196 #if defined(doxygen)
197 constexpr size_t PCP_INVALID_INDEX = unspecified;
198 #else
199 constexpr size_t PCP_INVALID_INDEX = std::numeric_limits<size_t>::max();
200 #endif
201 
202 PXR_NAMESPACE_CLOSE_SCOPE
203 
204 #endif // PCP_TYPES_H
std::map< std::string, std::vector< std::string > > PcpVariantFallbackMap
typedef std::map&lt;std::string, std::vector&lt;std::string&gt;&gt; PcpVariantFallbackMap
Definition: types.h:188
bool PcpIsInheritArc(PcpArcType arcType)
Returns true if arcType represents an inherit arc, false otherwise.
Definition: types.h:91
bool PcpIsClassBasedArc(PcpArcType arcType)
Returns true if arcType represents a class-based composition arc, false otherwise.
Definition: types.h:111
A &quot;string-based&quot; version of PcpSite.
Definition: site.h:81
bool PcpIsSpecializeArc(PcpArcType arcType)
Returns true if arcType represents a specialize arc, false otherwise.
Definition: types.h:99
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Definition: diagnostic.h:289
std::vector< PcpSiteTrackerSegment > PcpSiteTracker
Represents a single path through the composition tree.
Definition: types.h:130
PcpArcType
Describes the type of arc connecting two nodes in the prim index.
Definition: types.h:46
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
constexpr size_t PCP_INVALID_INDEX
A value which indicates an invalid index.
Definition: types.h:197
This is a space efficient container that mimics the TfHashSet API that uses a vector for storage when...
Definition: denseHashSet.h:61
VT_API bool operator==(VtDictionary const &, VtDictionary const &)
Equality comparison.
Used to keep track of which sites have been visited and through what type of arcs.
Definition: types.h:121