HDK
 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 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"
15 
16 #include <limits>
17 #include <vector>
18 
19 /// \file pcp/types.h
20 
22 
23 /// \enum PcpArcType
24 ///
25 /// Describes the type of arc connecting two nodes in the prim index.
26 ///
27 enum PcpArcType {
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.
31 
32  // The following arcs are listed in strength order.
39 
41 };
42 
43 /// \enum PcpRangeType
45  // Range including just the root node.
47 
48  // Ranges including child arcs, from the root node, of the specified type
49  // as well as all descendants of those arcs.
55 
56  // Range including all nodes.
58 
59  // Range including all nodes weaker than the root node.
61 
62  // Range including all nodes stronger than the payload
63  // node.
65 
67 };
68 
69 /// Returns true if \p arcType represents an inherit arc, false
70 /// otherwise.
71 inline bool
73 {
74  return (arcType == PcpArcTypeInherit);
75 }
76 
77 /// Returns true if \p arcType represents a specialize arc, false
78 /// otherwise.
79 inline bool
81 {
82  return (arcType == PcpArcTypeSpecialize);
83 }
84 
85 /// Returns true if \p arcType represents a class-based
86 /// composition arc, false otherwise.
87 ///
88 /// The key characteristic of these arcs is that they imply
89 /// additional sources of opinions outside of the site where
90 /// the arc is introduced.
91 inline bool
93 {
94  return PcpIsInheritArc(arcType) || PcpIsSpecializeArc(arcType);
95 }
96 
97 /// \struct PcpSiteTrackerSegment
98 ///
99 /// Used to keep track of which sites have been visited and through
100 /// what type of arcs.
101 ///
105 };
106 
107 /// \typedef std::vector<PcpSiteTrackerSegment> PcpSiteTracker
108 /// Represents a single path through the composition tree. As the tree
109 /// is being built, we add segments to the tracker. If we encounter a
110 /// site that we've already visited, we've found a cycle.
111 typedef std::vector<PcpSiteTrackerSegment> PcpSiteTracker;
112 
113 // Internal type for Sd sites.
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.
155  const SdfPath & path;
156 };
157 
158 // Internal type for Sd sites.
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 };
172 typedef 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.
178 /// \typedef PcpVariantFallbackMap
179 /// typedef std::map<std::string, std::vector<std::string>> PcpVariantFallbackMap
180 ///
181 /// A "map of lists" of fallbacks to attempt to use when evaluating
182 /// variant sets that lack an authored selection.
183 ///
184 /// This maps a name of a variant set (ex: "shadingComplexity") to a
185 /// ordered list of variant selection names. If there is no variant
186 /// selection in scene description, Pcp will check for each listed
187 /// fallback in sequence, using the first one that exists.
188 ///
189 typedef std::map<std::string, std::vector<std::string>> PcpVariantFallbackMap;
190 
192 
193 /// \var size_t PCP_INVALID_INDEX
194 /// A value which indicates an invalid index. This is simply used inplace of
195 /// either -1 or numeric_limits::max() (which are equivalent for size_t).
196 /// for better clarity.
197 #if defined(doxygen)
198 constexpr size_t PCP_INVALID_INDEX = unspecified;
199 #else
201 #endif
202 
204 
205 #endif // PXR_USD_PCP_TYPES_H
bool operator<=(const Pcp_SdSiteRef &other) const
Definition: types.h:137
Pcp_SdSiteRef(const SdfLayerRefPtr &layer_, const SdfPath &path_)
Definition: types.h:115
bool operator>=(const Pcp_SdSiteRef &other) const
Definition: types.h:147
PcpRangeType
Definition: types.h:44
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
Definition: site.h:28
const SdfLayerRefPtr & layer
Definition: types.h:154
bool PcpIsInheritArc(PcpArcType arcType)
Definition: types.h:72
bool PcpIsSpecializeArc(PcpArcType arcType)
Definition: types.h:80
bool operator!=(const Pcp_SdSiteRef &other) const
Definition: types.h:126
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
bool PcpIsClassBasedArc(PcpArcType arcType)
Definition: types.h:92
bool operator<(const Pcp_SdSiteRef &other) const
Definition: types.h:131
uint16_t nodeIndex
Definition: types.h:169
const SdfPath & path
Definition: types.h:155
Definition: path.h:273
bool operator==(const Pcp_SdSiteRef &other) const
Definition: types.h:121
constexpr size_t PCP_INVALID_INDEX
Definition: types.h:200
Pcp_CompressedSdSite(size_t nodeIndex_, size_t layerIndex_)
Definition: types.h:160
std::vector< Pcp_CompressedSdSite > Pcp_CompressedSdSiteVector
Definition: types.h:172
PcpArcType arcType
Definition: types.h:104
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
bool operator>(const Pcp_SdSiteRef &other) const
Definition: types.h:142
std::vector< PcpSiteTrackerSegment > PcpSiteTracker
Definition: types.h:111
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
uint16_t layerIndex
Definition: types.h:170
std::map< std::string, std::vector< std::string > > PcpVariantFallbackMap
Definition: types.h:189
PcpArcType
Definition: types.h:27