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 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"
32 
33 #include <limits>
34 #include <vector>
35 
36 /// \file pcp/types.h
37 
39 
40 /// \enum PcpArcType
41 ///
42 /// Describes the type of arc connecting two nodes in the prim index.
43 ///
44 enum PcpArcType {
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.
48 
49  // The following arcs are listed in strength order.
56 
58 };
59 
60 /// \enum PcpRangeType
62  // Range including just the root node.
64 
65  // Ranges including child arcs, from the root node, of the specified type
66  // as well as all descendants of those arcs.
72 
73  // Range including all nodes.
75 
76  // Range including all nodes weaker than the root node.
78 
79  // Range including all nodes stronger than the payload
80  // node.
82 
84 };
85 
86 /// Returns true if \p arcType represents an inherit arc, false
87 /// otherwise.
88 inline bool
90 {
91  return (arcType == PcpArcTypeInherit);
92 }
93 
94 /// Returns true if \p arcType represents a specialize arc, false
95 /// otherwise.
96 inline bool
98 {
99  return (arcType == PcpArcTypeSpecialize);
100 }
101 
102 /// Returns true if \p arcType represents a class-based
103 /// composition arc, false otherwise.
104 ///
105 /// The key characteristic of these arcs is that they imply
106 /// additional sources of opinions outside of the site where
107 /// the arc is introduced.
108 inline bool
110 {
111  return PcpIsInheritArc(arcType) || PcpIsSpecializeArc(arcType);
112 }
113 
114 /// \struct PcpSiteTrackerSegment
115 ///
116 /// Used to keep track of which sites have been visited and through
117 /// what type of arcs.
118 ///
122 };
123 
124 /// \typedef std::vector<PcpSiteTrackerSegment> PcpSiteTracker
125 /// Represents a single path through the composition tree. As the tree
126 /// is being built, we add segments to the tracker. If we encounter a
127 /// site that we've already visited, we've found a cycle.
128 typedef std::vector<PcpSiteTrackerSegment> PcpSiteTracker;
129 
130 // Internal type for Sd sites.
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.
172  const SdfPath & path;
173 };
174 
175 // Internal type for Sd sites.
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 };
189 typedef 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.
195 /// \typedef PcpVariantFallbackMap
196 /// typedef std::map<std::string, std::vector<std::string>> PcpVariantFallbackMap
197 ///
198 /// A "map of lists" of fallbacks to attempt to use when evaluating
199 /// variant sets that lack an authored selection.
200 ///
201 /// This maps a name of a variant set (ex: "shadingComplexity") to a
202 /// ordered list of variant selection names. If there is no variant
203 /// selection in scene description, Pcp will check for each listed
204 /// fallback in sequence, using the first one that exists.
205 ///
206 typedef std::map<std::string, std::vector<std::string>> PcpVariantFallbackMap;
207 
209 
210 /// \var size_t PCP_INVALID_INDEX
211 /// A value which indicates an invalid index. This is simply used inplace of
212 /// either -1 or numeric_limits::max() (which are equivalent for size_t).
213 /// for better clarity.
214 #if defined(doxygen)
215 constexpr size_t PCP_INVALID_INDEX = unspecified;
216 #else
218 #endif
219 
221 
222 #endif // PXR_USD_PCP_TYPES_H
bool operator<=(const Pcp_SdSiteRef &other) const
Definition: types.h:154
Pcp_SdSiteRef(const SdfLayerRefPtr &layer_, const SdfPath &path_)
Definition: types.h:132
bool operator>=(const Pcp_SdSiteRef &other) const
Definition: types.h:164
PcpRangeType
Definition: types.h:61
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
Definition: site.h:45
const SdfLayerRefPtr & layer
Definition: types.h:171
bool PcpIsInheritArc(PcpArcType arcType)
Definition: types.h:89
bool PcpIsSpecializeArc(PcpArcType arcType)
Definition: types.h:97
bool operator!=(const Pcp_SdSiteRef &other) const
Definition: types.h:143
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
bool PcpIsClassBasedArc(PcpArcType arcType)
Definition: types.h:109
bool operator<(const Pcp_SdSiteRef &other) const
Definition: types.h:148
uint16_t nodeIndex
Definition: types.h:186
const SdfPath & path
Definition: types.h:172
Definition: path.h:290
bool operator==(const Pcp_SdSiteRef &other) const
Definition: types.h:138
constexpr size_t PCP_INVALID_INDEX
Definition: types.h:217
Pcp_CompressedSdSite(size_t nodeIndex_, size_t layerIndex_)
Definition: types.h:177
std::vector< Pcp_CompressedSdSite > Pcp_CompressedSdSiteVector
Definition: types.h:189
PcpArcType arcType
Definition: types.h:121
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
bool operator>(const Pcp_SdSiteRef &other) const
Definition: types.h:159
std::vector< PcpSiteTrackerSegment > PcpSiteTracker
Definition: types.h:128
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:91
uint16_t layerIndex
Definition: types.h:187
std::map< std::string, std::vector< std::string > > PcpVariantFallbackMap
Definition: types.h:206
PcpArcType
Definition: types.h:44